Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
COBOL Sub Program Value Passing

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

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Thu Oct 22, 2009 4:38 pm    Post subject: COBOL Sub Program Value Passing
Reply with quote

Hi,

Let us say that JCL passes the operation date to my main COBOL program (referred as A from now on).

This program A calls a sub-program (referred as B from now on).

Now, in B i have a count declared as RECORD-COUNT PIC 9(9) in Linkage section. The value of this is say 001560626.

Now, when I am referring this variable in A, the value changes to 260015606. Can any one please let me know, where exactly I m going wrong.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


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

PostPosted: Thu Oct 22, 2009 4:49 pm    Post subject:
Reply with quote

Line 379 of program B.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Oct 22, 2009 4:51 pm    Post subject:
Reply with quote

Since you didn't post anything about the parameters passed from A to B, nor how B has them defined, nor anything else code related, just what kind of answer are you expecting us to give you, other than wild guesses? If you give us code (use BBcode please) -- and please do not extract what you think we need to know, give us the relevant sections as they are in the program -- we can provide a better answer.
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Thu Oct 22, 2009 5:00 pm    Post subject:
Reply with quote

Main Program A:
Code:

WORKING STORAGE SECTION
05  FILE-NAME                         PIC X(50)  VALUE SPACES.
05  RECORD-COUNT                PIC  9(09) VALUE ZEROES. 
.
.
LINKAGE SECTION.
01  LINK-AREA.
    05  PARM-LENGTH              PIC S9(04) COMP.       
    05  PARM-DATE.                                   
        10  PARM-DATE-YY    PIC  9(02) VALUE ZEROS.
        10  PARM-DATE-MM    PIC  9(02) VALUE ZEROS.
        10  PARM-DATE-DD    PIC  9(02) VALUE ZEROS.

PROCEDURE DIVISION USING LINK-AREA.
CALL "B" USING             
             BY REFERENCE FILE-NAME
             BY REFERENCE RECORD-COUNT

DISPLAY 'RECORD COUNT RCVD: ' RECORD-COUNT 




Declaration in Program B:
Code:

LINKAGE SECTION.                                         
01  LINK-AREA-SUBPROG.                                   
    05  PARM-LENGTH              PIC S9(04) COMP.         
    05  PARM-RECORD.                                     
        10  PARM-RECORD-COUNT    PIC  9(09) VALUE ZEROS. 
    EJECT.                                               

PROCEDURE DIVISION USING FILE-NAME       
                         LINK-AREA-SUBPROG.
.
.
.
.
MOVE WS-RECORDS-PROCESSED  TO PARM-RECORD-COUNT
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Oct 22, 2009 5:07 pm    Post subject:
Reply with quote

Based on what you've posted, your problem is that program B says USING FILE-NAME LINK-AREA-SUBPROG but FILE-NAME is not an 01 or 77 level in the LINKAGE SECTION. Section 6.1.2.1 of the COBOL Language Reference manual (link at the top of the page) explicitly states that each variable in a USING must be an 01 or 77 level in the LINKAGE SECTION.
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Thu Oct 22, 2009 9:19 pm    Post subject:
Reply with quote

Hi,

Even after making the following changes in Sub-Program B, I am still getting the same error:
Code:

LINKAGE SECTION.                                         
01  LINK-AREA.                                   
    05  PARM-LENGTH              PIC S9(04) COMP.         
    05  PARM-RECORD.                                     
        10  FILE NAME            PIC  X(50) VALUE SPACES. 
01  LINK-AREA-SUBPROG.                                   
    05  PARM-LENGTH              PIC S9(04) COMP.         
    05  PARM-RECORD.                                     
        10  PARM-RECORD-COUNT    PIC  9(09) VALUE ZEROS. 
    EJECT.                                               

PROCEDURE DIVISION USING LINK-AREA       
                         LINK-AREA-SUBPROG.
.
.
.
.
MOVE WS-RECORDS-PROCESSED  TO PARM-RECORD-COUNT
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Oct 22, 2009 9:40 pm    Post subject:
Reply with quote

swapnadeep.ganguly wrote:
Hi,

Even after making the following changes in Sub-Program B, I am still getting the same error:
Code:

LINKAGE SECTION.                                         
01  LINK-AREA.                                   
    05  PARM-LENGTH              PIC S9(04) COMP.         
    05  PARM-RECORD.                                     
        10  FILE NAME            PIC  X(50) VALUE SPACES. 
01  LINK-AREA-SUBPROG.                                   
    05  PARM-LENGTH              PIC S9(04) COMP.         
    05  PARM-RECORD.                                     
        10  PARM-RECORD-COUNT    PIC  9(09) VALUE ZEROS. 
    EJECT.                                               

PROCEDURE DIVISION USING LINK-AREA       
                         LINK-AREA-SUBPROG.
.
.
.
.
MOVE WS-RECORDS-PROCESSED  TO PARM-RECORD-COUNT


When calling a subprogram you don't normally have a length for each passed value. In the main program you have a length because the data is being passed from the system.

You sub program linkage should look like this
Code:
LINKAGE SECTION.                                         
01   FILE NAME            PIC  X(50).
01   PARM-RECORD-COUNT    PIC  9(09). 
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Thu Oct 22, 2009 10:47 pm    Post subject:
Reply with quote

Thanks for pointing out my mistake.

I made the changes as suggested by you and the same worked....
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
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts Calling IKJEFT01 program from Rexx upendrasri CLIST & REXX 8 Wed Nov 15, 2017 4:27 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us