As400 Questions and answers by users

Check Your AS400 Interview Skills

Question :What is the difference between array and a multiple occurrence data structure?
Answer: The values stored in array don’t vary. In the other hand, we can store the different values in same variables at various stages.

Question : How can we copy messages from one message file to another?
Answer : Use the command MRGMSGF. For example:
MRGMSGF FROMMSGF (MYLIB1/MSGF1) TOMSGF (MYLIB1/MSGF2)

Question : What commands can be specified in the EXEC parameter of program level MONMSG and command level MONMSG?
Answer : GOTO is the only valid value for the EXEC parameter on the program level MONMSG.
Any CL command can be coded in the EXEC parameter of the command level MONMSG.
The action specified on the command level MONMSG overrides the action specified on the program level MONMSG.

Question : What message types are monitored by MONMSG command?
Answer : The MONMSG command monitors only *STATUS, *NOTIFY AND *ESCAPE messages. It does not monitor *INFO and *INQ messages.

Question : What are Product libraries?
Answer : The product libraries are used to support languages and utilities that are dependent on libraries other than the system library, QSYS, to process their commands.

Question : What is the significance of QTEMP library?
Answer : The QTEMP library is cleared when a job ends.
As SBMJOB command initiates a new routing step, QTEMP library is not passed on to the submitted job but this submitted job will have its own QTEMP library, which is not visible to other jobs.
You can move object out of QTEMP but not in to QTEMP.

Question : If no current library exists in which library does a Create command create the object?
Answer : The object gets created in QGPL with Create command.

Question : Is Library list an object? In which order it is searched?
Answer : Library list is not an object.
The order in which the parts of the library list are searched is System, Product, Current and User.
There is no OS/400 command that saves the user library list. It has to be taken care of in the job description.

Question : What is the maximum number of libraries allowed in the user part of the library list?
Answer : A maximum of 25 libraries can be present in the user part of the library list.
Please note that libraries can never be created within libraries.

Question : What is the difference between Production and Test libraries?
Answer : Database files in Production library cannot be opened for update by a program running in debug mode if UPDPROD (*NO) was specified on the STRDBG command.
This restriction does not apply to database files in Test library.

Question : What is the significance of the values *LIBL, *ALLUSR and *USRLIBL for the library parameter on any command?
Answer : *LIBL is used to search for an object in the library list.
*ALLUSR is used to search for an object in all the user-defined libraries existing on the system.
*USRLIBL is used to search for an object only in the user part of the library list.

Question : What is a flat file?
Answer : It is a file created without any DDS. Record length has to be given. For Example:
CRTPF FILE (MYLIB1/PF1) RCDLEN (132)
The fields for this file can be described within the program in which it is being used. Hence it is also called program-described file.

Question : If a CL program contains the reference to a flat file, how can the data be retrieved in the program?
Answer : The data can be retrieved from the variable &FILENAME.

Question : How many record-formats can a database file have, which is declared in CL?
Answer : Only database files with single record format can be used in a CL program.
Please note that the database file need not have member when it is referred to create a program.

Question : What commands are allowed on a database file declared in CL?
Answer : Only RCVF command is allowed for database file as it can be opened for input only.

Question : Do I need to declare the fields of a file, which is declared in a CL?
Answer : If a database file is declared in CL, the fields in the file are automatically declared in the CL program with “&” prefixed to it.
Please note that the variable name in CL must begin with “&” followed by not more than 10 characters.

Question : How can I define a file member?
Answer : A member is a subset of records in a physical file (PF-SRC or PF-DTA). Each member conforms to the characteristics of the file.
For PF-SRC members, you can define the type of a member as well. For example CLP, RPGLE, PF, LF etc.

Question : What happens if a file is created with expiry date less than current date?
Answer : If a file is created with EXPDATE less than current date, the file gets created but member is not added on creation. An error message is sent at the time of creation saying that the EXPDATE is invalid.

Question : What is the significance of DYNSLT keyword in a logical file?
Answer : DYNSLT keyword does the SELECT/OMIT processing when a program reads records, rather than when records are added or changed.

Question : Are key fields mandatory for logical files? Can logical files be journaled?
Answer : Key fields are not mandatory for logical files. Logical files cannot be journaled.

Question : How many column headings can be specified for a field in a physical file?
Answer : For a field in a physical file, 3 column headings of not more than 20 bytes each can be specified.

Question : What are various types of access path maintenance?
Answer : With MAINT (*IMMED), the access path is updated each time a record is changed, added, or deleted from a member. *IMMED must be specified for files that require unique keys.
With MAINT (*REBLD), the entire access path is rebuilt when the file is opened.
With MAINT (*DLY), the access path is changed only for records added, changed, or deleted since the last open.

Question : Why would you prefer OPNQRYF to LF? When would you prefer an LF?
Answer :
OPNQRYF LF:We prefer OPNQRYF when selection criterion gets changed frequently.
LF:We go for logical file, when selection criterion is permanent.
OPNQRY: is a temporary file, it does not take any space on the disk.
LF: is a permanent file and it takes space on the disk.
OPNQRY:As it has to process the query every time, the run time for a particular program will be more.
LF:Run time for a particular program will be relatively less.

Question : What is Field Reference File?
Answer : A Field Reference File contains just the field descriptions. It does not contain any data. It is used as reference for the field description for other files. This is used to simplify record format descriptions and to ensure field descriptions are used consistently.

Question : What is the use of RGZPF?
Answer : The Reorganize Physical File Member (RGZPFM) command is used to compress (remove deleted records from) the member of a physical file in the database.

Question : Under what circumstances we will not be able to delete a PF?
Answer : When there are dependent Logical Files
When there is no authority
When the PF is locked or in use

Question : When do we use CLOF command?
Answer : When a file is opened using either OPNQRYF or OPNDBF command, CLOF command should be used to close the opened file.

Question : How actually SNDRCVF works?
Answer : The command SNDRCVF is the combination of write and read in that order. It writes the record and waits for the user input. After pressing any key it reads the data.

Question : What is difference between Command Attention (CA**) and Command Function (CF**) keys?
Answer : A key defined with CF** causes data to be returned to the program. A key defined with CA** does not.

Question : What would be the effect on a field with the following display attributes: reverse image, underline, and high intensity when used together?
Answer : The field will not be displayed i.e. becomes non-display.

Question : What is the difference between Non-display and Hidden fields?
Answer : Non-display - Causes the data in the field to be invisible to the operator. The display positions for the fields appear to be blank. Use this attribute for passwords or other security-sensitive data. Non-display fields do not print.
Hidden - Type H to indicate a hidden field (one that is used for both input and output but not displayed).

Question : What is the necessary command needed before OPNQRYF and why?
Answer : OVRDBF. We use this to make sure that the ODP (open data path) created by the OPNQRYF is shared by program.

Question : What is the significance of SECURE parameter on OVRDBF command?
Answer : Consider the following example:
OVRDBF FILE(ACCTMAST) SHARE(*YES) SECURE(*YES)

It will prevent ACCTMAST file from being overridden to SHARE (*NO) by any program that is called from the program in which the above command exists.

Question : What is the significance of SEQONLY parameter on OPNQRYF command?
Answer : The SEQONLY (Sequential Only) parameter indicates that the file will be processed sequentially (Arrival Sequence) and that one record at a time will be transferred from the database to the program’s internal buffer.

Question : What is the sequence in which PDM options are processed?
Answer : If you select more than one PDM option on a list display, the options are processed sequentially, starting with the first option selected.

Question : What are the groupings options on PDM?
Answer : When you select an option and press Enter, PDM first determines whether it is a grouping option. The Copy option, the Rename option, the Delete option, and the Move option are grouping options. If it is a grouping option, a grouping display is shown, listing all the items for which a particular option was chosen and requesting confirmation (and, possibly, additional input).

Question : Is there any similarity between the commands ALCOBJ and CHKOBJ?
Answer : Both the commands do checking for the existence of an object. ALCOBJ command allocates the object in addition to performing the existence check.

Question : What does DSPPGMREF do?
Answer : Displays the list of all objects used in the program.

Question : What actually RCLRSC command does?
Answer : The resources that are reclaimed by this command are

• Static storage
• Open files of object type *FILE
• User interface manager (UIM) application resources
• Common Programming Interface (CPI) Communications conversations
• Hierarchical file systems (HFS) resources
• User-defined communications sessions.

For an original program model (OPM) program, its static storage will be reclaimed.
For an Integrated Language Environment (ILE) program, its static storage will be marked so that it will be re-initialized on the next call.
Static storage is not affected for a service program, or any ILE program running in an activation group other than the default activation group.
The RCLRSC command is not needed to reclaim the files and static storage of most programs, such as CL programs that end (return) normally, RPG programs that have the last record (LR) indicator set on, and COBOL programs.

Question : What is the difference between the commands CALL, RETURN, TFRCTL?
Answer : In a CALL, the calling program receives the control after the called program finishes the processing at the command after the call to called program. Control is thus returned up the program stack.
The RETURN command has no parameters and removes the program from the program stack. If no RETURN statement is coded in a CL program, a return is performed after the last executable statement is performed.
The TRFCTL command transfers the control to the program and removes the transferring program from the program stack. It returns the control to the statement after the most recently run CALL command in the program that called the transferring program. No statements after the TFRCTL in a CL program will be executed.

Question : Why can’t retrieve commands be used on the command line?
Answer : Retrieve commands can not be used on command line, as those commands need a variable to store the retrieved value.
Please note that retrieve commands can not be used even in a call to QCMDEXC.

Question : What are the various concatenation operators in a CL program?
Answer : The *CAT operator concatenates two character strings. Blanks are included in the concatenation. For example:

ABC *CAT DEF becomes ABCDEF
'ABC ' *CAT 'DEF ' becomes 'ABC DEF '


-The *BCAT operator truncates all trailing blanks in the first character string; one blank is inserted, then the two character strings are concatenated. Leading blanks on the second operand are not truncated. For example:

ABC *BCAT DEF becomes ABC DEF
'ABC ' *BCAT DEF becomes 'ABC DEF'


-The *TCAT operator truncates all trailing blanks in the first character string, then the two character strings are concatenated. All leading blanks on the second operand are not truncated. For example:

ABC *TCAT DEF becomes ABCDEF
'ABC ' *TCAT DEF becomes 'ABCDEF'
ABC *TCAT ' DEF' becomes 'ABC DEF'
'ABC '*TCAT ' DEF' becomes 'ABC DEF'

-All blanks that surround the concatenation operator are ignored, but at least one blank must be on each side of the reserved value operator (*CAT, *BCAT, or *TCAT). If multiple blanks are wanted in the expression, a quoted character string (a character string enclosed within apostrophes) must be used.

 When you assign value to a character variable without apostrophes the value would be translated to uppercase.
The value is assigned as it is in case of assigning with apostrophes.
Also observe the assignment for the variables in the following example:

DCL VAR(&RES1) TYPE(*CHAR) LEN(10)
DCL VAR(&RES2) TYPE(*DEC) LEN(10)

CHGVAR VAR(&RES1) VALUE(‘1’) results in ‘1 ‘
CHGVAR VAR(&RES1) VALUE(‘A’) results in ‘A ‘
CHGVAR VAR(&RES1) VALUE(1) results in ‘0000000001’
CHGVAR VAR(&RES1) VALUE(a) results in ‘A ‘
CHGVAR VAR(&RES2) VALUE(1) results in ‘ 1’

Question : Is recursion allowed on CL programs?
Answer : Under any circumstances a CL program may call itself in the same manner that it calls any other program i.e. recursion is allowed.

Question : Do all the objects referred to in a CL program, need to exist at the time of the CL program compilation?
Answer : For most of the objects referred to in a CL program, the object dos not have to exist when the program is compiled.
However, Files and command definitions are exceptions to this rule.

Question : What is the difference between continuing a source statement with a plus sign (+) and a minus sign (-)?
Answer : The difference is that all the blanks in the next record that precede the first non-blank character are ignored when a plus sign is coded and included when a minus sign is coded.

Question : What is asynchronous communication?
Answer : It is the communication in which one of the commands waits for the output from another command to get executed. This involves WAIT parameter.
In the below example the RCVMSG waits for 10 seconds to receive the message from the command SNDPGMMSG.

SNDPGMMSG MSGID(A000004) MSGF(MYLIB1/MSGF1)
RCVMSG PGMQ(*PRV) WAIT(10) SENDER(&SENDER)

Question : What are the different ways to pass data between programs? Which one is the most efficient way?
Answer : Parameters, Data area, Data queue, Message queues, Files
Data queues are the most efficient way of data transfer.

Question : Explain about CUA and SAA?
Answer : Common User Access standards (CUA) are the standards for designing user interface of an application.
System Application Architecture standards (SAA) are the standards for coding.

Question : What is Job Description?
Answer : The job description may contain request data that causes a program or a command to run.
Job descriptions can also specify what user profile the job should run under.
The workstation entry tells what job description will be used when a job starts at that workstation.

Question : What is an authorization list?
Answer : An Authorization list contains the access rights for individual users and groups of users for the functions such as tasks, menus, batch environments, data sets and so on. For each authorization list, 10 levels of authorization rights can be defined (0 to 9). Level 0 means no authorization and a level greater than 0 means authorization. You can secure an object by the authorization list.

Question : What are the valid data types on AS/400?
Answer : The valid data types are
Entry Meaning
A Character
P Packed decimal
S Zoned decimal
B Binary
F Floating point
H Hexadecimal
L Date
T Time
Z Timestamp

Question : What is the difference between Interactive and Batch jobs?
Answer : CL commands are used in either batch or interactive jobs.
- The AS/400 system provides many menus and displays to assist the programmer, including the Programmer Menu, the Command Entry display, command prompt displays, and the Programming Development Manager (PDM) Menu to make interactive entries.
- Interactive job has to wait for the issued command to complete to continue with another command.
- SBMJOB command causes the command to run in batch.
- SBMJOB command causes the program that issues it to continue without waiting for the issued command to complete.
- In case of an exception, if the program is running in an interactive job, the system sends the message to the job's external message queue. If the program is running as a batch job, the system sends the message to the system operator message queue, QSYSOPR.

Question : To view the program source we generally use 2 or 5 option on PDM. Is there any other way to it?
Answer : Try using the following commands to view the code:

DSPPFM FILE (SRCPF) MBR (PROGRAM NAME)
e.g. DSPPFM FILE(REFUND/QRPGSRC) MBR(LRBLAJ)

DSPF FILE (SRCPF) MBR (PROGRAM NAME)

Question : The RUNQRY command displays the records but it is not possible to find a particular string in the file records, as the find option is not provided. Is there any way out?
Answer : Try using the following commands to find a particular string:

DSPPFM FILE (FILE NAME)
e.g. DSPPFM FILE(REFUND/LPINVTYP)
DSPF FILE (FILE NAME)

Question : How can I know the system date, its format etc.?
Answer : Use DSPSYSVAL command on the command line with the system values like QDATE, QDATFMT, QDATSEP, QDAY, QDAYOFWEEK etc.
Please note that the system date does not have any fixed format. It is always displayed in the format specified in the QDATFMT system value.

Question : Can I retrieve a CL source, which I have deleted by mistake?
Answer : A CL program can be reconstructed from the object program by using the command RTVCLSRC.
e.g. RTVCLSRC PGM(refund/LC#NREX) SRCFILE(mainp/QCLSRC)
program LC#NREX is created in library MAINP

Question : Can I avoid source listing while compiling a CL program?
Answer :Yes. By specifying OPTION (*NOSOURCE) for source listing options on a CRTCLPGM command only error messages are listed. A complete source listing is not printed.

Question : If I change the text for a source, is there any other way to reflect that change in the text of the object other than compilation?
Answer : Yes. Use CHGPGM command to change the object text of a CL program without recompiling the program. The CHGPGM command automatically recompiles the program with the changed text. However, the attribute FRCCRT should be (*YES) on CHGPGM command for automatic compilation.
CHGPGM PGM(REFUND/LRBLAJ) FRCCRT(*YES)

Question : What are the various methods of minimizing the program object size?
Answer : Removal of observability
- Optimization
- Compression

Question : What is observability?
Answer : Program observability consists of two types of data, namely Debug Data and Creation Data.
-Debug Data represented by the *DBGDTA value. This data is necessary to allow a program to be debugged.
-Creation Data represented by the *CRTDTA value. This data is necessary to translate the code to machine instructions. The program must have this data for you to change the program optimization level.
-Using the Change Program (CHGPGM) command, you can remove either type of data from the module, or remove both types. Removing all observability reduces the program to its minimum size (with compression). Once this data is removed, you cannot change the program in any way unless you compile the program again and replace the data. To compile it again, you must have authority to the source code.

Question : What is optimization?
Answer : Optimization is a process where the system looks for processing shortcuts that reduce the amount of system resources necessary to produce the same output.
- Optimization removes redundant instructions.
- To optimize, set the OPTIMIZE attribute on a CHGPGM command to *YES.

Question : What is the significance of CPROBJ command?
Answer : Use Compress Object (CPROBJ) command to compress selected objects in order to save disk space.
- You can use the Decompress object (DCPOBJ) command to decompress objects that have been compressed.
- Please note that the database files can not be compressed.

Question : How do I know whether an object is compressed or not?
Answer : Use DSPOBJD OBJ (TEST1) OBJTYPE (*PGM) DETAIL (*FULL) to know the compression status.
- Compressed objects are temporarily or permanently decompressed when used, depending on the object type and usage.
- For example *PGM is automatically permanently decompressed when used. *FILE is automatically decompressed when opened. If only description is retrieved, *FILE is temporarily decompressed.

Question : How can you retrieve the program name in a CL program?
Answer : Send a program message (SNDPGMMSG) to this job and receive (RCVMSG) the message. The call stack entry will be the name of this program. In the following example, the variable &PGMNM will have the program name:

PGM
DCL VAR(&PGMNM) TYPE(*CHAR) LEN(10)
DCL VAR(&CALLING) TYPE(*CHAR) LEN(10)
DCL VAR(&SENDER) TYPE(*CHAR) LEN(80)
SNDPGMMSG MSGID(A000004) MSGF(MYLIB1/MSGF1)
RCVMSG PGMQ(*PRV) SENDER(&SENDER)
CHGVAR VAR(&PGMNM) VALUE(%SST(&SENDER 27 10))
ENDPGM

- Please note that the below statement will retrieve the calling program name:
CHGVAR VAR(&CALLING) VALUE(%SST(&SENDER 56 10))

Question : Can I pass a numeric variable for the call to a program from command line?
Answer : Yes, the hexadecimal value of the numeric variable has to be passed. The following call command shows how to pass the value 25.5 to a program variable that is declared as LEN(15 5) in hexadecimal value
CALL PGMA PARM (X’02550F’)

Question : How can you read a particular member of a physical file in your program?
Answer : Mention the physical file member name you want to read on data member (DTAMBR) parameter of CRTLF command and use that logical file to read.

Question : Generally STRISDB is used for debugging CLP. Can I debug a CLP using STRDBG command?
Answer : Yes. The steps involved are as follows:
Compile CLP using with Source listing options… *SRCDBG.
Then issue command… STRDBG PGM (PGM1) OPMSRC (*YES)
- Follow the same process for debugging RPG also.

Question : It is very time consuming to go to spool and search for the spool file for the latest compilation made. Is there any way out?
Answer : Try this. If you are compiling a source by name PGM1, use the following command to see its spool:
DSPSPLF FILE (PGM1) SPLNBR (*LAST)

Question : Can I know in what all CL program objects a particular command is being used?
Answer : Use PRTCMDUSG (Print Command Usage) command.

Question : Is it possible to have different descriptions for a source and its object?
Answer : Yes, it is possible. When you try to compile a source the default for object text is *SRCMBRTXT. Instead of *SRCMBRTXT you can type your own text.
- Please note that this is valid only for objects created from sources.

Question : How can we take a back up of the spool file?
Answer : Create a physical file with record length = Length of the record in spool + 12.

CRTPF FILE (MYLIB1/SPOOL) RCDLEN (144)
- Open the spool file with option 2 (CHGSPLFA) and make note of Spooled file, Job name, User, Number, Spooled file number.
- Use CPYSPLF command as follows to copy the spool file to physical file SPOOL:
CPYSPLF FILE (PGM1) TOFILE (MYLIB1/SPOOL) JOB (599815/#VYERRAP/QPADEV004C) SPLNBR (12)
- Now use CPYF command as follows:
CPYF FROMFILE (MYLIB1/SPOOL) TOFILE (MYLIB1/QCLSRC) TOMBR (PGM1BKUP) MBROPT (*REPLACE) FMTOPT (*CVTSRC)
- The above process creates a member by name PGM1BKUP in source physical file QCLSRC.

Question : How can I know all the commands starting with a particular string?
Answer : For example if you want to know all the commands starting with string CHG type CHG* on command line and press enter.

Question : What is the significance of MRGSRC (Merge source) command?
Answer : If you are maintaining two copies of the same source and if one of the copies is updated, you can reflect those updates in other copy by using MRGSRC command (option 55 on PDM).

Question : How can I search for a string in all the members of a source physical file?
Answer : Type option 25 on first member in the source physical file.
- Press F13. Option 25 is repeated for all the members. Press Enter.
- Find String display is shown. Enter the string you want to search for and press Enter.
- The members having the string in them are displayed one after another by pressing Enter.
- The other way is to use FNDSTRPDM command as follows:
FNDSTRPDM STRING ('CHG') FILE (MYLIB1/QCLSRC) MBR (*ALL) OPTION (*DSP)

Question : What are User-defined options?
Answer : With user-defined options, you can call your own commands from any PDM list display. These options make it easier for you to do frequent operations, because you can type an option on a list display instead of retyping an entire command.
- The process to create an user-defined option is as follows:
- Press F16 on PDM. Work with User-Defined Options display is shown.
- Press F6. Create User-Defined Option display is shown. Type the option and command. For example: CC CHGCURLIB CURLIB (&L)
- Now you can use CC instead of CHGCURLIB as an option on PDM.

Question : Can I use CPYF command for copying a logical file?
Answer : If you try to copy a logical file using CPYF command a physical file with the same name is created. Therefore CRTDUPOBJ command should be used.

Question : How can I know the dependant logical files on a physical file?
Answer : The DSPDBR command on a physical file can be used to display a list of dependent logical files by default.

Question : How can I know all the files using the format of a physical file?
Answer : Use DSPDBR command with RCDFMT parameter on a physical file.

Question : For what all information I can use DSPFD command?
Answer : Use DSPFD command to know the number of records in a database file.
- Use TYPE (*MBRLIST) parameter on DSPFD command to know the members in a file.
- Use TYPE (*SELECT) parameter on DSPFD command to know the select/omit rules in a logical file.
- Use TYPE (*JOIN) parameter on DSPFD command to know the join description in a join logical file.

Question : Can I know the record count in a file using RUNQRY command?
Answer : Use OUTFORM (*SUMMARY) parameter on RUNQRY command to know the number of records in a file.

Question : Can I select records from a file based on certain criteria using RUNQRY command?
Answer : Use RUNQRY QRYFILE ((FILENAME)) RCDSLT (*YES).

Question : How do I specify the ‘OR’ and ‘AND’ select/omit conditions in the DDS of a logical file?
Answer : The OR condition for select rule in LF:

A S DEPART COMP(EQ ‘117’)
A S DEPART COMP(EQ ‘131’)

- The AND condition for select rule in LF:

A S DEPART COMP(EQ ‘117’)
A DEPART COMP(EQ ‘131’)

Question : Can I avoid underlining of input fields on display file screen?
Answer : By specifying CHGINPDFT at the file level or record level or field level the underlining of input fields on the screen be prevented.

Question : Can I retain the screen after closing the display file?
Answer : Using the KEEP keyword at the record level will prevent the screen from being erased when the display file is closed.

Question : Can you copy the records created by the OPNQRYF to other files?
Answer : Yes, by using CPYFRMQRYF.

Question : How to print the help for one CL command keyword parameter?
Answer : From a command line, type the CL command name and press F4 to display the command prompt display. Position the cursor anywhere on the line of the keyword parameter for which you want help. Press F1 to display the help for the keyword parameter. Press F14 to print the help.

Question : We can restore the source changes but not the source date for a particular line of code. Is there any way out?
Answer : For example if you want to change the source date for a particular line of code in member PGM1 in MYLIB1/QCLSRC, the steps involved would be:
- OVRDBF FILE (PGM1) TOFILE (MYLIB1/QCLSRC) MBR (PGM1)
- Start SQL session and enter the following command: UPDATE PGM1 SET SRCDAT = 111213 WHERE SRCDAT = 111215

Question : The system creates a job log when it is idle long enough and the system logs the user out but how can I have this created all the time i.e. whenever a user signs out?
Answer : Take prompt for SIGNOFF command and change the job log parameter to *LIST.

Question : Is it possible to use SQL in CL programs?
Answer : SQL in CL is no problem. Add this line to your CL program (MYCLPGM1):

RUNSQLSTM SRCFILE(MYLIB1/QCLSRC) SRCMBR(MYSQL1) COMMIT(*NONE)

- Create MYSQL1 member with the required SQL statements: (the member type in PDM is 'SQL' instead of 'CLP')
DELETE FROM MYLIB1/TCAFILE;

- Note: RUNSQLSTM runs the whole SQL member, no way to select only one statement of it. So you must create more SQL members for a CLP, if you need to run the statements from several places of your CLP. Perhaps like this: CLP = MYCLPGM, SQL members: MYCLPGM1, MYCLPGM2, ... then you have them right below the CL in PDM. See the ';' at the end of each line. It's important.

Question : How can I avoid status message while running commands like CPYF, OPNQRY etc. in a CL program?
Answer : The following code will avoid status message:
DCL VAR (&STSMSG) TYPE (*CHAR) LEN (7)
RTVJOBA STSMSG (&STSMSG)
CHGJOB STSMSG (*NONE)

CPYF…

CHGJOB STSMSG (&STSMSG)

Question : How to use QCMDEXC?
Answer : Execute Command (QCMDEXC) is an IBM-supplied program that runs a single command. This command is used to activate another command. After the command gets executed the control returns to your CL program.

The command runs as if it was not in a program. Therefore, variables cannot be used on the command because values cannot be returned by the command to CL variables. Additionally, the QCMDEXC program cannot run commands that can only be used in CL procedures or programs. The format of the call to the QCMDEXC program is the following:

CALL PGM (QCMDEXC) PARM (command command-length)

Enter the command you wish to run as a character string on the first parameter. You must enclose the command in apostrophes if it contains blanks. The maximum length of the character string is 6000 characters. Never count the delimiters (the apostrophes) as part of the string. The length that is specified as the second value on the PARM parameter is the length of the character string that is passed as the command. Length must be a packed decimal value of length 15 with 5 decimal positions. Thus, to replace a library list, the call to the QCMDEXC program would look like this:

CALL PGM (QCMDEXC) PARM ('CHGLIBL LIBL (QGPL NEWLIB QTEMP)' 31)

No comments