Modern RPG Unrealized Capabilities as easy as A
Modern RPG – Unrealized Capabilities as easy as A. B. C… Agenda A. Procedures – Use them!! B. Tools in RPGLE C. SQL D. Sockets Demo 1 E. Auto Refresh a screen in a program F. JDBC in RPGLE G. User Spaces with Pointers Demo 2 H. CEE Language and UNIX style API’s I. ENCRYPTION J. Random #’s K. PHP Command Line calls Modern RPG – Unrealized Capabilities George L. Slater 1
A. Procedures – Use Them!!! Procedures – Use them! • ILE Structure – any program can call any other ILE routine • Gained access to C from RPGLE • UNIX socket stuff from RPGLE • Write your own Built-In functions • Locally scoped variables so we don’t step on ourself – i(ndex) used multiple places ok • Recursive calls of procedures • That’s the platform – or basis we’re using – all of these use C language API’s Modern RPG – Unrealized Capabilities George L. Slater 2
B. Tools in RPGLE • Another way for QCmd. Exec • Sleep instead of Dly. Job • What is System Catalog? • Instead of DSPFFD – SYSCOLUMNS • TABLE_NAME = File Name • TABLE_SCHEMA = Library Modern RPG – Unrealized Capabilities George L. Slater 3
B. Tools in RPGLE QCmd. Exec 1 of 4 Another way for QCmd. Exec The traditional way: C C C Or /Free Eval Call Parm Command = ‘CHKOBJ QTEMP/WORKFILE – OBJTYPE(*FILE)’ Length = %Len(Command) ‘QCMDEXC’ Command Length Command = ‘CHKOBJ QTEMP/WORKFILE OBJTYPE(*FILE)’; Length = %Len(Command); QCMDEXEC(Command: Length); /End-Free Modern RPG – Unrealized Capabilities George L. Slater 4 50
B. Tools in RPGLE QCmd. Exec 2 of 4 Another way for QCmd. Exec Drawbacks of traditional way: • Command must be assembled into a variable. • Length of data is required • While you can determine if the command was successful or not, you cannot determine why it might have failed. Modern RPG – Unrealized Capabilities George L. Slater 5
B. Tools in RPGLE QCmd. Exec 3 of 4 Another way for QCmd. Exec The better approach – MODERN RPG: H Bnd. Dir(‘QC 2 LE’) D Exec. Cmd D Command Pr 10 i 0 * Ext. Proc(‘system’) Value Option(*String) D CPFError s 7 Import(‘_EXCP_MSGID’) /Free Reset CPFError; Exec. Cmd(‘CHKOBJ ‘ + %Trim(Work. Lib) + ‘/’ + %Trim(Work. File) + ‘ OBJTYPE(*FILE)’); If CPFError = ‘CPF 9084’; // do stuff End. If; /End-Free 5/15/2013 Update to source above ** Reset CPFError; Should be Clear CPFError; Modern RPG – Unrealized Capabilities George L. Slater 6
B. Tools in RPGLE QCmd. Exec 4 of 4 Another way for QCmd. Exec Modern RPG benefits: • Now you can get the same functionality you do in CL programs, including all the • added variable handling, • I/O, and • looping capability that you have in RPG. Modern RPG – Unrealized Capabilities George L. Slater 7
B. Tools in RPGLE Sleep instead of Dly. Job 1 of 2 The traditional way: C C C Eval Call Parm Command = ‘DLYJOB DLY(@num_sec)’ Length = %Len(Command) ‘QCMDEXC’ 50 Command Length Or /Free Command = ‘DLYJOB DLY(@num_sec)’; Length = %Len(Command); QCMDEXEC(Command: Length); /End-Free Modern RPG – Unrealized Capabilities George L. Slater 8
B. Tools in RPGLE Sleep instead of Dly. Job 2 of 2 The better approach – MODERN RPG: H Bnd. Dir(‘QC 2 LE’) D wait D seconds Pr ext. Proc(‘sleep’) 10 u 0 Const /Free // have the program wait 10 seconds. wait(10); /End-Free Modern RPG – Unrealized Capabilities George L. Slater 9
B. Tools in RPGLE System Catalog 1 of 1 What is System Catalog? You can use it to create your own display utilities for file definitions and record formats without the need to use DSPFD or DSPFFD, or DSPDBR. QSYS 2/SYSTABLES QSYS 2/SYSINDEXES QSYS 2/SYSCOLUMNS QSYS 2/SYSPINDEX File/Table definitions Logical File/Index definitions Column definitions Primary Index (Physical File Key) definitions … and many more Modern RPG – Unrealized Capabilities George L. Slater 10
C. SQL • Build a String • Return Day of Week • Recursive SQL • Demo • Highlight Union All, etc • IBM web site reference http: //publib. boulder. ibm. com/infocenter/iseri es/v 5 r 4/index. jsp? topic=%2 Fsqlp%2 Frbafyr ecursivequeries. htm Modern RPG – Unrealized Capabilities George L. Slater 11
C. SQL Build a string Build a String 1 of 1 Did you know that you can Execute a SQL statement that does not perform I/O? /Free Exec Sql Select ‘My ’ || ‘Data’ into : Data from Sys. Ibm/Sys. Dummy 1; //results in Data containing the value ‘My Data’ /End-Free Modern RPG – Unrealized Capabilities George L. Slater 12
C. SQL Day of Week 1 of 1 Return Day of Week Another SQL statement that does not perform I/O… /Free Exec Sql Select Day. Of. Week(Current Date) into : Today From Sys. Ibm/Sys. Dummy 1; //results in Today contains the numeric day of the week for the current // date where Sunday = 1, Monday =2. /End-Free Modern RPG – Unrealized Capabilities George L. Slater 13
C. SQL Recursive SQL 1 of 5 SQL File Specs for BOM Uses file METHDM: AQPART AQMTLP AQSEQ# AQLIN# AQBLWT AQMTLD AQQPPC AQUNIT Parent Part Material Part Production Sequence Line number Blow Thru Indicator (Phantom) Material Part Description Qty Per Unit of Measure Modern RPG – Unrealized Capabilities George L. Slater 14
C. SQL Recursive SQL 2 of 5 Recursive SQL for BOM With BOM( Level, Part, Blow. Thru, Total_Qty) Sub. Part, Description, Sequence. No, Quantity, Line#, UOM, As ( Select 1, Root. AQPART, Root. AQMTLP, Root. AQSEQ#, Root. AQBLWT, Root. AQMTLD, Root. AQQPPC From Meth. Dm Root Where Root. AQPART not in ( Select AQMTLP From METHDM) Union All Select Parent. Level + 1, Child. AQPART, Child. AQMTLP, Child. AQSEQ#, Child. AQBLWT, Child. AQMTLD, Child. AQQPPC * Parent. Quantity From BOM Parent Join METHDM Child On Parent. Sub. Part = Child. AQPART Where Parent. Level < 10 and Parent. Blow. Thru <> ‘ ‘) Search Depth First by Part, Sequence. No, Line# Set Seq. Col Select Level, Part, Sub. Part, Sequence. No, Line#, Quantity, UOM, Total_Qty, From BOM Order by Seq. Col Modern RPG – Unrealized Capabilities George L. Slater Root. AQLIN#, Root. AQUNIT, Child. AQLIN#, Child. AQUNIT, 15
C. SQL Recursive SQL 3 of 5 Sample Output of BOM LEVEL PART SUBPART SEQUENCENO LINE# QUANTITY SQL TOTAL_QTY 1 2 2 3 A B B D B F B C D E F G 10 10 10 Modern RPG – Unrealized Capabilities George L. Slater 1 1 2 1 1 1 UOM 1 2 2 4 1 1 1 2 2 8 1 1 16
C. SQL Recursive SQL 4 of 5 Recap of BOM SQL • • BOM, Bill of Material, that uses one file: METHDM With Clause defines a temporary work file As clause uses 2 SQL statements UNION ALL inserts the results of each SQL statement whether they duplicate an existing row or not • 1 st Select inserts only top row level items(Items that do not appear as components anywhere in the BOM) and sets the level column to “ 1” Modern RPG – Unrealized Capabilities George L. Slater 17
C. SQL Recursive SQL 5 of 5 Recap of BOM SQL cont. • 2 nd Select statement = MAGIC • Inserts rows into the work file for all children based on join back to work file • That join means that as children are added they update the join so that their children (aka grandchildren) are also part of result of 2 nd Select • That causes their children (great-grandchildren) to be added, and their children (great-great) and so on • STOP LOOPING = Parent level is less than 10 • Search Depth children exploded out immediately, also use Search Breadth Modern RPG – Unrealized Capabilities George L. Slater 18
D. Sockets Demo 1 -Sockets 1 of 3 Sockets Read a file with no F specs Demo 1 Send to a socket • • • Write a copy of original file R_TARGET – 1. Creates a socket 2. Starts a listener R_SOURCE – 1. Create a socket 2. Connect to the listener Once connected & Target accepts connection 3. Sends data and receives data SOURCE = Sending TARGET = Receiving Modern RPG – Unrealized Capabilities George L. Slater 19
D. Sockets • Demo 1 -Sockets 2 of 3 Sockets: R_TARGET Demo 1 • Communications set up • Socket, Bind, Listen • TARGET = Receiving • Receives Bytes_Read • Writes to a PF Member • Performs Add, Clear, Ovr. Dbf, Delete • Processes all entries until *END is received • Cool Prototype: • Rrn. Locate = Locate file pointer to a specific record in the file (SETLL) Modern RPG – Unrealized Capabilities George L. Slater 20
D. Sockets Demo 1 -Sockets 3 of 3 Sockets: R_SOURCE – Demo 1 connected to • Communications setup, listener and Target accepts connection • Sends data and receives data • SOURCE = Sending • Gets listing of members to read • Sends START of refresh • Sends RECORDS and will insert a deleted record for each missing record • Send END of refresh • Cool Prototype: • Get. Mbr. Lst = Creates User Space that lists the members of for the file Modern RPG – Unrealized Capabilities George L. Slater 21
E. Auto Refresh a screen in a program • Auto Refresh a screen in a Using Data. Queue and Ovr. Dsp. F • Code sample =program SPACED • Screen Definitions • DSPF – Wait time on Record Format, Compile Permanently, Limited • ** or ** Data Queue – Stored in QTEMP, not going to hang around afterwards, No issue with wait time and time out for program to get control, Preferred method • ** Gotcha ** • Write Screen with INVITE keyword *ON • Clear Screen with INVITE keyword *OFF • Single subfile = Works great; Multiple subfiles, 2 nd Screen F 12 complains back, write old subfile then do clear. Modern RPG – Unrealized Capabilities George L. Slater 22
F. JDBC in RPGLE • • • Scott Klement’s service program Type 4 JDBC driver Everything is a string (String and array) Tell what fields are where and not have to define Date, Time and Timestamp handling are biggest problems http: //www. scottklement. com/presentations/External%20 D atabases%20 from%20 RPG. pdf Modern RPG – Unrealized Capabilities George L. Slater 23
G. User Spaces with Pointers • • Demo 2 -Usr. Spc 1 of 3 User Spaces with Pointers Display an array and update with no API’s Demo 2 Run in 2 sessions • Data updated in one session • Refreshing in another session • API = QUSPTRUS, QUSCRTUS SPACED – 1. DSPF = SPACED_FM 2. Read Only SPACEU – 1. DSPF = SPACEU_FM 2. Update, Create & Write Modern RPG – Unrealized Capabilities George L. Slater 24
G. User Spaces with Pointers • Demo 2 -Usr. Spc 2 of 3 User Spaces with Pointers Remember…your program imposes the 2 structure onto Demo the Data Area • Forgot and not seeing in debug…dump it • DMPOBJ OBJ(WMSUGEX/DATATEST) OBJTYPE(*USRSPC) • Pointer • * is a pointer variable • Cool Prototype: • Get. Status. Ptr = Like Chk. Obj, 0=worked, no length, string on the fly Modern RPG – Unrealized Capabilities George L. Slater 25
G. User Spaces with Pointers • Demo 2 -Usr. Spc 3 of 3 User Spaces with Pointers User spaces do not have to look the same • You could Demo define the 2 original data structure so that it just looks at some control information at the beginning of the user space • Then that control information defines what the layout of the rest of the user space is • Guess what? You can then use the pointer to base a data structure of the correct format, or even stack multiple different data structure formats one after another in any number required to represent the data you want to store Modern RPG – Unrealized Capabilities George L. Slater 26
H. CEE & UNIX style API’s • CEE Language & UNIX Sockets programming style API’s • (TARGET/SOURCE) H Option(*Src. Stmt: *Nodebugio) Dft. Act. Grp(*No) Act. Grp(*New) H Debug(*Yes) Dat. Fmt(*ISO) Alw. Null(*Usr. Ctl) Bnd. Dir('QC 2 LE') • File processing without F specs • (TARGET/SOURCE) //********************************** // File API's D Open. File Pr * Ext. Proc('_Ropen') D File. Name * Options(*String) Value D Mode * Options(*String) Value Modern RPG – Unrealized Capabilities George L. Slater 27
I. ENCRYPTION EN-CRYPT-ION • Code page conversion • Encryption • Hex to character’ • Encryption • MD 5 – Web – no way to decrypt • RC 4 – uses key – way to decrypt and encrypt Modern RPG – Unrealized Capabilities George L. Slater 28
I. ENCRYPTION EN-CRYPT-ION Encryption 1 of 12 Display File for encryption example ============================================ A DSPSIZ(24 80 *DS 3) A R WDW 001 A CF 03(03) A CF 12(12) A WINDOW(*DFT 12 70) A WDWBORDER((*COLOR BLU) (*DSPATR RI)A (*CHAR ' ')) A USRRSTDSP A 1 6'Data Encryption with RPG ' A DSPATR(HI) A 11 2'F 3=Exit F 12=Cancel' A COLOR(BLU) A 3 1'Enter' A 3 7'the' A 3 11'data' A 3 16'to' A 3 19'encrypt: ' A CHARIN 32 I 4 3 A 6 1'Md 5' A 6 5'Value: ' A 8 1'Rc 4' A 8 5'Value: ' A MD 5 OUT 64 O 7 3 A RC 4 OUT 64 O 9 3 A R DUMMY ASSUME A 1 2' ' Modern RPG – Unrealized Capabilities George L. Slater 29
I. ENCRYPTION EN-CRYPT-ION Encryption 2 of 12 Source for Encryption Program Example =========================================== H Dft. Act. Grp(*No) Act. Grp(*Caller) Bnd. Dir('QC 2 LE': 'QUSAPIBD') H Option(*Src. Stmt: *No. Debug. IO) H Debug(*Yes) *********************************** * Modifications * *********************************** Fencrypt. D CF E Work. Stn D Sys. Cmd D Command Pr 10 i 0 Ext. Proc('system') * Value Options(*String) D CPFError s 7 a import('_EXCP_MSGID') D Sleep Pr D Sleep. Time D Cleanup DCipher D D D 10 i 0 Ext. Proc('sleep') 10 u 0 Const Pr Pr Ext. Proc('_CIPHER') * Value Modern RPG – Unrealized Capabilities George L. Slater 30
I. ENCRYPTION DConvert D Dcvthc D DGet. Cvt. Tbl D CCSID 1 D Start. Map D L 1 D CCSID 2 D St 2 D Gcc. Asn D L 2 D To 819 D L 3 D L 4 D Fb D Md 5 Encode D Input. String EN-CRYPT-ION Pr Encryption 3 of 12 EXTPROC('_XLATEB') * Value 10 u 0 Value Pr Ext. Proc('cvthc') 1 1 10 i 0 Value Pr Pr Ext. Pgm('QTQCVRT') 10 i 0 256 10 i 0 10 i 0 256 10 i 0 12 32 50 Const Modern RPG – Unrealized Capabilities George L. Slater 31
I. ENCRYPTION EN-CRYPT-ION D rc s D Lo c D Up c D Retry s D Retry. Count s Encryption 4 of 12 10 i 0 Const('abcdefghijklmnopqrstuvwxyz') Const('ABCDEFGHIJKLMNOPQRSTUVWXYZ') 1 5 i 0 D encrypt. Screen. Data. . . D Pr D RC 4 Encode D inputdata Pr 32 64 Const /free Do. W Not *In 03 and Not *In 12; Ex. Fmt Wdw 001; encrypt. Screen. Data(); End. Do; *In. LR = *On; return; /end-free Modern RPG – Unrealized Capabilities George L. Slater 32
I. ENCRYPTION EN-CRYPT-ION Encryption 5 of 12 //=================================== // Encrypt the screen data for redisplay //=================================== P encrypt. Screen. Data. . . P B D encrypt. Screen. Data. . . D Pi /Free If char. In <> *Blanks; md 5 out = Md 5 Encode(char. In); Rc 4 Out = Rc 4 Encode(char. In); Else; md 5 out = *Blanks; Rc 4 Out = *Blanks; endif; /End-Free P E //=================================== // MD 5 Encoding routine // Note: MD 5 is a standard encoding method used on the web and can // not be decrypted. There are websites available, however, // that let you test passwords by entering them and displaying // the Md 5 encrypted value. These websites should be avoided Modern RPG – Unrealized Capabilities George L. Slater 33
I. ENCRYPTION EN-CRYPT-ION Encryption 6 of 12 // They capture the passwords and resulting MD 5 hashes so that // users can also lookup a hash and determine what the original // password is. For this reason most web applications will not // use a direct one-time MD 5 conversion but will either: // 1. Perform the MD 5 encryption multiple times // 2. Seed the password with some characters (possibly // generated randomly) and store that seed along with // the password so that the seed can be recombined // with the password for encryption. // 3. Scramble the password in some fixed way so that the // entered value is not what is encrypted. //=================================== P Md 5 Encode B D Md 5 Encode D Input. String Pi DControls DS D Function D Hash. Alg D Sequence D Data. Lngth D Unused D Hash. Ctx. Ptr DOutput. String S DHash. Work. Area S 32 50 Const 5 i 0 inz(5) 1 inz(x'00') 10 i 0 inz(15) 8 inz(*LOVAL) * inz(%addr(Hash. Work. Area)) 32 96 inz(*LOVAL) Modern RPG – Unrealized Capabilities George L. Slater 34
I. ENCRYPTION DMsg S DReceiver. Hex S DReceiver. Ptr S DReceiver. Chr S DSource. Ptr S DStart. Map s DTo 819 s DCCSID 1 s DST 1 s DL 1 s DCCSID 2 s DST 2 s DGCCASN s DL 2 s DL 3 s DL 4 s DFB s DUpper c DLower c D Dx D Low. X 50 EN-CRYPT-ION Encryption 7 of 12 16 * inz(%addr(Receiver. Hex)) 32 * inz(%addr(Msg)) 256 10 i 0 inz(37) 10 i 0 inz(0) 10 i 0 inz(%size(Start. Map)) 10 i 0 inz(819) 10 i 0 inz(0) 10 i 0 inz(%size(To 819)) 10 i 0 12 Const('ABCDEF') Const('abcdef') ds 5 i 0 2 2 Modern RPG – Unrealized Capabilities George L. Slater 35
I. ENCRYPTION EN-CRYPT-ION Encryption 8 of 12 /Free // Get all single byte ebcdic hex values For x = 0 to 255; %Subst(Start. Map: x+1: 1) = Low. X; End. For; Get. Cvt. Tbl(CCSID 1: ST 1: Start. Map: L 1: CCSID 2: ST 2: Gcc. Asn: L 2: To 819: L 3: L 4: Fb); // Move the input constant to a variable and get it's length Msg = Input. String; Data. Lngth = %Len(%Trim(Msg)); If Data. Lngth > *Zero; // Convert the codepage of the data Convert( %Addr(Msg): %Addr(To 819): %Size(Msg)); Modern RPG – Unrealized Capabilities George L. Slater 36
I. ENCRYPTION EN-CRYPT-ION Encryption 9 of 12 // Encrypt the data Cipher(%Addr(Receiver. Ptr): %Addr(Controls): %Addr(Source. Ptr)); // Convert the encrypted data to hex Cvt. Hc(Receiver. Chr: Receiver. Hex: %Size(Receiver. Chr)); // Convert the hex characters to lower case since that // is the standard format of an MD 5 hash Output. String = %XLate(Upper: Lower: Receiver. Chr); Else; Output. String = *Blanks; End. If; // Return the encrypted data Return Output. String; /End-Free Modern RPG – Unrealized Capabilities George L. Slater 37
I. ENCRYPTION EN-CRYPT-ION Encryption 10 of 12 //=================================== // RC 4 Encryption routine // Note: Rc 4 encryption allows for decrypting the data once it is // encrypted so long as the original encryption key is known //=================================== P RC 4 encode B D RC 4 encode Pi 64 D data 2 Encrypt 32 Const D input. Data D encrypted s s 32 64 Inz(*Blanks) // This is the key used to encrypt the data D e_key s 54 A varying inz('Now. Is. The. Time. For. All. Good. MD en. To. Encrypt. Their. Data. With. Rc 4 Yeah') D Ds D RC 4_Controls D funct_id D datalen D operation D reserved D p_key_ctx D stream D len D reserved ds qualified 2 A 5 I 0 1 A 11 A * ds qualified 256 A 5 U 0 6 A Modern RPG – Unrealized Capabilities George L. Slater 38
I. ENCRYPTION D ds D Hex. Data s D p_recv D p_src s s EN-CRYPT-ION Encryption 11 of 12 64 * * /Free // Move input constant to variable for processing input. Data = data 2 Encrypt; // Setup the encryption key and processing information key_ctx = *ALLx'00'; %subst(key_ctx. stream: 1: %len(e_key)) = e_key; key_ctx. len = %len(e_key); RC 4_Controls = *ALLx'00'; RC 4_Controls. funct_id = x'0013'; RC 4_Controls. datalen = %size(input. Data); RC 4_Controls. operation = x'00'; // 0=Encrypt, 1=Decrypt RC 4_Controls. p_key_ctx = %addr(key_ctx); Modern RPG – Unrealized Capabilities George L. Slater 39
I. ENCRYPTION EN-CRYPT-ION Encryption 12 of 12 // Point to the source and destination values p_src = %addr(input. Data); p_recv = %addr(Encrypted); // Encrypt the data cipher( %addr(p_recv): %addr(RC 4_Controls): %addr(p_src)); // Convert the data to hex for display since the encrypted data // may contain non-displayable characters. Cvt. Hc(Hex. Data: Encrypted: %Size(Encrypted)); // Return the encrypted data Return Hex. Data; /End-Free P E Modern RPG – Unrealized Capabilities George L. Slater 40
J. Random #’s • Uses a random number generator • Creates a 5 character confirmation key • User must type in the key to verify that they want to perform a given action Modern RPG – Unrealized Capabilities George L. Slater 41
J. Random #’s Random # 1 of 4 Display File for Random Number example ========================================== A A A A A A DSPSIZ(24 80 *DS 3) R WDW 001 WINDOW(*DFT 10 40) WDWBORDER((*COLOR BLU) (*DSPATR RI)(*CHAR ' ')) USRRSTDSP CF 03(03) CF 12(12) 1 6'Random Character Generation' DSPATR(HI) 3 2'Confirm' 3 10'by' 3 13'typing' 3 20'the' 3 24'following' 3 34'key: ' @KEY 5 A O 5 16 DSPATR(HI) 7 2'Enter' 7 8'Key: ' @CONFIRM 5 A B 7 13 9 2'F 3=Exit F 12=Cancel' COLOR(BLU) R DUMMY ASSUME 1 2' ' Modern RPG – Unrealized Capabilities George L. Slater 42
J. Random #’s Random # 2 of 4 Program source for Random Number example ========================================== H Dft. Act. Grp(*No) Act. Grp(*Caller) Bnd. Dir('QC 2 LE') H Option(*Src. Stmt: *No. Debug. IO) FRANDOMD CF E Work. Stn D Sys. Cmd D Command Pr 10 i 0 Ext. Proc('system') * value options(*string) D CPFError s 7 a Import('_EXCP_MSGID') D Confirmed Pr D Get. Random. Nbr D Seed D Random D Char. Arr s n Pr Ext. Proc('CEERAN 0') 10 i 0 8 F 1 Dim(36) Ct. Data Per. Rcd(36) Modern RPG – Unrealized Capabilities George L. Slater 43
J. Random #’s Random # 3 of 4 /Free Do. U *In. LR; If Confirmed(); *In. LR = *On; End. If; End. Do; Return; /End-Free P Confirmed B D Confirmed Pi 1 n D Random. Float S 8 f D Seed S 10 i 0 Inz(0) D Random. Int S 10 i 0 DI S 5 i 0 /Free Do. U @Confirm = @Key or *In 03 = *On or *In 12 = *On; Modern RPG – Unrealized Capabilities George L. Slater 44
J. Random #’s Random # 4 of 4 For I = 1 to 5; Do. U Random. Int > *Zero; Get. Random. Nbr(Seed: Random. Float); Random. Int = %Int(Random. Float * 36); Random. Float = *Zero; End. Do; %Subst(@Key: I: 1) = Char. Arr(Random. Int); End. For; Ex. Fmt Wdw 001; End. Do; Return @Confirm = @Key; /End-Free P E ** Char. Arr ABCDEFGHIJKLMNOPQRSTUVWXYZ 01234567689 Modern RPG – Unrealized Capabilities George L. Slater 45
K. PHP Command Line calls • FTP • Image manipulation • Accessing an image from local storage: a form upload, or FTP and storing, displaying, resizing it and converting it to another format • PHP writes classes • Anything else you need it to do such as a web routine that you want to be called at intervals as well as being called from the web. Don’t write it twice. Modern RPG – Unrealized Capabilities George L. Slater 46
X. EXCLUDED from Presentation - EXCLUSIONS • Scheduling Jobs less than a day Modern RPG – Unrealized Capabilities George L. Slater 47
MODERNRPG/QSQLSRC Appendix RECURS_SQL. . . : 1 100 Browse MODERNRPG/QSQLSRC RECURS_SQL . . . +. . . 1. . . +. . . 2. . . +. . . 3. . . +. . . 4. . . +. . . 5. . . +. . . 6. . . +. . . 7. . . +. . . 8. . . +. . . 9. . . +. . . 0 ******** Beginning of data ******************************************** //================================= // All BOM's depth first (in and out of subassemblies as they are // encountered) //================================= With BOM(Level, Part, Sub. Part, Sequence. No, Line#, Blow. Thru, Description, Quantity, UOM, Total_Qty) As ( Select 1, Root. AQPART, Root. AQMTLP, Root. AQSEQ#, Root. AQLIN#, Root. AQBLWT, Root. AQMTLD, Root. AQQPPC, Root. AQUNIT, Root. AQQPPC From Meth. Dm Root Where Root. AQPART not in ( Select AQMTLP From METHDM) Union All Select Parent. Level + 1, Modern RPG – Unrealized Capabilities George L. Slater 48
MODERNRPG/QRPGLESRC Appendix R_TARGET. . . : 6 100 Browse MODERNRPG/QRPGLESRC R_TARGET . . . 1. . . +. . . 2. . . +. . . 3. . . +. . . 4. . . +. . . 5. . . +. . . 6. . . +. . . 7. . . +. . . 8. . . +. . . 9. . . +. . . 0 ******** Beginning of data ******************************************** //=============================== // Modifications * //========* // // 11/28/2006 Monitor for Locks on Data Areas and Retry up to // 10 times until a good read is achieved. // //=============================== H Option(*Src. Stmt: *Nodebugio) Dft. Act. Grp(*No) Act. Grp(*New) H Debug(*Yes) Dat. Fmt(*ISO) Alw. Null(*Usr. Ctl) Bnd. Dir('QC 2 LE') D R_Target Pr D Lib_Name 10 D File_Name 10 D R_Target D Lib_Name D File_Name Pi 10 10 //************************************************************************* // Sockets API's D Socket Pr 10 i 0 Extproc('socket') D 10 i 0 Value D Set. Sock. Opt Pr D D D // Sockets API's D Socket Pr D D D 10 i 10 i 0 0 Extproc('setsockopt') Value 10 i 10 i 0 0 Extproc('socket') Value 10 i. Capabilities 0 Extproc('setsockopt') Modern RPGPr– Unrealized George L. Slater 10 i 0 Value D Set. Sock. Opt D D 10 i 0 Value * Value 49
MODERNRPG/QRPGLESRC Appendix R_SOURCE. . . : 6 100 Browse MODERNRPG/QRPGLESRC R_SOURCE . . . 1. . . +. . . 2. . . +. . . 3. . . +. . . 4. . . +. . . 5. . . +. . . 6. . . +. . . 7. . . +. . . 8. . . +. . . 9. . . +. . . 0 ******** Beginning of data ******************************************** //=============================== // Modifications * //========* // // 11/28/2006 Monitor for Locks on Data Areas and Retry up to // 10 times until a good read is achieved. // //=============================== H Option(*Src. Stmt: *Nodebugio) Dft. Act. Grp(*No) Act. Grp(*New) H Debug(*Yes) Dat. Fmt(*ISO) Alw. Null(*Usr. Ctl) Bnd. Dir('QC 2 LE') D R_Source Pr D Lib_Name 10 D File_Name 10 D R_Source D Lib_Name D File_Name Pi 10 10 //************************************************************************* // Sockets API's D Socket Pr 10 i 0 Extproc('socket') D 10 i 0 Value D Set. Sock. Opt Pr D D D // Sockets API's D Socket Pr D D D 10 i 10 i 0 0 Extproc('setsockopt') Value 10 i 10 i 0 0 Extproc('socket') Value 10 i. Capabilities 0 Extproc('setsockopt') Modern RPGPr– Unrealized George L. Slater 10 i 0 Value D Set. Sock. Opt D D 10 i 0 Value * Value 50
MODERNRPG/QRPGLESRC Appendix JDBC_EXAMP. . . : 6 100 Browse MODERNRPG/QRPGLESRC JDBC_EXAMP *. 1. . . +. . . 2. . . +. . . 3. . . +. . . 4. . . +. . . 5. . . +. . . 6. . . +. . . 7. . . +. . . 8. . . +. . . 9. . . +. . . 0 ******** Beginning of data ******************************************** * Modifications * ************************************* H DFTACTGRP(*NO) BNDDIR('JDBC': 'QC 2 LE': 'PROP') ALWNULL(*USRCTL) H Actgrp(*New) /copy jdbc_h D Sys. Cmd D Command Pr 10 i 0 Ext. Proc('system') * Value Options(*String) D rc D Member. Number s s 10 i 0 20 D Push. Conn D rs 2 s s s like(Connection) like(Result. Set) D Upd_Stmt D Ins_Stmt s s Like(Prepared. Statement) D Pub_Conn D Proc. Ok s s 60 D Mode D Count. Stmt s s 10 256 D input. Data D Upd_Stmt D Ins_Stmt Ds s s D Pub_Conn D Proc. Ok s s Dtaara('PUB_CONN') n Inz(*Blanks) Qualified Inz Like(Prepared. Statement) 60 Dtaara('PUB_CONN') n 10 Capabilities Inz(*Blanks) George L. Slater Modern RPGss– Unrealized 256 D Mode D Count. Stmt D input. Data d Association. Id Ds 60 Qualified Inz Varying 51
MODERNRPG/QDDSSRC Appendix SPACED_FM. . . : 1 100 Browse MODERNRPG/QDDSSRC SPACED_FM . . . A*. 1. . . +. . . 2. . . +. . . 3. . . +. . . 4. . . +. . . 5. . . +. . . 6. . . +. . . 7. . . +. . . 8. . . +. . . 9. . . +. . . 0 ******** Beginning of data ******************************************** A*%%TS SD 20120705 135644 ASIGEORGE REL-V 5 R 4 M 0 5722 -WDS A*%%EC A DSPSIZ(24 80 *DS 3) A 66 INVITE A R SPACE_FT A*%%TS SD 20120705 135644 ASIGEORGE REL-V 5 R 4 M 0 5722 -WDS A 23 2'F 3=Exit' A COLOR(BLU) A 23 11'F 5=Refresh' A COLOR(BLU) A 23 23'F 12=Cancel' A COLOR(BLU) A R SPACE_SF SFL A*%%TS SD 20120705 134437 ASIGEORGE REL-V 5 R 4 M 0 5722 -WDS A 50 SFLNXTCHG A RRN 5 I 0 H A DISP_KEY 10 A O 6 11 A DISP_DATE 19 A O 6 23 A R SPACE_CT SFLCTL(SPACE_SF) A*%%TS SD 20120705 134437 ASIGEORGE REL-V 5 R 4 M 0 5722 -WDS A SFLSIZ(0015) A SFLPAG(0014) A VLDCMDKEY(25) A CF 03(03) A CF 05(05) A CF 12(12) A OVERLAY A 41 SFLDSP A N 40 SFLDSPCTL A 40 SFLCLR Modern RPG – Unrealized Capabilities George L. Slater 52
MODERNRPG/QRPGLESRC Appendix SPACED. . . : 6 100 Browse MODERNRPG/QRPGLESRC SPACED HKeywords+++++++++++++++++++++++++++++++++Comments++++++ ******** Beginning of data ******************************************** H Dft. Act. Grp(*No) Act. Grp(*Caller) Bnd. Dir('QC 2 LE') //=================================== // This program provides an example of how to use a user space with // pointers to pass or store data directly as if it were in memory. // Because this approach uses pointers the data layout is completly // dynamic since the pointer can be moved forward or backward through // the space and applied to various data structure definitions to // achieve multiple, conditional structures within the space itself //==================================== FSpaced_Fm CF E Work. Stn SFile(Space_SF: Rrn) Usr. Opn D Get. Status. Ptr Pr D Rtv. Spc. Ptr D User. Space D Space. Ptr Pr D Crt. Usr. Spc D User. Space FSpaced_Fm CF Pr * Ext. Pgm('QUSPTRUS') 20 * E D Get. Status. Ptr Pr D Rtv. Spc. Ptr D User. Space D Space. Ptr Pr D Crt. Usr. Spc D User. Space D Extend. Attr D Space. Size D Space. Val D Space. Aut D Space. Text D Space. Repl D Api_Error D Space. Domn D Space. Tfr D Space. Align Pr Ext. Pgm('QUSCRTUS') 20 Work. Stn SFile(Space_SF: Rrn) Usr. Opn * Ext. Pgm('QUSPTRUS') 20 * Ext. Pgm('QUSCRTUS') 20 10 10 i 0 1 10 50 10 Like. Ds(API_Error. Ds) Modern RPG – Unrealized Capabilities George L. Slater 10 10 i 0 1 53
MODERNRPG/QDDSSRC Appendix SPACEU_FM. . . : 1 100 Browse MODERNRPG/QDDSSRC SPACEU_FM . . . A*. 1. . . +. . . 2. . . +. . . 3. . . +. . . 4. . . +. . . 5. . . +. . . 6. . . +. . . 7. . . +. . . 8. . . +. . . 9. . . +. . . 0 ******** Beginning of data ******************************************** A*%%TS SD 20120705 140201 ASIGEORGE REL-V 5 R 4 M 0 5722 -WDS A*%%EC A DSPSIZ(24 80 *DS 3) A R SPACE_FT A*%%TS SD 20120705 135644 ASIGEORGE REL-V 5 R 4 M 0 5722 -WDS A 23 2'F 3=Exit' A COLOR(BLU) A 23 11'F 5=Refresh' A COLOR(BLU) A 23 23'F 12=Cancel' A COLOR(BLU) A R SPACE_UPD A*%%TS SD 20120705 140201 ASIGEORGE REL-V 5 R 4 M 0 5722 -WDS A VLDCMDKEY(25) A CF 03(03) A CF 12(12) A OVERLAY A 1 2 DATE A EDTCDE(Y) A 2 2 TIME A 1 21'User Space Update Utility ' A DSPATR(HI) A 2 19'Update User Space Keys and Dates ' A 1 59 SYSNAME A 1 70'SPACEUPD ' A 2 70 USER A 9 14'Space' A 9 20'Key: ' A SPACEKEY 10 A B 9 25 A 11 14'Current' Modern RPG – Unrealized Capabilities George L. Slater 54
MODERNRPG/QRPGLESRC Appendix SPACEU. . . : 6 100 Browse MODERNRPG/QRPGLESRC SPACEU HKeywords+++++++++++++++++++++++++++++++++Comments++++++ ******** Beginning of data ******************************************** H Dft. Act. Grp(*No) Act. Grp(*Caller) Bnd. Dir('QC 2 LE') FSpace. U_Fm CF E Work. Stn D Get. Status. Ptr Pr D Rtv. Spc. Ptr D User. Space D Space. Ptr Pr D Crt. Usr. Spc D User. Space D Extend. Attr D Space. Size D Space. Val D Space. Aut D Space. Text D Space. Repl D Api_Error D Space. Domn D Space. Tfr D Space. Align Pr D Display. Screen Pr D Check. Cmd. Keys Pr D Update. Space D Space. Data Pr D D * Ext. Pgm('QUSPTRUS') 20 * Ext. Pgm('QUSCRTUS') 20 10 10 i 0 1 10 50 10 Like. Ds(API_Error. Ds) 10 Pr Ext. Pgm('QUSCRTUS') 20 10 10 i 0 1 10 50 10 Like. Ds(API_Error. Ds) 10 10 i 0 1 10 Space. Tfr Space. Align Value 10 i 0 1 D Display. Screen Pr D Check. Cmd. Keys Pr Modern RPGPr– Unrealized Capabilities George L. Slater D Update. Space D Space. Data * User Space Definition 10 Value 55
MODERNRPG/QRPGLESRC Appendix INCJOBSCDE. . . : 6 100 Browse MODERNRPG/QRPGLESRC INCJOBSCDE HKeywords+++++++++++++++++++++++++++++++++Comments++++++ ******** Beginning of data ******************************************** H Dft. Act. Grp(*No) Act. Grp(*Caller) Option(*Src. Stmt: *No. Debug. Io) H Bnd. Dir('QC 2 LE': 'GRARBNDDIR') D Rets_Incr D Job_Name D Run_Interval Pr D Rets_Incr D Job_Name D Run_Interval Pi D Exec. Cmd D Command Pr D CPFMsg s D Sleep D interval Pr D 10 t 10 i 0 ext. Proc('system') * Value Options(*String) 7 a import('_EXCP_MSGID') 10 i 0 ext. Proc('sleep') 10 u 0 value Run_Interval t D Exec. Cmd D Command Pr D CPFMsg s D Sleep D interval Pr D Rtv. Job. Scd. E D Job. Name Pr D Job. Scd. E D Inf_Status D Job_Name D Entry_Number D Sched_Date D Sched_Days D Sched_Time D Rtv. Job. Scd. E D Job. Name Ds D Job. Scd. E D Inf_Status D Job_Name D Entry_Number D Sched_Date D Sched_Days D Sched_Time D Sched_Freq Ds 10 i 0 ext. Proc('system') * Value Options(*String) 7 a import('_EXCP_MSGID') 10 i 0 ext. Proc('sleep') 10 u 0 value * 10 Qualified Based(Job. Scd. EPtr) 1 10 10 10 70 6 Pr * 10 Qualified Based(Job. Scd. EPtr) 1 10 10 10 70 6 10 Modern RPG – Unrealized Capabilities George L. Slater 56
- Slides: 56