View previous topic :: View next topic
|
Author |
Message |
sandippawar21 Currently Banned New User
Joined: 09 Sep 2008 Posts: 9 Location: Pune
|
|
|
|
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 |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
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 |
|
|
k.junaid83
New User
Joined: 19 Apr 2006 Posts: 22 Location: bangalore
|
|
|
|
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 |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
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 |
|
|
Krishna Velamur
New User
Joined: 22 Aug 2008 Posts: 22 Location: Hyderabad
|
|
|
|
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 |
|
|
sandippawar21 Currently Banned New User
Joined: 09 Sep 2008 Posts: 9 Location: Pune
|
|
|
|
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 |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 |
|
|
sandippawar21 Currently Banned New User
Joined: 09 Sep 2008 Posts: 9 Location: Pune
|
|
|
|
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 |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
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 |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|