Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Unexpeted results from REXX code.

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

Active User


Joined: 10 Aug 2009
Posts: 160
Location: India

PostPosted: Mon Aug 16, 2010 7:53 pm    Post subject: Unexpeted results from REXX code.
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Mon Aug 16, 2010 8:13 pm    Post subject:
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: 160
Location: India

PostPosted: Tue Aug 17, 2010 10:41 am    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Tue Aug 17, 2010 1:14 pm    Post subject:
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: 160
Location: India

PostPosted: Thu Aug 26, 2010 10:39 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Weirdo results with JOINKEYS Balaryan DFSORT/ICETOOL 4 Wed Oct 18, 2017 9:04 pm
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 5 Wed Oct 04, 2017 6:54 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 47 Fri Sep 29, 2017 1:08 pm
No new posts Speed-up/reduce CPU use of code prino PL/I & Assembler 0 Tue Sep 26, 2017 12:05 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us