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
 
Difference between EQUAL and EQUAL TO in COBOL

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jithinraghavan

New User


Joined: 15 Apr 2018
Posts: 3
Location: United States

PostPosted: Thu Apr 19, 2018 2:22 am    Post subject: Difference between EQUAL and EQUAL TO in COBOL
Reply with quote

I've declared the below 2 fields in my cobol program

Code:
01  CLM-DETAIL1.                                           
  05  LINE-ITEM1                                           
              OCCURS 0050 TIMES                                   
              INDEXED BY LINE-ITEM1X.                     
    10  LINE-ITEM-CODE1                                   
              COMP-3       PIC 9(03).                             
    10  FIRST-DATE-OF-SVC1                             
              COMP-3       PIC S9(5).                             
    10  LAST-DATE-OF-SVC1                               
              COMP-3       PIC S9(5).                             
    10  CLM-PRIOR-AUTH-IND1         
                           PIC X(1).           

01  CLM-DETAIL2.                                           
  05  LINE-ITEM2                                           
              OCCURS 0050 TIMES                                   
              INDEXED BY LINE-ITEM2X.                     
    10  LINE-ITEM-CODE2                                   
              COMP-3       PIC 9(03).                             
    10  FIRST-DATE-OF-SVC2                             
              COMP-3       PIC S9(5).                             
    10  LAST-DATE-OF-SVC2                               
              COMP-3       PIC S9(5).                             
    10  CLM-PRIOR-AUTH-IND2         
                           PIC X(1).


When I do a compare between these fields with the below 2 if statements, I 'm getting different results. It's compiling successfully with both statements but the results are different.
Is there any difference in these statements really?

1. IF CLM-DETAIL1 NOT EQUAL CLM-DETAIL2
DISPLAY 'X'
END-IF

2. IF CLM-DETAIL1 NOT EQUAL TO CLM-DETAIL2
DISPLAY 'X'
END-IF
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8389
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 19, 2018 5:58 am    Post subject: Reply to: Difference between EQUAL and EQUAL TO in COBOL
Reply with quote

In the version 5.1 Enterprise COBOL Language Reference manual, on page 260, the syntax diagram for the conditional statement is provided. It explicitly states that NOT EQUAL and NOT EQUAL TO are treated by the compiler as identical conditions. Just as IS NOT EQUAL TO is equivalent to NOT EQUAL -- COBOL allows some words to be inserted for readability.

If you're getting different results, then something is not the same. Are the different results in the same program or different programs? For testing purposes, you should code the two statements one after the other in the same program, compile it (do not use the optimization option!), and show us the results.
Back to top
View user's profile Send private message
jithinraghavan

New User


Joined: 15 Apr 2018
Posts: 3
Location: United States

PostPosted: Thu Apr 19, 2018 10:04 pm    Post subject:
Reply with quote

I've declared 2 fields CLM-DETAIL1 and CLM-DETAIL2 with exactly same data except difference in CLM-PRIOR-AUTH-IND(1) field.

CLM-DETAIL1 -> CLM-PRIOR-AUTH-IND1(1) = 'Y'
CLM-DETAIL2 -> CLM-PRIOR-AUTH-IND2 (1) = SPACES

In my cobol program
Code:
IF CLM-DETAIL1 NOT EQUAL CLM-DETAIL2
    DISPLAY 'X'
END-IF


shows no display in sysout
and when I changed if statement in the same COBOL program as below, I got X in my SYSOUT which is correct and I don't know why it is not showing any sysout while using the first IF statement.
Code:
IF CLM-DETAIL1 NOT EQUAL TO CLM-DETAIL2
    DISPLAY 'X'
END-IF
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8389
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 19, 2018 10:11 pm    Post subject: Reply to: Difference between EQUAL and EQUAL TO in COBOL
Reply with quote

You seem to think the TO is making a difference to your program. It is not -- period. The COBOL compiler treats the TO as optional. To show this, look at the pseudo-assembler output generated by the LIST option and you will see the code is the same with or without the TO.

Topic locked as a waste of time; COBOL will not treat NOT EQUAL TO any differently than NOT EQUAL.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts COBOL - JSON GENERATE husni1972 COBOL Programming 1 Fri Aug 17, 2018 3:29 am
No new posts Comparing Comp-3 fields with greater ... Prateeksichem1 DFSORT/ICETOOL 11 Fri Jul 13, 2018 8:45 am
No new posts How to extract the difference from Su... pkmurali TSO/ISPF 3 Mon Jul 02, 2018 8:44 pm
No new posts SQL IN predicate using COBOL table jerryte DB2 16 Fri Jun 29, 2018 10:30 pm
No new posts Converting SAS code to Cobol or Easyt... Ashish.Raghav All Other Mainframe Topics 6 Fri Jun 29, 2018 6:01 pm

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