Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

IF statement doubt
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Thu Feb 10, 2011 2:50 am    Post subject: IF statement doubt
Reply with quote

We are having an IF statement which is seeming not working as correctly.
Here is our below cobols coding:

Code:
DISPLAY 'POLICY-NUMBER '   POLICY-NUMBER
DISPLAY 'CURRENT POLICY ' WS-POLICY
DISPLAY 'POLICY-TYPE '        POLICY-TYPE

DISPLAY 'BEFORE IF'

IF POLICY-NUMBER = WS-POLICY
   DISPLAY 'MATCH'
   PERFORM POLICY-MATCH
   IF POLICY-TYPE = 'A'
       DISPLAY 'A TYPE'
       PERFORM POLICY-A-TYPE
ELSE
   DISPLAY 'NO MATCH'
   PERFORM NO-MATCH.

DISPLAY 'AFTER IF'



And in the SYSOUTs we are seeing the below diagnostations:

Code:
POLICY-NUMBER 69832401
CURRENT POLICY 6983200
POLICY-TYPE A
BEFORE IF
AFTER IF



But we are not seeing the no match display which in this case must be coming because as we are seeing that the policys are not making a match.

Please can someone elaborate on how this can be as we need help to solving this in speed.

Thank you everyone.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Feb 10, 2011 3:10 am    Post subject: Reply to: IF statement doubt
Reply with quote

I do not know about cobol, but ....
according to common conflict resolution rules in compiler theory the else matches the closest if

Code:
IF POLICY-NUMBER = WS-POLICY
   DISPLAY 'MATCH'
   PERFORM POLICY-MATCH
   IF POLICY-TYPE = 'A'
       DISPLAY 'A TYPE'
       PERFORM POLICY-A-TYPE
   ELSE
      DISPLAY 'NO MATCH'
      PERFORM NO-MATCH.

unless the if' s are properly terminated by the relative end-if

and ...

Quote:
... can someone elaborate on how this can be as we need help to solving this in speed.


we do not do things in speed...
we answer on our own time
free of charge

if You have time constraint Your organization should plan on hiring a paid consultant

Your organization should also think about proper training sessions for You all!
it is inconceivable to waste money on so much incompetence!

from Your signature
Quote:
Confident coding is being excellent
icon_eek.gif
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Thu Feb 10, 2011 3:20 am    Post subject:
Reply with quote

Thank you sir, but, as I am seeing you have now changed the codings.

We are wanting the 'no match' part of the condition to be hapening when there is being no match. But you are moving it to a place where it is not logical in our scenario.

As in our coding our else will be happening when there is no matching occuring, only the displays are showing that this is not occuring as per our expectations.

Thank you sir for you help and your time which we know is free. We are appreciating your assisting in a big manner.

One other thing there is being. when we are trying to use the end-if clauses then it is no longer compiling and that is why we are leaving our codings as in the old ways.

Thank you again for your free time.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Feb 10, 2011 3:37 am    Post subject: Reply to: IF statement doubt
Reply with quote

Just shove all the bullshit

I did not post the code to show how it should be done,

I posted the code indented the way the compiler understood it

so learn to read before offending people who try to help You!

and... what does Your coding show ??? icon_evil.gif


I am no cobol expert , but for esthetics reasons I would try to put a full stop after
Code:
PERFORM POLICY-A-TYPE .
it might terminate the inner if
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 10, 2011 3:39 am    Post subject: Reply to: IF statement doubt
Reply with quote

If your version/release of COBOL is not a minimum of VS/COBOL II (some 25+ years old), then you'll get a compile error, because the END-IF construct (if you use it) was introduced with VS/COBOL II.

Your COBOL version/release (unless you know it already) is printed at the top of each page of the compile listing.

Please post this value....

Bill
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Feb 10, 2011 3:59 am    Post subject: Reply to: IF statement doubt
Reply with quote

Hello,

Quote:
But you are moving it to a place where it is not logical in our scenario.
Wrong - Enrico did not move the code to some other place. . . At least not that i can see. . .

Indenting source does not change the way it works - the complier does not need/use indentation. Indentation is help to people, not the machine and when done incorrectly, it only causes confusion.

Coded correctly, end-if works perfectly. If yours does not work, it i because whoever coded it had no knowledge of how it works - and appears to be unwilling/unable to read the documentation.

Quote:
Confident coding is being excellent
Not even close. Maybe this is politically correct in that organization, but nothing yet posted has been excellent. . .

As you have been told several times, you really, really need to bring someone in that knows how to work on the mainframe.

d
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu Feb 10, 2011 5:41 am    Post subject:
Reply with quote

If I did not know how COBOL IF / ELSE works, and I did not know that white space does not affect a COBOL program, I certainly would not be claiming to be a "COBOL specialist" as Pankaj Gupta does. So far the questions this week indicate that Pankaj Gupta should be using the other forum (IBM Mainframe Forum) for beginners and students instead of this one.
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Thu Feb 10, 2011 9:36 am    Post subject: Reply to: IF statement doubt
Reply with quote

Maintaining your coding syntax which may or may not be correct, you could try this and yes it is correctly indented but untested.

As stated you need to tell us the version of your Cobol Compiler - especially if you are saying END IF is being rejected...

Code:

DISPLAY 'POLICY-NUMBER '   POLICY-NUMBER
DISPLAY 'CURRENT POLICY ' WS-POLICY
DISPLAY 'POLICY-TYPE '        POLICY-TYPE

DISPLAY 'BEFORE IF'

IF POLICY-NUMBER NOT = WS-POLICY
   DISPLAY 'NO MATCH'
   PERFORM NO-MATCH
ELSE
   DISPLAY 'MATCH'
   PERFORM POLICY-MATCH
   IF POLICY-TYPE = 'A'
       DISPLAY 'A TYPE'
       PERFORM POLICY-A-TYPE.

DISPLAY 'AFTER IF'.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Feb 10, 2011 12:28 pm    Post subject: Reply to: IF statement doubt
Reply with quote

probably the TS blindly trusted ( as do many posters around here ) that ...

Quote:
"The z900 knows what you need before you do,"
said Dan Colby general manager, Enterprise Servers, IBM.
- Quoted from IBM Reinvents Mainframe and Marketplace

even if You write the wrong code

probably the above is the hardware implementation of ..
Code:

//justdoit  exec pgm=iehprophet
//syslib dd disp=shr,dsn=sys1.&deity


since iehprophet knows, no need for control cards nor other dd statements
and as a true deadline anybody can expect a 7 days elapsed icon_biggrin.gif
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Thu Feb 10, 2011 7:08 pm    Post subject:
Reply with quote

Thank you mr Jackson for your kind codings. This is indeed working as we are expecting so now we are adopting this method while the mainframe is not working correctly with or original coding.

For your interests, the compiler is saying at top of his listing:

Code:

PP 5740-CB1 RELEASE 2.4                              IBM OS/VS COBOL  JULY  1, 1982


but we are knowing this is a red fish in this scenario.

Thank you all for your kind help
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Thu Feb 10, 2011 7:15 pm    Post subject:
Reply with quote

Mr. Gulpta, your 'IF' statement is correct. If the policy number doesn't match then it would execute the next statement after the period.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Thu Feb 10, 2011 7:17 pm    Post subject:
Reply with quote

@ Pankaj Gupta !

If your COBOL version/release is really so old, that you can't code END-IF,
why not using two different IF's.
Could be understood without any maximum of intelligence in one second.


IF POLICY-NUMBER NOT = WS-POLICY
...performe anything.

IF POLICY-NUMBER NOT not = WS-POLICY
...performe anything.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Thu Feb 10, 2011 7:17 pm    Post subject:
Reply with quote

Code:
ELSE NEXT SENTENCE

would have been the easy way out
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 10, 2011 7:24 pm    Post subject: Reply to: IF statement doubt
Reply with quote

Yes, you are running a very old (as in prehistoric) version/release of the COBOL compiler, whose support was dropped 16+ years ago.

This version/release does NOT support the END-IF construct, as this was introduced with VS/COBOL II, the successor to OS/VS COBOL.

IMHO, your management should upgrade OS/VS COBOL to a more modern (and supported) version.

Keep in mind, when you eventually upgrade to a minimum version/release of CICS/TS 3.1, your OS/VS CICS/COBOL programs will stop working, because their support was dropped, beginning with TS/3.1.

There are 3rd-Party products that allow these programs to execute in a TS/3.1 and greater environment, without any code changes. But, they're not cheap.

Otherwise, your choice would be to modify these programs, for compliance with a more modern version, which in the long run, is the better way to go.

Just my 2ยข....

Bill
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Thu Feb 10, 2011 10:04 pm    Post subject:
Reply with quote

Pankaj Gupta wrote:

so now we are adopting this method while the mainframe is not working correctly with or original coding

You need to understand that your code was the problem not the mainframe.
Your code was rubbish and the mainframe simply acted upon what you asked..

If you do not understand that - then you need to go back to COBOL basics as the problem you reported is the level of a first day trainee programmer.

As has been suggested you should NOT be asking these basic questions in this forum. You should instead be using the other "Students" forum where you might receive a little more sympathy.

guyc wrote:

Code:

ELSE NEXT SENTENCE


I did not suggest that as he is clearly having a problem with a simple IF ELSE construct and adding something new would confuse him even further....
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Thu Feb 10, 2011 11:08 pm    Post subject:
Reply with quote

Dear all helpers, the end-if is being a red fish. It was mr enrico I think who was suggesting its employment. We are happy to be coding without such new constructs.

Now please could someone be elaborating on precisely how we must be upgrading our cobols version, if this is being the method of bringing certainty that the code will be executing as pertaining to the designs.
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Thu Feb 10, 2011 11:21 pm    Post subject:
Reply with quote

Quote:

if this is being the method of bringing certainty that the code will be executing as pertaining to the designs.

TOTAL RUBBISH.
Quote:
the end-if is being a red fish

Whether you use END IF or NOT is irrelevant.
The suggestion to use END IF was to try to make your life easier as you clearly have a trouble understanding the basic IF ELSE statement. It was also suggested that you aligned your IF ELSE statement correctly - again to make it easier for you to understand. If you don't want to do that then fine.

Your basic COBOL code that you supplied was wrong.


Upgrading your COBOL version WILL NOT improve your ability of writing crap code. If you ran exactly the same crap code that you provided us initially - it WILL STILL FAIL because your code is BAD BAD BAD. A different Compiler will not fix your lack of knowledge.

You have not yet appeared to have accepted that your code was wrong.

If as a separate unrelated exercise your company are considering upgrading your software, you need to have your SYSPROGS do that.
We cannot provide a do it yourself list of what needs to be done.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 10, 2011 11:26 pm    Post subject: Reply to: IF statement doubt
Reply with quote

IBM used to offer a migration plan, but (AFAIK), its availability has been removed.

Perhaps there's another colleague (at another shop) or another member on this site, who has this migration plan archived somewhere or has alternative methods (maybe, an in-house plan they will share)?

You really should jump on this, because one day, it will bite you....

Bill
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Feb 10, 2011 11:45 pm    Post subject:
Reply with quote

Presumably if the compiler has been unsupported since the last century, any migration plans must be of the same vintage. It would be interesting to know if Gupta's shop is also running MVS/XA and IMS with SHSAM data bases.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Feb 11, 2011 12:59 am    Post subject: Reply to: IF statement doubt
Reply with quote

Hi Bill,

Quote:
You really should jump on this, because one day, it will bite you....
This combined with the complete lack of qualified technical people. . .

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts Doubt in MFS abdulrafi IMS DB/DC 2 Fri Oct 21, 2016 3:09 pm
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm
This topic is locked: you cannot edit posts or make replies. Updating value of key using rewrite s... ParminderKumar COBOL Programming 4 Thu Aug 04, 2016 12:46 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us