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

Linkage Length Field


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

New User


Joined: 09 Sep 2008
Posts: 9
Location: Pune

PostPosted: Thu Sep 11, 2008 3:34 pm
Reply with quote

I have a JCL which will executes a program and passing PARM of length 4 and I am calling the same program from other program by passing one parameter of length 4.

//STEP01 EXEC PGM=VP11111,PARM='ABCD' ----Called thru JCL

&

CALL VP11111 USING WS-ABCD----- Called from other program & passing value 'ABCD' thru WS-ABCD field.

Now, in this case in pgm VP11111, how i need to declare the receiving field in linkage section. Do I need to mention only Receiving field OR I need to mention length field along with it.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Thu Sep 11, 2008 3:50 pm
Reply with quote

sandippawar21 wrote:
I have a JCL which will executes a program and passing PARM of length 4 and I am calling the same program from other program by passing one parameter of length 4.

//STEP01 EXEC PGM=VP11111,PARM='ABCD' ----Called thru JCL

&

CALL VP11111 USING WS-ABCD----- Called from other program & passing value 'ABCD' thru WS-ABCD field.

Now, in this case in pgm VP11111, how i need to declare the receiving field in linkage section. Do I need to mention only Receiving field OR I need to mention length field along with it.



Code:


01  WS-LINKAGE.
      05  WS-LENGTH     PIC   S9(04)  COMP.
      05  WS-ABCD       PIC   X(04).


Corrections are welcome.
Back to top
View user's profile Send private message
k.junaid83

New User


Joined: 19 Apr 2006
Posts: 22
Location: bangalore

PostPosted: Thu Sep 11, 2008 3:56 pm
Reply with quote

Hi Sri,

I believe the above decalration is fine when the program is being called by the JCL and the PARM is being passed to it.

What will be the case when the program is being call by another module as

CALL VP11111 USING WS-ABCD

Isnt in this case the value of WS-ABCD going to be assigned to WS-LENGTH.
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Thu Sep 11, 2008 4:07 pm
Reply with quote

Hi,

The code for pgm when

> you are passing value through PARM parameter is

Code:
01  WS-LINKAGE.
      05  WS-LENGTH     PIC   S9(04)  COMP.
      05  WS-ABCD       PIC   X(04).


> When you are calling from another pgm is


Code:
01  WS-LINKAGE.   
      05  WS-ABCD       PIC   X(04).



Note: In above code there is no Length field


Even U need to take care PROCEDURE DIVISION USING <clause>..


Hope you are clear
Back to top
View user's profile Send private message
Krishna Velamur

New User


Joined: 22 Aug 2008
Posts: 22
Location: Hyderabad

PostPosted: Thu Sep 11, 2008 4:12 pm
Reply with quote

When we are calling a sub module, no need to mention length in Linkage section.

Consider this example.

CALL VP11111 USING WS-ABCD

IN VP11111 program the linkage should have a structure similar to WS-ABCD to hold the values.
Suppose WS-ABCD is a group variable holding 100 characters.

LINKAGE SECTION.
01 WS-VP11111-STRUCTURE PIC X(100).

Let me know if Iam wrong.
Back to top
View user's profile Send private message
sandippawar21
Currently Banned

New User


Joined: 09 Sep 2008
Posts: 9
Location: Pune

PostPosted: Thu Sep 11, 2008 4:48 pm
Reply with quote

There is only one program which is been called thru JCL with PARM and called from other module with parameters passed.

In this case, how I will handle receiving field in linkage section.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Sep 11, 2008 4:52 pm
Reply with quote

Sandip,

Quote:
There is only one program which is been called thru JCL with PARM and called from other module with parameters passed.


Not clear.

Quote:
In this case, how I will handle receiving field in linkage section.


Did you read all the posts on this topic? Did you not understand?
Back to top
View user's profile Send private message
sandippawar21
Currently Banned

New User


Joined: 09 Sep 2008
Posts: 9
Location: Pune

PostPosted: Thu Sep 11, 2008 4:59 pm
Reply with quote

Hi Aaru,

I have read all the topics of this. I have understand the answers also, but every answer is stating different situations like

1) If pgm is called thru JCL with PARM &
2) If pgm is called thru other module with parameters.

I want a solution for combination of both above situations
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Thu Sep 11, 2008 5:13 pm
Reply with quote

Hello

Quote:
I want a solution for combination of both above situations


The one solution for above problem is

While CALLING VP11111 program, Have code like this

Code:
CALL VP11111 USING WS-LENGTH WS-ABCD


Declare WS-LENGTH as S9(04) COMP type, so that it can map to LINKAGE SECTION of called program.

Code:
01  WS-LINKAGE.
      05  WS-LENGTH     PIC   S9(04)  COMP.
      05  WS-ABCD       PIC   X(04).


and handle it in program how ever u want

Try to execute this program and let me know result
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Sep 11, 2008 5:14 pm
Reply with quote

Sandip,

Quote:
1) If pgm is called thru JCL with PARM &
2) If pgm is called thru other module with parameters.

I want a solution for combination of both above situations


Ooops Got it. It looks a bit tricky.

I have not dealt with such a situation before but this is what i could think of

- Pgm A executed using a JCL ( PARM passed and hence you would have length defined in the linkage section)

- Pgm B calls Pgm A using CALL USING WS-ABCD( In this case make sure that you have extra bytes for the length(S9(4) COMP) in the variable WS-ABCD so that no data gets truncated)

Techies,

Correct me if I am wrong.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Sep 11, 2008 6:34 pm
Reply with quote

I've used an approach similar to what Raghu stated above.

(I should have mentiond this - "include the parm length in the data you pass to the sub-pgm.)
In the CALLing pgm be sure to move hi-vals (-1 COMP) to the length field before the CALL.

In the CALLed pgm check the length value to determine how it was CALLed. If it's not hi-vals (-1 COMP) you can verify the PARM length.

I sometime use this to test the CALLed pgm instead of writing a test CALLer.

The one drawback is that someone can CALL the sub w/o initing the PARM len to hi-vals.
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 Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top