MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Odd behaviour when writing stem variable contents to file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
chuck
Beginner


Joined: 30 Nov 2007
Posts: 23
Topics: 10

PostPosted: Tue Mar 15, 2022 6:59 pm    Post subject: Odd behaviour when writing stem variable contents to file Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12354
Topics: 75
Location: San Jose

PostPosted: Tue Mar 15, 2022 10:57 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
chuck
Beginner


Joined: 30 Nov 2007
Posts: 23
Topics: 10

PostPosted: Fri Mar 18, 2022 3:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12354
Topics: 75
Location: San Jose

PostPosted: Mon Mar 21, 2022 1:30 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
chuck
Beginner


Joined: 30 Nov 2007
Posts: 23
Topics: 10

PostPosted: Wed Mar 23, 2022 4:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group