View previous topic :: View next topic
|
Author |
Message |
mosinjamadar
New User
Joined: 26 Sep 2007 Posts: 42 Location: pune
|
|
|
|
Hi
I am trying to pass arraa from one calling prog to called prog using ponter but i am facing S0C4
following is my code
PGM1
PROCESS DYNAM
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM1.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-PGM2 PIC X(4) VALUE 'PGM2'.
01 WS-TEMP.
03 WS-VAR1 OCCURS 10 TIMES.
05 WS-VAR2 PIC X(5).
01 WS-PTR POINTER.
PROCEDURE DIVISION.
MOVE '12' TO WS-VAR2(1).
MOVE '34' TO WS-VAR2(2).
MOVE '56' TO WS-VAR2(3).
MOVE '78' TO WS-VAR2(4).
SET WS-PTR TO ADDRESS OF WS-TEMP.
DISPLAY WS-TEMP.
CALL 'PGM2' USING WS-PTR.
STOP RUN.
PGM2
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM2.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TEMP.
03 WS-VAR1 OCCURS 10 TIMES.
05 WS-VAR2 PIC X(5).
LINKAGE SECTION.
01 WL-LN-VAR.
05 WL-LN PIC S9(4) COMP.
05 WL-PTR POINTER.
01 WL-TEMP.
03 WL-VAR1 OCCURS 10 TIMES.
05 WL-VAR2 PIC X(5).
PROCEDURE DIVISION USING WL-LN-VAR.
DISPLAY 'LENGTH IS' WL-LN.
SET ADDRESS OF WL-TEMP TO WL-PTR.
MOVE WL-VAR1(1) TO WS-VAR1(1).
DISPLAY 'IN PGM2'.
DISPLAY WS-VAR2(1).
GOBACK.
getting s0c4 in PGM2 on the statement
MOVE WL-VAR1(1) TO WS-VAR1(1).
Kindly help me
Mosin |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
WL-LN was not in the CALL statement so why do you think you need it in PGM2? When passing parameters from JCL PARM to COBOL programs a length is passed, but calling directly program to program there will be no such field unless you pass it explicitly. The presence of this field is throwing your pointer variable off by two bytes, so heaven only knows where the WL-PTR variable is pointing -- obviously somewhere that causes a S0C4 addressing abend in your program! |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
Not only that, but it is really not necessary to set and pass pointer(s) between programs. COBOL ( and most other compilers/assemblers ) do that automatically and transparently when you issue a CALL with direct references to the data-name(s) you wish to pass to/receive in a called program.
So, in your case. . .
in PGM1 all you need to do is
CALL WS-PGM2 USING WS-TEMP
and in PGM2 just code
PROCEDURE DIVISION USING WL-TEMP |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If your COBOL version/release is VS/COBOL II and greater, define the table as EXTERNAL WS exactly the same in all programs in the run-unit. In your example, the run-unit consists of PGM1 and PGM2.
Then, when PGM1 builds the table and CALLS PGM2 (without passing the table in the parmlist), as long as PGM2 has the same table defined (also as EXTERNAL WS), then PGM2 will have addressability to the table, without having to pass it as a parm in a CALL statement.
EXTERNAL definitions are documented in the Fine Manual.
Bill |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
While the use of EXTERNAL working-storage items is a valid alternative to use of the USING clause on the CALL and PROCEDURE DIVISION ( or ENTRY ) statements, it should be noted that no element in working-storage items defined as EXTERNAL can contain a VALUE clause. That may be a consideration at times. |
|
Back to top |
|
|
mosinjamadar
New User
Joined: 26 Sep 2007 Posts: 42 Location: pune
|
|
|
|
Thanks a lot to all of you both methods are working fine
Thx |
|
Back to top |
|
|
|