Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to call A COBOL-DB2 subprogram from COBOL-DB2 main pgm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
tushar_study

New User


Joined: 01 Feb 2007
Posts: 30
Location: Mumbai

PostPosted: Fri Feb 23, 2007 1:29 pm    Post subject: How to call A COBOL-DB2 subprogram from COBOL-DB2 main pgm
Reply with quote

Hi ,

Can anyone guide on this:

I need to call a COBOL-DB2 subprogram from my COBOL-DB2 main program.How do I give a call,how will the parameters be passed and is there any special declaration to be made in the subprogram?

Regards,
Tushar
Back to top
View user's profile Send private message

UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Fri Feb 23, 2007 3:23 pm    Post subject:
Reply with quote

Hi !

First of all, if you take a search through the forum, you will find a lot of examples.

Cobol/Db2 calls Cobol/DB2 -> nothing else than Cobol calls Cobol
Parameters are passed normaly via Linkage or External-CopyBook

Regards, UmeySan

Normal Example:

Fields are declared in normal CopyBooks

In Calling-Program (Main-Programm)
...Call with Params

C40-CALL-MDL60040 SECTION.
MOVE 'C40-MDL60040' TO FTEXT4
*---------------------------------------------------------

CALL 'MDL60040' USING MZPN-KOPF-DATEN
MZPN-AZ-SPEZIFISCHE-DATEN
MZPN-IFRS-ALLGEMEINE-DATEN
MZPN-ERGEBNIS-KOPF-DATEN
MZPN-ERGEBNIS-CASHFLOW-DATEN
MZPN-ERGEBNIS-BEWERTUNG-ALLG
END-CALL

*---------------------------------------------------------
MOVE SPACES TO FTEXT4.
C40-CALL-MDL60040-EXIT.
EXIT.

In Called-Program (Sub-Programm)
...the fields are declared in Linkage

LINKAGE SECTION.

01 MZPN-KOPF-DATEN.
COPY CMP10000.

01 MZPN-AZ-SPEZIFISCHE-DATEN.
COPY CMP10060.

01 MZPN-IFRS-ALLGEMEINE-DATEN.
COPY CMP10008.


01 MZPN-ERGEBNIS-KOPF-DATEN.
COPY CMP10100
REPLACING ==A:==
BY ==ERG-==.

01 MZPN-ERGEBNIS-CASHFLOW-DATEN.
COPY CMP10101
REPLACING ==A:==
BY ==ERG-==.

01 MZPN-ERGEBNIS-BEWERTUNG-ALLG.
COPY CMP10102
REPLACING ==A:==
BY ==ERG-==.


PROCEDURE DIVISION USING MZPN-KOPF-DATEN
MZPN-AZ-SPEZIFISCHE-DATEN
MZPN-IFRS-ALLGEMEINE-DATEN
MZPN-ERGEBNIS-KOPF-DATEN
MZPN-ERGEBNIS-CASHFLOW-DATEN
MZPN-ERGEBNIS-BEWERTUNG-ALLG.



Call with use of external CopyBook

Main-Programm:

Working-Storage
...here the CopyBooks are declared
COPY CIPUFMSG. ...this one is an external book

...in Procedure-Division normal Call statement without Params

F50-WRITE-IFRS-MESSAGES SECTION.
MOVE 'F50-WRT-IFR-MSG' TO FTEXT4
*----------------------------------------------
IF COM-ERGS-TYP-IFRS NOT = ZERO
CALL 'MDL60120' END-CALL
END-IF
*----------------------------------------------
MOVE SPACES TO FTEXT4.
F50-WRITE-IFRS-MESSAGES-EXIT.


Sub-Programm:

Working-Storage
...here the CopyBooks are declared
COPY CIPUFMSG. ...this one is an external book

LINKAGE SECTION.
...nothing needed

PROCEDURE DIVISION.
...normal cobol handling

S00-STEUERUNG SECTION.
MOVE 'S00-STEUERUNG' TO FTEXT0
-------------------------------------------------
PERFORM A05-VORLAUF
IF MDL60120-WEITER
PERFORM F05-VERARBEITUNG
END-IF
PERFORM Z05-NACHLAUF
-------------------------------------------------
MOVE SPACES TO FTEXT0.
S00-STEUERUNG-EXIT.


External Books:
IER1337.$$NDVR$$.WORK(CIPUFMSG)

01 IFP-MSG-MESSAGES EXTERNAL.

10 MSG-VERARB-ART PIC X(004).
10 MSG-FILLER-001 PIC X(001).
10 MSG-VERARB-CDE PIC X(002).
10 MSG-FILLER-002 PIC X(001).
10 MSG-VERARB-KTO PIC X(010).
10 MSG-FILLER-003 PIC X(001).
10 MSG-VERARB-COD PIC X(004).
10 MSG-FILLER-005 PIC X(001).
10 MSG-VERARB-MSG PIC X(108).

By use of external books, no parms are used by call-statement.
The book must be present in both programms.
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us