IBC233 W7 powerpoint
Download
Report
Transcript IBC233 W7 powerpoint
CL Programming with Database Files
Updated Summer 2007
Agenda
• Review of Database Objects
• CL Programming
• CL Programming exercise
Physical Files
•
•
•
•
Store Data
Have record formats
Can have keys (access paths)
Created using DDS Code or SQL
Object types
TYPE
And
SUBTYPE
Opt Object
PATIENT
PRFOUT
QCBL
QCBLSRC
QCL
QCLPSRC
Opt Member
AINTDEMO
APTRNSDF
APTRNSDF2
APVENDOR
ARCUST
ARCUSTLF2
ARCUSTX
Type
*FILE
*FILE
*FILE
*FILE
*FILE
*FILE
Attribute
Text
PF-DTA
PF-DTA Output file for DSPUSRPRF
PF-SRC
program sources
PF-SRC
program sources
PF-SRC
cl program sources
PF-SRC Cl Sources
Type
Text
PF
DSPF
DSPF
PF
PF
LF
PF
demo for external single field
in class developed
ASSIGNMENT 2 and in class 3/4
ASSIGNMENT 2 and in class 3/4
ASSIGNMENT 2 and in class 3/4
Logical Files
• Do not store data
– Stores key fields and record addresses
• Another view of the data
• Created using DDS Code or SQL
Files defined
Physical file
A* Physical file ARCUST ACCOUNTS RECEIVABLE Master File
A
UNIQUE
A
R ARCUSTR
A
CUSTNO
5S 0
TEXT('CUSTOMER NUMBER')
A
ALIAS(AR_CUST_NUMBER)
A
NAME
30A
TEXT('CUSTOMER NAME')
A
ALIAS(AR_CUST_NAME)
A
SALESMAN
2S 0
TEXT('SALESMAN')
ALIAS(AR_SLSM_NUMBER)
A
Logical file
A*Logical file ARCUSTLF based on Physical file ARCUST ACCOUNTS
A* RECEIVABLE Master File
A*
A
A
A
A
A
A
UNIQUE
R ARCUSTRL
CUSTNO
NAME
SALESMAN
STATUS
K CUSTNO
S NAME
O NAME
PFILE(ARCUST)
COMP(EQ 'BERNS')
COMP(EQ 'SWISS')
Steps to create a DDS OBJECT?
On the green screen
Create a source physical file (once)
CRTSRCPF F12 (work with)
Add a member F6 in WRKOBJPDM level
Code / edit the member WRKMBRPDM
Compile to create CRTPF / CRTLF / CRTDSPF
In a GUI
Navigate to the desired level and add the required object by right clicking and selecting
DDS/SQL Programming Review
Create a file to hold customer
information (Customer number ,
name, account balance and type).
Create a logical view by Customer
Name
CL Programming with Database
Objects
Great extra reading
See IBC233 home page!!
CL Programming Restrictions
• Only five *FILE per program
– Display file or Database File
• Can’t update Database Files
• Can’t create reports
File Commands
• DCLF - Declares a File
e.g. DCLF FILE(STUDENTS)
• RCVF - Reads a record from a screen or
database file
• SNDRCVF is used only with display files,
NOT database files!
• SNDF – sends a record to a screen
The Send File (SNDF) command is used by a CL procedure to send a record to a display device that is being used by
an interactive user. The device can be any display station, including the console.The command sends the data from the
program's CL variables to the display's device file in the specified record format. These variables were automatically
declared in the program (one for each field in the record format) when the CL source program was compiled and a
Declare File (DCLF) command was processed as part of the source
Example
Write a CL program which reads
the customer file, calculates the
account balance and displays it to
the user.
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
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)
Monitor Message Example
RCVF
MONMSG MSGID(CPF0864)
EXEC(GOTO CMDLBL(ENDIT))
+
Programming tasks
• Create a display file that uses all of the fields from
the customer file. All of the fields should be
output only. The text, ‘Customer owes money’
should be conditioned based on an indicator.
• Write a program that displays each record in the
customer file using the above display file. The
text, ‘Customer owes money’ should be displayed
if the account balance field is greater than zero.
Don’t forget
Lab 7 due on July 6 before lab starts
Assignment 2 due on Friday July 13
Do NOT forget to modify your “BYEBYE” program to authorize me to
ALL your objects, libraries and all the objects within the a libraries!!