REXX program skips an input record



IBM's Command List programming language & Restructured Extended Executor

Re: REXX program skips an input record

Postby willy jensen » Wed Sep 21, 2022 9:40 pm

I don't particular like having disp MOD for an input dataset, but there is probably a good reason.
Looking at the code shown I cannot offhand see why statement 43 does not list data record 79.
I suggest that you display the actual datasetname allocated and then browse that to verify the contents.
Also for a loop that big I personally would choose a more meaníngful control variable than just B, it is all too easy to reassign B somewhere in a subroutine.

These users thanked the author willy jensen for the post:
collinsm (Thu Sep 22, 2022 5:36 am)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: REXX program skips an input record

Postby sergeyken » Wed Sep 21, 2022 11:03 pm

I recommend you to start from the minimal code configuration:

DO B = 1 TO CUR_LINE.0 /* ! B LOOP */
   SAY B CUR_LINE.B
   WTO_INDEX1 = INDEX(CUR_LINE.B,'//ST10 ')
   CUR_LINE.B = '// '
   QUEUE_LINE = CUR_LINE.B /* USE QUEUE_LINE AS OUTPUT */
   WTO_INDEX = INDEX(CUR_LINE.B,'//ST10 ')
   SAY 'B IS ' B
   SAY 'CUR LINE IS ' CUR_LINE.B
END /* ! B LOOP */


Also you can improve your END statement a little bit:

DO B = 1 TO CUR_LINE.0 /* ! B LOOP */
   . . . . . . . . .
END B        /* ! B LOOP */



When you are sure it is working as desired, then start adding other parts of text processing, one logical part at a time. As soon as you are faced your initial issue again, it points to the last added part of code, which needs to be carefully reviewed.
Javas and Pythons come and go, but JCL and SORT stay forever.

These users thanked the author sergeyken for the post:
collinsm (Thu Sep 22, 2022 5:36 am)
User avatar
sergeyken
 
Posts: 409
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 6 times
Been thanked: 40 times

Re: REXX program skips an input record

Postby collinsm » Thu Sep 22, 2022 12:32 am

Sergeyken, first off, I didn't write this code; the administrator before me wrote it. Second, I do not appreciate you calling the code 'terrible' and a 'mess'. As you have said, you have not read it, so you have no idea if it is terrible or not. As you said, I am trying to be polite, however, it's hard to be polite when I am insulted.
collinsm
 
Posts: 13
Joined: Mon Sep 19, 2022 9:19 pm
Has thanked: 7 times
Been thanked: 0 time

Re: REXX program skips an input record

Postby willy jensen » Thu Sep 22, 2022 12:58 am

I have read the code, and all I will say is that coding habits differ.
But I will go along with sergeykens suggestion of getting down to the smallest program that will prove or disprove your point. As far as I can tell, something like this should do it:
"Allocate da(dsname) dd(dd1) shr"
"Execio * diskr dd1 (stem cur_line. finis)"
"free dd(dd1)"
DO B = 1 TO CUR_LINE.0 /* ! B LOOP */
   SAY right(B,6,0) strip(CUR_LINE.B,'t')
END /* ! B LOOP */

These users thanked the author willy jensen for the post:
collinsm (Thu Sep 22, 2022 5:36 am)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: REXX program skips an input record

Postby Pedro » Thu Sep 22, 2022 1:35 am

re: "calling the code 'terrible' "

Not sure if it is terrible or not, but it was shown to us without indentations and with line numbers. It is hard to read. I agree with earlier comments about not showing the entirety of the code, but only showing the parts that are pertinent.
Pedro Vera

These users thanked the author Pedro for the post:
collinsm (Thu Sep 22, 2022 5:37 am)
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: REXX program skips an input record

Postby Pedro » Thu Sep 22, 2022 1:51 am

Willy provided a good way to debug your code.

To debug further, I would add similar code at various spots:
DO _prob = 77 TO 80 /* ! _prob LOOP */
   SAY right(_prob,6,0) strip(CUR_LINE._prob,'t')
END /* ! _prob LOOP */

/* your main loop */
DO B = 1 TO CUR_LINE.0 /* ! B LOOP */
  ...
  /*  add this in a few spots to narrow source of problem */
  DO _prob = 77 TO 80 /* ! _prob LOOP */
     SAY right(_prob,6,0) strip(CUR_LINE._prob,'t')
  END /* ! _prob LOOP */
  ...
END /* ! B LOOP */

 
Pedro Vera

These users thanked the author Pedro for the post:
collinsm (Thu Sep 22, 2022 5:37 am)
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: REXX program skips an input record

Postby collinsm » Thu Sep 22, 2022 2:58 am

I did not write this program, and I only know a little REXX, so I cannot make comments about how it's written. I am able to read through the program. There are a couple of things that I can see don't need to be done.

I should say first that there is one of two datasets that is being read: a production DB2 bind file and an exception file. In this case, the REXX opens the exception file because it found the bind JCL in that one.

I stripped down the REXX to an open of one of the files and a do loop to display each of the records. When I run through all of the JCL lines, the one line that has the DB2 program in it, line 79 of 359 lines, is skipped.

I tried adding the element to the production dataset and removing it from the exception dataset. When it reads the production dataset, it does not skip the record and writes out all 359 records. Because the production library is PDSE and the exception is PDS, I copied the exception elements into a new PDSE file. That didn't make a difference.

There is something about the exception dataset that it doesn't like.
collinsm
 
Posts: 13
Joined: Mon Sep 19, 2022 9:19 pm
Has thanked: 7 times
Been thanked: 0 time

Re: REXX program skips an input record

Postby Pedro » Thu Sep 22, 2022 3:16 am

something about the exception dataset that it doesn't like


Nothing comes to mind about why it would skip a particular line. But, turn hex on and look for non-display characters that you do not expect to be there. Look in the lines before and also the skipped line.

Also, Willy mentioned about the use of MOD in the ALLOC statement. It should probably be SHR instead. I doubt it would cause this problem, but you should eliminate incorrect stuff when you find it.
Pedro Vera

These users thanked the author Pedro for the post:
collinsm (Thu Sep 22, 2022 5:37 am)
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: REXX program skips an input record

Postby collinsm » Thu Sep 22, 2022 3:20 am

I did as Pedro suggested. It does not see line 79. The first is how the member in the exception library looks, with the DB2 program listed. The second is the display of the REXX displaying those records.

000077      RELEASE(COMMIT)  -              
000078      PKLIST(          -              
000079             DB2SUBR.BC20P007 +        
000080             ) -                                                    
 



1 //DSCCHQ01 JOB (),BIND.EXCEP8,MSGLEVEL=(1,1),      
1 //DSCCHQ01 JOB (),BIND.EXCEP8,MSGLEVEL=(1,1),      
000077      RELEASE(COMMIT)  -                        
000078      PKLIST(          -                        
000079             ) -                                
000080      EXPLAIN(N) -                              
2 //     CLASS=A,PRTY=10,TIME=(,10),                  
2 //     CLASS=A,PRTY=10,TIME=(,10),                  
 
collinsm
 
Posts: 13
Joined: Mon Sep 19, 2022 9:19 pm
Has thanked: 7 times
Been thanked: 0 time

Re: REXX program skips an input record

Postby collinsm » Thu Sep 22, 2022 3:27 am

One of the first things I did was to turn HEX on, to see if there was a character in the line that would cause a problem. I also changed MOD to SHR. Same thing keeps happening.
collinsm
 
Posts: 13
Joined: Mon Sep 19, 2022 9:19 pm
Has thanked: 7 times
Been thanked: 0 time

PreviousNext

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post