Character not being displayed correctly

IBM's Command List programming language & Restructured Extended Executor
ddebevec
Posts: 2
Joined: Wed Nov 13, 2024 12:01 am
Skillset: z/OS Systems Programmer
Referer: Google browse

Character not being displayed correctly

Postby ddebevec » Tue May 06, 2025 8:22 am

I have a one off REXX program that generates SYSIN cards. The problem that I'm encountering is the final ')' being dropped. I have tried different character masks i.e. queue"-START DB(" || part1 || ") SPACE(" || part2 || ")" but to no avail. I have included the REXX code, records and output. Can anyone tell me where I'm missing it? Thanks!

Code:

/* REXX */

inputFile = "SYSTMDD.REORG.FILE1"
outputFile = "SYSTMDD.REORG.FILE3"

"ALLOC FI(INFILE) DA("inputFile") SHR"
"ALLOC FI(OUTFILE) DA("outputFile") SHR"

"EXECIO * DISKR INFILE (STEM filedata. FINIS" /* Read file into array */

num_records = filedata.0 /* getnumber of records read */

SAY "Number of recorders read:" num_records

DO i = 1 TO num_records
record = filedata.i
record2 = translate(record, ' ', '.') /* Replace '.' with space */
parse var record2 part1 part2
queue"-STOP DB("part1") SPACE("part2")" <== this parentheses is lost
END

"EXECIO" queued() "DISKW outfile (FINIS"

"FREE FI(INFILE)"
"FREE FI(OUTFILE)"
EXIT

Source data:
AGMAILPD.AGADDRTS
AGMAILPD.AGAGNTTS
AGMAILPD.AGALTKTS
AGMAILPD.AGCBUSTS
AGMAILPD.AGCNTYTS

Output:
-STOP DB(AGMAILPD) SPACE(AGADDRTS
-STOP DB(AGMAILPD) SPACE(AGAGNTTS
-STOP DB(AGMAILPD) SPACE(AGALTKTS
-STOP DB(AGMAILPD) SPACE(AGCBUSTS
-STOP DB(AGMAILPD) SPACE(AGCNTYTS

willy jensen
Posts: 474
Joined: Thu Mar 10, 2016 5:03 pm
Skillset: assembler rexx zOS ispf racf smf
Referer: saw it in the experts foprum thought I could help here

Re: Character not being displayed correctly

Postby willy jensen » Tue May 06, 2025 2:00 pm

Do a TRACE R before the loop to see what is really happening. The QUEUE statement is fine (I tested it), so one possible explanation is that the generated line is longer than the record length for the dataset that you write to, so that the records are truncated. Or in other words, the part2 variable might have a lot of spaces at the end. A quick way to verify this is to do a part2=STRIP(part2) before the QUEUE.

ddebevec
Posts: 2
Joined: Wed Nov 13, 2024 12:01 am
Skillset: z/OS Systems Programmer
Referer: Google browse

Re: Character not being displayed correctly

Postby ddebevec » Tue May 06, 2025 6:52 pm

Adding the " part2=STRIP(part2)" fixed it. Thanks for your help.

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Character not being displayed correctly

Postby sergeyken » Tue May 06, 2025 11:14 pm

Please, next time post it in such way.
Be polite to potential readers.

ddebevec wrote:I have a one off REXX program that generates SYSIN cards. The problem that I'm encountering is the final ')' being dropped. I have tried different character masks i.e.

Code: Select all

queue"-START DB(" || part1 || ") SPACE(" || part2 || ")"
but to no avail. I have included the REXX code, records and output. Can anyone tell me where I'm missing it? Thanks!

Code:

Code: Select all

/* REXX */                                                                

inputFile  = "SYSTMDD.REORG.FILE1"                                        
outputFile = "SYSTMDD.REORG.FILE3"  
                                     
"ALLOC FI(INFILE) DA("inputFile") SHR"                                                                            
"ALLOC FI(OUTFILE) DA("outputFile") SHR"                                  
                                                                         
"EXECIO * DISKR INFILE (STEM filedata. FINIS" /* Read file into array */  
                                                                         
 num_records = filedata.0  /* getnumber of records read */                
                                                                         
SAY "Number of recorders read:" num_records  

DO i = 1 TO num_records                                              
 record = filedata.i                                                
 record2 = translate(record, ' ', '.') /* Replace '.' with space */  
 parse var record2 part1 part2                                      
 queue"-STOP DB("part1") SPACE("part2")"         <== this parentheses is lost                  
END          
                                                       
 "EXECIO" queued() "DISKW outfile (FINIS"
                                         
"FREE FI(INFILE)"                        
"FREE FI(OUTFILE)"                      
EXIT  


Source data:

Code: Select all

AGMAILPD.AGADDRTS
AGMAILPD.AGAGNTTS
AGMAILPD.AGALTKTS
AGMAILPD.AGCBUSTS
AGMAILPD.AGCNTYTS


Output:

Code: Select all

-STOP DB(AGMAILPD) SPACE(AGADDRTS
-STOP DB(AGMAILPD) SPACE(AGAGNTTS
-STOP DB(AGMAILPD) SPACE(AGALTKTS
-STOP DB(AGMAILPD) SPACE(AGCBUSTS
-STOP DB(AGMAILPD) SPACE(AGCNTYTS
Javas and Pythons come and go, but JCL and SORT stay forever.

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Character not being displayed correctly

Postby sergeyken » Wed May 07, 2025 12:50 am

willy jensen wrote:Do a TRACE R before the loop to see what is really happening. The QUEUE statement is fine (I tested it), so one possible explanation is that the generated line is longer than the record length for the dataset that you write to, so that the records are truncated. Or in other words, the part2 variable might have a lot of spaces at the end. A quick way to verify this is to do a part2=STRIP(part2) before the QUEUE.


The correct solution should be like this:

Code: Select all

parse var record2 part1 part2 .

The dot as the last parameter placeholder eliminates all characters after the second parameter (in this example)

P.S.
One of the worst programming habits is: naming variables as "record2", "part1", "part2", "var23", "char27", "parm3", etc.
Javas and Pythons come and go, but JCL and SORT stay forever.

willy jensen
Posts: 474
Joined: Thu Mar 10, 2016 5:03 pm
Skillset: assembler rexx zOS ispf racf smf
Referer: saw it in the experts foprum thought I could help here

Re: Character not being displayed correctly

Postby willy jensen » Wed May 07, 2025 12:21 pm

Re "parse var record2 part1 part2 ." only if the part2 variable is supposed to be a single word.
Personally I'd rather do

Code: Select all

queue "-STOP DB("part1") SPACE("strip(part2)")"


@ddebevec just a hint, if you check the RC after the "EXECIO" queued() "DISKW outfile (FINIS" command, you would have seen a RC=2, which tells you that record(s) have been truncated.

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Character not being displayed correctly

Postby sergeyken » Fri May 09, 2025 12:52 am

Personally I'd rather do without unneeded variables, and manipulations

Code: Select all

. . . . . . . . .
"EXECIO * DISKR INFILE ( FINIS" /* Read file into stack, no need for a stem */                                                                        
 num_records = queued()  /* get number of records read */                
                                                                         
SAY "Number of records read:" num_records  

/* re-fill the stack in a circle */
DO num_records             /* no need to use index */                                            
 parse pull part1 "." part2 .      /* no need for extra variables */                                
 queue "-STOP DB("part1") SPACE("part2")"   /* <== this parentheses is NOT lost now */              
END      
. . . . . . . . .  
Javas and Pythons come and go, but JCL and SORT stay forever.


  • Similar Topics
    Replies
    Views
    Last post