View previous topic :: View next topic
|
Author |
Message |
jithinraghavan
New User
Joined: 15 Apr 2018 Posts: 4 Location: United States
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
jithinraghavan
New User
Joined: 15 Apr 2018 Posts: 4 Location: United States
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|