Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum 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: 4
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: 8479
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: 4
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: 8479
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
This topic is locked: you cannot edit posts or make replies. COBOL/CICS with real time MQ Series u... BPranav CICS 2 Mon Sep 16, 2019 9:19 pm
This topic is locked: you cannot edit posts or make replies. Compare two files logic in COBOL Nishant Singhal COBOL Programming 4 Sun Aug 25, 2019 2:25 am
No new posts Difference between CICS region bounce... polymathtarun CICS 3 Sun Aug 04, 2019 10:51 pm
This topic is locked: you cannot edit posts or make replies. Upgrade to Enterprise COBOL 6 JPVRoff COBOL Programming 4 Thu Aug 01, 2019 7:21 am
No new posts COBOL copybook to Focus anandgbe COBOL Programming 7 Wed Jul 31, 2019 11:52 am

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