Command codes in an SSA make the call powerful since DL/I treats such SSA differently from those without the command codes while performing some special functions.
IMS DB SSA Command Codes
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 an 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.
IMS DB Command codes
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
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 a first occurrence in the segment type which has a 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 COMMAND 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 inserts the segment occurrence as the last occurrence in the segment type which has a 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 the 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 as 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 the 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 the D command code in the higher-level SSAs 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 the 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 replacement 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 with the N command code is an exception to the rule that qualified SSA 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 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 THE 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 higher level SSA’S will also place the additional segment in the 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 THE C COMMAND CODE
GU HOSPITAL (HOSPNAME = RIVEREDGE )
WARD (WARDNO = 02 )
PATIENT (BEDIDENT = 0003 )
DOCTOR (DOCTNAME = KILLER )
WITH THE 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 a 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 the 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 the 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 IT 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 the 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, the V command code causes DL/I to act as though the U command code were set at that level, and at all the levels above it.
The two sets of SSA are functionally the same. The command saves the trouble of coding U command codes in SSA 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.
Without 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 an SSA into which you can store command codes during the program execution.
This way makes it possible to use the same set of SSA for more than one purpose.
HOSPITAL *——- (HOSPAME = Mac Neal )
Related Posts