COBOL CALL

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

COBOL CALL

Post by Gurugars » Tue Apr 21, 2015 7:06 pm

Dear friends,

I've a doubt on the below scenario. Please help me out understanding the same.

There is copybook as below

Code: Select all

copybook: COPYMAIN

01 COPY-MAIN.
     05 COPY-INPUT-FIELDS.
          07 INPUT-1 PIC X(02)
          07 INPUT-2 PIC X(03)
          07 INPUT-3 PIC X(04)
     05 COPY-OUTPUT-FIELDS.
          07 OUTPUT-1 PIC X(02)
          07 OUTPUT-2 PIC X(03)
          07 OUTPUT-3 PIC X(04)

.
.
.
PROCEDURE DIVISION.
.
.
.

CALL "PROG1" USING COPY-INPUT-FIELDS.

in the called program (PROG1)

Code: Select all

Linkage section

COPY COPYMAIN

PROCEDURE DIVISION USING COPY-MAIN.

           Move values for OUTPUT-* fields and Go BACK

Now, I have few questiosn on this.

I've called the program using part of the copybook variables, and in return I'll receive the data in output variables too. This is working fine for me. But is it a effective way.? Should I call the program with COPY-MAIN.? what is the difference if I'm calling with COPY-MAIN and COPY-INPUT-FIELDS.
Guru:-)

You're never fully dressed without a smile :)

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Apr 21, 2015 10:36 pm

With the copybook as it is at the moment, you will get the same results using COPY-MAIN or COPY-INPUT-FIELDS. This is because the start addresses of those two fields coincide.

It is much better to use COPY-MAIN in the CALL ... USING ... 1) it is clearer to the human reader 2) if someone defines data before COPY-INPUT-FIELDS, so the addresses no longer coincide, then it will no longer work.

There are no other differences. I'd also suggest that when defining new copybooks, if site standards allow, do so without the 01-level, so that it can be defined with different 01-level names.

User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Post by Gurugars » Wed Apr 22, 2015 11:50 am

Thanks William. This solves my doubts.
Guru:-)

You're never fully dressed without a smile :)

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others