IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Simple if statement - condition fail


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 12, 2010 2:19 pm
Reply with quote

Code:
IF RMF-RS-SECTION-ALPHA (RMF-VCA-SECTION-CNTL-INDX)
    MOVE '1' TO NQA-SW                             
    MOVE 99 TO RMF-VCA-SECTION-CNTL-INDX.         



will this work??
Quote:

RMF-RS-SECTION-ALPHA (RMF-VCA-SECTION-CNTL-INDX) returns a string


when will this condition fail??

Please help.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 12, 2010 3:16 pm
Reply with quote

what is the data definition of RMF-RS-SECTION-ALPHA?

and COBOL does not deal with strings.
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 12, 2010 3:21 pm
Reply with quote

Dick Brenholtz ,

Here is the definition.

Code:
20  RMF-RS-SECTION-TABLE OCCURS 99.   
             25  RMF-RS-SECTION-ALPHA   PIC X(03).


This is my production code, am analyzing this code.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 12, 2010 3:56 pm
Reply with quote

1. what cobol compiler was used to compile this production code?

2. where did the quote come from?

Quote:
Quote:

RMF-RS-SECTION-ALPHA (RMF-VCA-SECTION-CNTL-INDX) returns a string



actually the above addresses a 3 byte field defined as alphanumeric.
'returns a string' is verbiage applied to a function or method,
both of which the indexed Reference is not.

something else is going on, because the IF statement should not have compiled under ibm COBOL II or ibm E-COBOL.
are there any entries in the SPECIAL NAMES section?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Aug 12, 2010 4:00 pm
Reply with quote

I guess the condition is always true, cause you get a string or spaces what
is also a string returned.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 12, 2010 4:15 pm
Reply with quote

Peter,

could you explain why this would be true? why it would even compile?
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 12, 2010 4:18 pm
Reply with quote

thanks peter. i ll check
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 12, 2010 4:19 pm
Reply with quote

Dick Brenholtz,
Am not sure.
The code is written some 20 years back.
Special names section is not mentioned.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Aug 12, 2010 4:24 pm
Reply with quote

dbzTHEdinosauer wrote:
Peter,

could you explain why this would be true? why it would even compile?


Dick,

to be fair, I was thinking in C where string functions return a pointer
or NULL. So i assumed that today cobol has string functions too.
My latest cobol experience is about 30 years ago, so it maybe better to
refrain from cobol topics.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Aug 12, 2010 4:49 pm
Reply with quote

These things are not hard to test yourself, you know. If you put this into a program and attempt to compile it, you get
Code:
                IF RMF-RS-SECTION-ALPHA (RMF-VCA-SECTION-CNTL-INDX)

IGYPS2096-S An incomplete condition was found in a conditional expression.  The
            operand(s) was(were) discarded.
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 12, 2010 5:13 pm
Reply with quote

Ya I knew I will get the error but still it is in my production module and it is working.

Is it possible in previous versions of cobol??
Because as i said the code was written 22 years back.

Now, am using Cobol-II.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 12, 2010 5:15 pm
Reply with quote

Robert has proved that the code snippet will not compile.

to continue the theoretical discussion -
since this code is in production,
obviously it compiled - sometime in the distant past

we need the 'enveloping' code.
it it appears to be part of a perform varying
(since the code modifies the subscript).

shankarm,
could you post the code that invokes the code snippet that you showed.

also, your quote about the returned string,
who told you that?
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 12, 2010 5:56 pm
Reply with quote

Folks,

Sorry for the delay.
I have some problem with my ID.
I am not able to logon to mainframe.

I ll paste the code once my logon issue is solved(in few mins).
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 12, 2010 6:21 pm
Reply with quote

Guys here is the code..

Code:

C100-BD-VALIDATE.                                       
    MOVE 0 TO  ERR-HLD1.                               
                                                       
**** STA-BA IS OVERRIDE FOR SAA-L, -J, -2 ************ 
    IF P-PRES-IND(STA-BA) = 'Y'                         
        IF P-PRES-IND(SAA-L) NOT = 'Y'                 
            IF P-PRES-IND(SAA-J) NOT = 'Y'             
                IF P-PRES-IND(SAA-2) NOT = 'Y'         
                    MOVE 2469 TO ERR-HLD1               
                    MOVE P-SCAN-SUB(STA-BA) TO HLD-SUB1
                    MOVE 'STA' TO SRCH-KEY             
                    PERFORM D000-ERR-LOAD THRU D000-EXIT
                                                       
********************************************************
* THIS CODE COMMENTED OUT AS PER GARY GOODNUFF 3/8/89. 
********************************************************
*   IF RMF-GAA-A-FLAG = 'Y'                             
*       IF P-PRES-IND (WAA-M) NOT = 'Y'                 
*           MOVE 2258 TO ERR-HLD1                       
*           MOVE P-SCAN-SUB (GAA-A) TO HLD-SUB1         
*           MOVE 'GAA' TO SRCH-KEY                     
*           PERFORM D000-ERR-LOAD THRU D000-EXIT.       
                                                       
    MOVE 1 TO RMF-VCA-SECTION-CNTL-INDX.               
    MOVE '0' TO NQA-SW.                                 
C100-BD-NQA-CHK.                                       
    IF RMF-RS-SECTION-ALPHA (RMF-VCA-SECTION-CNTL-INDX)
        MOVE '1' TO NQA-SW                             
        MOVE 99 TO RMF-VCA-SECTION-CNTL-INDX.           
    ADD 1 TO RMF-VCA-SECTION-CNTL-INDX.                 
    IF RMF-VCA-SECTION-CNTL-INDX > RMF-RS-SECTION-COUNT
        NEXT SENTENCE                                   
    ELSE GO TO C100-BD-NQA-CHK.                         
    IF P-PRES-IND (FFA-N) = 'Y'                         
        IF ((P-PRES-IND (FSA) NOT = 'Y') AND               



and goes on...

the calling module is
Code:

IF RMF-KA-REPORT-TYPE = 'BD'               
    PERFORM C100-BD-VALIDATE THRU C100-EXIT


This callin module is inside another perform.. and that inside another... but nothing in perform varying loop.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 12, 2010 6:37 pm
Reply with quote

Code:

    IF P-PRES-IND(STA-BA) = 'Y'                         
        IF P-PRES-IND(SAA-L) NOT = 'Y'                 
            IF P-PRES-IND(SAA-J) NOT = 'Y'             
                IF P-PRES-IND(SAA-2) NOT = 'Y'         
                    MOVE 2469 TO ERR-HLD1               
                    MOVE P-SCAN-SUB(STA-BA) TO HLD-SUB1
                    MOVE 'STA' TO SRCH-KEY             
                    PERFORM D000-ERR-LOAD THRU D000-EXIT
                                                       
********************************************************
* THIS CODE COMMENTED OUT AS PER GARY GOODNUFF 3/8/89.
********************************************************
*   IF RMF-GAA-A-FLAG = 'Y'                             
*       IF P-PRES-IND (WAA-M) NOT = 'Y'                 
*           MOVE 2258 TO ERR-HLD1                       
*           MOVE P-SCAN-SUB (GAA-A) TO HLD-SUB1         
*           MOVE 'GAA' TO SRCH-KEY                     
*           PERFORM D000-ERR-LOAD THRU D000-EXIT.       
                                                       
    MOVE 1 TO RMF-VCA-SECTION-CNTL-INDX.


the code commented out as per gary goodnuff 3/8/89
removed the only period '.' (end of if statement)
thus causing the period after
MOVE 1 TO RMF-VCA-SECTION-CNTL-INDX.
to end the (typical 20-year old BS) IF statement.
also, the move will only be executed if all four IF's are statisfied
otherwise RMF-VCA-SECTION-CNTL-INDX is never reset.
afterwards, the logic falls thru this garbage:
Code:

    MOVE '0' TO NQA-SW.                                 
C100-BD-NQA-CHK.                                       
    IF RMF-RS-SECTION-ALPHA (RMF-VCA-SECTION-CNTL-INDX)
        MOVE '1' TO NQA-SW                             
        MOVE 99 TO RMF-VCA-SECTION-CNTL-INDX.           
    ADD 1 TO RMF-VCA-SECTION-CNTL-INDX.                 
    IF RMF-VCA-SECTION-CNTL-INDX > RMF-RS-SECTION-COUNT
        NEXT SENTENCE                                   
    ELSE GO TO C100-BD-NQA-CHK. 


the next time thru C100-BD-VALIDATE
the value of RMF-VCA-SECTION-CNTL-INDX will be 99.
depending on if the aforementioned set of nested IF's.


Good Luck with this crap.

so you have two problems:
1. what was this incomplete IF really meant to be
2. correct the missing .
Back to top
View user's profile Send private message
shankarm

Active User


Joined: 17 May 2010
Posts: 175
Location: India

PostPosted: Thu Aug 12, 2010 6:45 pm
Reply with quote

Thanks for your time and effort people.
I ll look into it and i ll post if i find any clue.
Back to top
View user's profile Send private message
saurabh39
Warnings : 1

Active User


Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

PostPosted: Thu Aug 12, 2010 8:05 pm
Reply with quote

Hi,

I have one question - Is it possible that, when this particular production code was moved, the load module did not refresh and was having same old load module.

Also, is it possible or are there any ways by which i can check whether a given statement is part of load module?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Aug 12, 2010 8:21 pm
Reply with quote

Depending upon how the move was done, it is possible that the load module was not refreshed -- but most of the time the production control group is aware of the possibility and is very careful to ensure the move actually did occur. An AMBLIST on the load module should resolve any doubts, one way or the other -- as long as you know the date of the move.

And as far as your second (of one) question, while there are some special circumstances in which source code is associated with load modules (such as compiling with products that allow source analysis of executions), in general you cannot determine which COBOL source statements were compiled to create a particular load module.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Add condition to a FINDREP SORT card DFSORT/ICETOOL 4
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Run a simple JOB as Started Task All Other Mainframe Topics 4
Search our Forums:

Back to Top