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
 

 

Issue in passing comp variables to sub program in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Fri Oct 23, 2009 12:15 pm    Post subject: Issue in passing comp variables to sub program in COBOL
Reply with quote

Hi All,

I am trying to pass few comp variables to Sub program but its giving me a problem which is explained below:

Let say Main program 'A' calls to subprogram 'B'

Program A:

WORKING-STORAGE-SECTION.

01 WS-VARIABLES.
05 A PIC X(5)
05 B PIC 9(2)
05 C PC S9(4) COMP.

PROCEDURE DIVISION.
INITIALIZE WS-VARIABLES.

CALL B USING WS-VARIABLES

Program B:

LINKAGE-SECTION

01 WS-VARIABLES.
05 X PIC X(5)
05 Y PIC 9(2)
05 Z PC S9(4) COMP

PROCEDURE DIVISION USING WS-VARIABLES.

DISPLAY 'Value of Z: ' Z

Its displaying value of Z as 16448.

when I changed declaration of Z to 9(2) it showed value of Z as Spaces.This is fine as I am initializing WS-variables.

I am not able to find out reason behind the issue when using S9(4) comp.

I will be very thankful if anyone guide me on this.

Regards,
Chandan
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Oct 23, 2009 3:12 pm    Post subject:
Reply with quote

how would decimal 16448 be stored in a COMP field? 4040

you are displaying a comp field. the display converts the comp to display.

10 seconds with a scientific calculator
(one of which is provided in your base PC software)
would have shown you the answer.

or

basic understanding of the display command.

understand the fundamentals and the complex things are easier to grasp.
Back to top
View user's profile Send private message
ashutosh.pr

New User


Joined: 13 Apr 2007
Posts: 36
Location: Pune

PostPosted: Fri Oct 23, 2009 3:14 pm    Post subject: Reply to: Issue in passing comp variables to sub program in
Reply with quote

You are not able to pass value or you are not able to display value??

Regards,
Ashutosh
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Fri Oct 23, 2009 3:22 pm    Post subject:
Reply with quote

Sorry for the inconvenience Dick..

I got the resolution for the problem..

Hence forth I will do thourugh analysis before posting

Regards,
Chandan
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Oct 23, 2009 4:14 pm    Post subject:
Reply with quote

chandan.inst,

I apologize for my attitude.
my intent was to explain the problem
and motivate you to think about things.

Though I was rude to you, you rose above the garbage and saw the point.
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
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 GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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