Compiling and Debugging Cobol/400 programs

AS/400 Programming Development Manager (PDM)

Select one of the following:

1. Work with libraries

2. Work with objects

3. Work with members

4. Work with projects

5. Work with groups

6. Work with parts

9. Work with user-defined options

Selection or command

===> 3

F3=Exit F4=Prompt F9=Retrieve F10=Command entry

F12=Cancel F18=Change defaults

(C) COPYRIGHT IBM CORP. 1981, 1998.

Start PDM (using STRPDM) and when the above screen is displayed select option 3 and press Enter.

Specify Members to Work With

Type choices, press Enter.

File ...... QCBLSRC Name, F4 for list

Library ...... MOHAMED *LIBL, *CURLIB, name

Member:

Name ...... *ALL *ALL, name, *generic*

Type ...... *ALL *ALL, type, *generic*, *BLANK

F3=Exit F4=Prompt F5=Refresh F12=Cancel

Enter your library name (instead of library MOHAMED) and then press Enter.

Work with Members Using PDM ODIN

File ...... QCBLSRC

Library . . . . MOHAMED Position to . . . . .

Type options, press Enter.

2=Edit 3=Copy 4=Delete 5=Display 6=Print 7=Rename

8=Display description 9=Save 13=Change text 14=Compile 15=Create module...

Opt Member Type Text

CBL344P CBL Intro to Cobol programming

CBL344PN CBL Intro to Cobol programming

14 SENIOR CBL The first Cobol program

TUITION3 CBL Tuition program (Initial with stubs)

TUITION5 CBL Tuition program (Completed)

Bottom

Parameters or command

===>

F3=Exit F4=Prompt F5=Refresh F6=Create

F9=Retrieve F10=Command entry F23=More options F24=More keys

As an example I choose to compile program SENIOR. To do that enter 14 and then press F4.

Create COBOL Program (CRTCBLPGM)

Type choices, press Enter.

Program ...... > SENIOR Name, *PGMID

Library ...... > MOHAMED Name, *CURLIB

Source file ...... > QCBLSRC Name

Library ...... > MOHAMED Name, *LIBL, *CURLIB

Source member ...... > SENIOR Name, *PGM

Generation severity level . . . 29 0-29

Text 'description' ...... *SRCMBRTXT

Additional Parameters

Replace program ...... > *NO *NO, *YES

Bottom

F3=Exit F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel

F13=How to use this display F24=More keys

In order to use the Interactive Source Debugger later on, you have to change the compile options in this screen. To do that press F10.

Create COBOL Program (CRTCBLPGM)

Type choices, press Enter.

Program ...... > SENIOR Name, *PGMID

Library ...... > MOHAMED Name, *CURLIB

Source file ...... > QCBLSRC Name

Library ...... > MOHAMED Name, *LIBL, *CURLIB

Source member ...... > SENIOR Name, *PGM

Generation severity level . . . 29 0-29

Text 'description' ...... *SRCMBRTXT

Additional Parameters

Source listing options . . . . . *SRCDBG *SOURCE, *NOSOURCE, *SRC...

+ for more values

Generation options ...... *NOLIST, *LIST, *NOXREF...

+ for more values

More...

F3=Exit F4=Prompt F5=Refresh F12=Cancel F13=How to use this display

F24=More keys

Enter *SRCDBG as the Source listings option and then press Enter.

Confirm Compile of Member

The following object already exists for the compile operation:

Object which exists ...... : SENIOR

Library ...... : MOHAMED

Object type ...... : *PGM

Member to compile ...... : SENIOR

File ...... : QLBLSRC

Library ...... : MOHAMED

Type choice, press Enter.

Press F12=Cancel to return and not perform the compile operation.

Delete existing object ...... Y Y=Yes, N=No

F12=Cancel

To replace the old compiled version of the program enter ‘Y’ and then press Enter.

Work with Members Using PDM ODIN

File ...... QCBLSRC

Library . . . . MOHAMED Position to . . . . .

Type options, press Enter.

2=Edit 3=Copy 4=Delete 5=Display 6=Print 7=Rename

8=Display description 9=Save 13=Change text 14=Compile 15=Create module...

Opt Member Type Text

SENIOR CBL The first Cobol program

TUITION3 CBL Tuition program (Initial with stubs)

TUITION5 CBL Tuition program (Completed)

Bottom

Parameters or command

===>

F3=Exit F4=Prompt F5=Refresh F6=Create

F9=Retrieve F10=Command entry F23=More options F24=More keys

The compile of member SENIOR was submitted to batch. +

The compilation of the program will be submitted to batch.

Work with Members Using PDM ODIN

File ...... QCBLSRC

Library . . . . MOHAMED Position to . . . . .

Type options, press Enter.

2=Edit 3=Copy 4=Delete 5=Display 6=Print 7=Rename

8=Display description 9=Save 13=Change text 14=Compile 15=Create module...

Opt Member Type Text

SENIOR CBL The first Cobol program

TUITION3 CBL Tuition program (Initial with stubs)

TUITION5 CBL Tuition program (Completed)

Bottom

Parameters or command

===> WRKSBMJOB *JOB

F3=Exit F4=Prompt F5=Refresh F6=Create

F9=Retrieve F10=Command entry F23=More options F24=More keys

Job 342470/MOHAMED/SENIOR submitted to job queue QBATCH in library QGPL.

To check whether the program compiled successfully enter WRKSBMJOB *JOB on the command line as shown and then press Enter.

Work with Submitted Jobs ODIN

10/03/99 17:53:13

Submitted from ...... : *JOB

Type options, press Enter.

2=Change 3=Hold 4=End 5=Work with 6=Release 7=Display message

8=Work with spooled files

Opt Job User Type -----Status----- Function

8 SENIOR MOHAMED BATCH OUTQ

Bottom

Parameters or command

===>

F3=Exit F4=Prompt F5=Refresh F9=Retrieve F11=Display schedule data

F12=Cancel

Enter option 8 to display the compiled spool file.

Work with Job Spooled Files

Job: SENIOR User: MOHAMED Number: 342470

Type options, press Enter.

1=Send 2=Change 3=Hold 4=Delete 5=Display 6=Release 7=Messages

8=Attributes 9=Work with printing status

Device or Total Current

Opt File Queue User Data Status Pages Page Copies

5 SENIOR MOHAMED RDY 5 1

Bottom

Parameters for options 1, 2, 3 or command

===>

F3=Exit F10=View 3 F11=View 2 F12=Cancel F22=Printers F24=More keys

To view the compiled program spool file enter option 5 and press Enter.

Display Spooled File

File . . . . . : SENIOR Page/Line 1/1

Control . . . . . B Columns 1 - 130

Find ...... ______

*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3

5769CB1 V4R2M0 980228 IBM COBOL/400 MOHAMED/SENIOR ODIN 10/03/99 17:45:53 Page 1

Program ...... : SENIOR

Library ...... : MOHAMED

Source file ...... : QLBLSRC

Library ...... : MOHAMED

Source member ...... : SENIOR 09/11/99 17:22:52

Generation severity level . . . . . : 29

Text 'description' ...... : The first Cobol program

Source listing options ...... : *SRCDBG

Generation options ...... : *NONE

Conversion options ...... : *NONE

Sort sequence ...... : *HEX

Library ...... :

Language identifier ...... : *JOBRUN

Message limit:

Number of messages ...... : *NOMAX

Message limit severity ...... : 29

Print file ...... : QSYSPRT

Library ...... : *LIBL

More...

F3=Exit F12=Cancel F19=Left F20=Right F24=More keys

Enter B in the control field and press Enter to go to the bottom of the compile listing.

Display Spooled File

File . . . . . : SENIOR Page/Line 4/34

Control . . . . . B Columns 1 - 130

Find ......

*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3

* 44 MSGID: LBL0014 SEVERITY: 10 SEQNBR: 005900

Message . . . . : Delimiter for literal is not correct.

Literal accepted.

* 49 MSGID: LBL0014 SEVERITY: 10 SEQNBR: 006500

Message . . . . : Delimiter for literal is not correct.

Literal accepted.

* * * * * E N D O F M E S S A G E S * * * * *

Message Summary

Total Info(0-4) Warning(5-19) Error(20-29) Severe(30-39) Terminal(40-99)

9 2 5 2 0 0

Source records read ...... : 66

Copy records read ...... : 0

Copy members processed ...... : 0

Sequence errors ...... : 0

Highest severity message issued . . : 20

LBL0901 00 Program SENIOR created in library MOHAMED on 10/03/99 17:46:22.

5769CB1 V4R2M0 980228 AS/400 COBOL Messages MOHAMED/SENIOR ODIN 10/03/99 17:45:53 Page 5

STMT

* * * * * E N D O F C O M P I L A T I O N * * * * *

Bottom

F3=Exit F12=Cancel F19=Left F20=Right F24=More keys

The first highlighted line shows the number and type of errors found. The second highlighted line states that the compilation was successful and that the program was created in library MOHAMED (in your case the program must be created in your own library).

Display Spooled File

File . . . . . : SENIOR Page/Line 4/8

Control . . . . . Columns 1 - 130

Find ...... ______

*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3

clause. System-name QPRINT assumed.

* 13 MSGID: LBL0116 SEVERITY: 20 SEQNBR: 001500

Message . . . . : Largest record description does not match

RECORD CONTAINS clause for file. '42' assumed.

* 13 MSGID: LBL0117 SEVERITY: 20 SEQNBR: 001500

Message . . . . : Smallest record description '42' characters.

Does not match RECORD CONTAINS. '42' assumed.

* 13 MSGID: LBL0650 SEVERITY: 00 SEQNBR: 001500

Message . . . . : Blocking/Deblocking for file 'STUDENT-FILE'

will be performed by compiler-generated code.

* 28 MSGID: LBL0014 SEVERITY: 10 SEQNBR: 003200

Message . . . . : Delimiter for literal is not correct.

Literal accepted.

* 37 MSGID: LBL0014 SEVERITY: 10 SEQNBR: 004500

Message . . . . : Delimiter for literal is not correct.

Literal accepted.

* 39 MSGID: LBL0014 SEVERITY: 10 SEQNBR: 004900

Message . . . . : Delimiter for literal is not correct.

Literal accepted.

More...

F3=Exit F12=Cancel F19=Left F20=Right F24=More keys

If you have errors that exceed severity level 29 then your compile will fail and you have to scroll up to look at the error messages generated.

Work with Job Spooled Files

Job: SENIOR User: MOHAMED Number: 342470

Type options, press Enter.

1=Send 2=Change 3=Hold 4=Delete 5=Display 6=Release 7=Messages

8=Attributes 9=Work with printing status

Device or Total Current

Opt File Queue User Data Status Pages Page Copies

SENIOR MOHAMED RDY 5 1

Bottom

Parameters for options 1, 2, 3 or command

===> STRISDB

F3=Exit F10=View 3 F11=View 2 F12=Cancel F22=Printers F24=More keys

If the compile is successful then you can run the Interactive Source Debugger (STRISDB) and press Enter.

Start ISDB (STRISDB)

Type choices, press Enter.

Program ...... > SENIOR Name

Library ...... > MOHAMED Name, *CURLIB, *LIBL

Update production files . . . . *NO *YES, *NO

Invoke program ...... *YES *YES, *NO, *CMD

Bottom

F3=Exit F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel

F13=How to use this display F24=More keys

Enter the program name and library as shown (make sure the library is your library name). If your program is called directly (i.e. you are not using a CL program or another program to call your program) then enter *YES in the Invoke program field.

Start ISDB (STRISDB)

Type choices, press Enter.

Program ...... > SENIOR Name

Library ...... > MOHAMED Name, *CURLIB, *LIBL

Update production files . . . . *NO *YES, *NO

Invoke program ...... *YES *YES, *NO, *CMD

Parameters for call ...... ______

______

+ for more values ______

______

Bottom

F3=Exit F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel

F13=How to use this display F24=More keys

Press Enter.

Debug Goto Program Options Help

MOHAMED/SENIOR:/0001 ISDB/400 More: + >

000100 IDENTIFICATION DIVISION.

000200 PROGRAM-ID. SENIOR.

000300 AUTHOR. ROBERT GRAUER.

000400

000500 ENVIRONMENT DIVISION.

000600 INPUT-OUTPUT SECTION.

000700 FILE-CONTROL.

000800 SELECT STUDENT-FILE ASSIGN TO DATABASE-SENIORDAT

000900 ORGANIZATION IS SEQUENTIAL.

001000 SELECT PRINT-FILE

001100 ASSIGN TO PRINTER.

001200

001300 DATA DIVISION.

001400 FILE SECTION.

001500 FD STUDENT-FILE

001600 RECORD CONTAINS 43 CHARACTERS

001700 DATA RECORD IS STUDENT-IN.

001800 01 STUDENT-IN.

ISDB ===>

F3=Exit F5=Step F6=Break F11=Display variable

F12=Cancel F17=Run F23=Change variable F24=More keys

(C) COPYRIGHT IBM CORP. 1993, 1997.

You are now in the Interactive debug mode. Use the Function Keys (shown highlighted) to debug your program. You can use the F1 help function to read the help topics.

Debug Goto Program Options Help

MOHAMED/SENIOR:4200.1 ISDB/400 More: - + >

004200 OPEN INPUT STUDENT-FILE

004300 OUTPUT PRINT-FILE.

004400 READ STUDENT-FILE

004500 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH

004600 END-READ.

004700 PERFORM WRITE-HEADING-LINE.

004800 PERFORM PROCESS-RECORDS

004900 UNTIL DATA-REMAINS-SWITCH = 'NO'.

005000 CLOSE STUDENT-FILE

005100 PRINT-FILE.

005200 STOP RUN.

005300

005400 WRITE-HEADING-LINE.

005500 MOVE HEADING-LINE TO PRINT-LINE.

005600 WRITE PRINT-LINE.

005700

005800 PROCESS-RECORDS.

005900 IF STU-CREDITS > 110 AND STU-MAJOR = 'ENGINEERING'

ISDB ===>

F3=Exit F5=Step F6=Break F11=Display variable

F12=Cancel F17=Run F23=Change variable F24=More keys

Stopped at statement 4200.1.

Note: The debugging starts at the first statement of the first paragraph of the Procedure Division.

Debug Goto Program Options Help

MOHAMED/SENIOR:4200.1 ISDB/400 More: - + >

004200 OPEN INPUT STUDENT-FILE

004300 OUTPUT PRINT-FILE.

004400 READ STUDENT-FILE

004500 ......

004600 : Cancel ISDB :

004700 : :

004800 : You have requested to cancel ISDB. :

004900 : :

005000 : If you are servicing another :

005100 : job, enter the ENDISDB command :

005200 : afterward, to end debugging. :

005300 : :

005400 WR : Cancel ISDB ...... 1 1=Yes, 2=No :

005500 : :

005600 : F12=Cancel :

005700 :...... :

005800 PROCESS-RECORDS.

005900 IF STU-CREDITS > 110 AND STU-MAJOR = 'ENGINEERING'

ISDB ===>

F3=Exit F5=Step F6=Break F11=Display variable

F12=Cancel F17=Run F23=Change variable F24=More keys

Stopped at statement 4200.1.

To exit the debug session press F3 and enter 1 to Cancel ISDB.