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

IF statement doubt


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Feb 10, 2011 3:10 am
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Feb 10, 2011 3:37 am
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 10, 2011 3:39 am
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

Moderator Emeritus


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

PostPosted: Thu Feb 10, 2011 3:59 am
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Feb 10, 2011 5:41 am
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Feb 10, 2011 12:28 pm
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
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: 121
Location: Puerto Rico

PostPosted: Thu Feb 10, 2011 7:15 pm
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: 771
Location: Germany

PostPosted: Thu Feb 10, 2011 7:17 pm
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: 1281
Location: Belgium

PostPosted: Thu Feb 10, 2011 7:17 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 10, 2011 7:24 pm
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
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
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 10, 2011 11:26 pm
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: 1788
Location: Bloomington, IL

PostPosted: Thu Feb 10, 2011 11:45 pm
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

Moderator Emeritus


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

PostPosted: Fri Feb 11, 2011 12:59 am
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
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Fri Feb 11, 2011 3:40 am
Reply with quote

Thanking one and all. This is being now resolved as we are using mr jackson's fine workaround which is executing as per our expectations on each executions.

As being for the compiling upgrades, I am being told it is not to be a possibility because of the line.


Thank you all again for your fine and speedy helping.
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Fri Feb 11, 2011 4:21 am
Reply with quote

Pankaj Gupta wrote:

This is being now resolved as we are using mr jackson's fine workaround

My suggested example was NOT a Workaround but simply demonstrated that your own code was incorrect.

You really need to sit down and understand your own code and not simply use something that is provided as demonstration as you have clearly learned nothing from your mistakes.

I can guarantee that you will be back in the next couple of days with another
basic question that you will then want us to fix for you.
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Fri Feb 11, 2011 4:22 am
Reply with quote

"...Confident coding is being excellent..."
You are kidding?
I'm losing the will to live.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Feb 11, 2011 3:15 pm
Reply with quote

if the management sees fit to use ops-software that is so old,
that it is probably free,

you can understand managements decision to hire such talented and skilled professionals
that resort to forums for their problem resolution.
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Fri Feb 11, 2011 11:06 pm
Reply with quote

Quote:

if the management sees fit to use ops-software that is so old,
that it is probably free,

They would have to be licensed for it as it was not public domain as was the earlier version from the 70's.
If memory serves me right, support for this version was dropped in 1994 (but may be off on the date).
I believe it continued to be made available post that date for shops that were licensed to use it - with the 'no support' caveat.

I do not believe it was shipped post that date on a new shop's CBIPO.
[/quote]
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts process statement for SUPREC, CMPCOLM... TSO/ISPF 4
No new posts Doubt about pl/1 (job offer) General Talk & Fun Stuff 5
No new posts SYNCSORT/ICETOOL JOINKEYS SORT Statem... DFSORT/ICETOOL 13
Search our Forums:

Back to Top