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
 

 

Passing an array from one prog to another prog in batch

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Passing an array from one prog to another prog in batch
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: 8002
Location: Bellevue, IA

PostPosted: Fri Dec 18, 2009 6:07 pm    Post subject:
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Dec 18, 2009 6:27 pm    Post subject: Reply to: Passing an array from one prog to another prog in
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    Post subject:
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    Post subject: Reply to: Passing an array from one prog to another prog in
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    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 Batch job tuning sgandhla Testing & Performance analysis 5 Fri Mar 24, 2017 9:41 pm
No new posts MIPS/CPU consumption reduction in Batch vishwakotin DFSORT/ICETOOL 4 Sat Mar 18, 2017 5:46 pm
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm


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