1 / 10

Calling programs

Calling programs. Fall 2012. Static vs Dynamic Calls. Calling Programs The program being called. Linkage Section Part of the Data Division, usually coded after the working-storage section. Defines the parameters being sent to the called program.

bert
Download Presentation

Calling programs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Calling programs Fall 2012

  2. Static vs Dynamic Calls

  3. Calling ProgramsThe program being called • Linkage Section • Part of the Data Division, usually coded after the working-storage section. • Defines the parameters being sent to the called program. • Only needed if parameters being passed to the program

  4. Calling ProgramsThe program being called • Procedure Division Statement • Using clause • Only needed if parameters are passed to calling program. • Example: Linkage Section. 01 PARM-Customer PIC X(10). Procedure Division using PARM-Customer.

  5. Calling ProgramsProgram being called • Must end with EXIT PROGRAM instead of STOP RUN. • Because … STOP RUN terminates the entire application

  6. Calling ProgramsThe program doing the calls Syntax: CALL LINKAGE TYPE IS PROCEDURE/PROGRAM ‘programname’ USING parameter list END-CALL. PROCEDURE is used if the object being called is a *MODULE. PROGRAM is used if the object being called is a *PGM. USING is used only if parameters are passed.

  7. CALL Statement with Parameters Called Program Identification Division PROGRAM-ID. PGMB. Data Division. Linkage Section. 01 FLDX PIC X(2). 01 FLDY PIC 9(5). Procedure Division USING FLDX FLDY. Calling Program Data Division. 01 FLDA PIC X(2). 01 FLDB PIC 9(5). Procedure Division. CALL Linkage type is program PGMB USING FLDA FLDB.

  8. CALL … BY CONTENT • Passes Parameters, but the values do not get returned to the calling program.

  9. CALL … BY CONTENT Calling Program Called Programs Identification Division. PROGRAM-ID. SUBPGM1. Procedure Division using FLDX FLDY. COMPUTE FLDX = FLDY * 5. PROGRAM EXIT. Procedure Division. MOVE 4 to FLDA. MOVE 5 to FLDB. CALL Linkage Type is procedure ‘SUBPGM1’ USING FLDA FLDB CALL Linkage Type is program ‘SUBPGM2’ USING BY CONTENT FLDA FLDB DISPLAY FLDA. DISPLAY FLDB. Identification Division. PROGRAM-ID. SUBPGM2. Procedure Division using FLDX FLDY. COMPUTE FLDY = FLDX * 2. PROGRAM EXIT.

  10. Combining Modules Example MODA *MODULE calls MODB *MODULE To create a program call MODCALL: CRTPGM MODCALL MODULES(MODA MODB)

More Related