Posts

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                                      *   // ****************************************************************   // *                            ...

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

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

IBMi (AS400) fans only : 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 (                  ...

IBMi (AS400) fans only : RUNSQLSTM Run SQL Scripts example

Image
#IBMiSample The Run SQL Statements (RUNSQLSTM) command processes a source file of Structure Query Language (SQL) statements. let's have an example: Create a source member AS52A00F into library VDOTEST1/QSQLSRC. VDOTEST1 is MyLibrary. Use your library name. AS52A00F.SQL

IBMi (AS400) fans only : How to check a date field ddmmyy

Image
#IBMiSample How to check the correctness of a numeric date field 6 with 0 decimals. This program receives as input 1. a date in the DDMMYY format ( p_data ), for example p_data= 100612, that is June 10, 2012, an Error field ( p_error ). 2. a Flag field accepts date = 0 ( p_zero ). 3. returns a BLANK or 'E' value in the p_error field as a result of the check. CHKDATA.RPGLE       **free        ctl-opt option(*nodebugio:*srcstmt:*nounref) dftactgrp(*no)         ALWNULL(*USRCTL) ;         // Try with  STRDBG and         // CALL CHKDATA PARM(X'0120718F' 'x' 'N') valid date         // CALL CHKDATA PARM(X'0999999F' 'x' 'N') wrong date         // CALL CHKDATA PARM(X'0000000F' 'x' 'Y') no date, but it is allowed         // CALL CHKDATA PARM(X'0000000F' 'x' 'N') no date, it is not allowed         dcl-pi CHKDATA; ...

IBMi (AS400) fans only : Rpg Free Program Sample: How to manage a table through a program with two or more video formats

Image
#IBMiSample Typically we have a table and we need to perform read, write, update operations. This simple program is an example of how. First of all look at  this post  and compile and populate these files to use this example.

IBMi (AS400) fans only : Minimalist Subfile with filter fields

Image
#IBMiSample First of all please refer to  this post  to compile and populate the necessary files for this example. Then, compile the following sources: OT08SF.DSPF for the display file and OT08SF.SQLRPGLE for the RPGLE program.   Display File: OT08SFV.DSPF                                             CHGINPDFT(CS UL HI)                                             INDARA                                             CA03(03 'F3=EXIT')                                             REF(OTORD00F)       *--...

IBMi (AS400) fans only : How to write to the same printerfile from more programs

Image
#IBMiSample A simple way is to leave the file open by ending programs with RETURN instead of SETON LR. Example: Program A calls Program B. Program B opens a printerfile and write some pages in the spool file. Program B closes with RETURN. The printer file is already open. Program A calls Program B again. Program B opens a printerfile (it is already open) and write some other pages on the same spool file. Program B closes with RETURN. The printer file is already open. Program A calls Program B again. Program B opens a printerfile (it is already open) and write some other pages on the same spool file. Program B closes with RETURN. The printer file is already open. ... and so on. At the end, run RCLACTGRP ACTGRP(QILE). This command will end the QILE activation group, it means the spool file will also be closed. I appreciate all the comments made on this blog.