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
 

 

Linkage Length Field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Linkage Length Field
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: 216
Location: India

PostPosted: Thu Sep 11, 2008 3:50 pm    Post subject: Re: Linkage Length Field
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Sep 11, 2008 4:52 pm    Post subject: Reply to: Linkage Length Field
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    Post subject:
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Sep 11, 2008 5:14 pm    Post subject: Reply to: Linkage Length Field
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    Post subject:
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    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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm


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