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(QMQMSAMP/AMQ3GET4) PARM('Queue_Name','Queue_Manager_Name')

CL_ibmmq_receiver_to_program.jpg

CALL PGM(QMQMSAMP/AMQ3PUT4) 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

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

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.