View previous topic :: View next topic
|
Author |
Message |
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Line 379 of program B. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
swapnadeep.ganguly
Active User
Joined: 21 Mar 2007 Posts: 203 Location: India
|
|
|
|
Thanks for pointing out my mistake.
I made the changes as suggested by you and the same worked.... |
|
Back to top |
|
|
|