ALLDONE: ENDPGM
As an alternative to using the job log, the following RPG program uses the error
code structure to receive error messages:
Hᑍ ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Hᑍ ᑍ
Hᑍ MODULE: ERRCODE ᑍ
Hᑍ ᑍ
Hᑍ LANGUAGE: RPG ᑍ
Hᑍ ᑍ
Hᑍ FUNCTION: THIS APPLICATION DEMONSTRATES THE USE OF THE ᑍ
Hᑍ ERROR CODE PARAMETER. ᑍ
Hᑍ ᑍ
Hᑍ APIs USED: QHFRTVAT, QHFCRTDR ᑍ
Hᑍ ᑍ
Hᑍ ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Hᑍ ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Hᑍ ᑍ
Hᑍ THIS PROGRAM DOES SOME SIMPLE VERIFICATION ON AN HFS ᑍ
Hᑍ DIRECTORY. THE QHFRTVAT API IS USED TO VERIFY THE EXISTENCE ᑍ
Hᑍ OF THE SPECIFIED DIRECTORY. IF THE DIRECTORY DOES NOT EXIST, ᑍ
Hᑍ AN ATTEMPT IS MADE TO CREATE THE DIRECTORY. ᑍ
Hᑍ ᑍ
Hᑍ THERE ARE THREE PARAMETERS TO THIS PROGRAM ᑍ
Hᑍ ᑍ
Hᑍ 1 INPUT PATHNM - NAME OF DIRECTORY ᑍ
Hᑍ 2 INPUT PATHLN - LENGTH OF PATHNM PARAMETER ᑍ
Hᑍ 3 OUTPUT SUCCES - INDICATES SUCCESS OR FAILURE ᑍ
Hᑍ '' SUCCESS ᑍ
Hᑍ '1' FAILURE ᑍ
Hᑍ ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
ISUCCES DS
I B 1 4RETCOD
IPLENG DS
I B 1 4PATHLN
IBINS DS
I B 1 4RETDTA
I B 5 8ATTRLN
IERROR DS
I B 1 4BYTPRV
I B 5 8BYTAVA
I 9 15 ERRID
I 16 16 ERR###
I 17 272 INSDTA
C ᑍENTRY PLIST
C PARM PATHNM 8
C PARM PLENG
C PARM SUCCES
Cᑍ
Cᑍ INITIALIZE BYTES PROVIDED AND THE ATTRIBUTE LENGTH VARIABLE
Cᑍ
C Z-ADD272 BYTPRV
C Z-ADD ATTRLN
Cᑍ
Cᑍ RETRIEVE DIRECTORY ENTRY ATTRIBUTES
Cᑍ
C CALL 'QHFRTVAT'
C PARM PATHNM
C PARM PATHLN
C PARM ATTR 1
C PARM ATTRLN
C PARM ATTR
C PARM ATTRLN
C PARM RETDTA
C PARM ERROR
Cᑍ
Cᑍ CHECK FOR DIRECTORY NOT FOUND OR FILE NOT FOUND ERRORS.
Cᑍ IF WE RECEIVE ONE OF THESE THIS IS THE INDICATION THAT
Cᑍ WE CAN TRY TO CREATE THE DIRECTORY.
Cᑍ
C BYTAVA IFEQ ᑍZERO
Chapter 2. Getting Started with APIs
2-11