×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Retrieve only certain lines from dataset using REXX

Retrieve only certain lines from dataset using REXX

Retrieve only certain lines from dataset using REXX

(OP)
Hello,
I was wondering if anyone could assist me in some REXX coding. Here is the scenario, I'm using JCL to dump SAR information into a dataset and then I'm wanting to grab only certain information from the dataset. There is a particular beginning word that I know is in the dataset which is on line 255, so I'm doing a select statement with a when pos('BEGIN',in.i) > 0. I'm at the beginning of the line I would like to output the information from to another dataset. How do I output this line and the next 10? I figured I would need a counter of some sort but I haven't been able to figure this one out. Is there a way to delete all lines before 255 and all lines after 234? Any help would be greatly appreciated. Thanks, Chris

RE: Retrieve only certain lines from dataset using REXX

If you do not know how to use a counter then you have a problem!

Basic outline:

CODE -->

Using EXECIO read the first 250 lines
Read 1 record using EXECIO
Do While RC = 0
   Select
      When Pos('BEGIN',in.1) > 0
      Then Do
         Do i = 1 To 11
            Use EXECIO to write the record
            Read 1 record using EXECIO
         End
         Signal eoj
      End
      OTHERWISE
            Read 1 record using EXECIO
   End
End
eoj: Exit 

However - will that required line always be the 255th line? Will there always be 11 lines to write out?


Nic

RE: Retrieve only certain lines from dataset using REXX

(OP)
Hello Nic,
I have been using a counter just not receiving the correct information. I've been parsing the data and then queuing it then running the execio at the end of the code. To answer your question, yes, the same data will always been in line 255 with 11 rows needed captured. It'll only have different processing data information in those lines

RE: Retrieve only certain lines from dataset using REXX

Have you tried with a trace? I would set it in the WHEN. If running interactively start with '?R'.


Nic

RE: Retrieve only certain lines from dataset using REXX

A solution using OORexx

CODE

/*-------------------------------------------------------------------*/
/*                                                                   */
/* Program : tek-tips-extract.rex                                    */
/*                                                                   */
/* Function: Extract records 255 to 265 inclusive from a file.       */
/*                                                                   */
/* Usage   : rexx tek-tips-extract                                   */
/*                                                                   */
/*-------------------------------------------------------------------*/
Trace 'O'
infile = '"300records.txt"'		/* Input                     */
extract = '"11extracted.txt"'	        /* Extract 		     */
exit_msg = "Program ended OK"           /* Default exit message      */
rows_extracted = 0			/* Count of rows extracted   */
/*----------------------*/
/* Mainline starts here */
/*----------------------*/
	
	/* Skip 254 records */
	Address HOSTEMU "EXECIO 254 DISKR "infile" (STEM not_needed."
	If rc <> 0
	Then Do
		exit_msg = "Failed reading 254 records. Code:"rc
		Signal door
	End
	Drop not_needed.
	
	/* Read 11 records */
	Address HOSTEMU "EXECIO 11 DISKR "infile" (STEM needed."
	If rc <> 0
	Then Do
		exit_msg = "Failed reading 11 records. Code:"rc
		Signal door
	End
	
	/* Write 11 records */
	Address HOSTEMU "EXECIO "needed.0" DISKw "extract" (STEM needed."
	If rc <> 0
	Then Do
		exit_msg = "Failed writing 11 records. Code:"rc
		Signal door
	End

/* Done */
door:
	Say exit_msg

Exit
/*===================================================================*/
::requires "hostemu" library 


Nic

RE: Retrieve only certain lines from dataset using REXX

(OP)
Appreciate the information. I ended up going another route and just using an IF statement and pulling 3 lines instead of the 11. These 3 lines had the information the support team needed. I was able to parse out the information and send the support team an email whenever the job failed. Thanks again for the time and information.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close