Search syntax in cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Search syntax in cobol

Postby arya_starc » Mon Nov 28, 2016 12:55 pm

In this below code when the first WHEN condition is satisfy the search loop automatically ends. Is it right?


  MOVE  1   TO WS-DATE                              
  PERFORM UNTIL WS-DATE IS GREATER THAN 05          
    SET X-HOLIDAY     TO 1                          
    SEARCH WS-HOLIDAY-RECORD                        
          AT END CONTINUE                            
    WHEN WS-HOLIDAY(X-HOLIDAY) IS EQUAL TO WS-JULIAN
            COMPUTE WS-JULIAN = WS-JULIAN + 1        
    END-SEARCH                                      
            COMPUTE WS-DATE = WS-DATE + 1            
  END-PERFORM                                        
  SET DATE-NOT-ASSIGN       TO TRUE                  

 
arya_starc
 
Posts: 60
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Search syntax in cobol

 

Re: Search syntax in cobol

Postby Robert Sample » Mon Nov 28, 2016 6:25 pm

Your question is answered in the Enterprise COBOL Language Reference manual for your version of Enterprise COBOL. This is a HELP forum, not a READ-THE-MANUAL-FOR-YOU forum. I suggest you start reading to find the answer to your question.

These users thanked the author Robert Sample for the post:
kenken1+1 (Tue Nov 29, 2016 8:03 am)
Robert Sample
Global moderator
 
Posts: 3130
Joined: Sat Dec 19, 2009 8:32 pm
Location: Bellevue, Iowa
Has thanked: 1 time
Been thanked: 185 times

Re: Search syntax in cobol

Postby BillyBoyo » Mon Nov 28, 2016 9:47 pm

And pay attention to this in the manual:

Before executing a serial search, you must set the value of the first (or only) index associated with identifier-1 (the search index) to indicate the starting occurrence for the search.


The index used for the SEARCH has its current value used as the starting-point of the search. If you don't explicitly set it to something (like 1) it will restart from wherever the previous SEARCH left off (or from somewhere else if you've later modified that index value).
BillyBoyo
Global moderator
 
Posts: 3761
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 256 times

Re: Search syntax in cobol

Postby Robert Sample » Tue Nov 29, 2016 3:29 am

when the first WHEN condition is satisfy the search loop automatically ends. Is it right?
After reviewing your post, I'm not sure what you are referring to here. Your code only has one WHEN so "first WHEN" is redundant at best, completely wrong at worst. And what does "search loop" mean -- the scope of the sequential SEARCH verb you specified? the PERFORM loop? something else? You need to clearly state your problem, the results you expect, and how the actual results vary from the expected results.
Robert Sample
Global moderator
 
Posts: 3130
Joined: Sat Dec 19, 2009 8:32 pm
Location: Bellevue, Iowa
Has thanked: 1 time
Been thanked: 185 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post