IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Move a particular line from a PS file into a variable


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Jitesh Kumar

New User


Joined: 05 Aug 2019
Posts: 1
Location: India

PostPosted: Mon Aug 05, 2019 2:48 am
Reply with quote

My requirement is to process a particular line from a PS file using REXX Macro. For example, Consider a PS file 'ABC.PS'. Now I want to find the first occurrence of a particular account say "10001" and get the entire line (where searched account is found) into a variable for further processing.

I tried this, but it is not working for me.

Code:
/* REXX */                                                       
ADDRESS ISREDIT                       
"BROWSE DATASET('ABC.PS')"       
"FIND '10001' FIRST"           
"(CURL,CURC)=CURSOR"                         
"(LINEDATA)=LINE" CURL                                             
SAY LINEDATA 


Can someone help me ?

Please use the code tags to present code and data (including spool output)
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8569
Location: Dubuque, Iowa, USA

PostPosted: Mon Aug 05, 2019 3:27 am
Reply with quote

Saying something "is not working" is a useless statement to make. HOW is it not working:
- is it not executing at all?
- is it executing but generating an ABEND?
- is it executing without doing anything?
- is it executing but not giving you the desired result? (If this is the case, tell us what result you are getting for the input data and what result you are expecting.)
etc
etc
etc

You have to give us SOMETHING for us to help you -- and telling us that something "is not working" gives us NOTHING. You should be posting whatever output you are getting.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2448
Location: Hampshire, UK

PostPosted: Mon Aug 05, 2019 3:47 am
Reply with quote

Macros are executed against datasets opened in edit or view mode. Why are you trying to browse a dataset within your macro?
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 416
Location: Denmark

PostPosted: Mon Aug 05, 2019 1:52 pm
Reply with quote

As Nic indicates, the find must be done in a seperate macro. Something like the following. Note that I am using VIEW as I offhand cannot remember if an edit macro can be used with browse.
1. REXX script to drive the macro
Code:
/* REXX */                                                       
Address IspExec "VIEW DATASET('ABC.PS') macro(myfind)"


2. ISPF exit macro named MYFIND
Code:
/* REXX */                                                       
ADDRESS ISREDIT                       
"FIND '10001' FIRST"           
"(CURL,CURC)=CURSOR"                         
"(LINEDATA)=LINE" CURL                                             
SAY LINEDATA
"END"
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 416
Location: Denmark

PostPosted: Mon Aug 05, 2019 1:54 pm
Reply with quote

Another question, is the dataset very big? Personally I would just read the data using EXECIO and scan the text using REXX features.
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Moderator


Joined: 14 Mar 2007
Posts: 10712
Location: italy

PostPosted: Mon Aug 05, 2019 2:24 pm
Reply with quote

if the dataset is large sort should be the first choice, and after that process the output.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1348
Location: Israel

PostPosted: Mon Aug 05, 2019 8:04 pm
Reply with quote

enrico-sorichetti wrote:
if the dataset is large sort should be the first choice, and after that process the output.


SORT can easily be executed from within a REXX program.
It is indeed the best option for extracting a few records from a large dataset.
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 416
Location: Denmark

PostPosted: Mon Aug 05, 2019 8:22 pm
Reply with quote

Yup, I agree that SORT is preferred for large datasets. It would be also worthwhile to check if the PIPE program is available. Such a shame that it isn't standard.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Command line placement in DB2I panels TSO/ISPF 1
No new posts Converting a file from PD to display ... SYNCSORT 4
No new posts Record count of RECFM=U tape file DFSORT/ICETOOL 17
This topic is locked: you cannot edit posts or make replies. Write Character to Hexadecimal file w... COBOL Programming 8
No new posts Checking the total counts inside a re... JCL & VSAM 5
Search our Forums:

Back to Top