1 * "F" (file) specs define files and other i/o devices 2 F ARMstF1 IF E K Disk Rename(ARMST:RARMST) 3 4 * "D" (data) specs are used to define variables 5 D pCusNo S 6p 6 D pName S 30a 7 D pAddr1 S 30a 8 9 * The "chain" command is used for random access of a keyed file 10 C pCusNo chain ARMstF1 11 12 * If a record is found, move fields from the file into parameters 13 C if %found 14 C eval pName = ARNm01 15 C eval pAddr1 = ARAd01 16 C eval pAddr2 = ARAd02 17 C eval pCity = ARCy01 18 C endif 19 20 * RPG makes use of switches. One switch "LR" originally stood for "last record" 21 * LR flags the program and its dataspace as removable from memory 22 23 C eval *InLR = *On 24 25 * "F" (file) specs define files and other i/o devices 26 FARMstF1 IF E K Disk Rename(ARMST:RARMST) 27 28 * "D" (data) specs are used to define variables and parameters 29 * The "prototype" for the program is in a separate file 30 * allowing other programs to call it 31 /copy cust_pr 32 * The "procedure interface" describes the *ENTRY parameters 33 D getCustInf PI 34 D pCusNo 6p 0 const 35 D pName 30a 36 D pAddr1 30a 37 D pAddr2 30a 38 D pCity 25a 39 D pState 2a 40 D pZip 10a 41 /free 42 // The "chain" command is used for random access of a keyed file 43 chain pCusNo ARMstF1; 44 45 // If a record is found, move fields from the file into parameters 46 if %found; 47 pName = ARNm01; 48 pAddr1 = ARAd01; 49 pAddr2 = ARAd02; 50 pCity = ARCy01; 51 pState = ARSt01; 52 pZip = ARZp15; 53 endif; 54 55 // RPG makes use of switches. One switch "LR" originally stood for "last record" 56 // LR actually flags the program and its dataspace as removable from memory. 57 *InLR = *On; 58 /end-free 59 60 H main(GetCustInf) 61 D ARMSTF1 E DS 62 P GetCustInf B 63 D GetCustInf PI extpgm('CUS001') 64 D inCusNo like(arCNum) const 65 D outName like(arName) 66 D outAddr1 like(arAdd1) 67 D outAddr2 like(arAdd2) 68 D outCity like(arCity) 69 D outState like(arStte) 70 D outZip like(arZip) 71 /free 72 exec sql select arName, arAdd1, arAdd2, arCity, arStte, arZip 73 into :outName, :outAddr1, :outAddr2, :outCity, :outState, 74 :outZip 75 from ARMSTF1 76 where arCNum = :inCusNo 77 fetch first 1 row only 78 with CS 79 use currently committed; 80 /end-free 81 P GetCustInf E 82