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

print out the correct info in LOOP?


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

Active User


Joined: 09 Jun 2014
Posts: 119
Location: CT

PostPosted: Wed Dec 23, 2015 10:39 pm
Reply with quote

I got the following code to print out data set name that meet the condition, if not ,it will print out "NOT FOUND' . Because of the loop ,everytime it not meet the condition, it will print one "NOT FOUND". eg, if A=4 , all four date set are not meet the condition , it print :

Code:
NOT FOUND
NOT FOUND
NOT FOUND
NOT FOUND


if thrid one meet the condition , it print
Code:
NOT FOUND                             
NOT FOUND                             
CPM.GCICS.BATCH.DB2SUMM.BKUP.G4300V00
NOT FOUND   


How to correct this code to print only one "NOT FOUND" when condition not meet and only date set name when it meet the condition?

Thank you !

Code :

Code:
WHEN FOUND='DEC' THEN DO                 
  DAY= INPUT_DAY+335   /* CHECK FOR DAY */
    DO L=1 TO A                           
     SELECT                               
      WHEN DEC.L /='' & DS_D.L= DAY THEN 
           SAY DEC.L                     
      WHEN DEC.L /='' & INPUT_DAY=0 THEN 
           SAY DEC.L                     
      OTHERWISE                           
           SAY 'NOT FOUND'               
     END                                 
    END                                   
 END                                     
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Wed Dec 23, 2015 10:59 pm
Reply with quote

I think it should be simple enough. Just use an indicator (FILE_FOUND)
Code:
WHEN FOUND='DEC' THEN DO                 
   DAY= INPUT_DAY+335   /* CHECK FOR DAY */
     FILE_FOUND = 'N'
     DO L=1 TO A                           
      SELECT                               
       WHEN DEC.L /='' & DS_D.L= DAY THEN
          DO
            FILE_FOUND = 'Y' 
            SAY DEC.L   
          END                 
       WHEN DEC.L /='' & INPUT_DAY=0 THEN 
          DO   
            FILE_FOUND = 'Y'
            SAY DEC.L
          END                     
       OTHERWISE                                     
      END                                 
     END
     IF FILE_FOUND = 'N'
     THEN DO
          SAY 'NOT FOUND'
     END                                   
  END           
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 119
Location: CT

PostPosted: Wed Dec 23, 2015 11:29 pm
Reply with quote

Thank you ! I should think about this
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2572
Location: NYC,USA

PostPosted: Thu Dec 24, 2015 12:10 am
Reply with quote

Is that what you expect? just to print only 1 'NOT FOUND' if A=p?
p= any number
Code:
WHEN FOUND='DEC' THEN DO                 
   DAY= INPUT_DAY+335   /* CHECK FOR DAY */
     n = 1
     m= 0
     DO L=1 TO A                           
      SELECT                               
       WHEN DEC.L /='' & DS_D.L= DAY THEN 
            SAY DEC.L                     
       WHEN DEC.L /='' & INPUT_DAY=0 THEN 
            SAY DEC.L                     
       OTHERWISE   
            m = n+1
            if m=2                         
            SAY 'NOT FOUND'           
            end               
      END                                 
     END                                   
  END 
RahulG31, in your case (if I get him correctly), it will still print 'NOT FOUND' 4 times if none of the dataset condition is meet when say A= 4.
Also, check if you can club (DS_D.L= DAY or INPUT_DAY=0) & DEC.L /='' together instead of two separate hence simple if else will do instead of select when.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Dec 24, 2015 12:14 am
Reply with quote

No. The following condition is outside the DO loop, so only 1 'NOT FOUND':
Code:
     IF FILE_FOUND = 'N'
      THEN DO
           SAY 'NOT FOUND'
      END

There will be multiple File Names that will be printed (if multiple are found) but if none is found then only one 'NOT FOUND'.

.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2572
Location: NYC,USA

PostPosted: Thu Dec 24, 2015 12:17 am
Reply with quote

so if A=4 and first 3 are FILE_FOUND = N and last one is FILE_FOUND ='Y' then it will never print 'NOT FOUND' or I am mistaken?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Dec 24, 2015 12:20 am
Reply with quote

Yes, that's what it should be.
Quote:
How to correct this code to print only one "NOT FOUND" when condition not meet

Quote:
and only date set name when it meet the condition?

I believe, print 'NOT FOUND' when none is found and If even a single one is found then print the file name and then No need to print 'NOT FOUND'.

.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2572
Location: NYC,USA

PostPosted: Thu Dec 24, 2015 12:27 am
Reply with quote

if what you believe is true then it should work otherwise he have another choice.
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 Proc print in Mainframe All Other Mainframe Topics 4
No new posts Need to read duplicate rows from tabl... DB2 3
No new posts Force a Return Code and print error m... SYNCSORT 30
No new posts Print next line strings when a condit... DFSORT/ICETOOL 9
No new posts SQL pretty print CLIST & REXX 7
Search our Forums:

Back to Top