Posts

RPGLE CL Command to call aprogram with numeric parameter

PGM : TESTHEX H DftActGrp(*NO) Option(*SRCSTMT)    D charval         S             26a   inz('123.00')            DRunCommand       PR                  ExtPgm('QCMDEXC')                DpCommand                     2560    const                            DPCmdLen                        15  5 const                            DpCommand         S           2560                          ...

RPGLE date format example

H DftName(TESTRPG) DftActGrp(*No) ActGrp(*New)      H Option(*srcstmt:*NoDebugIo)                        D*                                                  D*                                                  D vDate           S               d    datfmt(*ISO)  d wrk_date        DS                                D wrk_Cent                       2                  d wrk_year...

Data area RPGLE Example

H Option(*SrcStmt:*noDebugIo)                                       *                                                                   * Test Program for Data area                                       *                                                                  D                                                      ...

AS400: RPGLE - Get the job attribute and Trap Error using Monitor

This program will check if a job is active, If active it will give the status of the job. D eFlag             S              1        DQusrJobi         PR                  EXTPGM('QUSRJOBI')    DRcvVar                      32766A   options(*varsize)      DRcvVarLen                      10I 0 const                  DFormat                             8A   const                  DQualJob                          26A   const   ...

AS400 RPG: override a file that is defined in Fspec

If the need is to just override the file to a single file then in the F Spec we can define the EXTFILE() EXTMBR() to override the file  FDDMF      UF A E           K DISK    EXTFILE(LIB/FILENAME) EXTMBR(MBRA) If the need is to override the file to different file then we need to execute the override command based on the logic. We can use QCMDEXEC to run the CL command so that we dont need another CL program to do Overrides. To override a file that is defined in the F Spec we need to override the file before it is open.. So we need to control the file opening using USROPN option on that file. Run the command to override using   QCMDEXEC. The scope of the override has to at job level due to ILE concept and activation group the default scope (Activation Group level) wont work. Then open the file and perform the program logic. At end close the file and delete the override (LVL(*JOB)) F Spec: FDDMF  ...

AS400 CL: Run a command in a target system from the current system

Below Command will submit a Command (here a job with Parameter) in the remote system where the PF file of the DDM file resides. The job will be submitted with the users default jobd. QGPL/TSTJOBD gets overidden. To run this command you need to a file (Lets say SYS2) in the target system and a DDM file (RUSYS2 for that file SYS2 in target system) in the source system for that file. The command has no separate parameter for the remote system information; it know the command has to run in the system where the PF file of the DDM file is. In this case SYS2 PF resides in SYSTEM2 and RUSYS2 DDM file resides in SYSTEM1. This command will the run in SYSTEM1 will submit the job to call TSTLIB/PGMEML in SYSTEM2   SBMRMTCMD CMD('SBMJOB CMD(CALL PGM(TSTLIB/PGMEML) PARM(''DUMMY@XEMAIL.COM'')) JOBD(QGPL/TSTJOBD)') DDMFILE(TSTLIB/RUSYS2)                      

AS400 CL PGM Send a message to QSYSOPR and get reply from user to perform a process

PGM DCL &MSGKEY  *char     4                                DCL &RPLY     *char     1   ' '                                                                                      SNDPGMMSG MSG('Dont have enough Space. Type Y after clear some space or N to stop prcess (Y/N)') +               KEYVAR(&MSGKEY) MSGTYPE(*INQ)  TOMSGQ(QSYSOPR)                                                             RCVMSG MSGTYPE(*RPY) MSGKEY(...