View previous topic :: View next topic
|
Author |
Message |
Mayur Soneji
New User
Joined: 25 Jan 2013 Posts: 4 Location: India
|
|
|
|
Hi,
I am trying to Concatenate 2 members and store the result in another member of different PDS. I am doing this to automate a process in our project.
The problem is, after EXECIO DISKW command, when I am trying to open the member in Edit mode, I am not able to see the data; but
when I open it after the REXX is executed, I can see the data.
May be this is happening because the data written is not getting saved from buffer to the member when I open it...
The code is as given:
Code: |
/* REXX */
TRACE I
DSN1 = "HLQ1.HLQ2.JCL3"
DSN2 = "HLQ1.HLQ2.JCL3(CONC)"
ADDRESS TSO
"ALLOCATE DATASET('"DSN1"') F(DAT) NEW SPACE(50,20) DIR(100)",
"DSORG(PO) RECFM(F,B) LRECL(80) BLKSIZE(8000)"
"FREE F(DAT)"
"ALLOC DA('"DSN2"') F(OUTDD) OLD REUSE"
LIM = 1
NUM_STEP = 2
DO WHILE LIM <= NUM_STEP
DD_NUM = 'DD'LIM
SKEL_NUM = 'SKEL'LIM
DSN_NUM = 'HLQ1.UTIL.SKELS('||SKEL_NUM||')'
"ALLOC F("DD_NUM") DA('"DSN_NUM"') SHR"
'EXECIO * DISKR 'DD_NUM' (STEM DATA.FINIS'
QUEUE''
'EXECIO * DISKW OUTDD (STEM DATA.FINIS'
LIM = LIM + 1
END
"ISPEXEC EDIT DATASET("DSN2")"
EXIT
|
LMCOPY could have worked if I want to copy from one member to another, but here there are multiple members and I want the concatenated output in third member.
The code is getting executed properly, except for one thing that I am not able to see the output in EDIT mode when I open it in REXX itself.
Please help me solve this problem. |
|
Back to top |
|
|
Stefan
Active User
Joined: 12 Jan 2006 Posts: 110 Location: Germany
|
|
|
|
Dataset DSN2 is allocated exclusively (DISP=OLD). So first issue a FREE DD(OUTDD) before you try to edit it.
By the way: Within your loop (DO WHILE LIM <= NUM_STEP) you allocate the input dataset without freeing it afterwards. You have to get yourself used to always FREE a dataset as quick as possible ! |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
and ...
using EXECIO * for write is a very bad practice !
meditate on
what will happen if the first file read into the stem has more records than the second one
the proper way would be ....
Code: |
"EXECIO * DISKR ..... ( STEM <stemvar>. finis "
"EXECIO" <stemvar>.0 "DISKW...... (STEM <stemvar>."
|
not to talk about the fact that using FINIS on every DISKW will close the output dataset
and You will end up with just the last file processed |
|
Back to top |
|
|
Mayur Soneji
New User
Joined: 25 Jan 2013 Posts: 4 Location: India
|
|
|
|
Stefan, thanks for the suggestion.
But, this command just before EDIT is also not working.
The error I am getting is:
Code: |
IKJ56861I FILE OUTDD NOT FREED, DATA SET IS OPEN
+++ RC(12) +++
|
Its evident from the error, that file is not Closed; but how do we close it before I can open it in Edit mode ??
Enrico,
Thanks a lot for your input.
It makes sense that if first file is larger than the other ones, it can create a problem. The reason I have used EXECIO * is that the files are not larger than a 100 records, so its fair to use EXECIO.
Correct me if I am wrong. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
The reason I have used EXECIO * is that the files are not larger than a 100 records, so its fair to use EXECIO. |
there was a typo in my previous post ...should have been
Code: |
"EXECIO * DISKR ..... ( STEM <stemvar>. finis "
"EXECIO" <stemvar>.0 "DISKW...... (STEM <stemvar>." |
I am questioning the use of EXECIO * for write, not for read
the number of records which can be reasonably processed thru rexx is a different can of worms |
|
Back to top |
|
|
Mayur Soneji
New User
Joined: 25 Jan 2013 Posts: 4 Location: India
|
|
|
|
Ok...
Quote: |
LMCOPY could have worked if I want to copy from one member to another, but here there are multiple members and I want the concatenated output in third member.
|
I am not able to think of any other option to read from multiple members and write it into a different one.
Can you please suggest.... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
looks like there is language barrier here
repeat on ...
for such a small number of records EXECIO is an acceptable solution
what is wrong is to use EXECIO * DISKW
it might result in dropped records , or extra records from previous invocations |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
try this
Code: |
****** ***************************** Top of Data ******************************
000001 /* rexx */
000002 trace "o"
000003 signal on novalue name novalue
000004 do i = 1 to 100
000005 stem.i = "line"i
000006 end
000007 stem.10 = ""
000008 Address TSO
000009 "ALLOC FI(F1) DS('ENRICO.TEST.PS1') SHR REUS"
000010 "EXECIO * DISKW F1 (STEM STEM. FINIS"
000011 exit
000012 novalue:
000013 say "*********************************"
000014 say "** **"
000015 say "** novalue trapped at line" || right(sigl,4) || " **"
000016 say "** **"
000017 say "*********************************"
000018 exit
****** **************************** Bottom of Data **************************** |
allocate PS dataset insert the snippet the proper dsname
and run three times
1) without statement 7
2) with statement 7
3) with statement 7 using 100 instead of the "*" |
|
Back to top |
|
|
Stefan
Active User
Joined: 12 Jan 2006 Posts: 110 Location: Germany
|
|
|
|
Mayur Soneji wrote: |
Stefan, thanks for the suggestion.
But, this command just before EDIT is also not working.
The error I am getting is:
Code: |
IKJ56861I FILE OUTDD NOT FREED, DATA SET IS OPEN
+++ RC(12) +++
|
Its evident from the error, that file is not Closed; but how do we close it before I can open it in Edit mode ??
|
You haven't closed the file because the keyword FINIS is missing on the EXECIO DISKW statement. You missed the blank between the stem variable DATA. and the keyword FINIS so that it is not recognized. I assume that when you insert the missing blank, the file will be closed and the changed data will be written to the new dataset.
Give it a try! |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
that' s what happens when giving too much credit to sloppy coders
i thought that (STEM stem.finis was a typo ... for (STEM STEM. FINIS
but stem.finis verbatim is a good variable
and
Code: |
****** ***************************** Top of Data ******************************
000001 /* rexx */
000002 trace "o"
000003 signal on novalue name novalue
000004 Address TSO
000005 "ALLOC FI(F1) DS('ENRICO.TEST.PS1') SHR REUS"
000006 "EXECIO * DISKR F1 (STEM STEM.FINIS"
000007 say RC
000008 say rxvars()
000009 exit
...... ... |
gives back
Code: |
0
RC STEM.FINIS0 STEM.FINIS1 STEM.FINIS2
|
it would be wiser for the TS to start over from scratch
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
here is how a better written script could look like
Code: |
/* REXX */
Trace "I"
outds = "HLQ1.HLQ2.JCL3"
outmbr = "HLQ1.HLQ2.JCL3(CONC)"
Address TSO
"ALLOC FI(OU) DS('"outds"') F(DAT) NEW SPACE(50,20) DIR(100)",
"DSORG(PO) RECFM(F,B) LRECL(80) BLKSIZE(8000)"
if ( RC \= 0 ) then do
exit
end
"FREE FI(OU)"
if ( RC \= 0 ) then do
exit
end
"ALLOC FI(OU) DS('"outmbr"') OLD REUSE"
if ( RC \= 0 ) then do
exit
end
coun = 0
steps = 2
Do s = 1 to steps
inpmbr = "SKEL"s
inpds = "HLQ1.UTIL.SKELS("inpmbr")"
"ALLOC FI(IN) DA('"inpds"') SHR REUSE"
if ( RC \= 0 ) then do
exit
end
"EXECIO * DISKR IN (STEM DATA. FINIS'
if ( RC \= 0 ) then do
exit
end
"FREE FI(IN)"
"EXECIO" data.0 "DISKW OU (STEM DATA."
if ( RC \= 0 ) then do
exit
end
coun = coun + data.0
end
"EXECIO 0 DISKW OU (FINIS"
"FREE FI(OU)"
Address ISPEXEC "EDIT DATASET("outmbr")"
exit
|
[/code] |
|
Back to top |
|
|
Mayur Soneji
New User
Joined: 25 Jan 2013 Posts: 4 Location: India
|
|
|
|
Stefan,
You were right... There was a silly mistake of missing out a blank.
After correcting that, it took me to what Enrico has pointed out:
Quote: |
what is wrong is to use EXECIO * DISKW
it might result in dropped records , or extra records from previous invocations
|
Enrico,
Thanks a lot for your valuabe inputs.
The result was having dropped records, it only reflected data from second member because of FINIS I was using while writing everytime.
Your modified script worked like a Gem.
Also, the code snippet that you asked me to try
Code: |
****** ***************************** Top of Data ******************************
000001 /* rexx */
000002 trace "o"
000003 signal on novalue name novalue
000004 do i = 1 to 100
000005 stem.i = "line"i
000006 end
000007 stem.10 = ""
000008 Address TSO
000009 "ALLOC FI(F1) DS('ENRICO.TEST.PS1') SHR REUS"
000010 "EXECIO * DISKW F1 (STEM STEM. FINIS"
000011 exit
000012 novalue:
000013 say "*********************************"
000014 say "** **"
000015 say "** novalue trapped at line" || right(sigl,4) || " **"
000016 say "** **"
000017 say "*********************************"
000018 exit
****** **************************** Bottom of Data **************************** |
gave me a better insight of how things work.
Thanks a ton for your inputs Enrico and Stefan. |
|
Back to top |
|
|
|