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

Whats the answer for this SUBROUTINE program


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

New User


Joined: 04 Jan 2006
Posts: 22
Location: Chennai

PostPosted: Sun Jan 08, 2006 11:39 am
Reply with quote

1) IN THE CALLING PROGRAM I USED,

CALL SUB1 USING DD MM YY .

DD, MM, YY ARE DESCRIBED AS PIC 9(2).

IN THE CALLED PROGRAM,

PROCEDURE DIVISION USING DATE.

DATE IS DESCRIBED AS PIC 9(6) WHICH IS JUST A DATA ITEM.

WILL THE VALUE OF DD,MM,YY GET PASSED TO DATE ?

2)

IN THE CALLING PROGRAM I USED,

CALL SUB1 USING DD MM YY .

DD, MM, YY ARE DESCRIBED AS PIC 9(2).

IN THE CALLED PROGRAM,

WHETHER THESE DATA ITEMS SHOULD CORRESPOND TO DATA

ITEMS IN LINKAGE SECTION OR DATA ITEMS USED IN THE PROCEDURE

DIVISION USING PHRASE ?

LINKAGE SECTION.

77 DD PIC 9(2).

77 MM PIC 9(2).

77 YY PIC 9(2).

(OR)

PROCEDURE DIVISION USING DD MM YY .

WHICH OF THE ABOVE IS NECESSARY ?
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Jan 09, 2006 8:49 pm
Reply with quote

Good Monday maheshk84,

The answers to Q#1 are: NO, Maybe, But you won?t like it.

NO ? For each using and linkage 01 in the Called program you need to have a corresponding argument in the calling program. The pointers for the linkage 01?s are set to the working storage area in the calling programs working storage.

The linkage section PIC 9(6) will look at 6 contiguous bytes from the storage pointer. If the DD,MM,YY are not in contiguous storage it will not pick up the date you expect.

Maybe ? If the DD,MM,YY are in contiguous storage the linkage PIC 9(6) will pick up the date, but this is dangerous.

But you won?t like it ? When the Calling program calls the subroutine with augments, the location of the NSI (Next Sequential Instruction) is based on the number of arguments in the argument list. If the Calling and Called programs do not match, the Called program will return control to the incorrect address in the Calling program.

The answer to Q#2. You need both, they must correspond to each other. i.e. the first 01 in the linkage section MUST correspond the first USING on the PROCEDURE DIVISION, the second to the second, etc. AND they must correspond to the arguments in the Calling program.
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 Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top