Posts

Showing posts with the label as400

IBMi (AS400) fans only ' Encrypting/Decrypting data with RpgFree & SQL embedded

Image
  #IBMiSample Compile and Run this SQLRPGLE. This is an explanation how to encrypt/decrypt data in a DB2 table using RpgFree & SQL embedded.       **free       ************************************************       * Encrypting/Decrypting data with SQL embedded *       * Encrypt/decript example with                 *       * ENCRYPT_AES                                  *       * ENCRYPT_RC2                                  *       * ENCRYPT_TDES                                 *       *                                              *       * DECRYPT_BIT                                  *       ************************************************        ctl-opt        option(*nodebugio) dftactgrp(*no) actgrp(*new);        dcl-s encryptionPassword VARCHAR(128);        dcl-s p0                     CHAR(10);        dcl-s p1                     CHAR(10);        dcl-s p2                     CHAR(10);        dcl-s p3                     CHAR(10);        // The EXEC SQL is never executed. It is

AS/400 fans only ' How to send a DB2 file per Email as CSV attachment

Image
#IBMiSample A simple CMD and CLP to send a DB2 file as CSV attachment.                                                                            /************************************/  SNDCSV.CMD              CMD        PROMPT('Send DB2 file as CSV attachm.') /* COMMAND PROCESSING PROGRAM IS: SNDCSVCL */              PARM       KWD(SNDFIL) TYPE(*CHAR) LEN(10) MIN(1) PROMPT('DB2 +                           file to send as CSV')              PARM       KWD(LIBR00) TYPE(*CHAR) LEN(10) PROMPT('Library') +                           DFT(*LIBL)              PARM       KWD(MAIL00) TYPE(*CHAR) LEN(50) MIN(1) PROMPT(' +                           Email destination address')              PARM       KWD(SUBJCT) TYPE(*CHAR) LEN(100) MIN(1) PROMPT(' +                           Email subject')              PARM       KWD(BODY00) TYPE(*CHAR) LEN(500) MIN(1) PROMPT(' +                           Email body') /************************************/  Compile

IBMi (AS400) fans only ‘ How to check the display size on 5250 screen. *DS3 80 columns or *DS4 132 columns

Image
#IBMiSample In this example CHKDS4.RPGLE detects the screen setting. As an example I propose a CLP that calls PGM1 if the setting of 80 columns is detected, or calls PGM2 if the setting of 132 columns is detected.

IBMi (AS400) fans only ‘ Subfile window with mouse Selection - DoubleLeftClick - MOUBTN(*ULD CA04)

Image
#IBMiSample Subfile window with mouse selection - DoubleLeftClick - MOUBTN(*ULD CA04) This example uses DoubleLeftClick MOUBTN(*ULD CA04) to select a subfile row. Please note: the mouse works with "Personal Communications iSeries Access" and does not work with a simple 5250 emulator (for example Mocha TN5250 does not detect the mouse). If you don't have "Personal Communications iSeries Access" it doesn't matter, the mouse doesn't work but the function keys work as usual. First of all look at this post and compile and populate CLANA00F to use this example. Don't forget to set the screen to 132 columns!    This is the display file: CL01SFV.DSPF       **************************************************************       *  CLANA01L Subfile with select option       **************************************************************                                             DSPSIZ(27 132 *DS4)                                             INDARA              

IBMi (AS400) fans only ' how to calculate the check digit for EAN-13 codes

Image
#IBMiSample The check digit is the last digit of each barcode and is used to verify the correctness of the GS1 codes (formerly EAN codes). This program calculates the check digit of an EAN-13 barcode: EAN13C.RPGLE **FREE   ctl-opt option(*nodebugio:*srcstmt:*nounref) dftactgrp(*no);   // ****************************************************************   // * Autore.......: ALDO SUCCI                                    *   // * Descrizione..: CALCOLO DEL CHECK DIGIT X EAN13               *   // * Data.........: 15/06/09                                      *   // ****************************************************************   // *                                                              *   // * Parametri in input:PARAM (12 cifre EAN)                      *   // *             output:WDIGIT (13° carattere Check digit)        *   // *                                                              *   // *                                                              *   // * il caratt

IBMi (AS400) fans only ' %DIFF BIF - How to add or subtract days from a date field %days(n)

Image
#IBMiSample We can use %DAYS to add or subtract to a date. Hier is an example:

IBMi (AS400) fans only ' As an alternative to WRKACTJOB: How to get Active Jobs data using SQL ACTIVE_JOB_INFO table function

Image
#IBMiSample The ACTIVE_JOB_INFO table function returns one row for every active job.  You can use it to get the same information as the WRKACTJOB command in an alternate mode. Look at the following examples: a. List all jobs of  user VDOTEST SELECT JOB_NAME, SUBSYSTEM, SUBSY00001, AUTHO00001, JOB_TYPE, FUNCT00001, FUNCTION, JOB_STATUS,  MEMOR00001                 FROM TABLE(ACTIVE_JOB_INFO())                                 WHERE JOB_NAME LIKE '%VDOTEST%'                               b. List all jobs of  subsystem QBATCH SELECT JOB_NAME, AUTHORIZATION_NAME, ELAPSED_TOTAL_DISK_IO_COUNT, ELAPSED_CPU_PERCENTAGE                                            FROM TABLE(QSYS2.ACTIVE_JOB_INFO(                                 SUBSYSTEM_LIST_FILTER => 'QBATCH')) A                             ORDER BY ELAPSED_TOTAL_DISK_IO_COUNT DESC                         c. List all jobs temporary storage SELECT JOB_NAME, AUTHORIZATION_NAME, TEMPORARY_STORAGE,      SQL_STATEMENT_TEXT         

IBMi (AS400) fans only ' Modernizing RPG's indicator with INDARA (Indicator Area) keyword

Image
#IBMiSample INDARA (Indicator Area) keyword for ICF files workstn indds indicator data structure INDARA is used to put the field option indicators and function(response) key indicators in a separate area of memory called indicator area. By using this keyword, we can make indicator data structure in our program to give the customized name to indicators defined in the display file. Hence, it makes the program more readable and easy to understand. Step 1. indicate INDARA  keyword in your Display File Step 2. indicate INDDS in your RPG workstation file declaration dcl-f PKLTSFV workstn indds(Dspf) sfile(SFL1 : SF1NUM); Step 3. declare the  indicator area        dcl-ds Dspf qualified ;          Exit            ind pos(03) inz(*off);          SflClr          ind pos(50) inz(*off);          DspAtrRI        ind pos(61) inz(*off);          DspClrRed       ind pos(62) inz(*off);          SflEnd          ind pos(91) inz(*off);        end-ds ;     Step 4. In the RPG source program replace all the

IBMi (AS400) fans only ‘ Rpg Free: Create a Window to display a very long program message

Image
#IBMiSample I'm tired of one-line messages. Too short. The average user needs clear and comprehensive messages. Then I need a large enough window to display a clear and complete message . Why not use a SUBFILE? A SUBFILE program can handle a list of many lines, a clear and complete message is just a list of many text lines! Here's how I did it I need a table that contains the messages.                           --                                                  --  RUNSQLSTM SRCFILE(VDOTEST1/QSOURCE) SRCMBR(W03AM00F) --                                                  CREATE TABLE VDOTEST1/W03AM00F (                    W3FANN CHARACTER(1) NOT NULL WITH DEFAULT,          W3TPMS CHARACTER(6) NOT NULL WITH DEFAULT,          W3COD0 NUMERIC(4, 0) NOT NULL WITH DEFAULT,         W3RIG0 NUMERIC(2, 0) NOT NULL WITH DEFAULT,         W3TXT0 CHARACTER(078) NOT NULL WITH DEFAULT         )                                                   RCDFMT W03AM