CL language analysis results


DataQ CL example

/*/
/* QSNDDTAQ and QRCVDTAQ example for DataQ                           */
/*/
             PGM
             DCL VAR(&DQNAME) TYPE(*CHAR) LEN(10) VALUE('FILEINFO')
             DCL VAR(&DQLIB) TYPE(*CHAR) LEN(10) VALUE('QGPL')
             DCL VAR(&DQSNDLEN) TYPE(*DEC) LEN(5 0) VALUE(14)
             DCL VAR(&DQLEN) TYPE(*DEC) LEN(5 0)
             DCL VAR(&DQSNDDATA) TYPE(*CHAR) LEN(100)
             DCL VAR(&DQDATA) TYPE(*CHAR) LEN(100)
             DCL VAR(&DQWAIT) TYPE(*DEC) LEN(5 0) VALUE(0)
             CHGVAR VAR(&DQSNDDATA) VALUE('THIS IS A TEST')
             CALL QSNDDTAQ PARM(&DQNAME &DQLIB &DQSNDLEN &DQSNDDATA)
             CALL QRCVDTAQ PARM(&DQNAME &DQLIB &DQLEN &DQDATA &DQWAIT)
             SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&DQDATA)
             ENDPGM

CL_program_to_dataQ_publisher.jpg

/CL_dataQ_receiver_to_program.jpg

IBM MQ CL example

CALL PGM(MQGET) PARM('Queue_Name','Queue_Manager_Name')

CL_ibmmq_receiver_to_program.jpg

CALL PGM(MQPUT) PARM('Queue_Name','Queue_Manager_Name')

CL_program_to_ibmmq_publisher.jpg

SQL CL examples

PGM
RUNSQL SQL('PREPARE MYSTMT FROM SELECT * FROM VIEWSQ')
ENDPGM

cl_exec_sql_example.jpg

SQL Script CL example

PGM
RUNSQLSTM  SRCFILE(CGSRC/QSQLSRC) SRCMBR(S_REQ46) +
           COMMIT(*NC)
ENDPGM

cl_call_to_sql_file_example.png

STRQMQRY CL example

PGM
    STRQMQRY   QMQRY(MYLIB/S_REQ46)  QMFORM(FORM1)
ENDPGM

cl_call_to_sql_file_example.png

DCLF command example

Two modelisations have been made for DCLF instructions based on the type of file. DCLF commands can declare database file or display device file. To distinguish between both types of file, we must look at the presence of other commands:

Command available to file type description
RCVF both read the file within the CL program
SNDF display device file write the file within the CL program
SNDRCVF display device file write and then read the file within the CL program

Also, when multiple declarations of DCLF are present in the same file, then a matching OPNID or RCDFMT must be present between a specific DCLF command and for example a RCVF command.

Disk File (alias for database file)

For the following sample file TAACFGAC.clp:

    PGM
      DCLF FILE(QADSPOBJ)
      DCL VAR(&MBRNAME) TYPE(*CHAR) LEN(10)
      DCL VAR(&MBR) TYPE(*CHAR) LEN(10)
    ENDPGM

The associated results:

MissingDiskFile.png

When the DDS Physical File or DDS Logical File is present the CL Missing Physical/Logical File is replaced by the DDS Physical File or DDS Logical File object and an additional link is made from the CL program to the DDS Physical File or DDS Logical File. Also, if Table or View are found by the com.castsoftware.sqlanalyzerexternal link extension then these objects are prioritized as follows:

DiskFileToTable.png

Display File

  PGM                                                                        
  DCLF FILE(TAADTQCD)                                                        
  DCL VAR(&DTAQ) TYPE(*CHAR) LEN(10) VALUE(DTQ1)                             
  DCL VAR(&LIB) TYPE(*CHAR) LEN(10) VALUE(*LIBL)                             
  DCL VAR(&ENTLEN) TYPE(*DEC) LEN(5 0)
  DCL VAR(&ENTRY) TYPE(*CHAR) LEN(80)
  SNDF RCDFMT(FMT1)
  CHGVAR VAR(&RCDINPUT) VALUE('')                                                                                   
  CHGVAR VAR(&WAIT) VALUE(99999)                                                                                     
  CALL PGM(QRCVDTAQ) PARM(&DTAQ &LIB &ENTLEN &ENTRY &WAIT)                                                           
  IF COND('*DSPF' *EQ %SST(&ENTRY 1 5)) THEN(DO)                                                                     
  RCVF RCDFMT(FMT1)   
  ENDPGM

MissingDisplay.png

CLRPFM command example

CLRPFM creates a Use Delete Link from the CL program to a Disk File. Multiple CLRPFM commands within the same program referencing the same file create only one Disk File object with multiple Use Delete Links, if not already create prior to the first CLRPFM call.

PGM
    CLRPFM (QADSPOBJ) MBR(MAIL)
    CLRPFM (QADSPOBJ) MBR(DATA)
    CLRPFM FILE(QADSPOBJ)
ENDPGM

CLRPFM_MissingDDS.png

When the DDS Physical File or DDS Logical File is present the CL Missing Physical/Logical File is replaced by the DDS Physical File or DDS Logical File object and an additional link is made from the CL program to the DDS Physical File or DDS Logical File. Also, if Table or View are found by the com.castsoftware.sqlanalyzerexternal link extension then these objects are prioritized as follows:

CLRPFM_WithDDS.png

OVRDBF command example

OVRDBF creates a Use Select Link from the CL program to Disk File for both parameters FILE and TOFILE. Multiple OVRDBF commands within the same program referencing the same file create only one Disk File object with multiple Use Select Links, if not already create prior to the first OVRDBF call.

modelisation for the OVRDBF command is thus similar to the one for the DCLF, CLRPFM, CPYF command for database files.

(see CLRPFM command example and DCLF command example sections).

OVRPRTF command example

similar to the OVRDBF command, but with the CL Printer File object instead of the CL Disk File object.

CPYF command example

CPYF creates a Use Select Link and Use Update Link from the CL program to Disk File for both parameters FROMFILE and TOFILE, respectively. Multiple CPYF commands within the same program referencing the same file create only one Disk File object with multiple Use Select Links or Use Update Links, if not already create prior to the first CPYF call.

modelisation for the CPYF command is thus similar to the one for the DCLF, CLRPFM, OVRDBF command for database files.

(see CLRPFM command example and DCLF command example sections).

Data Area Example

Two modelisations have been made for Data Area instruction based on the type of Data Area. Data Area are either local or non-local. There are five commands available to manipulate the Data Area listed in the table below:

Command Link Type description
CRTDTAARA Access Link create the Data Area
CHGDTAARA Write Access Link update the Data Area
RTVDTAARA Read Access Link retrieve the Data Area
DSPDTAARA Read Access Link display the Data Area
DLTDTAARA Write Access Link delete the Data Area

Local Data Area (*LDA)

     DCL        VAR(&QNOM) TYPE(*CHAR) LEN(10)                                                                  
    /*=========================================================*/                                                       
    /* RECHERCHE ENVIRONNEMENT DE TRAVAIL                      */                                                       
    /*=========================================================*/                                                       
     RTVDTAARA  DTAARA(*LDA (24 2)) RTNVAR(&SEC)    

data_area1.png

Non-Local Data Area

Example with constant string

    RTVDTAARA  DTAARA(DMAMELERR *ALL) RTNVAR(&DATANO)                                                          
    CHGVAR     VAR(&QMDATANO) VALUE(&QUOTE *TCAT &DATANO +                                                     
                 *TCAT &QUOTE)                                                                                 
    RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&QDATE)                                                                    
    RTVSYSVAL  SYSVAL(QTIME) RTNVAR(&QTIME)                                                                    
    CALLSUBR   SUBR(EXTRACTION)                                                                                
    CVTDAT     DATE(&QDATE) TOVAR(&DATE) FROMFMT(*SYSVAL) +                                                    
                 TOFMT(*YYMD) TOSEP('-')                                                                       
    CHGVAR     VAR(&DATANO) VALUE(&DATE *TCAT '-' *TCAT +                                                      
                 %SST(&QTIME 1 2) *TCAT '.' *TCAT +                                                            
                 %SST(&QTIME 3 2) *TCAT '.' *TCAT +                                                            
                 %SST(&QTIME 5 2) *TCAT '.000000')                                                             
    CHGDTAARA  DTAARA(DMAMELERR *ALL) VALUE(&DATANO)                                                           

data_area2.png

Example with variable

     DSPDTAARA DTAARA(&OBJLIB/&OBJ) OUTPUT(*PRINT)   

data_area3.png

Run Query example

Modelisation for the RUNQRY command triggers links based on the parameters of the command. Three parameters are considered:

  • The value of the QRY parameter is associated to the property IBM i Named Query.
  • values of the QRYFILE parameter are associated to the Use Select Link between the CL program and the database file
  • the value of the OUTFILE parameter is associated to the Use Insert Link between the CL program and the database file

The database file refers to the following objects:

  • DDS Logical File
  • DDS Physical File
  • CL Missing Physical/Logical File

In addition, if Table or View objects are found by the com.castsoftware.sqlanalyzer extension then these objects are prioritized as follows:

runqry.png

CL Command interacting with DDS files

An exhaustive list of CL commands that interact with DDS files has been added to support the modelisation of weak referencing toward DDS files. In the following sections, we present the CL commands that interact with DDS files and the associated modelisation. The CL commands are categorized based on the type of DDS file they interact with. Most of the commands below use a FILE parameter to identify the target DDS file, which is used to create the corresponding link.

CL Command interacting with DDS Physical Files

Command Link Type
CRTPF, CRTSRCPF, CHGPF useLink
DLTF, RMVM useDeleteLink
ADDPFM, RGZPFM, INZPFM, CHGPFM, SETPFM, CPYFRMIMPF, CPYFRMSTMF, CPYFRMPCD, CPYFRMQRYF accessWriteLink
OPNDBF, POSDBF, CLOF, STRJRNPF, ENDJRNPF, WRKJRNPF, SAVPF, RSTPF accessLink
CPYTOIMPF, CPYTOSTMF, CPYTOPCD, SNDNETF useSelectLink
SAVOBJ, RSTOBJ, DLCOBJ stub

CL Command interacting with DDS Logical Files

Command Link Type
CRTLF, CHGLF useLink
DLTF, RMVM useDeleteLink
ADDLFM, CHGLFM, CPYFRMQRYF accessWriteLink
OPNDBF, POSDBF, CLOF accessLink
RNMOBJ, CHGOBJ, SAVOBJ, RSTOBJ, DLCOBJ stub

CL Command interacting with DDS Printer Files

Command Link Type
CRTPRTF, CHGPRTF useLink
DLTF useDeleteLink
DLTSPLF, HLDSPLF, RLSSPLF, CPYSPLF, SPLOBJ, WRKSPLF, STRWTR, ENDWTR, HLDWTR, RLSWTR, SAVOBJ, RSTOBJ, DLCOBJ stub

CL Command interacting with DDS Display Files

Command Link Type
CRTDSPF, CRTDFUDSPF, CHGDSPF useLink
OVRDSPF useSelectLink (FILE + TOFILE)
DLTF useDeleteLink
CLOF accessLink
SAVOBJ, RSTOBJ, DLCOBJ stub

Limitations

  • If evaluation of the file type fails, the default type is ‘Disk File`.
  • If evaluations of the data area fail, the default name is the variable name.
  • If evaluations of the RUNQRY parameter fail, the default name is the variable name.
  • If evaluations of the runqry parameter failed, the default name is the variable name.
  • Dynamic CL command interacting with DDS files are resolved when the parameter value is either a litteral or a local variable. When the variable comes from another program, the value is not resolved, thus no link to the corresponding file (LF, PF, PRTF, DSPF) is created.