This is why Command Codes are most popular in IMS DB

Command codes in a SSA makes the call powerful since DL/I treats such SSA’S differently from those without the command codes while performing some special functions.

Command codes save programming and processing time

Command codes are specified in an SSA following the segment name and an Asterisk ‘*’

An Asterisk ‘*’ in the ninth position in a SSA indicates that one or more command codes follow the asterisk
A Blank or Left Parenthesis marks the end of command codes ONE or MORE command codes can be used in any combination


Related


Ten command codes are available under IMS
F – Locate First Occurrence

L – Locate Last Occurrence

D – Retrieve this segment data into the I-O Area (Path Call)

N – Do not replace this segment

C – Concatenated key in this SSA

Q – Enqueue this segment

U – Maintain current position at this level

V – Maintain current position at this and higher level

P – Establish Parentage at this level

-,-Null command code

Command codes in a Qualified SSA
WARD            *D(WARDNO           =03)

WARD            *DNP(WARDNO      =03)

Command codes in an Unqualified SSA
WARD            *PD


Subscribe to Blog for Daily Tips

Enter your email address to follow this blog and receive notifications of new posts by email.


F COMMAND CODE

Tells DL/I to begin the search with the first occurrence of this segment type in a twin chain under its parent.
It can be used only with GN, GNP, GHN and GHNP calls.

In a retrieved call this command code allows the segment occurrence to be inserted as first occurrence in the segment type which has non-unique or no key field and RULES=HERE is specified for this segment in the DBD.
Suppose you search through all the treatment segments under a particular patient segment occurrence for a treatment type of Morphine. If you find one, you would like to print all the Treatment occurrences for that patient.

WITHOUT COMMAND CODE

GU HOSPITAL (HOSPNAME = RIVEREDGE         )
WARD            (WARDNO    = 04                 )

PATIENT       (BEDIDENT  = 08                 )

GNP TREATMNT (TRTYPE        = MORPHINE           )
If status code is GE, exit from procedure, Else if Blank
GU HOSPITAL (HOSPNAME = RIVEREDGE         )
WARD            (WARDNO    = 04                 )

PATIENT       (BEDIDENT  = 08                 )

GNP TREATMNT
Print a treatment segment occurrence
Loop back to step 5 until a GE status code

WITH COMMAND CODE

GU HOSPITAL (HOSPNAME = RIVEREDGE         )
WARD            (WARDNO    = 04                 )

PATIENT       (BEDIDENT  = 08                 )

GNP TREATMNT (TRTYPE        = MORPHINE           )
If status code is GE, exit from procedure, Else if Blank
GNP TREATMNT * F
Print a treatment segment occurrence
GNP TREATMNT
Loop back to step 5 until status-code GE

L COMAMND CODE

Tells DL/I to retrieve the last occurrence of this segment type in a twin chain under its parent.
In an insert call this command code insert the segment occurrence as the last occurrence in the segment type which has non-unique or no key field.

L command code can be used only in the dependent segment types. It is ignored, if used in the root segment. Suppose you want to retrieve the last twin occurrence of the Treatment Segment type for a particular patient segment.

WITHOUT COMMAND CODE

GU HOSPITAL (HOSPNAME = Mac Neal                 )
WARD            (WARDNO    = 08                 )

PATIENT       (BEDIDENT  = 04                 )

GNP TREATMENT
Loop back to step 2 until status code is GE. When GE, the I-O area will contain the last twin occurrence of treatment.

WITH COMMAND CODE

GU HOSPITAL (HOSPNAME             = Mac Neal     )
WARD            (WARDNO                = 08     )

PATIENT       (BEDIDENT              = 04     )

TREATMNT * L

D COMMAND CODE & N COMMAND CODE

D & N command codes work together to process multiple segments in a single call.

D command code performs a PATH call, wherein, DL/I retrieves multiple segments along the retrieval path in the I-O area. Thus the I-O area must be defined large enough to accommodate all the segments being retrieved in the path. DL/I will place the segment at the higher level in front of the segment at the lower levels. The segment layouts within the I-O area must be defined in the hierarchical structure.

If D command code is not coded, only the segment identified by the last SSA is placed in the I-O area by default. Necessary to retrieve all the segments in the hierarchical path. Therefore, you can code D command code in the higher level SSA’s only for those segments you want DL/I to place in the I-O area.

A processing option of P must be coded in the PROCOPT operand of the PCB in your PSB for the segment, if D command code is to be used in an SSA for that segment. PROCOPT = P

DL/I remembers how many segments are stored in the I-O area by the Get Hold path call. So a subsequent replace call without SSA’s will replace all the segments in the I-O area along the path.

N command code is coded in the SSA’S for those segments used in the Replace call that you don’t want to Replace.
SSA’S with the N command code is an exception to the rule that qualified SSA’S cannot be coded in a Replace call.
One can code a combination of D and N command codes within the same SSA if the same sets of SSA’S are used in both the Get Hold Path Call and the Replace Call.

WITH D COMMAND CODE

GHU   HOSPITAL     * D      (HOSPNAME = RIVEREDGE         )

WARD            * D      (WARDNO     = 02     )

PATIENT                   (BEDIDENT   = 0005 )

WITH N COMMAND CODE

REPL  HOSPITAL     * N      (HOSPNAME = RIVEREDGE         )

WARD            * N      (WARDNO     = 02     )

PATIENT                   (BEDIDENT   = 0005 )

WITH D & N COMBINATION

Both for GHU & REPL

HOSPITAL     * DN   (HOSPNAME = RIVEREDGE         )

WARD            * DN   (WARDNO     = 02     )

PATIENT                   (BEDIDENT   = 0005 )

D command code in one or more higher level SSA’S will also place the additional segment in lt I-O area. It is not if SSA omitted default n replace all implicit N will be ignored for Get and D W.

RETRIEVING AND REPLACING WITHOUT COMMAND CODE

GU HOSPITAL     (HOSPNAME = RIVEREDGE         )
Save Hospital information

GN WARD            (WARDNO     = 02     )
Save Ward information

GHN PATIENT       (BEDIDENT   = 0005 )
Print Patient, Ward and Hospital information
Update information in the Patient segment
REPL

C COMMAND CODE

C command code is used in situations where you would normally use fully qualified calls.
It allows you to use a concatenated key value in a single SSA rather than using a set of fully qualified SSA’S
The concatenated key must be enclosed in Parenthesis and no key in the path can be omitted from the concatenated key.

Only a single SSA naming the segment to be retrieved can be used in the call with C command code.

WITHOUT C COMMAND CODE

GU                  HOSPITAL     (HOSPNAME = RIVEREDGE         )

WARD            (WARDNO     = 02                 )

PATIENT       (BEDIDENT   = 0003             )

DOCTOR       (DOCTNAME = KILLER     )

WITH C COMMAND CODE

GU      DOCTOR       * C (RIVEREDGE     02 0003 KILLER       )

CALL ‘CBLTDLI’     GU

CONCATENATED-KEY

CONCATENATED-KEY
05        SEG-NAME   PIC X (08)

CON-CODE VALUE ‘X C ‘(‘
HOSP-KEY X (02)
05        WARDKEY   PIC

CLOSE X (01) VALUE ‘)’

Q COMMAND CODE

Q command code is only used when multiple applications will be accessing the same database at the same time. Normally used in the O/L MPP where the O/L programs are running under multitasking environment and more than one task can update the same database at the same time.

If you do not want this to happen, issue DL/I calls with Q command code to ENQUEUE the particular segment occurrence for exclusive use by your task, preventing other online transactions from updating the segment until your task is completed.

Other users cannot make a Get Hold type call for that segment, only get calls can access that segment. Get Hold type calls must wait until the Enqueued segment has been Dequeued through the DEQ call, CHKP call, or the program termination.

Q command code set at the root segment level will not allow any other user to gain access to any segment in that database record.

A one-byte class identifier in the range of ‘A ‘through’ J follows Q command code. This class identifier must be specified in the DEQ call to dequeue the segments.
GHU   HOSPITAL    WQB ( HOSP = APPDO )

WARD            (WARDNO = 05)

PATIENT       (= MUNNU)

U AND V COMMAND CODES

U and V command codes are used to prevent a GN or GNP call from leaving the current position. They help exercise some control over calls that cannot be satisfied for a particular parent, but can be satisfied further in the database under a different parent.

WITHOUT U COMMAND CODE

GU (HOSPITAL   ( HOSPNAME = Mac Neal )
GNP WARD
GET A WARD KEY FROM PCB AND STORE IN WARD SSA
GNP WARD (WARDNO = WORDKEY)
PATIENT

LOOP BACK TO STEP 4 UNTIL A GE STATUS CODE

In the above example you have to get the key value of the ward segment out of the PCB every time Step 2 of the procedure is executed. Store the key value into the qualified SSA in Step 4 before starting the loop that retrieves the Patient segments. This keeps the GNP calls within the same domain in the database.

GE status code is returned by DL/I after you run out of Patient segments for each Ward, just as though you had established parentage at the Ward Level for getting the necessary Control Breaks.

WITH U COMMAND CODE

GU HOSPITAL (HOSPNAME = Mac Neal )
GNP WARD
GNP WARD * U
PATIENT

LOOP BACK TO STEP 3 UNTIL A GE STATUS CODE

In the above example coding a U command code in an unqualified SSA has the same effect as using a qualified SSA at that level. Using U command code at the ward level tells DL/I to maintain the current position established on the ward segment level.

WITH V COMMAND CODE

GNP    WARD * U

PATIENT * U

SYMPTOM

(OR)

GNP    PATIENT * V

SYMPTOM

In the above example, V command code causes DL/I to act as though U command code were set at that level, and at all the levels above it. The two sets of SSA’S are functionally the same. The command saves the trouble of coding U command codes in SSA’S at each higher level.

P COMMAND CODE

P command code allows the parentage to be set at any levels in the database other than the one identified by the last SSA Code the P command code in the SSA for the segment at which you would like the parentage established and DL/I will still retrieve the segment identified by the last SSA, but sets parentage where you set the P command code.
The parentage will be destroyed when another GU or GN call is executed.

WITH OUT P COMMAND CODE

GU HOSPITAL    (HOSPNAME = Mac Neal )
WARD            (WARDNO     = 08 )

GNP PATIENT
PRINT A PATIENT SEGMENT
LOOP BACK TO STEP 2 UNTIL A GE STATUS CODE

WITH P COMMAND CODE

GU      HOSPITAL    (HOSPNAME = Mac Neal )
WARD            * P (WARDNO = 08 )

PATIENT

PRINT A PATIENT SEGMENT
GNP PATIENT
LOOP BACK TO STEP 2 UNTIL A GE STATUS CODE

By using a P command code, you saved one call by retrieving the first patient segment in the Get Unique call itself and setting the parentage at the ward level.

NULL COMMAND CODE

The NULL command code ‘___ ‘ is used in the SSA to simplify the construction of SSA within the program and does not perform any function at all.

The SSA is treated as if no command code were coded. The null command code ‘__’ reserves one or more positions in a SSA into which you can store command codes during the program execution. This way making it possible to use the same set of SSA’S for more than one purpose.
HOSPITAL *——- (HOSPAME = Mac Neal )

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.