How to insert a new line in a PDS member using REXX..



IBM's Command List programming language & Restructured Extended Executor

How to insert a new line in a PDS member using REXX..

Postby santosh bm » Wed Jan 08, 2014 12:12 am

Hii,,

Someone please give me tips to insert new lines inside a PDS member using REXX code.

I have used a cursor to fetch some rows from a table in my REXX code. The requirement is, if my cursor returns four rows, i need to insert those four rows into a PDS member (say in the line numbers 107,108,109 and 110 resp).
santosh bm
 
Posts: 14
Joined: Tue Oct 29, 2013 11:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to insert a new line in a PDS member using REXX..

Postby Pedro » Wed Jan 08, 2014 1:58 am

You did not say how big the member is. If there are many lines, then rexx is not the right tool. Or perhaps, a PDS is not the right kind of data set to store your data.

Since you are inserting new lines, you will have to read the whole thing and then write the whole thing (including the new records). Perhaps the easiest approach to insert new lines:
1. use EXECIO to read in the PDS records into a stem variable.
2. copy the stem to a second stem, while also merging in your new records.
3. use EXECIO to write the second stem to the PDS member.
Pedro Vera
User avatar
Pedro
 
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: How to insert a new line in a PDS member using REXX..

Postby santosh bm » Wed Jan 08, 2014 5:14 pm

The PDS member is being created by the same rexx code. The PDS member has about 140 lines. Why i need to insert those lines is, i'm creating certain forms, which are stored as pds members. I always read a flat file, string manipulate the data and write it to a pds member. My code has a query(cursor), which could fetch a number of rows from the table. I need to insert these lines into that pds member. Please inform me, if you need more information on this.
santosh bm
 
Posts: 14
Joined: Tue Oct 29, 2013 11:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to insert a new line in a PDS member using REXX..

Postby NicC » Wed Jan 08, 2014 5:19 pm

I think Pedro has given you sufficient information to carry on.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: How to insert a new line in a PDS member using REXX..

Postby santosh bm » Wed Jan 08, 2014 5:31 pm

Is there any macro way of doing it ?
santosh bm
 
Posts: 14
Joined: Tue Oct 29, 2013 11:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to insert a new line in a PDS member using REXX..

Postby santosh bm » Wed Jan 08, 2014 5:38 pm

Like ISREDIT or something ?
santosh bm
 
Posts: 14
Joined: Tue Oct 29, 2013 11:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to insert a new line in a PDS member using REXX..

Postby Pedro » Wed Jan 08, 2014 7:25 pm

You can create an editor macro that issues LINE_AFTER statements. I think it is easier to start at the bottom and work your way up; because as you insert lines, the line numbers below it change.
Pedro Vera
User avatar
Pedro
 
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: How to insert a new line in a PDS member using REXX..

Postby santosh bm » Wed Jan 08, 2014 8:15 pm

I'm facing two problems with the macro.
1] i'm not able to pass the data from rexx code to macro. i.e., the data i fetch from the query is not being passed on to the macro.
2] The pds member is getting opened in the edit mode, instead of getting closed after the edit process.

Macro is as below :
ADDRESS ISREDIT "MACRO (STRING)"                   
address ISREDIT "scan off"
if rc > 0 then exit 
address  ISREDIT "LINE_AFTER" 106 "=" (GDGNAME2) 
"end"                                             
"exit"

where GDGNAME2 is the variable in the rexx code which contains some data, i want to insert in the pds member.
santosh bm
 
Posts: 14
Joined: Tue Oct 29, 2013 11:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to insert a new line in a PDS member using REXX..

Postby Steve Coalbran » Wed Jan 08, 2014 8:36 pm

The title is not the question.
This is the answer to the question of CHANGING 4 lines in a member (VERY OVER-SIMPLIFIED!)
;)

If you are running an EditMacro on the PDS member in question you could do this:
Outside process
:
/* get field values  into vnnn vars below */
ADDRESS DSNREXX stuff?
...
QUEUE v107
QUEUE v108
QUEUE v109
QUEUE v110
ADDRESS ISPEXEC "EDIT DATASET('"libname"') MEMBER("member") MACRO(ADD4FLDS) "
...


where EditMacro (ADD4FLDS) says something like...
ADDRESS ISPEXEC "CONTROL ERRORS RETURN "
ADDRESS ISREDIT
"MACRO NOPROCESS "
PARSE PULL v107
PARSE PULL v108
PARSE PULL v109
PARSE PULL v110
"LINE 107 = (V107) "
"LINE 107 = (V108) "
"LINE 107 = (V109) "
"LINE 107 = (V110) "
"END "

but this is a VERY simplified example! No variables. Just add logic!?!
Untested too, no intranet connection here today!
As has been said before on many posts... "SUPPLY YOUR CURRENT CODE" ...however embarrassing it may be.
We all started somewhere?! However long ago ahem! that may have been!?

If you are doing this for a whole PDS in the outside process then you need to use LM services around the EDITs on the members. Use DATAID instead of DATASET on the EDIT line etc.
Use MODEL with LMINIT, LMOPEN, LMMLIST, LMCLOSE, or failing all else RTFM ...
    SC34-4819 z/OS V1R13.0 ISPF Services Guide
    SC34-4820 z/OS V1R13.0 ISPF Edit and Edit Macros
I think I coded something like this about 10 years ago at some Customer's requirement.
Good luck.
Steve
User avatar
Steve Coalbran
 
Posts: 138
Joined: Wed Apr 06, 2011 11:49 am
Location: Stockholm, Sweden
Has thanked: 13 times
Been thanked: 1 time

Re: How to insert a new line in a PDS member using REXX..

Postby Pedro » Wed Jan 08, 2014 11:47 pm

2] The pds member is getting opened in the edit mode, instead of getting closed after the edit process.

You need to issue the END macro statement. You try to in your example, but you are missing the Address ISREDIT and instead of editor END, it tries to issue TSO END (likely resulting in 'command not found')

ADDRESS ISREDIT "MACRO (STRING)"                   
address ISREDIT "scan off"
if rc > 0 then exit
address  ISREDIT "LINE_AFTER" 106 "=" (GDGNAME2)
address  ISREDIT  "END"                                             


I do not think "EXIT" is needed.

Steve recommended QUEUE with PARSE PULL. I suggest that you use NEWSTACK and DELSTACK also. Actually, I recommend VPUT SHARED and VGET SHARED instead of using the stack. It just seems cleaner to me.
Pedro Vera
User avatar
Pedro
 
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post