Posts

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(...

AS400 : Add a new line in text in email SNDSMTPEMM

Declare  ** NAMED CONSTANTS FOR CARRIAGE RETURN  Which will move the control to next line                      D CR              C                   CONST(X'0D')                  //0->Zero D vSepj           S              1    Inz('/')   D vQot            S              1    INZ('''')  DRunCommand       PR                  extpgm('QCMDEXC')                D pCommand                    2560    const                  ...

Pass Parameters more than 32 byte in SBMJOB command using RQSDTA

Variable greater than 32 byte length will be truncated to 32 byte (including the trailing spaces) when a call command is submitted using SBMJOB CMD(CALL PGM(*LIBL/PGM1) PARM( &ERROR & USER ....) Since you are trying to pass the value of a variable to another job from your interactive job environment but the other wont share the same environment hence the variable values are not accessible. hence these values are sent as values to another job and the default length is 32 per variable in CMD. When your RPG/CL/CBL program get these variable the Error will have 32 byte of Error and then the 32 of User and so on (result in undesirable effect). One way to do it put a limiter value at the end of each variable so there is no trailing spaces, but the best way to do that is instead using SBMJOB CMD(CALL PGM(*LIBL/PGM1) PARM( &ERROR & USER ....)  use SBMJOB RQSDTA(CMDV) Example shown below (CL Program) but similar can be done in RPG or COBOL build the command string an...

COBOL/RPG run CL command

01  WS-CMD-STRING       PIC X(2560).                          01  WS-CMD-LEN          PIC S9(10)V9(05) COMP-3 VALUE 2560. MOVE "OVRPRTF FILE(FileNM) SHARE(*YES) OPNSCOPE(*JOB)"                      TO WS-CMD-STRING.            CALL "QCMDEXC" USING WS-CMD-STRING, WS-CMD-LEN.          RPG:  * Run Command                                                    DRunCommand       PR                  extpgm('QCMDEXC')            D pCommand                   32702    const...

Email from AS400 with Attachment

Email Spool as PDF Convert Spool to PDF (Need 5770TS1 option 01 installed in the machine/LPAR) CPYSPLF FILE(SPLFfilename) TOFILE(*TOSTMF) JOB(jobname/user/jobnumber) SPLNBR(*ONLY) TOSTMF('ifs or stream filename.pdf') WSCST(*PDF) STMFOPT(*REPLACE)                    QSYS/SNDSMTPEMM RCP((mail@domain.COM)) SUBJECT('test email') ATTACH(('ifs or stream filename.pdf'))                                                                                                                                                                  ...