Compiling and Debugging Cobol/400 programs AS/400 Programming Development Manager (PDM) Select one of the following: 1. 2. 3. 4. 5. 6. Work Work Work Work Work Work with with with with with with libraries objects members projects groups parts 9. Work with user-defined options Selection or command ===> 3 F3=Exit F12=Cancel F4=Prompt F9=Retrieve F18=Change defaults F10=Command entry (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 . . . . . . . . . . Library . . . . . . . . Member: Name . . . . . . . . . Type . . . . . . . . . F3=Exit F4=Prompt QCBLSRC MOHAMED *ALL *ALL F5=Refresh Name, F4 for list *LIBL, *CURLIB, name *ALL, name, *generic* *ALL, type, *generic*, *BLANK F12=Cancel Enter your library name (instead of library MOHAMED) and then press Enter. Work with Members Using PDM File . . . . . . Library . . . . QCBLSRC MOHAMED Position to Type options, press Enter. 2=Edit 3=Copy 4=Delete 5=Display 8=Display description 9=Save 13=Change text module... Opt 14 Member CBL344P CBL344PN SENIOR TUITION3 TUITION5 Type CBL CBL CBL CBL CBL ODIN . . . . . 6=Print 14=Compile 7=Rename 15=Create Text Intro to Cobol programming Intro to Cobol programming The first Cobol program Tuition program (Initial with stubs) Tuition program (Completed) Bottom Parameters or command ===> F3=Exit F4=Prompt F9=Retrieve F10=Command entry F5=Refresh F23=More options F6=Create 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 . . . . . . . . . Library . . . . . . . . Source file . . . . . . . Library . . . . . . . . Source member . . . . . . Generation severity level Text 'description' . . . . . . . . . . . . . . . . . . . . . . . . . > SENIOR > MOHAMED > QCBLSRC > MOHAMED > SENIOR 29 *SRCMBRTXT Name, Name, Name Name, Name, 0-29 *PGMID *CURLIB *LIBL, *CURLIB *PGM Additional Parameters Replace program . . . . . . . . > *NO F3=Exit F4=Prompt F5=Refresh F13=How to use this display *NO, *YES F10=Additional parameters F24=More keys Bottom F12=Cancel 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 . . . . . . . . . Library . . . . . . . . Source file . . . . . . . Library . . . . . . . . Source member . . . . . . Generation severity level Text 'description' . . . . . . . . . . . . . . . . . . . . . . . . . > SENIOR > MOHAMED > QCBLSRC > MOHAMED > SENIOR 29 *SRCMBRTXT Name, Name, Name Name, Name, 0-29 *PGMID *CURLIB *LIBL, *CURLIB *PGM Additional Parameters Source listing options . . . . . + for more values Generation options . . . . . . . + for more values *SRCDBG F3=Exit F4=Prompt F24=More keys F12=Cancel F5=Refresh *SOURCE, *NOSOURCE, *SRC... *NOLIST, *LIST, *NOXREF... More... F13=How to use this display 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 . . . . . . . . : Library . . . . . . . . . . . . . : Object type . . . . . . . . . . . . : SENIOR MOHAMED *PGM Member to compile . . . . . . . . . : File . . . . . . . . . . . . . . . . : Library . . . . . . . . . . . . . : SENIOR QLBLSRC 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 File . . . . . . Library . . . . QCBLSRC MOHAMED Position to Type options, press Enter. 2=Edit 3=Copy 4=Delete 5=Display 8=Display description 9=Save 13=Change text module... Opt Member SENIOR TUITION3 TUITION5 Type CBL CBL CBL ODIN . . . . . 6=Print 14=Compile 7=Rename 15=Create Text The first Cobol program Tuition program (Initial with stubs) Tuition program (Completed) Bottom Parameters or command ===> F3=Exit F4=Prompt F5=Refresh F9=Retrieve F10=Command entry F23=More options The compile of member SENIOR was submitted to batch. The compilation of the program will be submitted to batch. F6=Create F24=More keys + Work with Members Using PDM File . . . . . . Library . . . . QCBLSRC MOHAMED Position to Type options, press Enter. 2=Edit 3=Copy 4=Delete 5=Display 8=Display description 9=Save 13=Change text module... Opt Member SENIOR TUITION3 TUITION5 Type CBL CBL CBL ODIN . . . . . 6=Print 14=Compile 7=Rename 15=Create Text The first Cobol program Tuition program (Initial with stubs) 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 10/03/99 Submitted from . . . . . . . . : Type options, press Enter. 2=Change 3=Hold 4=End 8=Work with spooled files Opt 8 Job SENIOR User MOHAMED *JOB 5=Work with Type BATCH ODIN 17:53:13 6=Release -----Status----OUTQ 7=Display message Function Bottom Parameters or command ===> F3=Exit F4=Prompt F5=Refresh F12=Cancel F9=Retrieve Enter option 8 to display the compiled spool file. F11=Display schedule data Work with Job Spooled Files Job: SENIOR User: MOHAMED Number: Type options, press Enter. 1=Send 2=Change 3=Hold 4=Delete 5=Display 8=Attributes 9=Work with printing status Opt 5 File SENIOR Device or Queue MOHAMED User Data Status RDY 342470 6=Release Total Pages 5 7=Messages Current Page Copies 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 Control . . . . . B Find . . . . . . _____________________________ Page/Line 1/1 Columns 1 - 130 *...+....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 Control . . . . . B Find . . . . . . Page/Line 4/34 Columns 1 - 130 *...+....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. ***** END OF MESSAGES ***** 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 STMT AS/400 COBOL Messages MOHAMED/SENIOR ODIN 10/03/99 17:45:53 Page 5 ***** END OF COMPILATION ***** 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 Control . . . . . Find . . . . . . _________________ Page/Line 4/8 Columns 1 - 130 *...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3 Enter Statement number and press F16 (shift F4) to search for the statement. * 13 * 13 * 13 * 28 * 37 * 39 clause. System-name QPRINT assumed. MSGID: LBL0116 SEVERITY: 20 SEQNBR: 001500 Message . . . . : Largest record description does not match RECORD CONTAINS clause for file. '42' assumed. MSGID: LBL0117 SEVERITY: 20 SEQNBR: 001500 Message . . . . : Smallest record description '42' characters. Does not match RECORD CONTAINS. '42' assumed. MSGID: LBL0650 SEVERITY: 00 SEQNBR: 001500 Message . . . . : Blocking/Deblocking for file 'STUDENT-FILE' will be performed by compiler-generated code. MSGID: LBL0014 SEVERITY: 10 SEQNBR: 003200 Message . . . . : Delimiter for literal is not correct. Literal accepted. MSGID: LBL0014 SEVERITY: 10 SEQNBR: 004500 Message . . . . : Delimiter for literal is not correct. Literal accepted. 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: Type options, press Enter. 1=Send 2=Change 3=Hold 4=Delete 5=Display 8=Attributes 9=Work with printing status Opt File SENIOR Device or Queue MOHAMED User Data Status RDY 342470 6=Release Total Pages 5 Current Page 7=Messages Copies 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 . . . . . . . . Library . . . . . . . Update production files Invoke program . . . . . . . . . . . . . . . . . . > SENIOR . > MOHAMED . *NO . *YES Name Name, *CURLIB, *LIBL *YES, *NO *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. >