1 / 16

CL Programming with Database Files

CL Programming with Database Files. Updated Fall 2010. Agenda . CL programming with Database Objects RPG Programming with Database Objects. Physical Files. Store Data Have record formats Can have keys (access paths) Created using DDS Code or SQL. Logical Files. Do not store data

midori
Download Presentation

CL Programming with Database Files

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. CL Programming with Database Files Updated Fall 2010

  2. Agenda • CL programming with Database Objects • RPG Programming with Database Objects

  3. Physical Files • Store Data • Have record formats • Can have keys (access paths) • Created using DDS Code or SQL

  4. Logical Files • Do not store data • Stores key fields and record addresses • Another view of the data • Created using DDS Code or SQL

  5. CL Programming with Database Objects

  6. CL Programming Restrictions • Only five *FILE per program • Display file or Database File • Can’t update Database Files • Can’t create reports

  7. File Commands • DCLF - Declares a Filee.g. DCLF FILE(STUDENTS) • RCVF - Reads a record from a screen or database file • SNDRCVF is used only with display files, NOT database files! • SNDPGMMSG – Send Program Message • Sends a message to the calling program

  8. Example Write a CL program which reads the student file, calculates the total Feesowed and total Finesowed displays it to the user.

  9. Pseudo Code Initialize variables Receive information Do while not end of file Update account balance total Receive information End of file: format the message to display the total account balance

  10. Monitoring for messages • When something unusual happens, the system sends a message back to the program. • It is up to the program to ‘trap’ the message if necessary and take the appropriate action.e.g. an end-of-file condition (msg CPF0864)

  11. Monitor Message Example RCVF MONMSG MSGID(CPF0864) + EXEC(GOTO CMDLBL(ENDIT))

  12. RPG Programming with Database Objects

  13. FSPEC Review File name – name of file File Type – C for a Display file I, U, or O for Database Objects O, for Printer Files (reports) File Format – E for Externally Described Record Address Type – K if the object has a sort Device – Disk for Database Object Workstn for display files Printer for reports

  14. RPG Verbs and Functions • Read filename; • reads a record from a database object • %EOF(filename) • Checks for End of File

  15. Programming tasks • Create a display file that uses all of the fields from the Student file. All of the fields should be output only. Feesowed and Finesowed should have the attribute Reverse Image (RI) conditioned by an indicator • Write an RPG program that displays each record in the Student file using the above display file. Feesowed and Finesowed should be displayed in Reverse Image if they are greater than zero.

  16. Pseudo Code Initialize variables Receive information Do while not end of file Display the screen Receive information End of file: exit program

More Related