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
 

 

COBOL linkage - Passing both copybook and other fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Wed Sep 19, 2012 8:27 pm    Post subject: COBOL linkage - Passing both copybook and other fields
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Wed Sep 19, 2012 8:36 pm    Post subject:
Reply with quote

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
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Wed Sep 19, 2012 8:45 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Sep 19, 2012 8:57 pm    Post subject: Reply to: COBOL linkage - Passing both copybook and other fi
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Wed Sep 19, 2012 9:21 pm    Post subject:
Reply with quote

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
View user's profile Send private message
vinu78

Active User


Joined: 02 Oct 2008
Posts: 129
Location: India

PostPosted: Wed Sep 19, 2012 9:27 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 21, 2012 8:13 am    Post subject:
Reply with quote

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
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 Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm


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