Submitting Jobs from S/36E
Here is an easy method for submitting a CL program to a job queue from a S/36E procedure which also needs to pass variable (not fixed) parameters.
You can build the CALL command string within a procedure parameter and then execute the parameter as follows:
// EVALUATE P64='CALL XYZ (?1? ?2?)' // SBMJOB CMD(?64?) JOBQ(QBATCH)
Suppose now that the first parameter contains 'ABC' and the second parameter contains 'IJK'. The EVALUATE statement changes parameter 64 to CALL XYZ (ABC IJK), and the next statement runs the program.
You'll run into a bit of trouble if the parameters need to be surrounded by single quotes. For example, if parameter one contains 'ABC DEF', the above technique will fail when the second statement tries to CALL program XYZ, passing it three parameters instead of two (ABC, DEF and IJK). A more generic solution, then, would be as follows:
// EVALUATE P64='CALL XYZ (''?1?'' ''?2?'')' // SBMJOB CMD(?64?) JOBQ(QBATCH)
Get Printer File Information in RPG36 Programs
In RPG36, the only INFDS allowed is for WORKSTN files. Sometimes you need information for printer files, like the current printer line number or forms length, which is only available in a printer INFDS. You can get the data using shared open data paths.
Before running the RPG36 program, issue an OVRPRTF FILE(file_name) SHARE(*YES). Then, whenever you need the INFDS status, CALL a short RPG/400 program sharing the same printer file. It needs to perform a printer operation to update its INFDS, but a space before and after of zero lines without any output fields does the trick. Then just pass back whichever fields you need.
... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+ FPRTFNAMEO F 132 OV PRINTER KINFDSPRTFDS IPRTFDS DS I [printer file information fields] C *ENTRY PLIST C PARM ... C* C EXCPTDUMMY C* C* Convert numeric fields to charater for passing to RPG36 C* C MOVE ... C RETRN OPRTFNAMEE 00 DUMMY ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+
The FLIB Command
In V1R2M0 of OS/400, IBM added a new feature to the S/36E to allow changing the file libraries when running S/36 functions. By using the FLIB procedure, you can switch libraries. Before release 2, the S/36 file library could only be changed by using the CHG36 command, requiring a dedicated S/36E system. The FLIB procedure could be entered on the command line or you could use the // FLIB OCL statement to change the library in the procedure. For example, if you want a CATALOG listing of the files in QGPL, you do the following:
STRS36 FLIB QGPL CATALOG ALL,F1
This can be handy when testing S/36 applications. Your test data can be in a test library and you can issue the FLIB command before you start testing. The new file library will be in effect until it is changed again or until you sign off.
Library List Support for S/36E Files
Files do not have to reside in QS36F. Library list support can be globally enabled via CHGS36, or temporarily enabled or disabled via // FILELIB LIBL- YES|NO or the FLIB procedure. Files will still be created in QS36F unless you also change the current file library.
For example, for testing you may want to have a procedure similar to:
// FILELIB LIB-S36TESTF,SESSION-YES,LIBL-YES // FILELIB LIB-S36TESTF,SESSION-NO ADDLIBLE QS36F (*AFTER S36TESTF) STRDGB UPDPROD(*NO)
This will cause new files to be created in S36TESTF, and existing files in QS36F to be used only if the program does not attempt to open the file for update (assuming S36TESTF is created as a *TEST library).
Numeric Parameter Passing Between RPG36 and RPG/400 Programs
When CALLing an RPG/400 program from RPG36, numeric fields will not be compatible. This is because RPG36 uses zoned decimals for all internal fields, whereas RPG/400 expects numeric fields to be packed unless otherwise defined in a data structure. Since *ENTRY fields cannot be defined in a data structure (because they are passed by address), there is no way to tell the RPG/400 program the field is zoned decimal.
One way to circumvent the problem is to pass the data in a character field. Perform MOVEs on both ends to convert the field between formats.