View previous topic :: View next topic |
Author |
Message |
chuck Beginner
Joined: 30 Nov 2007 Posts: 26 Topics: 12
|
Posted: Tue Mar 15, 2022 6:59 pm Post subject: Odd behaviour when writing stem variable contents to file |
|
|
I have this really simple REXX script that reads a list of member names from a input file and for each member writes out a line to an output. The output lines are meant for a JCL. For some reason it's balking at writing out anything more than 999 lines. So here is the code
Code: |
/*rexx*/
/*generate FTP statements*/
"alloc da(ALL.INVENTRY(JUSTPGMS)) f(MYINDD),shr reuse"
/*alloc input dataset with SOURCE memb
"execio * diskr MYINDD (finis stem memlist."/*read all into stem*/
output_line_count=1
do i = 1 to memlist.0
memname = strip(memlist.i)
if i < 100 then
outputstem.output_line_count= ,
'PUT //DD:INFILE' ||i ||' ' memname
else if i >= 100 & i < 1000 then
outputstem.output_line_count= ,
'PUT //DD:INFIL' ||i ||' ' memname
else if i > 1000 then
outputstem.output_line_count= ,
'PUT //DD:INFI' ||i ||' ' memname
output_line_count=output_line_count + 1
end
x = OUTTRAP("var.") /*Don't want to display message if */
"FREE FI("ftpline1")" /*file doesn't exist*/
x = outtrap('off')
"alloc dataset(JCL.CNTL(ftpline1)) fi(outdd) shR "
"EXECIO * DISKW "OUTDD" (FINIS STEM OUTPUTSTEM."
"FREE FI("outdd")" /*file doesn't exist*/
exit 0
|
I added that conditional logic to limit the length of that literal INFILE to 8 bytes, so INFILExx, INFILxxx, INFIxxxx
Strangely if I remove that, it has no problems writing out everything. There are 1095 input members, so a maximum of 1095 lines should be written out.
I put in some SAY statements in there and the stem variable does contain all the lines, just doesn't get written out when I have that conditional logic in. One strange thing though, in the display output it has this funky line as if some threshold is being met
Code: |
PUT //DD:INFIL999 RRMB315
OUTPUTSTEM.1000
PUT //DD:INFI1001 RRMB330
PUT //DD:INFI1002 RRMB331
|
Btw, I am receptive to better ways to do this- but really would like to know what's going on. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Tue Mar 15, 2022 10:57 pm Post subject: |
|
|
chuck,
You need to replace the OUTPUTSTEM. with memlist. when you are writing.
i.e change this line
Code: |
"EXECIO * DISKW "OUTDD" (FINIS STEM OUTPUTSTEM."
|
to
Code: |
"EXECIO * DISKW "OUTDD" (FINIS STEM memlist.)"
|
_________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
chuck Beginner
Joined: 30 Nov 2007 Posts: 26 Topics: 12
|
Posted: Fri Mar 18, 2022 3:00 pm Post subject: |
|
|
kolusu wrote: | chuck,
You need to replace the OUTPUTSTEM. with memlist. when you are writing.
i.e change this line
Code: |
"EXECIO * DISKW "OUTDD" (FINIS STEM OUTPUTSTEM."
|
to
Code: |
"EXECIO * DISKW "OUTDD" (FINIS STEM memlist.)"
|
|
But sir, that won't help. I need to write out what is in the stem variable OUTPUTSTEM, ie I need a series of strings that look like this
Code: |
PUT //DD:INFILE1 MEMBER1
PUT //DD:INFILE2 MEMBER2
PUT //DD:INFILE3 MEMBER3
|
If I use memlist. all that will get written out is
Code: |
MEMBER1
MEMBER2
MEMBER3
|
|
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Mon Mar 21, 2022 1:30 pm Post subject: |
|
|
chuck,
I found the problem with your code. The Last IF is ONLY check for value > 1000 , but it should be >= 1000 ( Greater than or EQUAL to 1000)
ie.
Code: | else if i > 1000 then |
Should be
Code: | else if i >= 1000 then |
Also I am not sure as to why you need these checks. If your intention is to generate 8 character DDname you can do it quite easily with just padding the record-count with zeros to the left.
Code: |
do i = 1 to memlist.0
memname = strip(memlist.i)
outputstem.output_line_count= ,
'PUT //DD:INDD' || right(i,4,'0') ||' ' memname
output_line_count=output_line_count + 1
end
|
This will generate
Code: |
PUT //DD:INDD0001 MEM0001
...
PUT //DD:INDD9999 MEM9999
|
_________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
chuck Beginner
Joined: 30 Nov 2007 Posts: 26 Topics: 12
|
Posted: Wed Mar 23, 2022 4:03 pm Post subject: |
|
|
Thank you! Especially for the suggested improvement.
I don't really know REXX but a couple three times a year I have to cobble something together! I am glad this forum is still around. |
|
Back to top |
|
|
|
|