49
Tips ‘n’ Facts (Version 1) An e-book on AS/400 programming (OS/400 & CL/400) - 1 -

Synon Tips and Facts

Embed Size (px)

Citation preview

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 1/49

Tips ‘n’ Facts

(Version 1)

An e-book on AS/400 programming(OS/400 & CL/400)

- 1 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 2/49

Tips ‘n’ Facts

Preface

In the initial stages of my career as an AS/400 application programmer,I had many questions in my mind, which needed clarifications. ThoughI could not get everything clarified I had to get on with myprogramming as per my project requirements. I had to code in aparticular way without knowing why it has to be coded that way. Now,all those questions in my mind got clarified but at the cost of time.

Of late, I realized that had I got clarified those questions in my mind Icould have done much better job as a programmer in the initial stagesitself. This prompted me to sum up my experiences as a programmerfor the benefit of the novice programmers. At the same time this bookcan also serve as a quick reference for senior programmers. Before using this book, you should be familiar with generalprogramming concepts and terminology, and have a generalunderstanding of Operating System/400 (OS/400) and the AS/400system.

 You may need to refer to IBM manuals for more specific informationabout a particular topic.

Author:Ramakrishna Rao YVSSenior Software EngineerSignal Tree Solutions India Limited

Mail to:[email protected]

- 2 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 3/49

Tips ‘n’ Facts

CONTENTS

THE FREQUENTLY ASKED QUESTIONS…..........................................................................................7

Messages..................................................................................................................................................7HOW CAN WE COPY MESSAGES FROM ONE MESSAGE FILE TO ANOTHER ?......................................................................7

WHAT COMMANDS CAN BE SPECIFIED IN THE EXEC PARAMETER  OF PROGRAM LEVEL MONMSG AND COMMAND LEVEL 

MONMSG?...................................................................................................................................................7

WHAT MESSAGE TYPES ARE MONITORED BY MONMSG COMMAND?.......................................................................7Libraries..................................................................................................................................................7

WHAT ARE PRODUCT LIBRARIES?........................................................................................................................7

WHAT IS THE SIGNIFICANCE OF QTEMP LIBRARY?...............................................................................................7

IF  NO CURRENT LIBRARY EXISTS IN WHICH LIBRARY DOES A CREATE COMMAND CREATE THE OBJECT?.............................7IS LIBRARY LIST AN OBJECT? I N WHICH ORDER  IT IS SEARCHED?...............................................................................7

WHAT IS THE MAXIMUM  NUMBER  OF LIBRARIES ALLOWED IN THE USER  PART OF THE LIBRARY LIST?...............................8

WHAT IS THE DIFFERENCE BETWEEN PRODUCTION AND TEST LIBRARIES?...................................................................8

WHAT IS THE SIGNIFICANCE OF THE VALUES *LIBL, *ALLUSR AND *USRLIBL FOR  THE LIBRARY PARAMETER  ON ANY COMMAND?................................................................................................................................................8

Database Files.........................................................................................................................................8

WHAT IS A FLAT FILE?.......................................................................................................................................8

IF A CL PROGRAM CONTAINS THE REFERENCE TO A FLAT FILE, HOW CAN THE DATA BE RETRIEVED IN THE PROGRAM?.......8

HOW MANY RECORD-FORMATS CAN A DATABASE FILE HAVE, WHICH IS DECLARED IN CL?............................................8

WHAT COMMANDS ARE ALLOWED ON A DATABASE FILE DECLARED IN CL?................................................................8DO I  NEED TO DECLARE THE FIELDS OF A FILE, WHICH IS DECLARED IN A CL?............................................................8

HOW CAN I DEFINE A FILE MEMBER ?....................................................................................................................8

WHAT HAPPENS IF A FILE IS CREATED WITH EXPIRY DATE LESS THAN CURRENT DATE?..................................................9

WHAT IS THE SIGNIFICANCE OF DYNSLT KEYWORD IN A LOGICAL FILE?.................................................................9

ARE KEY FIELDS MANDATORY FOR  LOGICAL FILES? CAN LOGICAL FILES BE JOURNALED?..............................................9

HOW MANY COLUMN HEADINGS CAN BE SPECIFIED FOR  A FIELD IN A PHYSICAL FILE?....................................................9

WHAT ARE VARIOUS TYPES OF ACCESS PATH MAINTENANCE?....................................................................................9

WHY WOULD YOU PREFER  OPNQRYF TO LF? WHEN WOULD YOU PREFER  AN LF?................................................9

WHAT IS FIELD R EFERENCE FILE?......................................................................................................................9WHAT IS THE USE OF RGZPF?..........................................................................................................................9

U NDER  WHAT CIRCUMSTANCES WE WILL  NOT BE ABLE TO DELETE A PF? ................................................................10

WHEN DO WE USE CLOF COMMAND?...............................................................................................................10Display files...........................................................................................................................................10

HOW ACTUALLY SNDRCVF WORKS? .............................................................................................................10

WHAT IS DIFFERENCE BETWEEN COMMAND ATTENTION (CA**) AND COMMAND FUNCTION (CF**) KEYS?...............10

WHAT WOULD BE THE EFFECT ON A FIELD WITH THE FOLLOWING DISPLAY ATTRIBUTES: REVERSE IMAGE, UNDERLINE, AND HIGH INTENSITY WHEN USED TOGETHER ?.............................................................................................................10

WHAT IS THE DIFFERENCE BETWEEN NON-DISPLAY AND HIDDEN FIELDS?................................................................10OVRDBF & OPNQRYF......................................................................................................................10

WHAT IS THE  NECESSARY COMMAND  NEEDED BEFORE OPNQRYF AND WHY?........................................................10

WHAT IS THE SIGNIFICANCE OF SECURE PARAMETER  ON OVRDBF COMMAND?..................................................10

WHAT IS THE SIGNIFICANCE OF SEQONLY PARAMETER  ON OPNQRYF COMMAND?............................................11PDM.......................................................................................................................................................11

WHAT IS THE SEQUENCE IN WHICH PDM OPTIONS ARE PROCESSED? ......................................................................11

WHAT ARE THE GROUPINGS OPTIONS ON PDM?..................................................................................................11

Commands.............................................................................................................................................11

IS THERE ANY SIMILARITY BETWEEN THE COMMANDS ALCOBJ AND CHKOBJ?....................................................11

WHAT DOES DSPPGMREF DO?....................................................................................................................11

WHAT ACTUALLY RCLRSC COMMAND DOES? ..................................................................................................11

WHAT IS THE DIFFERENCE BETWEEN THE COMMANDS CALL, RETURN, TFRCTL?............................................12

WHY CAN’T RETRIEVE COMMANDS BE USED ON THE COMMAND LINE?......................................................................12

- 3 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 4/49

Tips ‘n’ Facts

Operators...............................................................................................................................................12

WHAT ARE THE VARIOUS CONCATENATION OPERATORS IN A CL PROGRAM?.............................................................12

WHAT ARE THE VARIOUS TYPES OF OPERATORS THAT CAN BE USED IN CL?..............................................................13General..................................................................................................................................................13

WHAT IS THE DIFFERENCE IN ASSIGNING VALUE TO A CHARACTER  VARIABLE WITH APOSTROPHES AND WITH OUT APOSTROPHES IN A CL PROGRAM? ....................................................................................................................13

IS

 RECURSION

 ALLOWED

 ON

CLPROGRAMS

?.......................................................................................................13DO ALL THE OBJECTS REFERRED TO IN A CL PROGRAM,  NEED TO EXIST AT THE TIME OF THE CL PROGRAM COMPILATION?

....................................................................................................................................................................13

WHAT IS THE DIFFERENCE BETWEEN CONTINUING A SOURCE STATEMENT WITH A PLUS SIGN (+) AND A MINUS SIGN (-)? .14

WHAT IS ASYNCHRONOUS COMMUNICATION?.......................................................................................................14

WHAT ARE THE DIFFERENT WAYS TO PASS DATA BETWEEN PROGRAMS? WHICH ONE IS THE MOST EFFICIENT WAY?.........14

EXPLAIN ABOUT CUA AND SAA?...................................................................................................................14WHAT IS JOB DESCRIPTION?.............................................................................................................................14

WHAT IS AN AUTHORIZATION LIST?....................................................................................................................14

WHAT ARE THE VALID DATA TYPES ON AS/400?................................................................................................14

WHAT IS THE DIFFERENCE BETWEEN I NTERACTIVE AND BATCH JOBS?......................................................................15

THE TIPS…..................................................................................................................................................16

TO VIEW THE PROGRAM SOURCE WE GENERALLY USE 2 OR 5 OPTION ON PDM. IS THERE ANY OTHER  WAY TO IT?.........16THE 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?..............................................................16

HOW CAN I KNOW THE SYSTEM DATE, ITS FORMAT ETC.?.......................................................................................16

CAN I RETRIEVE A CL SOURCE, WHICH I HAVE DELETED BY MISTAKE?....................................................................16

CAN I AVOID SOURCE LISTING WHILE COMPILING A CL PROGRAM?.........................................................................16

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?..............................................................................................................................16

WHAT ARE THE VARIOUS METHODS OF MINIMIZING THE PROGRAM OBJECT SIZE?........................................................16WHAT IS OBSERVABILITY?................................................................................................................................16

WHAT IS OPTIMIZATION?..................................................................................................................................17

WHAT IS THE SIGNIFICANCE OF CPROBJ COMMAND?.........................................................................................17

HOW DO I KNOW WHETHER  AN OBJECT IS COMPRESSED OR   NOT?.............................................................................17

HOW CAN YOU RETRIEVE THE PROGRAM  NAME IN A CL PROGRAM?........................................................................17

CAN I PASS A  NUMERIC VARIABLE FOR  THE CALL TO A PROGRAM FROM COMMAND LINE?............................................18HOW CAN YOU READ A PARTICULAR  MEMBER  OF A PHYSICAL FILE IN YOUR  PROGRAM? ..............................................18

GENERALLY STRISDB IS USED FOR  DEBUGGING CLP. CAN I DEBUG A CLP USING STRDBG COMMAND? ............18IT IS VERY TIME CONSUMING TO GO TO SPOOL AND SEARCH FOR  THE SPOOL FILE FOR  THE LATEST COMPILATION MADE. IS 

THERE ANY WAY OUT?......................................................................................................................................18

CAN I KNOW IN WHAT ALL CL PROGRAM OBJECTS A PARTICULAR  COMMAND IS BEING USED?.....................................18

IS IT POSSIBLE TO HAVE DIFFERENT DESCRIPTIONS FOR  A SOURCE AND ITS OBJECT?.....................................................18

HOW CAN WE TAKE A BACK  UP OF THE SPOOL FILE?.............................................................................................18

HOW CAN I KNOW ALL THE COMMANDS STARTING WITH A PARTICULAR  STRING?.......................................................19

WHAT IS THE SIGNIFICANCE OF MRGSRC (MERGE SOURCE) COMMAND?..............................................................19

HOW CAN I SEARCH FOR  A STRING IN ALL THE MEMBERS OF A SOURCE PHYSICAL FILE?..............................................19

WHAT ARE USER -DEFINED OPTIONS?..................................................................................................................19

CAN I USE CPYF COMMAND FOR  COPYING A LOGICAL FILE?.................................................................................19

HOW CAN I KNOW THE DEPENDANT LOGICAL FILES ON A PHYSICAL FILE?.................................................................19HOW CAN I KNOW ALL THE FILES USING THE FORMAT OF A PHYSICAL FILE?..............................................................19

FOR  WHAT ALL INFORMATION I CAN USE DSPFD COMMAND?...............................................................................19

CAN I KNOW THE RECORD COUNT IN A FILE USING RUNQRY COMMAND?.............................................................20

CAN I SELECT RECORDS FROM A FILE BASED ON CERTAIN CRITERIA USING RUNQRY COMMAND?..............................20

HOW DO I SPECIFY THE ‘OR’ AND ‘AND’ SELECT/OMIT CONDITIONS IN THE DDS OF A LOGICAL FILE?.....................20

CAN I AVOID UNDERLINING OF INPUT FIELDS ON DISPLAY FILE SCREEN?...................................................................20

CAN I RETAIN THE SCREEN AFTER  CLOSING THE DISPLAY FILE?...............................................................................20CAN YOU COPY THE RECORDS CREATED BY THE OPNQRYF TO OTHER  FILES? .......................................................20

HOW TO PRINT THE HELP FOR  ONE CL COMMAND KEYWORD PARAMETER ? ..............................................................20

- 4 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 5/49

Tips ‘n’ Facts

WE CAN RESTORE THE SOURCE CHANGES BUT  NOT THE SOURCE DATE FOR  A PARTICULAR  LINE OF CODE. IS THERE ANY WAY OUT? ............................................................................................................................................................20

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? ...................................................................21

IS IT POSSIBLE TO USE SQL IN CL PROGRAMS?...................................................................................................21...................................................................................................................................................................21

HOW

 CAN

IAVOID

 STATUS

 MESSAGE

 WHILE

 RUNNING

 COMMANDS

 LIKE

CPYF, OPNQRYETC

.IN

 A

CLPROGRAM

? ..21HOW TO USE QCMDEXC?............................................................................................................................21

THE FACTS…..............................................................................................................................................23

APPENDIX A - USING COMMAND PROMPTS....................................................................................24

APPENDIX B - SELECTIVE PROMPTING CHARACTER.................................................................24

APPENDIX C - OBJECT AUTHORITIES AND LOCK STATES........................................................26

OBJECT AUTHORITIES......................................................................................................................................26

OBJECT LOCK  STATES......................................................................................................................................27

APPENDIX D - MESSAGE QUEUES AND MESSAGES.......................................................................28

TYPES OF MESSAGE QUEUES..............................................................................................................................28

TYPES OF MESSAGES........................................................................................................................................28

SNDMSG (SEND MESSAGE)...........................................................................................................................29

SNDPGMMSG (SEND PROGRAM MESSAGE)....................................................................................................29

SNDUSRMSG (SEND USER  MESSAGE)...........................................................................................................30

SNDBRKMSG (SEND BREAK  MESSAGE).........................................................................................................30DEFINING SUBSTITUTION VARIABLES...................................................................................................................30

APPENDIX E - %BINARY AND %SWITCH BUILT-IN FUNCTIONS.............................................31

USING THE %BINARY BUILT-IN FUNCTION.....................................................................................................31

USING THE %SWITCH BUILT-IN FUNCTION.....................................................................................................32

APPENDIX F - DATA QUEUES................................................................................................................34

TO CLEAR  A DATA QUEUE:................................................................................................................................34

TO SEND DATA TO A DATA QUEUE:.....................................................................................................................34

TO RECEIVE DATA FROM DATA QUEUE:................................................................................................................34

APPENDIX G - DATA AREA ....................................................................................................................35

APPENDIX H - SEU COLORS AND ATTRIBUTES..............................................................................36

APPENDIX I - SELECTING RECORDS USING THE OPNQRYF COMMAND...............................37

TO REQUEST A SELECTION AGAINST A CHARACTER  CONSTANT ................................................................................37

TO REQUEST A SELECTION AGAINST A  NUMERIC CONSTANT:....................................................................................37

WHEN COMPARING A CHARCTER  FIELD VALUE TO A CL VARIABLE .........................................................................37

WHEN COMPARING A  NUMERIC FIELD VALUE TO A CL VARIABLE ..........................................................................37

SELECTING RECORDS USING THE CONTAINS FUNCTION............................................................................................37MAPPING FIELDS FOR  PACKED  NUMERIC DATA FIELDS............................................................................................37

USING THE "WILDCARD" FUNCTION....................................................................................................................37

APPENDIX J - USER DEFINED COMMANDS......................................................................................38

COMMAND STATEMENTS..................................................................................................................................38...............................................................................................................................................................38

COMMAND PROCESSING PROGRAM.....................................................................................................................38

VALIDITY CHECKING PROGRAM.........................................................................................................................38

- 5 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 6/49

Tips ‘n’ Facts

PROMPT OVERRIDE PROGRAM...........................................................................................................................38

COMMAND CREATION......................................................................................................................................38

The code for the Command Program (WM).....................................................................................39

The code for Command Processing Program (WMPRC)................................................................39

The code for Command Validity Checking Program (WMVAL)...................................................39

DDS REFERENCE: DISPLAY FILES......................................................................................................40

EDTCDE (EDIT CODE) KEYWORD FOR  DISPLAY FILES........................................................................................40

DDS REFERENCE: DISPLAY FILES......................................................................................................45

EDTCDE (EDIT CODE) KEYWORD FOR  DISPLAY FILES........................................................................................45

- 6 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 7/49

Tips ‘n’ Facts

The Frequently Asked Questions…

Messages

How can we copy messages from one message file to another?- Use the command MRGMSGF. For example:

MRGMSGF FROMMSGF (MYLIB1/MSGF1) TOMSGF (MYLIB1/MSGF2)

What commands can be specified in the EXEC parameter of program levelMONMSG and command level MONMSG?

- 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 onthe program level MONMSG.

What message types are monitored by MONMSG command?-  The MONMSG command monitors only *STATUS, *NOTIFY AND *ESCAPE messages Itdoes not monitor *INFO and *INQ messages.

Libraries

What are Product libraries?-  The product libraries are used to support languages and utilities that are

dependent on libraries other than the system library, QSYS, to process theircommands.

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

If no current library exists in which library does a Create command createthe object?

-  The object gets created in QGPL with Create command.

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

- 7 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 8/49

Tips ‘n’ Facts

What is the maximum number of libraries allowed in the user part of thelibrary list?

- 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.What is the difference between Production and Test libraries?- 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.

What is the significance of the values *LIBL, *ALLUSR and *USRLIBL for thelibrary parameter on any command?

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

Database Files

What is a flat file?- It is a file created with out any DDS. Record length has to be given. For example:

CRTPF FILE (MYLIB1/PF1) RCDLEN (132)-  The fields for this file can be described with in the program in which it is being used.Hence it is also called program-described file.

If a CL program contains the reference to a flat file, how can the data beretrieved in the program?

-  The data can be retrieved from the variable &FILENAME.

How many record-formats can a database file have, which is declared in CL?- 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.

What commands are allowed on a database file declared in CL?- Only RCVF command is allowed for database file as it can be opened for input

only.

Do I need to declare the fields of a file, which is declared in a CL?- If a database file is declared in CL, the fields in the file are automatically declared in theCL program with & prefixed to it.- Please note that the variable name in CL must begin with & followed by not more than10 characters.

How can I define a file member?- 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.

- 8 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 9/49

Tips ‘n’ Facts

- For PF-SRC members, you can define the type of a member as well. For exampleCLP, RPGLE, PF, LF etc.

What happens if a file is created with expiry date less than current date?- 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 theEXPDATE is invalid.

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

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

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

What are various types of access path maintenance?- 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, ordeleted since the last open.

Why would you prefer OPNQRYF to LF? When would you prefer an LF?

OPNQRYF LF

We prefer OPNQRYF when selectioncriterion gets changed frequently.

We go for logical file, when selectioncriterion is permanent.

OPNQRY is a temporary file, it does nottake any space on the disk.

LF is a permanent file and it takes spaceon the disk.

As it has to process the query every time,the run time for a particular program willbe more.

Run time for a particular program will berelatively less.

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

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

- 9 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 10/49

Tips ‘n’ Facts

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

When do we use CLOF command?- When a file is opened using either OPNQRYF or OPNDBF command, CLOF commandshould be used to close the opened file.

Display files

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

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

What would be the effect on a field with the following display attributes:reverse image, underline, and high intensity when used together?

-  The field will not be displayed i.e. becomes non-display.

What is the difference between Non-display and Hidden fields?- 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 othersecurity-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 butnot displayed).

OVRDBF & OPNQRYF

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

What is the significance of SECURE parameter on OVRDBF command?- 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 iscalled from the program in which the above command exists.

- 10 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 11/49

Tips ‘n’ Facts

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

PDM

What is the sequence in which PDM options are processed?- If you select more than one PDM option on a list display, the options are

processed sequentially, starting with the first option selected.

What are the groupings options on PDM?- 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 allthe items for which a particular option was chosen and requesting confirmation(and, possibly, additional input).

Commands

Is there any similarity between the commands ALCOBJ and CHKOBJ?- Both the commands do checking for the existence of an object. ALCOBJ commandallocates the object in addition to performing the existence check.

What does DSPPGMREF do?- Displays the list of all objects used in the program.

What actually RCLRSC command does?-  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 programsthat have the last record (LR) indicator set on, and COBOL programs.

- 11 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 12/49

Tips ‘n’ Facts

What is the difference between the commands CALL, RETURN, TFRCTL?- 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. Controlis thus returned up the program stack.

-  The RETURN command has no parameters and removes the program from theprogram 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 thetransferring program from the program stack. It returns the control to thestatement after the most recently run CALL command in the program that calledthe transferring program. No statements after the TFRCTL in a CL program will beexecuted.

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

Operators

What are the various concatenation operators in a CL program?-  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 secondoperand 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 twocharacter strings are concatenated. All leading blanks on the second operand are nottruncated. 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 blankmust be on each side of the reserved value operator (*CAT, *BCAT, or *TCAT). If multipleblanks are wanted in the expression, a quoted character string (a character string enclosedwithin apostrophes) must be used.

- 12 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 13/49

Tips ‘n’ Facts

What are the various types of operators that can be used in CL?-  There are four broad categories of operators. Each operator can be replaced by a

special character as shown below:

Logical

operator

*AND *OR

Specialcharacter

& |

Characteroperator

*CAT *BCAT *TCAT

Specialcharacter

|| |> |<

Arithmeticoperator

ADD SUB MULT DIV

Specialcharacter

+ - * /

Relationaloperator

*EQ *GT *LT *GE *LE *NE *NG *NL

Specialcharacter = > < >= <= ¬= ¬> ¬<

General

What is the difference in assigning value to a character variable withapostrophes and with out apostrophes in a CL program?

- When you assign value to a character variable without apostrophes the value would betranslated 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’

Is recursion allowed on CL programs?- Under any circumstances a CL program may call itself in the same manner that it calls

any other program i.e. recursion is allowed.

Do all the objects referred to in a CL program, need to exist at the time of the CL program compilation?

- For most of the objects referred to in a CL program, the object dos not have toexist when the program is compiled.

- However, Files and command definitions are exceptions to this rule.

- 13 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 14/49

Tips ‘n’ Facts

What is the difference between continuing a source statement with a plussign (+) and a minus sign (-)?

-  The difference is that all the blanks in the next record that precede the first non-blankcharacter are ignored when a plus sign is coded and included when a minus sign is coded.

What is asynchronous communication?- It is the communication in which one of the commands waits for the output fromanother command to get executed. This involves WAIT parameter.

- In the below example the RCVMSG waits for 10 seconds to receive the messagefrom the command SNDPGMMSG.

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

What are the different ways to pass data between programs? Which one isthe most efficient way?

- Parameters, Data area, Data queue, Message queues, Files- Data queues are the most efficient way of data transfer.

Explain about CUA and SAA?- 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.

 What is Job Description?-  The job description may contain request data that causes a program or a command torun.-  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 thatworkstation.

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

What are the valid data types on AS/400?-  The valid data types are

Entry MeaningA CharacterP Packed decimalS Zoned decimalB BinaryF Floating pointH HexadecimalL Date T Time

- 14 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 15/49

Tips ‘n’ Facts

Z TimestampWhat is the difference between Interactive and Batch jobs?

- 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 anothercommand.- SBMJOB command causes the command to run in batch.- SBMJOB command causes the program that issues it to continue without waiting for theissued command to complete.- In case of an exception, if the program is running in an interactive job, the system sendsthe 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.

- 15 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 16/49

Tips ‘n’ Facts

The Tips…

To view the program source we generally use 2 or 5 option on PDM. Is thereany other way to it?

-  Try using the following commands to view the code:

DSPPFM FILE (SRCPF) MBR (PROGRAM NAME)DSPF FILE (SRCPF) MBR (PROGRAM NAME)

The RUNQRY command displays the records but it is not possible to find aparticular string in the file records, as the find option is not provided.Is there any way out?

-  Try using the following commands to find a particular string:

DSPPFM FILE (FILE NAME)DSPF FILE (FILE NAME)

How can I know the system date, its format etc.?- 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 displayedin the format specified in the QDATFMT system value.

Can I retrieve a CL source, which I have deleted by mistake?- A CL program can be reconstructed from the object program by using the commandRTVCLSRC.

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

If I change the text for a source, is there any other way to reflect thatchange in the text of the object other than compilation?

-  Yes. Use CHGPGM command to change the object text of a CL program withoutrecompiling the program. The CHGPGM command automatically recompiles the programwith the changed text. However, the attribute FRCCRT should be (*YES) on CHGPGMcommand for automatic compilation.

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

What is observability? 

- 16 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 17/49

Tips ‘n’ Facts

- Program observability consists of two types of data, namely Debug Data and CreationData:- Debug Data represented by the *DBGDTA value. This data is necessary to allow aprogram to be debugged.- Creation Data represented by the *CRTDTA value. This data is necessary to translate thecode 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 datafrom the module, or remove both types. Removing all observability reduces the program toits minimum size (with compression). Once this data is removed, you cannot change theprogram in any way unless you compile the program again and replace the data. To compileit again, you must have authority to the source code.

What is optimization?- Optimization is a process where the system looks for processing shortcuts that reducethe 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.

What is the significance of CPROBJ command?- 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.

How do I know whether an object is compressed or not?- 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.

How can you retrieve the program name in a CL program?- 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:

PGMDCL 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))

- 17 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 18/49

Tips ‘n’ Facts

Can I pass a numeric variable for the call to a program from command line?-  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 variablethat is declared as LEN(15 5) in hexadecimal value

CALL PGMA PARM (X’02550F’)

How can you read a particular member of a physical file in your program?- 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.

Generally STRISDB is used for debugging CLP. Can I debug a CLP usingSTRDBG command?

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

It is very time consuming to go to spool and search for the spool file for thelatest compilation made. Is there any way out?

-  Try this. If you are compiling a source by name PGM1, use the following commandto see its spool:

DSPSPLF FILE (PGM1) SPLNBR (*LAST)

Can I know in what all CL program objects a particular command is beingused?

- Use PRTCMDUSG (Print Command Usage) command.

Is it possible to have different descriptions for a source and its object?-  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.

How can we take a back up of the spool file?- 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 fileQCLSRC.

- 18 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 19/49

Tips ‘n’ Facts

How can I know all the commands starting with a particular string?- For example if you want to know all the commands starting with string CHG type

CHG* on command line and press enter.

What is the significance of MRGSRC (Merge source) command?

- If you are maintaining two copies of the same source and if one of the copies isupdated, you can reflect those updates in other copy by using MRGSRC command(option 55 on PDM).

How can I search for a string in all the members of a source physical file?-  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)

What are User-defined options?- 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, becauseyou 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.

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

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

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

For what all information I can use DSPFD command?- 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 alogical file.- Use TYPE (*JOIN) parameter on DSPFD command to know the join description in a joinlogical file.

- 19 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 20/49

Tips ‘n’ Facts

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

Can I select records from a file based on certain criteria using RUNQRY command?

- Use RUNQRY QRYFILE ((FILENAME)) RCDSLT (*YES).

How do I specify the ‘OR’ and ‘AND’ select/omit conditions in the DDS of alogical file?

-  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’)

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

Can I retain the screen after closing the display file?- Using the KEEP keyword at the record level will prevent the screen from being erasedwhen the display file is closed.

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

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

We can restore the source changes but not the source date for a particularline of code. Is there any way out?

- For example if you want to change the source date for a particular line of code inmember 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

- 20 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 21/49

Tips ‘n’ Facts

The system creates a job log when it is idle long enough and the systemlogs the user out but how can I have this created all the time i.e.whenever a user signs out?

-  Take prompt for SIGNOFF command and change the job log parameter to *LIST.

Is it possible to use SQL in CL programs?- 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 fromseveral 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 eachline. It's important.

How can I avoid status message while running commands like CPYF,OPNQRY etc. in a CL program?

-  The following code will avoid status message:DCL VAR (&STSMSG) TYPE (*CHAR) LEN (7)RTVJOBA STSMSG (&STSMSG)CHGJOB STSMSG (*NONE)

CPYF…

CHGJOB STSMSG (&STSMSG)

How to use QCMDEXC?Execute Command (QCMDEXC) is an IBM-supplied program that runs a singlecommand. This command is used to activate another command. After the commandgets executed the control returns to your CL program.  The command runs as if it was not in a program. Therefore, variables cannot be usedon the command because values cannot be returned by the command to CLvariables. Additionally, the QCMDEXC program cannot run commands that can onlybe used in CL procedures or programs. The format of the call to the QCMDEXCprogram 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. Youmust enclose the command in apostrophes if it contains blanks. The maximumlength of the character string is 6000 characters. Never count the delimiters (theapostrophes) as part of the string. The length that is specified as the second value onthe PARM parameter is the length of the character string that is passed as thecommand. Length must be a packed decimal value of length 15 with 5 decimal

- 21 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 22/49

Tips ‘n’ Facts

positions. Thus, to replace a library list, the call to the QCMDEXC program would looklike this: 

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

- 22 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 23/49

Tips ‘n’ Facts

The Facts…

1. A CL program can handle up to 1000 MONMSG commands. Up to 50 message identifierscan be entered on a MSGID parameter for a MONMSG command.

2. Up to 10 programs can be debugged simultaneously in a job.

3. CLP does not support zoned and binary variables. It supports only packed variables.

4. The maximum number of parameters that can be passed to another program is 40.

5. There is no limit on command label length as long as the label fits on one line in thesource record.

6. Up to 10 levels of embedding are permitted in CL. Let us see the IF condition embedding.E.g. IF (A=1) THEN (IF (B=2) THEN (IF C=3) THEN (DO)))

7. When a call command is run in batch mode, variables passed as arguments aretreated as constants.

8. CL does not support arrays. CL does not support CASE statement.

9. A null value can not be passed to another program.

10. CL cannot be used for processing printer or ICF files.

11. All keywords in a CL command can be coded positional.

12. The command QCMD is used to display command entry screen.

 The command MOVOBJ is used to move the object from one library to another.

13. DCL, DCLF commands must precede all other commands except the PGM command.

14. The system message file is QCPFMSG. You can view all the exception messages in thismessage file.

15. CL cannot be used for processing sub files within display files. However message subfiles can be processed.

16. CL cannot be used to update or add records in database files. However, it can readrecords from the database files.

17. The only way, a program can determines that no messages were received by a RCVMSGcommand if the message text is blank.

18. If an override command through a call to QCMDEXEC is executed, the override will be ineffect at the same invocation level as the program that issued the call to QCMDEXEC.

19. Only one file can be declared in a CL.

- 23 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 24/49

Tips ‘n’ Facts

Appendix A - Using Command prompts

- On a prompt display of a command, enter ‘?‘ on a field to know the permissible valuesfor that field. This character can be used in all entry fields. It performs the same function as

the F4 (Prompt) key.

- On a prompt display of a command, enter ‘&‘ to increase the length of the entry field. If aparticular input field is not large enough for the parameter value or values you want to type,you can expand the field by using the ampersand (&). The field will expand to the nextlarger length of 25, 80, 132, 256, or 512 characters.

- If you type a less than sign (<) followed by at least one blank in place of the firstcharacter of a value, that value is deleted. This character can be used only in fields thatallow a list of values.

- By typing a greater than sign (>) in the input field, you tell the system you want to typeadditional values ahead of that value. On an input field that already contains a value, type

the > over the first character of the value and press the spacebar or press the Field Exit keyto remove the remaining characters. Then press the Enter key. The value in the input fieldwhere you typed the > is not lost. When you enter the additional values and press the Enterkey, the replaced value reappears following the inserted value. This character can be usedonly in fields that allow a list of values.

Appendix B - Selective prompting character.

 The special prompt characters help us in displaying command prompts both oncommand line and while running the programs. For example the command? WRKMBRPDM will display the prompt as if F4 is pressed. Let us see how otherswork…

- WRKMBRPDM ??FILE (*N) The parameter is displayed and input-capable.

- WRKMBRPDM ?*FILE(*N) The parameter is displayed but not input-capable.

- WRKMBRPDM ?<FILE(*N) The parameter is displayed and input-capable, but the command default is sent tothe CPP unless the value displayed on the parameter is changed.

- ? WRKMBRPDM ?-FILE(*N) The parameter is not displayed. The specified value is passed to the CPP. Not allowedprompt override programs.

- WRKMBRPDM ?&FILE(*N) The parameter is not displayed until F9 is pressed and the parameters are input-capable.

- WRKMBRPDM ?%FILE(*N) The parameter is not displayed until F9 is pressed and the parameters are not input-capable.

- 24 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 25/49

Tips ‘n’ Facts

- ?/ Reserved for IBM use.

- 25 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 26/49

Tips ‘n’ Facts

Appendix C - Object Authorities and Lock states

Object Authorities

A user can be given one of the following authorities to objects: *ALL, *EXCLUDE,

*USE, *CHANGE.

ObjectAuthority

---------------Object-------------- --------------------Data---------------------

OPR MGT EXIST ALTER REF READ ADD UPDATE DELETE EXECUTE*ALL X X X X X X X X X X*EXCLUDE*USE X X X*CHANGE X X X X X X

Note: You can type an "X" or a blank to give or remove object/data authorities. Forsome *FILE objects, a "/" may appear in the column. A "/" indicates that the user hasthe specified authority to some, but not all of the fields in the file.

- Object operational authority - It provides the user authority to display the object’sattributes.

- Object management authority - It provides authority to specify security, to moveor rename the object, and to add members if the object is a database file.

- Object existence authority - It provides authority to control the object's existenceand ownership.

- Object alter authority - It provides authority to change the attributes of an object,such as adding or removing triggers for a database file.

- Object reference authority - It provides authority to specify the object as the firstlevel in a referential constraint.

- Read authority - It provides authority to access the contents of the object.

- Add authority - It provides authority to add entries to the object.

- Update authority - It provides authority to change the content of existing entriesin the object.

- Delete authority - It provides authority to remove entries from the object.

- Execute authority - It provides authority to run a program or search a library or

directory.

- 26 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 27/49

Tips ‘n’ Facts

Object Lock states

Objects are allocated on the basis of their intended use and whether they can beshared. A lock state identifies the use of the object and whether it is shared. The fivelock states are as follows:

- Exclusive (*EXCL) - The object is reserved for the exclusive use of the requesting job. No other job can use the object.

- Exclusive allow read (*EXCLRD) - The object is allocated to the job that requestedit but other jobs can read the object.

- Shared for update (*SHRUPD) - The object can be shared either for update or readwith another job.

- Shared no update (*SHRNUP) - The object can be shared with another job if the job requests either a *SHRNUP lock state or *SHRRD lock state.

- Shared for read (*SHRRD) - The object can be shared with another job if the userdoes not request exclusive use of the object.

Use WRKJOB (work with job) command and take option ‘12’ to display the lock statesfor objects. Use WRKOBJLCK (Work with object locks) to display the lock state for aspecified object.

- 27 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 28/49

Tips ‘n’ Facts

Appendix D - Message queues and Messages

Types of message queues

All messages are sent to the message queue. In addition to the below message

queues, you can create your own message queues for sending messages to systemusers and between application programs.

- Workstation message queue is used for sending and receiving messagesbetween workstation users and between workstation users and the systemoperator.

- User profile message queue can be used for communication between users. Itis automatically created when the user profile is created.

-  Job message queue is used for receiving requests to be processed and forsending messages that result from processing the requests. It exists for each joband only exists for the life of job. It consists of an external message queue (*EXT)and a set of program message queues.

- System operator message queue (QSYSOPR) is used for receiving andreplying to messages from the system, display station users, and applicationprograms.

- The history log message queue is used for sending information to the historylog (QHST) from any job in the system.

Types of messages

- Informational (*INFO) message that conveys information about the condition of a function.

- Inquiry (*INQ) message that conveys information and also asks for a reply.- Notify (*NOTIFY) message that describes a condition for which a program

requires corrective action.- Request (*RQS) message that requests a function from the receiving program.- Completion (*COMP) message that conveys completion status of work.- Diagnostic (*DIAG) message about errors in the processing of a system

function.- Status (*STATUS) message that describes the status of the work done by a

program. Status messages sent to the external message queue (*EXT) is shownat the display station.

- Escape (*ESCAPE) message that describes a condition for which a programmust end abnormally.

 The message identifier you specify on the ADDMSGD command is used to refer to themessage and is the name of the message description. The message identifier mustbe of 7 characters: 

PPPMMNN

 Where PPP is the product or application code, MM is the numeric group code andNN is the numeric subtype code. The number specified as MMNN can be used tofurther divide a set of product or application messages. Numeric group and subtypecodes consist of decimal numbers 0 through 9 and the characters A through F. For example: CPF1234 is message 1234 of CPF.

- 28 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 29/49

Tips ‘n’ Facts

 You should use care in using a numeric subtype code of 00 in the message identifier.If you use a numeric subtype code of 00 for a message that can be sent as anescape, notify, or status message and that can, therefore, be monitored, a subtypecode of 00 in the Monitor Message (MONMSG) command causes all messages in thenumeric group to be monitored.

Valid message types for message queue typesMessageType

Message Queue Type

External Program QSYSOPR Work  station

User

Informational X X X X XInquiry X X X XCompletion X X X X XDiagnostic X X X X XRequest X XEscape XStatus X XNotify X X

Message types that can be send with different message sending commandsSendingmessage

Message Type

*INFO *INQ *RQS *COMP *DIAG *NOTIFY *ESCAPE

*STATUS

SNDMSG X XSNDUSRMSG

X X

SNDPGMMSG

X X X X X X X X

SNDBRKMSG

X X

SNDMSG (Send message)

- It can be used on a command line.- It can not use messages in message file for sending messages. It can only use the

message text entered by the user.- It can be used to send message either to a user profile or a message queue.-  The type of messages allowed on SNDMSG are *INFO, *INQ.

E.g. SNDMSG MSG('AS/400 MESSAGE FILE') TOUSR(#VYERRAP) +MSGTYPE (*INQ) RPYMSGQ (#VYERRAP)

SNDPGMMSG (Send program message)

- It can not be used on a command line.- It can use messages in message file for sending messages. It can also use the

message text entered by the user.- It can be used to send message either to a user profile or a message queue.-  The type of messages allowed on SNDPGMMSG are *INFO, *INQ, *RQS, *COMP,

*DIAG, *NOTIFY, *ESCAPE, *STATUS.

- 29 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 30/49

Tips ‘n’ Facts

- For *NOTIFY, *ESCAPE, *STATUS messages Message Id and Message file aremandatory. It does not take message text entered by the user.

E.g. For status message:SNDPGMMSG MSGID(A000010) MSGF(MSGF1) TOPGMQ(*EXT) +

MSGTYPE(*STATUS)

For message at display station:SNDPGMMSG MSGID(A000010) MSGF(MSGF1)

SNDUSRMSG (Send user message)

- It can not be used on a command line.- It can use messages in message file for sending messages. It can also use the

message text entered by the user.- It can be used to send message either to a user profile or a message queue.-  The type of messages allowed on SNDMSG are *INFO, *INQ.

E.g. SNDUSRMSG MSG('AS/400 MESSAGE FILES') TOUSR(#VYERRAP)

SNDBRKMSG (Send break message)- It can be used on a command line.- It can not use messages in message file for sending messages. It can only use the

message text entered by the user.- It can be used to send message only to a work station message queue.-  The type of messages allowed on SNDMSG are *INFO, *INQ.

E.g. SNDBRKMSG MSG('AS/400 MESSAGE FILES') + TOMSGQ (QPADEV000D)

Defining substitution variables

Consider the message “File &1 not found” in message file. Here &1 is the substitutionvariable. The value in &1 is populated to make the message more meaningful asfollows:

Add message Id P000001 in message file MSGF1 with message text as “File &1 notfound”. And define substitution variable &1 is as FMT ((*CHAR 10) in the messagefile.

SNDPGMMSG MSGID(P000001) MSGF(MGS1) MSGDTA(ORDHDR)

&1 is replaced with ORDHDR. Now the message will be displayed as “File ORDHDRnot found”.

Please note that the command RMVMSG CLEAR(*ALL) removes all messages frommessage queue.

- 30 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 31/49

Tips ‘n’ Facts

Appendix E - %BINARY and %SWITCH built-in Functions

Using the %BINARY built-in Function  The binary built-in function (%BINARY or %BIN) interprets the contents of a specified

CL character variable as a signed binary integer. The syntax of the binary built-infunction is: %BIN (character-variable-name starting-position length)  The starting position and length are optional. You can use the binary built-in functionwith both the IF and CHGVAR commands. The following are examples of the binarybuilt-in function: 

DCL VAR(&B2) TYPE(*CHAR) LEN(2) VALUE(X'001C')DCL VAR(&N) TYPE(*DEC) LEN(3 0)CHGVAR &N %BINARY (&B2)

  The content of variable &B2 is treated as a 2-byte signed binary integer and

converted to its decimal equivalent of 28. It is then assigned to the decimal variable&N 

DCL VAR(&N) TYPE(*DEC) LEN(5 0) VALUE(107)DCL VAR(&B4) TYPE(*CHAR) LEN(4)CHGVAR %BIN (&B4) &N

  The value of the decimal variable &N is converted to a 4-byte signed binary

number and is placed in character variable &B4 Variable &B4 will have the value of X'0000006B'. 

DCL VAR(&P) TYPE(*CHAR) LEN(100)DCL VAR(&L) TYPE(*DEC) LEN(5 0)CHGVAR &L VALUE(%BIN(&P 1 2) * 5)

  The first two characters of variable &P is treated as a signed binary integer,

converted to its decimal equivalent, and multiplied by 5. The product is assigned tothe decimal variable &L. 

- 31 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 32/49

Tips ‘n’ Facts

Using the %SWITCH built-in Function  The switch built-in function (%SWITCH) compares one or more of eight switches withthe eight switch settings already established for the job and returns a logical value of '0' or '1'. The initial values of the switches for the job are determined first by theCreate Job Description (CRTJOBD) command; the default value is 00000000. You can

change this if necessary using the SWS parameter on the SBMJOB, CHGJOB, or JOBcommand. Other high-level languages may also set job switches. If, in the comparison of your %SWITCH values against the job values, every switch isthe same, a logical value of '1' (true) is returned. If any switch tested does not havethe value indicated, the result is a '0' (false). The syntax of the %SWITCH built-infunction is: 

%SWITCH (8-character-mask)  The 8-character mask is used to indicate which job switches are to be tested, andwhat value each switch is to be tested for. Each position in the mask correspondswith one of the eight job switches in a job. Position 1 corresponds with job switch 1,position 2 with switch 2, and so on. Each position in the mask can be specified as oneof three values: 0, 1, or X. 0 The corresponding job switch is to be tested for a 0 (off). 1 The corresponding job switch is to be tested for a 1 (on). X The corresponding job switch is not to be tested. The value in the switch doesnot affect the result of %SWITCH. If %SWITCH (0X111XX0) is specified, job switches 1 and 8 are tested for 0s; switches3, 4, and 5 are tested for 1s; and switches 2, 6, and 7 are not tested. If each jobswitch contains the value (1 or 0 only) shown in the mask, the result of %SWITCH istrue '1'.

On the IF command, %SWITCH can be specified on the COND parameter as thelogical expression to be tested. In the following example, 0X111XX0 is compared tothe predetermined job switch setting: IF COND(%SWITCH(0X111XX0)) THEN(GOTOC) If job switches 1, 3, 4, 5, and 8 contain 0, 1, 1, 1, and 0, respectively, the result istrue and the procedure branches to the command having the label C. If one or moreof the switches tested do not have the values indicated in the mask, the result isfalse, and the branch does not occur.

On the CHGVAR command, you can specify %SWITCH to change the value of a logicalvariable. The value of the logical variable is determined by the results of comparing

your %SWITCH settings with the job switch settings. If the result of the comparison istrue, the logical variable is set to '1'. If the result is false, the variable is set to '0'.For instance, if the job switch is set to 10000001 and this procedure is processed: 

PGMDCL &A *LGLCHGVAR VAR(&A) VALUE(%SWITCH(10000001))..

- 32 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 33/49

Tips ‘n’ Facts

ENDPGM Then the variable &A has a value of '1'.

- 33 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 34/49

Tips ‘n’ Facts

Appendix F - Data Queues

- Data queues are a type of system object that you can create to which one HLLprogram can send data. They are the fastest means of asynchronouscommunication between two jobs. To receive and send data to DQ has fewer

overheads than using database files, message queues or data areas. They shouldnot be used for storing large volumes of data and for long term storage of data. They are similar to message queues in that programs can send and receive datafrom them. While only one program can have receive pending on a messagequeue more than one program can have a receive pending on a message queueat the same time.

To clear a data queue:

PGMDCL VAR(&QNAME) TYPE(*CHAR) LEN(10) VALUE('DTAQ1')DCL VAR(&LIB) TYPE(*CHAR) LEN(10) VALUE('MYLIB1')CALL PGM(QCLRDTAQ) PARM(&QNAME &LIB)ENDPGM

To send data to a data queue:

PGMDCL VAR(&QNAME) TYPE(*CHAR) LEN(10) VALUE('DTAQ1')DCL VAR(&LIB) TYPE(*CHAR) LEN(10) VALUE('MYLIB1')DCL VAR(&FLDLEN) TYPE(*DEC) LEN(5) VALUE(17)DCL VAR(&FIELD) TYPE(*CHAR) LEN(17) +

VALUE ('Sample data queue')CALL PGM(QSNDDTAQ) PARM(&QNAME &LIB &FLDLEN +

&FIELD)ENDPGM

To receive data from data queue:

PGMDCL VAR(&QNAME) TYPE(*CHAR) LEN(10) VALUE('DTAQ1')DCL VAR(&LIB) TYPE(*CHAR) LEN(10) VALUE('MYLIB1')DCL VAR(&FLDLEN) TYPE(*DEC) LEN(5) VALUE(20)DCL VAR(&FIELD) TYPE(*CHAR) LEN(20)DCL VAR(&WAIT) TYPE(*DEC) LEN(5 0) VALUE(1)CALL PGM(QRCVDTAQ) PARM(&QNAME &LIB &FLDLEN +

&FIELD &WAIT)ENDPGM

-  The commands using all the parameters:

CALL PGM(QSNDDTAQ) PARM(&QNAME &LIB &FLDLEN +&FIELD &KEYLEN &KEY)

CALL PGM(QRCVDTAQ) PARM(&QNAME &LIB &FLDLEN +&FIELD & WAIT &ORDER &KEYLEN &KEY &SENDRLEN &SNDR)

- 34 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 35/49

Tips ‘n’ Facts

&QNAME is 10-length character field that names the data queue.

&LIB is 10-length character field that names the library containing data queue.

&FLDLEN is 5-digit packed decimal variable, which specifies the number of characterssent to/received from the data queue.

&FIELD is a character field of length equal to the value in &FLDLEN.

&KEYLEN is a 3-digit packed decimal variable, which specifies the length of the keysent to/received from the data queue.

&KEY is a character field of length equal to the value in &KEYLEN.

&WAIT is a 5-digit packed decimal variable, which waits for the time specified in thisvariable if there are no entries in the data queue.

&ORDER is a 2-length character field that retrieves a message using the specifiedcharacter key like GT: or LT: or NE: etc

&SNDRLEN is a 3-digit packed decimal field that sends the length of the senderidentification parameter. It must be zero or equal to or greater than 8.

&SNDR is a character field that identifies the variable to contain the senderidentification information associated with the received message.

Appendix G - Data area

- A local data area cannot be created, deleted or allocated.

- A local data area can not be referred to from any other job. Other programs within same job can refer it.

- A Program Initialization Parameter data area (PIP) is created for each pre-start jobwhen the job is started. The size of PDA is 2000 bytes but the number of parameters contained in it is not restricted.

- A data area is an object used to hold data for access by any job running on thesystem. It can be used to store information of limited size, independent of theexistence of programs and files.

- A local data area (*LDA) is created for each job in the system with a length of 1024 and type *CHAR. It can not be referred to from any other job. It can not becreated, deleted or allocated. No library is associated with it.

-  The contents of the submitting job’s LDA is copied in to submitted job’s LDA.Hence, the contents of LDA exist across routing step boundaries.

- A group data area (*GDA) is created when an interactive job becomes a group jobwith a length of 512 and type *CHAR. It can not be referred to from by jobsoutside the group. It can not be created, deleted or allocated. No library isassociated with it.

- 35 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 36/49

Tips ‘n’ Facts

Appendix H - SEU Colors and Attributes

-  You need to embed the hex value for the display attribute (highlight, blink,underline, color, etc.) directly in the source statement to achieve this.

- Create a member by name SEUFMTCODE of type TEXT in source physical file

QRPGLESRC.- Do the following override and compile interactively the SEUCODES program of type RPGLE:

OVRDBF FILE (DUMMY) TOFILE (MYLIB1/QRPGLESRC) MBR (SEUFMTCODE)- Call the program SEUCODES, which will keep lines for various attributes in

member SEUFMTCODE. Copy the line that you want into the member you areediting and type over it.

The code for SEUCODES program

FDUMMY o e Disk RENAME(QRPGLESRC:SEUFMTCODE)*D Normal s 1 Inz(x'20')D RI s 1 Inz(x'21')D HI s 1 Inz(x'22')D RI_HI s 1 Inz(x'23')D UL s 1 Inz(x'24')D RI_UL s 1 Inz(x'25')D HI_UL s 1 Inz(x'26')D ND s 1 Inz(x'27')D BL s 1 Inz(x'28')D RI_BL s 1 Inz(x'29')*C eval SRCDTA = ' ' + RI + ' RI'C write SEUFMTCODEC eval SRCDTA = ' ' + HI + ' HI'C write SEUFMTCODEC eval SRCDTA = ' ' + RI_HI + ' RI_HI'C write SEUFMTCODEC eval SRCDTA = ' ' + UL + ' UL'C write SEUFMTCODEC eval SRCDTA = ' ' + RI_UL + ' RI_UL'C write SEUFMTCODEC eval SRCDTA = ' ' + HI_UL + ' HI_UL'C write SEUFMTCODEC eval SRCDTA = ' Non-display next'C write SEUFMTCODEC eval SRCDTA = ' ' + ND + ' ND'C write SEUFMTCODE

C eval SRCDTA = ' ' + BL + ' BL'C write SEUFMTCODEC eval SRCDTA = ' ' + RI_BL + ' RI_BL'C write SEUFMTCODEC eval *inlr = *on*

- 36 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 37/49

Tips ‘n’ Facts

Appendix I - Selecting Records Using the OPNQRYF Command In all of the following examples, it is assumed that a single-format database file(physical or logical) is being processed. (The FILE parameter on the OPNQRYF

command allows you to specify a record format name if the file is a multiple formatlogical file.) To request a selection against a character constant

OPNQRYF FILE(FILEA) QRYSLT('CODE *EQ "D" ')

To request a selection against a numeric constant:OPNQRYF FILE(FILEA) QRYSLT('AMT *GT 1000.00')

 When comparing a charcter field value to a CL variable

OPNQRYF FILE(FILEA) QRYSLT('"' *CAT &CHAR *CAT '" *EQ FIELDA')Notice that apostrophes and quotation marks enclose the CL variables and *CAToperators. (only character CL variables can be used)

When comparing a numeric field value to a CL variableOPNQRYF FILE(FILEA) QRYSLT(&CHARNUM *CAT ' *EQ NUM')

Notice that apostrophes enclose the field and operator only. (only character CLvariables can be used) Selecting records using the contains function To process all records in which the Addr field contains the street named BROADWAYyou can specify:

OPNQRYF FILE(FILEA) QRYSLT('ADDR *CT "BROADWAY" ')

Mapping fields for packed numeric data fieldsIn this example, if DATE was a date data type, it could be specified as follows: 

OPNQRYF FILE(FILEA) QRYSLT ('YEAR *EQ 88') MAPFLD((YEAR '%YEAR(DATE)')) Note: Mapped field definitions are always processed before the QRYSLT parameter isevaluated.  You could accomplish the same result by specifying the substring on the QRYSLTparameter and dropping one of the mapped field definitions as follows: 

OPNQRYF FILE(FILEA) +QRYSLT('%SST(CHAR6 5 2) *EQ "88" ') +MAPFLD((CHAR6 '%DIGITS(DATE)'))

 

Using the "wildcard" function You would not select the other records because a comparison is made with blanksadded to the value you specified. The way to select all four names is to specify: 

QRYSLT('NAME *EQ %WLDCRD("JOHNS*")') 

- 37 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 38/49

Tips ‘n’ Facts

Appendix J - User Defined Commands  The AS/400 control program lets users define a command that calls a program toperform some function. Users can define commands by using a command definitionstatement.

Command Statements The command definition statement of each command contains one or more of thefollowing command statements: - CMD (Command) - Specifies the prompt text for the command (Only one

statement)- DEP (Dependent) - Defines the relationship among parameters- ELEM (Element) - Defines an element in a list used as a parameter value (A

maximum of 300 statements)- PARM (Parameter) - Defines a parameter or key parameter for a command (A

maximum 75 300 statements)- PMTCTL (Prompt Control) - Defines conditions under which certain parameters are

prompted- QUAL (Qualifier) - Defines a qualifier of a name used as a parameter (A maximum

of 300 statements)

 Command Processing Program The command processing program (CPP) is the program that the command analyzercalls to perform the function requested. The CPP can be a CL program, another HLLprogram. The CPP must accept the parameters as defined by the command definitionstatements. A command processing program is mandatory.

Validity Checking program To ensure that the valid values are entered for the required parameters, You maywrite your own validity checking program. A Validity Checking program is optional.

Prompt Override Program You can write prompt override programs to supply current values for parameterdefaults when prompting the command. For example, prompt override programs arefrequently used on Change commands to supply values for parameters with a defaultvalue of *SAME. A prompt override program is optional.

Command Creation

Let us create command similar to WRKMBRPDM, by name WM with the followingfunctionality:- When WM command is taken it will prompt for source file and library.- After you enter valid values it will show that PDM with the source file and library

the user has entered.- If incorrect values are entered, the validation program sends error messages.

We need three sources as follows:- WM of type CMD - Command program.- WMPRC of type CLLE - Command processing program.- WMVAL of type CLLE - Command validation program.- While compiling the command program take prompt to enter the processing

program and validation program.

- 38 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 39/49

Tips ‘n’ Facts

 The code for the Command Program (WM)

CMD PROMPT('WORK WITH MEMBERS USING PDM')

PARM KWD(FILE) TYPE(*NAME) LEN(10) PROMPT('File')PARM KWD(LIB) TYPE(*NAME) LEN(10) PROMPT('Library')

 The code for Command Processing Program (WMPRC)

PGM PARM(&File &Library)DCL VAR(&File) TYPE(*CHAR) LEN(10)DCL VAR(&Library) TYPE(*CHAR) LEN(10)WRKMBRPDM FILE(&LIBRARY/&FILE)ENDPGM

 The code for Command Validity Checking Program (WMVAL)

PGM PARM(&FILE &LIBRARY)

DCL VAR(&FILE) TYPE(*CHAR) LEN(10)DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10)

/* Check for the existence of Library on the system */

CHKOBJ OBJ(&LIBRARY) OBJTYPE(*LIB)MONMSG MSGID(CPF0000) EXEC(DO)SNDPGMMSG MSGID(CPD0006) MSGF(QCPFMSG) MSGDTA('0000 +

Library . . does not exist on the +

System.') MSGTYPE(*DIAG)SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE)ENDDO

/* Check for the existence of Source File in the specified Library */

CHKOBJ OBJ(&LIBRARY/&FILE) OBJTYPE(*FILE)MONMSG MSGID(CPF0000) EXEC(DO)SNDPGMMSG MSGID(CPD0006) MSGF(QCPFMSG) MSGDTA('0000 +

File . . does not exist in specified +Library.') MSGTYPE(*DIAG)

SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE)ENDDO

ENDPGM

- 39 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 40/49

Tips ‘n’ Facts

DDS Reference: Display Files

EDTCDE (Edit Code) keyword for display files

Use this field-level keyword to edit output-capable numeric fields.

The format of the keyword is:

EDTCDE(edit-code [* |floating-currency-symbol])

Editing includes the following changes to the appearance of displayed fields, dependingon which edit code is specified:

• Leading zeros are suppressed.

• The field can be punctuated with commas and periods to show decimal position and to group

digits by threes.

•  Negative values can be displayed with a minus sign or CR to the right.

• Zero values can be displayed as zero or blanks.

• Asterisks can be displayed to the left of significant digits to provide asterisk protection.

• A currency symbol (corresponding to the system value QCURSYM) can be displayed

immediately to the left of the significant digit that is farthest to the left (called floating-currency

 symbol ). For fixed-currency symbols, use the EDTWRD keyword.

• The field can be further edited using a user-defined edit code.

EDTCDE covers most editing requirements. Use EDTWRD when the EDTCDE keywordis not sufficient.

The EDTCDE keyword is valid only for fields with Y or blank in position 35 (Data

Type/Keyboard Shift). The use of this keyword changes the default used for position 35

to a Y.

You cannot specify both EDTCDE and EDTWRD for the same field. If a field previously

defined in a database file has EDTCDE specified, you need not specify EDTCDE for thatfield in the display file. You can specify R in position 29 to refer to the previously

defined field. The editing specified for the referenced field is included in the display file.

However, if you also specify length, data type, or decimal positions for a display filefield, editing specified for the referenced field is not included in the display file, and you

must specify editing again in the display file.

The DFT and DFTVAL keywords cannot be specified with the EDTCDE keyword.

Option indicators are not valid for this keyword.

- 40 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 41/49

Tips ‘n’ Facts

The rules for specifying edit codes and edit words are the same in all types of files. You

can specify two kinds of edit codes: OS/400 edit codes and user-defined edit codes.

OS/400 edit codes: 

The OS/400 edit codes are the following:

1 through 4A through D

J through QW through Z

Note: 

The iSeries server hardware operates with a preferred sign of F, which is equivalent to using edit

code X. Edit code X causes a blank keyboard shift (position 35) to default to numeric-only

(attribute Y). The display length of the field is determined by the keyboard shift and not by edit

code X (the default numeric only Y attribute may add 1 position to the field for decimals). If the

DATE or TIME keyword is specified with edit code X, the separator character is not displayed.

Optionally specifying asterisk fill or floating currency symbol: 

You can optionally specify asterisk fill or floating currency symbol with edit codes 1

through 4, A through D, and J through Q.

When you specify asterisk fill, an asterisk (*) is printed for each zero that is suppressed.

A complete field of asterisks is printed for a zero balance field.

When you specify floating currency symbol, the symbol appears to the left of the first

significant digit. The symbol does not print on a zero balance when an edit code is used

that suppresses the zero balance. (The symbol that you specify must match the systemvalue for the currency symbol (QCURSYM). The symbol must match when the file is

created. It does not have to match when the file is used.)

Note: If an edit code is changed after a file is created, the editing specified at the time the file was

created is used. The new edit code is not used unless the file is recreated.

The following table summarizes the functions provided by OS/400 edit codes.

Table 6. Summary Chart for OS/400 Edit Codes

Edit Codes

Commas1

Displayed

Decimal

Points1

Displayed

Sign

Displayed

When

Negative

Value

Blank Value

of 

QDECFMT

System

Value

I Value of 

QDECFMT

System

Value

J Value of 

QDECFMT

System

Value

Leading

Zero

Suppressed

1 Yes Yes No sign .00 or 0 ,00 or 0 0,00 or 0 Yes2 Yes Yes No sign Blanks Blanks Blanks Yes

3 Yes No sign .00 or 0 ,00 or 0 0,00 or 0 Yes

4 Yes No sign Blanks Blanks Blanks Yes

A Yes Yes CR .00 or 0 ,00 or 0 0,00 or 0 Yes

B Yes Yes CR Blanks Blanks Blanks Yes

C Yes CR .00 or 0 ,00 or 0 0,00 or 0 Yes

- 41 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 42/49

Tips ‘n’ Facts

D Yes CR Blanks Blanks Blanks Yes

J Yes Yes -(Minus) .00 or 0 ,00 or 0 0,00 or 0 Yes

K Yes Yes -(Minus) Blanks Blanks Blanks Yes

L Yes -(Minus) .00 or 0 ,00 or 0 0,00 or 0 Yes

M Yes -(Minus) Blanks Blanks Blanks Yes  N Yes Yes -(Minus) .00 or 0 ,00 or 0 0,00 or 0 Yes

O Yes Yes -(Minus) Blanks Blanks Blanks Yes

P Yes -(Minus) .00 or 0 ,00 or 0 0,00 or 0 Yes

Q Yes -(Minus) Blanks Blanks Blanks Yes

W2 Yes

Y3 Yes

Z4 Yes

Notes:

1. The QDECFMT system value determines the decimal point character (period in U.S. usage), the

character used to separate groups of three digits (comma in U.S. usage), and the type of zero

suppression (depending on comma and period placement).

2. The W edit code suppresses the farthest left zero of a date field that is five digits long. It alsosuppresses the three farthest left zeros of a field that is six to eight digits long. The W edit code also

inserts slashes (/) between the month, day, and year according to the following pattern:

nn/nnn

nnnn/nn

nnnn/nnn

nnnn/nn/nn

3. The Y edit code suppresses the farthest left zero of a date field that is three to six digits long or eight

digits long. It also suppresses the two farthest left zeros of a field that is seven positions long. The Y

edit code also inserts slashes (/) between the month, day, and year according to the following

 pattern:

nn/n

nn/nn

nn/nn/nnn/nn/nn

nnn/nn/nn

nn/nn/nnnn

If the DATE keyword is specified with EDTCDE(Y), the separator character used

- 42 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 43/49

Tips ‘n’ Facts

is the job attribute, DATSEP at run time. The slash (/) is the default DATSEP.

4. The Z edit code removes the sign (plus and minus) from a numeric field. The sign of the units

 position is changed to a hexadecimal F before the field is written.

Note: For more information on the QDECFMT system value, see the System values topic under the

Systems Management category of the iSeries Information Center.

User-defined edit codes: 

Edit codes 5 through 9 are user-defined edit codes. A user-defined edit code can do moreediting than an OS/400 edit code. For example, you may need to edit numbers that

include hyphens (such as telephone numbers) or more than one decimal point. You can

use user-defined edit codes for these functions. These edit codes are named QEDIT5,QEDIT6, QEDIT7, QEDIT8, and QEDIT9, and can be referred to in DDS or a high-level

language program by number (5, 6, 7, 8, or 9).

A user-defined edit code is an OS/400 object and must exist before display file creation.

It is created using the Create Edit Description (CRTEDTD) command. When you create a

display file in which a user-defined edit code is specified, editing information is extracted

from the previously created edit description. Changing a user-defined edit code after display file creation does not affect the display file unless the display file is re-created.

The following table shows edit codes, unedited source data, and edited output. Zerosuppression and decimal characters are determined by the system value QDECFMT. The

date separator character is determined by the job attribute DATSEP. In this figure,

QDECFMT is assumed to equal x (blank), and DATSEP is assumed to equal / (slash).

Table 7. Valid Edit Codes, Source Data, and Edited Output

Edit codes

Positive

number with

two decimal

positions

Positive

number with

no decimal

positions

Negative

number with

three decimal

positions1 

Negative

number with

no decimal

positions1 

Zero balance

with two

decimal

positions1 

Zero balance

with no decimal

positions1 

Unedited 1234567 1234567 xxxx.125- 125- xxxxxx xxxxxx

1 12,345.67 1,234,567 .125 125 .00 0

2 12,345.67 1,234,567 .125 125

3 12345.67 1234567 .125 125 .00 0

4 12345.67 1234567 .125 125

A 12,345.67 1,234,567 .125CR 125CR .00 0

B 12,345.67 1,234,567 .125CR 125CR 

C 12345.67 1234567 .125CR 125CR .00 0

D 12345.67 1234567 .125CR 125CR 

J 12,345.67 1,234,567 .125- 125- .00 0

K 12,345.67 1,234,567 .125- 125-

- 43 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 44/49

Tips ‘n’ Facts

L 12345.67 1234567 .125- 125- .00 0

M 12345.67 1234567 .125- 125-

  N 12,345.67 1,234,567 -.125 -125 .00 0

O 12,345.67 1,234,567 -.125 -125

P 12345.67 1234567 -.125 -125 .00 0Q 12345.67 1234567 -.125 -125

W2 1234/567 1234/567 0/125 0/125 0/000 0/000

Y3 123/45/67 123/45/67 0/01/25 0/01/25 0/00/00 0/00/00

Z4 1234567 1234567 125 125

Notes:

1. The x represents a blank.

2. The W edit code suppresses the farthest left zero of a date field that is five digits long. It also

suppresses the three farthest left zeros of a field that is six to eight digits long. For more information,

see the second footnote in Table 6.

3. The Y edit code suppresses the farthest left zero of a date field that is three to six digits long or eight

digits long. It also suppresses the two farthest left zeros of a field that is seven positions long. For 

more information, see the third footnote in Table 6. 

4. The Z edit code removes the sign (plus or minus) and suppresses leading zeros.

Example: 

The following example shows how to specify the EDTCDE keyword.

|...

+....1....+....2....+....3....+....4....+....5....+....6....+....7....+

....8

00010A PRICE 5 2 1 10EDTCDE(J)

00020A SALES 7 2 2 10EDTCDE(K $)

00030A SALARY 8 2 3 10EDTCDE(1 *)

A

The display length for PRICE is 7 because the J edit code is specified, causing the field tocontain a decimal point and an ending minus sign. It is edited as:

ddd.dd-

where d represents a digit.

The display length for SALES is 11 because the K edit code and floating currencysymbol are specified. It is edited as:

$dd,ddd.dd-

The display length for SALARY is 10 because the edit code 1 is specified with asterisk fill. It is edited as:

ddd,ddd.dd

- 44 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 45/49

Tips ‘n’ Facts

DDS Reference: Display FilesEDTCDE (Edit Code) keyword for display files

Use this field-level keyword to edit output-capable numeric fields.

The format of the keyword is:

EDTCDE(edit-code [* |floating-currency-symbol])

Editing includes the following changes to the appearance of displayed fields, depending

on which edit code is specified:

• Leading zeros are suppressed.

• The field can be punctuated with commas and periods to show decimal position and to group

digits by threes.

•  Negative values can be displayed with a minus sign or CR to the right.

• Zero values can be displayed as zero or blanks.

• Asterisks can be displayed to the left of significant digits to provide asterisk protection.

• A currency symbol (corresponding to the system value QCURSYM) can be displayed

immediately to the left of the significant digit that is farthest to the left (called floating-currency

 symbol ). For fixed-currency symbols, use the EDTWRD keyword.

• The field can be further edited using a user-defined edit code.

EDTCDE covers most editing requirements. Use EDTWRD when the EDTCDE keyword

is not sufficient.

The EDTCDE keyword is valid only for fields with Y or blank in position 35 (Data

Type/Keyboard Shift). The use of this keyword changes the default used for position 35

to a Y.

You cannot specify both EDTCDE and EDTWRD for the same field. If a field previously

defined in a database file has EDTCDE specified, you need not specify EDTCDE for that

field in the display file. You can specify R in position 29 to refer to the previouslydefined field. The editing specified for the referenced field is included in the display file.

However, if you also specify length, data type, or decimal positions for a display file

field, editing specified for the referenced field is not included in the display file, and youmust specify editing again in the display file.

The DFT and DFTVAL keywords cannot be specified with the EDTCDE keyword.

Option indicators are not valid for this keyword.

The rules for specifying edit codes and edit words are the same in all types of files. You

can specify two kinds of edit codes: OS/400 edit codes and user-defined edit codes.

OS/400 edit codes: 

- 45 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 46/49

Tips ‘n’ Facts

The OS/400 edit codes are the following:

1 through 4

A through DJ through Q

W through Z

Note: The iSeries server hardware operates with a preferred sign of F, which is equivalent to using edit

code X. Edit code X causes a blank keyboard shift (position 35) to default to numeric-only(attribute Y). The display length of the field is determined by the keyboard shift and not by edit

code X (the default numeric only Y attribute may add 1 position to the field for decimals). If the

DATE or TIME keyword is specified with edit code X, the separator character is not displayed.

Optionally specifying asterisk fill or floating currency symbol: 

You can optionally specify asterisk fill or floating currency symbol with edit codes 1

through 4, A through D, and J through Q.

When you specify asterisk fill, an asterisk (*) is printed for each zero that is suppressed.

A complete field of asterisks is printed for a zero balance field.

When you specify floating currency symbol, the symbol appears to the left of the firstsignificant digit. The symbol does not print on a zero balance when an edit code is used

that suppresses the zero balance. (The symbol that you specify must match the system

value for the currency symbol (QCURSYM). The symbol must match when the file iscreated. It does not have to match when the file is used.)

Note: 

If an edit code is changed after a file is created, the editing specified at the time the file was

created is used. The new edit code is not used unless the file is recreated.

The following table summarizes the functions provided by OS/400 edit codes.

Table 6. Summary Chart for OS/400 Edit Codes

Edit Codes

Commas1

Displayed

Decimal

Points1

Displayed

Sign

Displayed

When

Negative

Value

Blank Value

of 

QDECFMT

System

Value

I Value of 

QDECFMT

System

Value

J Value of 

QDECFMT

System

Value

Leading

Zero

Suppressed

1 Yes Yes No sign .00 or 0 ,00 or 0 0,00 or 0 Yes

2 Yes Yes No sign Blanks Blanks Blanks Yes

3 Yes No sign .00 or 0 ,00 or 0 0,00 or 0 Yes

4 Yes No sign Blanks Blanks Blanks Yes

A Yes Yes CR .00 or 0 ,00 or 0 0,00 or 0 Yes

B Yes Yes CR Blanks Blanks Blanks Yes

C Yes CR .00 or 0 ,00 or 0 0,00 or 0 Yes

D Yes CR Blanks Blanks Blanks Yes

J Yes Yes -(Minus) .00 or 0 ,00 or 0 0,00 or 0 Yes

K Yes Yes -(Minus) Blanks Blanks Blanks Yes

- 46 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 47/49

Tips ‘n’ Facts

L Yes -(Minus) .00 or 0 ,00 or 0 0,00 or 0 Yes

M Yes -(Minus) Blanks Blanks Blanks Yes

  N Yes Yes -(Minus) .00 or 0 ,00 or 0 0,00 or 0 Yes

O Yes Yes -(Minus) Blanks Blanks Blanks Yes

P Yes -(Minus) .00 or 0 ,00 or 0 0,00 or 0 YesQ Yes -(Minus) Blanks Blanks Blanks Yes

W2 Yes

Y3 Yes

Z4 Yes

Notes:

1. The QDECFMT system value determines the decimal point character (period in U.S. usage), the

character used to separate groups of three digits (comma in U.S. usage), and the type of zero

suppression (depending on comma and period placement).

2. The W edit code suppresses the farthest left zero of a date field that is five digits long. It also

suppresses the three farthest left zeros of a field that is six to eight digits long. The W edit code also

inserts slashes (/) between the month, day, and year according to the following pattern:

nn/nnn

nnnn/nn

nnnn/nnn

nnnn/nn/nn

3. The Y edit code suppresses the farthest left zero of a date field that is three to six digits long or eight

digits long. It also suppresses the two farthest left zeros of a field that is seven positions long. The Y

edit code also inserts slashes (/) between the month, day, and year according to the following

 pattern:

nn/n

nn/nn

nn/nn/n

nn/nn/nn

nnn/nn/nn

nn/nn/nnnn

If the DATE keyword is specified with EDTCDE(Y), the separator character usedis the job attribute, DATSEP at run time. The slash (/) is the default DATSEP.

4. The Z edit code removes the sign (plus and minus) from a numeric field. The sign of the units

 position is changed to a hexadecimal F before the field is written.

- 47 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 48/49

Tips ‘n’ Facts

Note: 

For more information on the QDECFMT system value, see the System values topic under the

Systems Management category of the iSeries Information Center.

User-defined edit codes: 

Edit codes 5 through 9 are user-defined edit codes. A user-defined edit code can do more

editing than an OS/400 edit code. For example, you may need to edit numbers that

include hyphens (such as telephone numbers) or more than one decimal point. You canuse user-defined edit codes for these functions. These edit codes are named QEDIT5,

QEDIT6, QEDIT7, QEDIT8, and QEDIT9, and can be referred to in DDS or a high-level

language program by number (5, 6, 7, 8, or 9).

A user-defined edit code is an OS/400 object and must exist before display file creation.

It is created using the Create Edit Description (CRTEDTD) command. When you create a

display file in which a user-defined edit code is specified, editing information is extractedfrom the previously created edit description. Changing a user-defined edit code after 

display file creation does not affect the display file unless the display file is re-created.

The following table shows edit codes, unedited source data, and edited output. Zero

suppression and decimal characters are determined by the system value QDECFMT. The

date separator character is determined by the job attribute DATSEP. In this figure,QDECFMT is assumed to equal x (blank), and DATSEP is assumed to equal / (slash).

Table 7. Valid Edit Codes, Source Data, and Edited Output

Edit codes

Positive

number with

two decimal

positions

Positive

number with

no decimal

positions

Negative

number with

three decimal

positions1

 

Negative

number with

no decimal

positions1

 

Zero balance

with two

decimal

positions1

 

Zero balance

with no decimal

positions1

 Unedited 1234567 1234567 xxxx.125- 125- xxxxxx xxxxxx

1 12,345.67 1,234,567 .125 125 .00 0

2 12,345.67 1,234,567 .125 125

3 12345.67 1234567 .125 125 .00 0

4 12345.67 1234567 .125 125

A 12,345.67 1,234,567 .125CR 125CR .00 0

B 12,345.67 1,234,567 .125CR 125CR 

C 12345.67 1234567 .125CR 125CR .00 0

D 12345.67 1234567 .125CR 125CR 

J 12,345.67 1,234,567 .125- 125- .00 0

K 12,345.67 1,234,567 .125- 125-

L 12345.67 1234567 .125- 125- .00 0

M 12345.67 1234567 .125- 125-

  N 12,345.67 1,234,567 -.125 -125 .00 0

O 12,345.67 1,234,567 -.125 -125

- 48 -

8/3/2019 Synon Tips and Facts

http://slidepdf.com/reader/full/synon-tips-and-facts 49/49

Tips ‘n’ Facts

P 12345.67 1234567 -.125 -125 .00 0

Q 12345.67 1234567 -.125 -125

W2 1234/567 1234/567 0/125 0/125 0/000 0/000

Y3 123/45/67 123/45/67 0/01/25 0/01/25 0/00/00 0/00/00

Z4 1234567 1234567 125 125

Notes:

1. The x represents a blank.

2. The W edit code suppresses the farthest left zero of a date field that is five digits long. It also

suppresses the three farthest left zeros of a field that is six to eight digits long. For more information,

see the second footnote in Table 6.

3. The Y edit code suppresses the farthest left zero of a date field that is three to six digits long or eight

digits long. It also suppresses the two farthest left zeros of a field that is seven positions long. For 

more information, see the third footnote in Table 6. 

4. The Z edit code removes the sign (plus or minus) and suppresses leading zeros.

Example: 

The following example shows how to specify the EDTCDE keyword.

|...

+....1....+....2....+....3....+....4....+....5....+....6....+....7....+

....8

00010A PRICE 5 2 1 10EDTCDE(J)

00020A SALES 7 2 2 10EDTCDE(K $)

00030A SALARY 8 2 3 10EDTCDE(1 *)

A

The display length for PRICE is 7 because the J edit code is specified, causing the field to

contain a decimal point and an ending minus sign. It is edited as:

ddd.dd-

where d represents a digit.

The display length for SALES is 11 because the K edit code and floating currencysymbol are specified. It is edited as:

$dd,ddd.dd-

The display length for SALARY is 10 because the edit code 1 is specified with asterisk 

fill. It is edited as:ddd,ddd.dd