IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Unexpeted results from REXX code.


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Mon Aug 16, 2010 7:53 pm
Reply with quote

Hi,

I have written a small REXX code. Functionality is read two input files and compare the key values. If both are match check the ZON field whether it is ZERO or not. Display the counts in the end.

Here is the code:


Code:

/* REXX */                                                             
IPEOF=0                                                               
DCEOF=0                                                               
Match_Brk_Cnt=0                                                       
M_Brk_Zzon_Cnt=0                                                       
M_Brk_Non_Zzon_Cnt=0                                                   
                                                                       
ADDRESS TSO                                                           
    "EXECIO" 1 "DISKR INFILE"                                         
     If RC <> 0 then IPEOF=1                                           
     PULL Record                                                       
                                                                       
    "EXECIO" 1 "DISKR DACFILE"                                         
     If RC <> 0 then DCEOF=1                                           
     PULL dacRecord                                                   
                                                                       
Do Forever Until(IPEOF|DCEOF)                                         
      Inbroker=substr(Record,2,5)                                     
      Zon=substr(Record,8,3)                                           
      Dacagent=substr(dacRecord,1,5)                                   
     If (Inbroker=Dacagent) Then                                       
      Do                                                               
          Match_Brk_Cnt=Match_Brk_Cnt+1                               
          Call M_ZON_Verify                                           
                                                                       
            "EXECIO" 1 "DISKR INFILE"                                 
            If RC <> 0 then IPEOF=1                                   
            PULL Record                                               
            "EXECIO" 1 "DISKR DACFILE"                                 
            If RC <> 0 then DCEOF=1                                   
            PULL dacRecord                                             
      End                                                             
     Else If (Inbroker<Dacagent) Then                                 
          Do                                                           
            "EXECIO" 1 "DISKR INFILE"                                 
            If RC <> 0 then IPEOF=1                                   
            PULL Record                                               
          End                                                         
     Else If (Inbroker>Dacagent) Then                                 
          Do                                                           
            "EXECIO" 1 "DISKR DACFILE"                                 
            If RC <> 0 then DCEOF=1                                   
            PULL dacRecord                                             
          End                                                         
 End /* End of Do */                                                   
                                                                       
"EXECIO 0 DISKR INFILE(FINIS"                                         
"EXECIO 0 DISKR DACFILE(FINIS"                                         
"FREE F(INFILE)"                                                       
"FREE F(DACFILE)"                                                     
SAY "M_Brk_Zzon_Cnt: "||M_Brk_Zzon_Cnt                                 
SAY "M_Brk_Non_Zzon_Cnt: "||M_Brk_Non_Zzon_Cnt                         
EXIT                                                                   
                                                                       
M_ZON_Verify: PROCEDURE EXPOSE M_Brk_Zzon_Cnt M_Brk_Non_Zzon_Cnt Zon   
      SAY "ZON: "||Zon                                                 
      If Zon=000 Then                                                 
          M_Brk_Zzon_Cnt=M_Brk_Zzon_Cnt+1                             
      Else                                                             
          M_Brk_Non_Zzon_Cnt=M_Brk_Non_Zzon_Cnt+1                     
Return                                                                 


INFILE data:

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
900004 .4.
9A5763 .9.
9B0560 000
9B2046 .5.
9B2087 .6.
9B6355 000
9B6733 .2.
9B9828 000
9D9145 000
9F5475 .1.
912345 000


DACFILE data:

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00004
A5763
B0560
B2046
B2087
B6355
B6733
B9828
D9145
F5475


When execute the above code. First time both the files are read and compared, both the keys are matched. When it reads second time it is not reading from second file.

Could you please let me know here I am doing mistake?
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Mon Aug 16, 2010 8:03 pm
Reply with quote

How do you know that the REXX Exec is reading the first file and not the second when invoked the second time?

I see that you FREE both files within the REXX Exec but I do not see that they are ALLOCATED within the REXX Exec. If you run just the REXX Exec twice, neither file is allocated at the beginning of the second run - and I must assume that both are allocated manually prior to the first invocation, otherwise the first invocation would fail as well.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Aug 16, 2010 8:13 pm
Reply with quote

apparently you are running this in background (batch) and not foreground.

without seeing the 'SAY' output, it is very difficult - we only have your word that it goes thru the 'matched' logic.

suggest you run with TRACE and see where the flow is really going.
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Tue Aug 17, 2010 10:41 am
Reply with quote

Hi Dick,

Yes, I am running this program in batch.

I have added below "SAY" statements after "Do Forever Until" statement.

Code:

SAY "inRecord: "||Record
SAY "dacRecord: "||dacRecord


Below mentioned output I got when I ran my code

Code:

inRecord: 900004  4
dacRecord: 00004
inRecord: 900004  4
dacRecord: A5763
inRecord: 900004  4
dacRecord: B0560
inRecord: 900004  4
dacRecord: B2046
inRecord: 900004  4
dacRecord: B2087
inRecord: 900004  4
dacRecord: B6355
inRecord: 900004  4
dacRecord: B6733
inRecord: 900004  4
dacRecord: B9828
inRecord: 900004  4
dacRecord: D9145
inRecord: 900004  4
dacRecord: F5475


It was read only one record from the input file but it read all the records from the dacfile.

Could you please suggest me what change I need to do to my code?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 17, 2010 1:14 pm
Reply with quote

satish.ms10,

you will reduce your need to refer to this website when you learn to use TRACE.
I generally use
TRACE ?R
and rarely have any questions about why my code does not work.

stop with the SAY instructions for debugging. All you have accomplished is to show that for some reason variable Record never changes.
Had you put a trace statement in, (put it right after /* REXX */), you would know what your problem is.
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Thu Aug 26, 2010 10:39 am
Reply with quote

Hi Dick,

Sorry for the later reply. I tried with TRACE ?R and found the problem in my rexx code. It is working fine now.

Thank you very much for all your support.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top