Chapter 10: Create Batch Programs

This chapter contains the following sections:

Concepts of APS Batch Programming

Shorthand method for creating programs

You create batch programs using the Program Painter, a tool that offers a shorthand method for developing applications. To fully define all divisions of your program except the Procedure Division, you simply enter APS keywords and their arguments. To help you create the Procedure Division more quickly, APS lets you write your database calls in simplified APS formats, saving you many lines of coding. You complete your Procedure Division by entering COBOL, COBOL/2, or S-COBOL structures. S-COBOL is an optional set of COBOL-like statements that simplify procedural coding. You enter all your program source code--including the APS keywords, database calls, and S-COBOL structures--on a blank Program Painter screen using its ISPF-like text editor.

Write reports using Report Writer structures

You can also use the Program Painter to create batch report programs using the APS Report Writer structures. This chapter only discusses creating batch programs that generate to a flat file. For information about writing reports, see Create Reports with Report Writer.

Mix batch with online programs

Your application can consist entirely of batch programs, or you can mix batch programs with online programs in the same application. In addition, the programs of a single application can access different database and data communication (DB/DC) targets. For example, your batch programs can access VSAM files and IMS databases, while your online programs use CICS to access VSAM files and SQL databases. For all valid batch and online DB/DC target combinations, see Paint the Application Definition.

Keywords generate programs

APS builds batch program source code from the following items:

Identification Division:

Generated by APS, based on your Application Painter specifications

Environment Division:

Generated by APS keywords and arguments that you enter

Data Division
   File Section:


Generated by APS keywords and arguments that you enter

Data Division
   Working-Storage Section:

    Database record definitions

    IMS database PCB mask

    Flags required by APS

    Data elements and flags for your procedural routines


Generated by:

APS, based on your subschema

APS, based on your subschema

APS

APS keywords and source code that you enter

Data Division
   Linkage Section:

    Data elements and flags for your procedural routines


Generated by:

APS keywords and source code that you enter

Procedure Division:

  Routines to initialize APS Working-Storage flags

  Procedural source code

Generated by:

APS

APS keywords, database calls, and other procedural source code that you enter

 

Add procedural source code

To specify procedural logic, you can use any combination of the following types of source code.

Include external source code in your programs

In addition, you can include in your programs externally-defined source code that further streamlines the process of developing applications. When you do so, you enter additional APS keywords to specify the program location where the source code belongs. Applications created in the Program Painter can use any of the following types of external source code:

External Source Code
Data Set

Global stubs, which are COBOL, COBOL/2, or S-COBOL paragraphs that all programs of your application can share

APSPROG, your APS Project and Group data set for Program Painter programs and global stubs. You create stubs using the Program Painter; APS stores each stub in a separate file. For information on writing global stubs, see the "Stubs" topic in the APS Reference.

COBOL copybooks containing data structures or other source code

COPYLIB, your APS Project and Group data set for COBOL copybooks.

Data structures created in the APS Data Structure Painter

APSDATA, your APS Project and Group data set for data structures that you create using the Data Structure Painter.

User-defined macros

USERMACS, your APS Project and Group data set for user-defined Customization Facility macros. For information on writing user-defined macros, see the Customization Facility User's Guide.

 

Columns for keywords and source code

You enter all program keywords and source code in the following columns of the Program Painter screen, depending on which compiler you use.

Compiler
Keyword Column Range
Source Code Column Range

OS/VS COBOL

8 through 11

12 through 72

COBOL/2

8 through 11

12 through 80

 

Creating Batch Programs

To create a batch program using the Program Painter, follow these steps:

  1. Create your application definition using the Application Painter, as described in Paint the Application Definition. Steps 2 and 3 below describe how to specify your DC and DB targets when creating your application definition.

  2. Specify your DC target on the Application Painter as follows:

    If application contains …
    Specify this DC target …

    Both batch and online programs

    Your online DC target. To identify the batch programs, enter *batch in the Screen field next to each batch program name and leave the I/O fields blank.

    Only batch programs

    Mvs. Additionally, leave each Screen field and I/O field blank.

     

  3. Specify your database (DB) target in the DB field. For a list of valid DB/DC combinations for generating executable programs to run on various operating systems, see the "DB/DC Target Combinations" topic in the APS Reference.

    To target DB/2, leave this field blank or let default to VSAM. Then, before generating the application, specify db2 in the SQL field on the Generation Options screen.

    If your application accesses multiple database targets, specify a target as follows:

    If application accesses …
    Specify this DB target …

    Two DB targets, including VSAM

    The non-VSAM target, because APS always gives you access to the VSAM target.

    Two or more DB targets, not including VSAM

    Any of those DB targets. When you generate the programs, first generate just the programs of your specified DB target. Then change the DB target to the next target and generate just the programs of that next target. For example, if your application accesses both VSAM and IMS subschemas, generate your VSAM programs separately from your IMS programs.

  4. On the Application Painter, enter s next to a program name to display the Program Painter.

  5. Begin entering your program source code. As you do so, specify the COBOL program locations where the code belongs--such as the Input-Output Section or File Section--by entering APS keywords next to the source code in the KYWD columns, 8 through 11. You can enter your source code and associated keywords in any sequence; when you generate the program, APS arranges the source into the proper COBOL program sequence. For example, you can define Working-Storage fields in the Procedure Division instead of Working-Storage.

  6. Write Remarks
    To write Identification Division Remarks text, enter the REM keyword in the KYWD column, and the text starting in column 12, on the same line. Continue on as many lines as you need. REM is invalid for COBOL/2; to write remarks in this environment, use the comment keyword /* instead. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     REM     Comment text 
             continues onto the next line.
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     /*      Comment text 
     /*      continues onto the next line.
    

  7. Specify Special-Names
    To write an Environment Division Special-Names statement, enter the SPNM keyword in the KYWD column, and the statement starting in column 12, on the same line.

  8. Define File-Control
    Define the Input-Output Section's File-Control paragraph as follows. For each input and output file, enter the IO keyword in the KYWD column, and, starting in column 12, enter the paragraph clauses. Do not enter the word SELECT in the SELECT clause; APS generates it for you. Continue on as many lines as you need. APS generates the Input-Output Section and File-Control headers. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     IO      INPUT-CUSTFILE
             ASSIGN TO EXTERNAL GARYDD
             ORGANIZATION IS LINE SEQUENTIAL
     IO      OUTPUT-FILE
             ASSIGN TO EXTERNAL GARYOUT
             ORGANIZATION IS LINE SEQUENTIAL
    

    Generated APS source:

     INPUT-OUTPUT SECTION.  
     FILE-CONTROL.  
         SELECT INPUT-CUSTFILE
         ASSIGN TO EXTERNAL GARYDD
         ORGANIZATION IS LINE SEQUENTIAL.
         SELECT OUTPUT-FILE
         ASSIGN TO EXTERNAL GARYOUT
         ORGANIZATION IS LINE SEQUENTIAL.
    

  9. Define input file description
    Define the file description of your first (or only) input file in the File Section as follows. Enter the FD keyword in the KYWD column, and a COBOL file description starting in column 12. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     FD      INPUT-CUSTFILE
             RECORD CONTAINS 80 CHARACTERS.
    

  10. Define input file record description
    To define the File Section input file's record description in COBOL format, enter the 01 keyword in the KYWD column (columns 8 and 9), and the 01-level data item starting in column 12. To define elementary data items, skip a line and enter them starting in column 12, as shown below. We recommend that you indent each new level of elementary data items four columns.
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     01      INPUT-REC.
             05  INP-ACTION-CODE     PIC X(1).
             05  INP-CUSTOMER-NO     PIC X(6).
             05  INP-CUSTOMER-NAME   PIC X(20).
             05  INP-CUSTOMER-ADDR   PIC X(20).
             05  INP-CUSTOMER-CITY   PIC X(20).
             05  INP-CUSTOMER-ZIP    PIC X(9).
             05  FILLER              PIC X(4).
    

  11. To define the File Section input file's record description in Data Structure Painter format, enter the REC keyword in the KYWD column (columns 8 through 10), and the 01-level data item starting in column 12. To define elementary data items, skip a line and enter them starting in column 16, as shown below. Do not enter the data item level numbers, such as 01 or 05; APS automatically generates them based on how you indent the items. We recommend that you indent each new level of elementary data items four columns.
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     REC     INPUT-REC
                 INP-ACTION-CODE     X1
                 INP-CUSTOMER-NO     X6
                 INP-CUSTOMER-NAME   X20
                 INP-CUSTOMER-ADDR   X20
                 INP-CUSTOMER-CITY   X20
                 INP-CUSTOMER-ZIP    X9
                 FILLER              X4
    

    Generated APS source:

    
     01  INPUT-REC.
         05  INP-ACTION-CODE     PIC X(1).
         05  INP-CUSTOMER-NO     PIC X(6).
         05  INP-CUSTOMER-NAME   PIC X(20).
         05  INP-CUSTOMER-ADDR   PIC X(20).
         05  INP-CUSTOMER-CITY   PIC X(20).
         05  INP-CUSTOMER-ZIP    PIC X(9).
         05  FILLER              PIC X(4).
    

  12. If you created the File Section input file's record description using the Data Structure Painter, include the data structure in your program as follows. Enter the DS keyword in the KYWD column, and the data structure file name in column 12. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     DS      INREC
    

  13. Define any additional input files in the File Section, in the same manner that you defined the first one.

  14. Define output file description
    Define the file description of your first (or only) output file in the File Section as follows. Enter the FD keyword in the KYWD column, and a COBOL file description starting in column 12. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     FD      OUTPUT-FILE
             RECORD CONTAINS 80 CHARACTERS.
    

  15. Define output file record description
    Define the File Section output file's record description in the same manner that you defined the input file's record description, as described in steps 10 through 12. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     01      OUTPUT-REC.
             05  OUTPUT-STATUS           PIC X(2).
             05  OUTPUT-CUSTOMER-NO      PIC X(6).
             05  OUTPUT-CUSTOMER-NAME    PIC X(20).
             05  OUTPUT-CUSTOMER-ADDR    PIC X(20).
             05  OUTPUT-CUSTOMER-CITY    PIC X(20).
             05  OUTPUT-CUSTOMER-ZIP     PIC X(9).
             05  OUTPUT-FILLER           PIC X(3).
    

  16. Define any additional output files in the File Section, in the same manner that you defined the first one.

  17. Define sort file description
    To define a sort file description in the File Section, enter the SD keyword in the KYWD column, and the file description starting in column 12. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     SD      SORT-FILE
             RECORD CONTAINS 80 CHARACTERS
             DATA RECORD IS SORT-RECORD.
    

  18. Define sort file record description
    Define the File Section sort file's record description in the same manner that you defined those of the input and output files. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     01      SORT-RECORD.
             05  SORT-CUSTOMER-NAME      PIC X(8).
             05  FILLER                  PIC X(72).
    

  19. Define or include Working-Storage structures
    Mark the beginning of your Working-Storage entries by entering the WS keyword in the KYWD column. Then skip a line and enter your Working-Storage structures--such as data structures, copylibs, and DB2 table and cursor declarations--as described below in steps 20 through 25.

  20. To define in Working-Storage a data structure in COBOL format, enter the 01 keyword in the KYWD column (columns 8 and 9), and your 01-level data item starting in column 12. To define elementary data items, skip a line and enter them starting in column 12, as shown below. We recommend that you indent each new level of elementary data items four columns. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     01      WS-STRUCT-IN-COBOL-FORMAT.
             05  MY-WS-FIELD-1                   PIC X(8).
             05  MY-WS-FIELD-2.
                 10  MY-WS-FIELD-3               PIC X(8).
                 10  MY-WS-FIELD-4               PIC X(3).
    

    Generated APS source:

    
     01  WS-STRUCT-IN-COBOL-FORMAT.
         05  MY-WS-FIELD-1                   PIC X(8).
         05  MY-WS-FIELD-2.
             10  MY-WS-FIELD-3               PIC X(8).
             10  MY-WS-FIELD-4               PIC X(3).
    

  21. To define in Working-Storage a data structure in Data Structure Painter format, enter the REC keyword in the KYWD column (columns 8 through 10), and the 01-level data item starting in column 12. To define elementary data items, skip a line and enter them starting in column 16, as shown below. Do not enter the data item level numbers, such as 01 or 05; APS automatically generates them based on how you indent the items. We recommend that you indent each new level of elementary data items four columns. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     REC     WS-STRUCT-IN-DSPAINTER-FORMAT
                 MY-WS-FIELD-1                   X8
                 MY-WS-FIELD-2
                     MY-WS-FIELD-3               X8
                     MY-WS-FIELD-3               X3
    

    Generated APS source:

    
     01  WS-STRUCT-IN-DSPAINTER-FORMAT.
         05  MY-WS-FIELD-1                   PIC X(8).
         05  MY-WS-FIELD-2.
             10  MY-WS-FIELD-3               PIC X(8).
             10  MY-WS-FIELD-4               PIC X(3).
    

  22. To include a copybook in Working-Storage, choose one of the following methods:

  23. To include in Working-Storage an externally-defined data structure defined in the Data Structure Painter, choose one of the following methods:

  24. To define in Working-Storage a DB2 table declaration or one or more cursor declarations, enter the SQL keyword in the KYWD column, and the declaration(s) in column 12. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     SQL     DECLARE DSN8.TDEPT TABLE
             ... (DEPTNO CHAR(3) NOT NULL,
             ... DEPTNAME CHAR(36) NOT NULL,
             ... MGRNO CHAR(3) NOT NULL,
             ... ADMRDEPT CHAR(3) NOT NULL)
    

  25. To include a PANVALET record in Working-Storage, enter the ++ keyword in the KYWD column, and the record name in column 12. For example:
    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     ++      PANWSREC
    

  26. Define or include Linkage Section structures
    If your program receives data from a calling program, define its Linkage Section as follows. Mark the beginning of your Linkage Section entries by entering the LK keyword in the KYWD column. Skip a line and enter your Linkage Section structures in the same manner that you enter Working-Storage structures.


    Note: To include a copybook in the Linkage Section, substitute the SYWS keyword, as shown in step 22, with the SYLT or SYLK keyword.


  27. Begin to define the Procedure Division
    Mark the beginning of the Procedure Division by entering either the PROC or NTRY keyword to generate the PROCEDURE DIVISION statement appropriate for your program, as shown below.

    Program Type
    Procedure Division Keyword

    Calling or non-calling

    NTRY or PROC; both keywords generate a PROCEDURE DIVISION statement.

    Called

    PROC with optional USING clause; generates a PROCEDURE DIVISION USING statement, enabling the program to receive data items from a calling program' s CALL statement.

    Any IMS program

    NTRY. PROC is invalid. To specify arguments for a PROCEDURE DIVISION USING clause, specify them in a TP-LINKAGE call that you code in the Linkage Section.

    For example, enter the PROC keyword with the USING clause data items TOTAL, W-BALANCE, and CHARGERECORD to generate a PROCEDURE DIVISION USING statement in a called program, as shown below.

    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     PROC    TOTAL W-BALANCE CHARGERECORD
    

    Generated APS source:

    
     PROCEDURE DIVISION USING TOTAL W-BALANCE CHARGERECORD.
    

  28. Enter Procedure Division source code
    On the next line, enter your Procedure Division source code, which can include the following:

  29. Define Declaratives Section
    To define a Declaratives Section, choose one of the following methods:

  30. Write comments
    To document your program with comments, use the following formats in the following program locations. Note that in the Procedure Division, you can enter comments at the end of a line of source code.

    Program Location
    Comment Format

    Anywhere

    -KYWD-   12-*----20---*----30---*----40---*--
     /*      comment text
     /*      comment text

    Procedure Division

    -KYWD-   12-*----20---*----30---*----40---*--
             /* comment text
             program source code /* comment text

     

  31. Enter Customization Facility macro calls and statements
    Enter any Customization Facility macro calls or statements that your program requires. For example, if on the Application Painter you include a user-defined macro library in your program, you should call the macros you need, and assign values to any variables that the macros require. Use the following keywords to place the calls and statements in the following program locations:

    Keyword
    Program Location

    SYM1

    At the beginning of the program, before macro libraries that you include at the beginning of the program

    SYM2

    After macro libraries that you include at the beginning of the program

    SYEN

    In the Environment Division, after the Special-Names paragraph

    SYIO

    In the Input-Output Section, after macro libraries that you include at the beginning of the Input-Output Section

    SYDD

    At the beginning of the Data Division

    SYFD

    In the File Section, after macro libraries that you include at the beginning of the File Section

    SYWS

    In the Working-Storage Section, after macro libraries and data structures that you include in Working-Storage

    SYLT

    In the Linkage Section, after macro libraries and data structures that you include at the beginning of Linkage

    SYLK

    In the Linkage Section, after source code that you include with the SYLT keyword

    SYRP

    In the Report Section, after any macro libraries that you include at the beginning of the Report Section

    SYBT

    At the end of the program

    For example:

    
    -KYWD-   12-*----20---*----30---*----40---*----50---*----
     SYM1
     /*      MACRO VARIABLE TO APPEAR AT BEGINNING OF PROGRAM,
     /*      AFTER MACRO LIBRARY THAT I INCLUDE AT BEGINNING OF 
     /*      PROGRAM.
             % &REC-LEN = 80
     SYFD
     /*      MACRO CALL TO APPEAR IN FILE SECTION, AFTER MACRO 
     /*      LIBRARY THAT I INCLUDE AT BEGINNING OF FILE SECTION.
             % $INPUTFILE-REC-DESCRIP( 'INPUT-REC')
    

  32. Validate source code syntax
    To validate that your source code contains no Program Painter syntax errors, enter validate or val in the Command field. APS displays a message for each syntax error.

  33. Preview the program as generated source
    To preview the program as it will look when generated, enter convert or conv in the Command field. APS converts the Program Painter source code to generated APS source code. APS does not include in the converted source any components defined externally to the program; APS includes them when you generate the program. Such externally-defined components not included at this step are:

    Component
    Project\Group Data Set

    Database record definitions

    DDISYMB and COPYLIB

    Data structures included from copylibs

    COPYLIB

    Data structures included from the Data Structure Painter

    APSDATA

    User-defined macros

    USERMACS

    To view the source in Program Painter format again, enter reset or unconv.

  34. Exit the Program Painter by pressing PF3 or entering cancel.

     

Special Consideration

When modifying your program, do not modify the generated source code; modify only your Program Painter source code.

 

Sample Batch Program

Below is a complete program illustrating many APS batch programming features.

Program Painter source:


-KYWD-   12-*----20---*----30---*----40---*----50---*----
 IO      INPUT-CUSTFILE 
         ASSIGN TO GARYDD
         ORGANIZATION IS LINE SEQUENTIAL
 IO      OUTPUT-FILE
         ASSIGN TO GARYOUT
         ORGANIZATION IS LINE SEQUENTIAL
 FD      INPUT-CUSTFILE
         RECORD CONTAINS 80 CHARACTERS.
 01      INPUT-REC.
         05  INP-ACTION-CODE     PIC X(1).
         05  INP-CUSTOMER-NO     PIC X(6).
         05  INP-CUSTOMER-NAME   PIC X(20).
         05  INP-CUSTOMER-ADDR   PIC X(20).
         05  INP-CUSTOMER-CITY   PIC X(20).
         05  INP-CUSTOMER-ZIP    PIC X(9).
         05  FILLER              PIC X(4).
 FD      OUTPUT-CUSTFILE
         RECORD CONTAINS 80 CHARACTERS.
 01      OUTPUT-REC.
         05  OUTPUT-STATUS           PIC X(2).
         05  OUTPUT-CUSTOMER-NO      PIC X(6).
         05  OUTPUT-CUSTOMER-NAME    PIC X(20).
         05  OUTPUT-CUSTOMER-ADDR    PIC X(20).
         05  OUTPUT-CUSTOMER-CITY    PIC X(20).
         05  OUTPUT-CUSTOMER-ZIP     PIC X(9).
         05  OUTPUT-FILLER           PIC X(3).
 
 PROC    
         OPEN INPUT INPUT-CUSTFILE
         ...  OUTPUT OUTPUT-FILE
         REPEAT
             READ INPUT-CUSTFILE
             WS-CUST-NO = INP-CUSTOMER-NO
         UNTIL AT END ON INPUT-CUSTFILE
             EVALUATE INP-ACTION-CODE
             WHEN 'Q'
                 PERFORM QUERY-LOGIC
             WHEN 'U'
                 PERFORM UPDATE-LOGIC
             WHEN 'D'
                 PERFORM DELETE-LOGIC
         CLOSE INPUT-CUSTFILE
         ...   OUTPUT-FILE
 
 PARA    QUERY-LOGIC
         DB-OBTAIN REC CUSTOMER-REC
         ... WHERE CM_CUSTOMER_NO = #WS-CUST-NO
         IF OK-ON-REC
             OUTPUT-STATUS      = 'SQ'
             PERFORM MOVE-COPYLIB-TO-OUTPUT
             PERFORM WRITE-MSGOUT
         ELSE
             OUTPUT-STATUS      = 'UQ'
             PERFORM MOVE-INPUT-TO-OUTPUT
             PERFORM WRITE-MSGOUT
 
 PARA    UPDATE-LOGIC
         PERFORM MOVE-INPUT-TO-COPYLIB
         DB-MODIFY REC CUSTOMER-REC 
         ... WHERE CM_CUSTOMER_NO = #WS-CUST-NO
         IF OK-ON-REC
             OUTPUT-STATUS      = 'SM'
             PERFORM MOVE-COPYLIB-TO-OUTPUT
             PERFORM WRITE-MSGOUT
         ELSE
             OUTPUT-STATUS      = 'UM'
             PERFORM MOVE-COPYLIB-TO-OUTPUT
             PERFORM WRITE-MSGOUT
 
 PARA    DELETE-LOGIC
         DB-ERASE REC CUSTOMER-REC 
         ... WHERE CM_CUSTOMER_NO = #WS-CUST-NO
         IF OK-ON-REC
             OUTPUT-STATUS      = 'SE'
             PERFORM MOVE-INPUT-TO-OUTPUT
             PERFORM WRITE-MSGOUT
         ELSE
             OUTPUT-STATUS      = 'UE'
             PERFORM MOVE-INPUT-TO-OUTPUT
             PERFORM WRITE-MSGOUT
 
 PARA    ADD-LOGIC
         PERFORM MOVE-INPUT-TO-COPYLIB
         DB-STORE REC CUSTOMER-REC 
         ... WHERE CM_CUSTOMER_NO = #WS-CUST-NO
         IF OK-ON-REC
             OUTPUT-STATUS      = 'SS'
             PERFORM MOVE-INPUT-TO-OUTPUT
             PERFORM WRITE-MSGOUT
         ELSE
             OUTPUT-STATUS      = 'BS'
             PERFORM MOVE-INPUT-TO-OUTPUT
             PERFORM WRITE-MSGOUT
 
 PARA    MOVE-INPUT-TO-OUTPUT
         OUTPUT-STATUS                  = OUTPUT-STATUS
         OUTPUT-CUSTOMER-NO             = INP-CUSTOMER-NO
         OUTPUT-CUSTOMER-NAME           = INP-CUSTOMER-NAME
         OUTPUT-CUSTOMER-ADDR           = INP-CUSTOMER-ADDR
         OUTPUT-CUSTOMER-CITY           = INP-CUSTOMER-CITY
         OUTPUT-CUSTOMER-ZIP            = INP-CUSTOMER-ZIP
 
 PARA    MOVE-COPYLIB-TO-OUTPUT
         OUTPUT-CUSTOMER-NO             = CM-CUSTOMER-NO
         OUTPUT-CUSTOMER-NAME           = CM-CUSTOMER-NAME
         OUTPUT-CUSTOMER-ADDR           = CM-CUSTOMER-ADDR
         OUTPUT-CUSTOMER-CITY           = CM-CUSTOMER-CITY
         OUTPUT-CUSTOMER-ZIP            = CM-CUSTOMER-ZIP
 
 PARA    MOVE-INPUT-TO-COPYLIB
         CM-CUSTOMER-NO                 = INP-CUSTOMER-NO
         CM-CUSTOMER-NAME               = INP-CUSTOMER-NAME
         CM-CUSTOMER-ADDR               = INP-CUSTOMER-ADDR
         CM-CUSTOMER-CITY               = INP-CUSTOMER-CITY
         CM-CUSTOMER-ZIP                = INP-CUSTOMER-ZIP
 
 PARA    WRITE-MSGOUT
         WRITE OUTPUT-REC
 WS
 01      THEFLDS.
         05  WS-CUST-NO              PIC X(6).

Generated APS source:

 %   &AP-GEN-VER = 2200
 %   &AP-PGM-ID = "SAMPLPGM"
 %   &AP-MAIN-PROGRAM- = "NO"
 %   &AP-GEN-DC-TARGET = "MVS"
 %   &AP-GEN-DB-TARGET = "VSAM"
 %   &AP-GEN-USER-HELP = "NO"
 %   &AP-PROC-DIV-KYWD-SEEN = 1
 %   &AP-FILE-CONTROL-SEEN = 1
 %   &AP-SUBSCHEMA = "SAMPLSUB"
 %   &AP-APPLICATION-ID = "JOHND"
 %   &AP-GEN-DATE = "930407"
 %   &AP-GEN-TIME = "07244461"
  
  
 %*  --- SUBSCHEMA / PSB FROM APPLICATION DEFINITION ---
 $DB-SUBSCHEMA("SAMPLSUB")
 
 IDENTIFICATION DIVISION.
 PROGRAM-ID.                       SAMPLPGM.
 AUTHOR.                           JOHND.
 DATE-WRITTEN.                     93/04/07.
 DATE-COMPILED.                    &COMPILETIME.
 
 ENVIRONMENT DIVISION.
 
 CONFIGURATION SECTION.
 SOURCE-COMPUTER.                  &SYSTEM.
 OBJECT-COMPUTER.                  &SYSTEM.
 
 INPUT-OUTPUT SECTION.
 FILE-CONTROL.
     SELECT INPUT-CUSTFILE
     ASSIGN GARYDD
     ORGANIZATION IS LINE SEQUENTIAL.
     SELECT OUTPUT-FILE
     ASSIGN GARYOUT
     ORGANIZATION IS LINE SEQUENTIAL.
 
 DATA DIVISION.
 
 FILE SECTION.
 
 FD  INPUT-CUSTFILE
     RECORD CONTAINS 80 CHARACTERS.
 01  INPUT-REC.
     05  INP-ACTION-CODE     PIC X(1).
     05  INP-CUSTOMER-NO     PIC X(6).
     05  INP-CUSTOMER-NAME   PIC X(20).
     05  INP-CUSTOMER-ADDR   PIC X(20).
     05  INP-CUSTOMER-CITY   PIC X(20).
     05  INP-CUSTOMER-ZIP    PIC X(9).
     05  FILLER              PIC X(4).
 FD  OUTPUT-FILE
     RECORD CONTAINS 80 CHARACTERS.
 01  OUTPUT-REC
     05  OUTPUT-STATUS           PIC X(2).
     05  OUTPUT-CUSTOMER-NO      PIC X(6).
     05  OUTPUT-CUSTOMER-NAME    PIC X(20).
     05  OUTPUT-CUSTOMER-ADDR    PIC X(20).
     05  OUTPUT-CUSTOMER-CITY    PIC X(20).
     05  OUTPUT-CUSTOMER-ZIP     PIC X(9).
     05  OUTPUT-FILLER           PIC X(3).
 
 
 WORKING-STORAGE SECTION.
 $TP-WS-MARKER
 
 01  THEFLDS.
     05  WS-CUST-NO              PIC X(6).
 
 01  TEXT-MSG                    PIC X(30)
             VALUE &SQ+PLEASE ENTER NEXT TRANSID&SQ.
 
 PROCEDURE DIVISION.
 
     OPEN INPUT INPUT-CUSTFILE
     ...  OUTPUT OUTPUT-FILE
    REPEAT
         READ INPUT-CUSTFILE
         WS-CUST-NO = INP-CUSTOMER-NO
     UNTIL AT END ON INPUT-CUSTFILE
         EVALUATE INP-ACTION-CODE
         WHEN 'Q'
             PERFORM QUERY-LOGIC
         WHEN 'U'
             PERFORM UPDATE-LOGIC
         WHEN 'D'
             PERFORM DELETE-LOGIC
     CLOSE INPUT-CUSTFILE
     ...   OUTPUT-FILE
 
 QUERY-LOGIC
     $DB-OBTAIN ( "REC CUSTOMER-REC WHERE CM_CUSTOMER_NO = ",
     %... "#WS-CUST-NO" )
     IF OK-ON-REC
         OUTPUT-STATUS      = 'SQ'
         PERFORM MOVE-COPYLIB-TO-OUTPUT
         PERFORM WRITE-MSGOUT
     ELSE
         OUTPUT-STATUS      = 'UQ'
         PERFORM MOVE-INPUT-TO-OUTPUT
         PERFORM WRITE-MSGOUT
 
 UPDATE-LOGIC
     PERFORM MOVE-INPUT-TO-COPYLIB
     $DB-MODIFY ( "REC CUSTOMER-REC WHERE CM_CUSTOMER_NO = ",
     %... "#WS-CUST-NO" )
     IF OK-ON-REC
         OUTPUT-STATUS      = 'SM'
         PERFORM MOVE-COPYLIB-TO-OUTPUT
         PERFORM WRITE-MSGOUT
     ELSE
         OUTPUT-STATUS      = 'UM'
         PERFORM MOVE-COPYLIB-TO-OUTPUT
         PERFORM WRITE-MSGOUT
 
 DELETE-LOGIC
     $DB-ERASE ( "REC CUSTOMER-REC WHERE CM_CUSTOMER_NO = ",
     %... "#WS-CUST-NO" )
     IF OK-ON-REC
         OUTPUT-STATUS      = 'SE'
         PERFORM MOVE-INPUT-TO-OUTPUT
         PERFORM WRITE-MSGOUT
     ELSE
         OUTPUT-STATUS      = 'UE'
         PERFORM MOVE-INPUT-TO-OUTPUT
         PERFORM WRITE-MSGOUT
 
 ADD-LOGIC
     PERFORM MOVE-INPUT-TO-COPYLIB
     $DB-STORE ( "REC CUSTOMER-REC WHERE CM_CUSTOMER_NO = ",
     %... "#WS-CUST-NO" )
     IF OK-ON-REC
         OUTPUT-STATUS      = 'SS'
         PERFORM MOVE-INPUT-TO-OUTPUT
         PERFORM WRITE-MSGOUT
     ELSE
         OUTPUT-STATUS      = 'BS'
         PERFORM MOVE-INPUT-TO-OUTPUT
         PERFORM WRITE-MSGOUT
 
 MOVE-INPUT-TO-OUTPUT
     OUTPUT-STATUS                  = OUTPUT-STATUS
     OUTPUT-CUSTOMER-NO             = INP-CUSTOMER-NO
     OUTPUT-CUSTOMER-NAME           = INP-CUSTOMER-NAME
     OUTPUT-CUSTOMER-ADDR           = INP-CUSTOMER-ADDR
     OUTPUT-CUSTOMER-CITY           = INP-CUSTOMER-CITY
     OUTPUT-CUSTOMER-ZIP            = INP-CUSTOMER-ZIP
 
 MOVE-COPYLIB-TO-OUTPUT
     OUTPUT-CUSTOMER-NO             = CM-CUSTOMER-NO
     OUTPUT-CUSTOMER-NAME           = CM-CUSTOMER-NAME
     OUTPUT-CUSTOMER-ADDR           = CM-CUSTOMER-ADDR
     OUTPUT-CUSTOMER-CITY           = CM-CUSTOMER-CITY
     OUTPUT-CUSTOMER-ZIP            = CM-CUSTOMER-ZIP
 
 MOVE-INPUT-TO-COPYLIB
     CM-CUSTOMER-NO                 = INP-CUSTOMER-NO
     CM-CUSTOMER-NAME               = INP-CUSTOMER-NAME
     CM-CUSTOMER-ADDR               = INP-CUSTOMER-ADDR
     CM-CUSTOMER-CITY               = INP-CUSTOMER-CITY
     CM-CUSTOMER-ZIP                = INP-CUSTOMER-ZIP
 
 WRITE-MSGOUT
     WRITE OUTPUT-REC

 


Copyright © 2002 Micro Focus International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.