Positioning the File Pointer and calling programs

8
Positioning the File Pointer and calling programs Fall 2011

description

Positioning the File Pointer and calling programs. Fall 2011. SETLL – Positioning the File Pointer. Sequential Access File Positions the file pointer at the first record where the key field is greater than on equal to what’s looked for Must be followed by a READ - PowerPoint PPT Presentation

Transcript of Positioning the File Pointer and calling programs

Page 1: Positioning the File Pointer and calling programs

Positioning the File Pointer and calling programs

Fall 2011

Page 2: Positioning the File Pointer and calling programs

SETLL – Positioning the File Pointer• Sequential Access File• Positions the file pointer at the first record where

the key field is greater than on equal to what’s looked for

• Must be followed by a READ• Use %FOUND to determine if the record found is

greater than or equal to the key field• Use %EQUAL to determine if the record found is

exactly the same as the key field that you are looking for

Page 3: Positioning the File Pointer and calling programs

SETLL Example

/Freesetll *loval custmast;

read custmast;/end-free

Page 4: Positioning the File Pointer and calling programs

SETLL – Example

/Freesetll custin custmast;

if %equal(custmast);exsr validcust;

else;exsr invalidcust;

endif;/end-free

Custno Note Note_dtls1 1 Customer arrived1 2 Customer left3 1 Customer away

If Custin = 1, then the file pointer for the first record will be returned

Page 5: Positioning the File Pointer and calling programs

SETGT

• Sequential Access File• Positions the file pointer at the first record where the

key field is greater than what’s looked for• Must be followed by a READ• Use %FOUND to determine if the record found is

greater than the key field

Page 6: Positioning the File Pointer and calling programs

Setgt Example

/Freesetll custin custmast;

if %equal(custmast);exsr validcust;

else;exsr invalidcust;

endif;/end-free

Custno Note Note_dtls1 1 Customer arrived1 2 Customer left3 1 Customer away

If Custin = 1, then the file pointer for the last record will be returned

Page 7: Positioning the File Pointer and calling programs

Calling Programs

Code in pgmADfullreport PR EXTPGM(‘REPORT’)/free callp fullreport();

Code in pgmB

pgmA pgmBNo parametersPassed

Page 8: Positioning the File Pointer and calling programs

Calling Programs

Code in pgmA Code in pgmBDDtlreport PR EXTPGM(‘REPORT’) Ddtlreport PRD parm1 10A D parm1 10A/free Ddtlreport PI callp Dtlreport(field1); D parm1 10A

Code in pgmB

pgmA pgmBparametersPassed