Page 1 of 1

Search syntax in cobol

PostPosted: Mon Nov 28, 2016 12:55 pm
by arya_starc
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                  

 

Re: Search syntax in cobol

PostPosted: Mon Nov 28, 2016 6:25 pm
by Robert Sample
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.

Re: Search syntax in cobol

PostPosted: Mon Nov 28, 2016 9:47 pm
by BillyBoyo
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).

Re: Search syntax in cobol

PostPosted: Tue Nov 29, 2016 3:29 am
by Robert Sample
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.