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

Passing an array from one prog to another prog in batch


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mosinjamadar

New User


Joined: 26 Sep 2007
Posts: 42
Location: pune

PostPosted: Fri Dec 18, 2009 5:55 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Dec 18, 2009 6:07 pm
Reply with quote

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
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Dec 18, 2009 6:22 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Dec 18, 2009 6:27 pm
Reply with quote

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
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Dec 18, 2009 7:03 pm
Reply with quote

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
View user's profile Send private message
mosinjamadar

New User


Joined: 26 Sep 2007
Posts: 42
Location: pune

PostPosted: Sat Dec 19, 2009 12:51 am
Reply with quote

Thanks a lot to all of you both methods are working fine

Thx
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

 


Similar Topics
Topic Forum Replies
No new posts How to get a stack trace on a looping... ABENDS & Debugging 5
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts Help in Automating Batch JCL jobs mon... JCL & VSAM 3
No new posts Passing Parameters to Programs Invoke... PL/I & Assembler 5
No new posts Passing SYSPRINT to Invoked Program PL/I & Assembler 9
Search our Forums:

Back to Top