View previous topic :: View next topic
|
Author |
Message |
vinu78
Active User
Joined: 02 Oct 2008 Posts: 179 Location: India
|
|
|
|
Hi All,
My requirement is related to COBOL Linkage section.
Through CICS online module, I would like to pass User ID, Region No, Account Number, Item Code to the subroutine. The User ID and Region No will be passed only though copybook (say COPYBK1) while the Account number and Item Code should also be passed to the subroutine.
The subroutine accepts the User ID and Region No through copybook and also Account No and Item code and processes it and pass back SQL return code to the main module which will be further processed.
My question is - How to pass both Copybook and Account number, Item code to the subroutine from main module.
Code: |
I know to pass copybook from main module as
CALL <SUBROUTINE> USING Commarea,
WS01-ADSNTIAR,
COPYBK1 01 level,
SQL Code variable
In the subroutine's linkage section, it will be coded as
LINKAGE SECTION.
01 WS01-ADSNT.
05 WS01-ADSN-LEN PIC S9(04) COMP.
05 WS01-ADSN-TEXT PIC X(120) OCCURS 8 TIMES
INDEXED BY ERR-IX.
05 WS01-ADSN-ERR-LEN PIC S9(9) COMP.
COPY COPYBK1.
COPY SQL Code copybook.
PROCEDURE DIVISION USING WS01-ADSNT,
COPYBK1 01 level,
SQL code variable
|
Can you please help me with syntax, how to pass the Account Number and Item code ALSO in the above mentioned code (along with the copybook) ?
Thanks
Vinu |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Terminology is critical in IT, where similar terms may mean very different things. And your terminology is so far from normal that it is not possible to tell for sure what you want to do.
A copy book is COBOL source statements that are placed in a library. These statements may be variable definitions or PROCEDURE DIVISION statements. They are included in the source code by using COPY ???????? (where ???????? is the member name of the source in the library PDS). Once the copy is done, there is no difference between an inline variable and a variable in the copy book -- the program compiles them EXACTLY THE SAME!
Accordingly, your statement
Quote: |
The User ID and Region No will be passed only though copybook (say COPYBK1) while the Account number and Item Code should also be passed to the subroutine. |
is complete and utter GARBAGE! If you are passing 4 variables to the subroutine, then your program is passing 4 variables. Whether 1, 2, 3, or all 4 of them are defined in the program or a copy book makes no different to how you write the code, nor to how the code behaves.
You should be posting in Beginners and Students Forum since this forum is for professionals, not rank amateurs. |
|
Back to top |
|
|
vinu78
Active User
Joined: 02 Oct 2008 Posts: 179 Location: India
|
|
|
|
Sorry Robert. Let me make it clear.
The Copybook COPYBK1 is an existing one and will hold only User ID and Region Number. I can't change the copybook to add Account number or Item Code since it is not allowed as per standards.
Code: |
01 COPYBK1
05 CPY-USERID PIC X(8).
05 CPY-RGN-NO PIC X(3). |
So I need to pass Copybook as well as Account number / Item Code to the subroutine. My question is - Whether we can pass both Copybook (that has User ID / Region No) as well as Account No / Item Code to subroutine at the same time and how will be the Parm length be impacted ?
Sorry if it is basic question.
Thanks
Vinu |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If you define WS01-ADSNTIAR, COPYBK1 01 level and the SQL Code variable as EXTERNAL (your COBOL Version/Release must be VS/COBOL II and greater) and define them EXACTLY the same way in the COBOL sub-program (it's not a sub-routine) WORKING-STORAGE, then pass the commarea to the sub-program, using a LINK-API and the above three EXTERNAL references will be automatically addressable, as they're part of the same run-unit.
Give it a try.... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Whether we can pass both Copybook |
No -- you cannot pass a copybook at all, ever, period.
You pass variables (technically, not even variables -- just data) between programs, nothing more and nothing less. You can use the same COPY statement in both the calling program and subroutine if you want. You can code
Code: |
CALL 'PROGRAMB' USING CPY-USERID CPY-RGN-NO A B C |
where A, B, and C are defined as variables in your code and the other two variables come from the copy book. You can even code in PROGRAMB
Code: |
LINKAGE SECTION.
COPY COPYBK1.
01 A PIC ....
02 B PIC ...
01 C PIC ... |
if you want. However, this is not passing a copy book between the program -- it is still passing variables, and only variables. I don't know where you got the idea in your head about passing a copybook, but you need to get that thought completely out of your head. And if you know who told you that, you need to ignore them from here on out since they either do not know COBOL or do not know how to explain things to people. |
|
Back to top |
|
|
vinu78
Active User
Joined: 02 Oct 2008 Posts: 179 Location: India
|
|
|
|
Thanks Bill for the logic.
Thanks Robert for the information. Now I got to know that, it is actually the variables that is getting passed.
I will try the logic.
Thanks
Vinu |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Now I got to know that, it is actually the variables that is getting passed |
It does not sound like you have understood - even if you get something to run. What you have is a Most basic quezstion and it does not require any kind of "special knowledge".
As suggested before, you will do better in our beginner/student forum. |
|
Back to top |
|
|
|