Question & Answer
Question
How is an IMS segment with 3 levels down mapped?
Answer
The pure relational approach would be to map 3 tables:
Table 1: Map A by itself with all fields in the segment.
Table 2: Map A+B with only the key from A and all fields from B.
Table 3: Map A+B+C with only key fields from A and B, and all fields from C.
If mapping a single table with all fields from all segments, the result of a query against that table is essentially an inner join of the 3 tables described above without actually having to perform a join.
The bottom line is that your specific needs should drive how you map the data. If your needs are more generic in nature, then the pure relational approach is probably the best way to go. Note that this general approach can be more expensive if joins are performed.
Here are steps for CDA and mapping 3 segements.
When mapping an IMS table in the CDA using the mapping wizard, if the leaf segment is set to a third level segment (Figure 1 below), the 'MAP IMS SEGMENT' window will appear once for each segment in the hierarchy. For each segment, a separate copybook can be selected and the required
columns can be selected to map into the table. Figure 2 below shows the first appearance of the window and we have selected only the root key for mapping.
Here is the generated DDL for a 3 level mapping, with the first 3 columns in highlighted in blue showing they come from 3 different segments.
Generated DDL for 3 level mapping
Generated DDL for 3 level mapping
--<ScriptOptions statementTerminator=";"/>
CREATE TABLE "IMS"."L3KKEYED" DBTYPE IMS "L3FPDB00"
"L3KKEYED"
(
"IOA_ROOT_KEY" SOURCE DEFINITION
ENTRY "L1ROOT"
DATAMAP OFFSET 2 LENGTH 9
DATATYPE C
USE AS CHAR(9),
"IOA_L2SEG_KEY" SOURCE DEFINITION
ENTRY "L2KEYED"
DATAMAP OFFSET 2 LENGTH 9
DATATYPE C
USE AS CHAR(9),
"IOA_L3SEG_KEY" SOURCE DEFINITION
ENTRY "L3KKEYED"
DATAMAP OFFSET 2 LENGTH 9
DATATYPE C
USE AS CHAR(9),
"IOA_TIME_OF_DAY" SOURCE DEFINITION
ENTRY "L3KKEYED"
DATAMAP OFFSET 11 LENGTH 21
DATATYPE C
USE AS CHAR(21),
"IOA_UPDATE_COUNT" SOURCE DEFINITION
ENTRY "L3KKEYED"
DATAMAP OFFSET 32 LENGTH 8
DATATYPE UP
USE AS DECIMAL(15 , 0),
"IOA_GUID" SOURCE DEFINITION
ENTRY "L3KKEYED"
DATAMAP OFFSET 40 LENGTH 8
DATATYPE C
USE AS CHAR(8),
"IOA_PLUGIN" SOURCE DEFINITION
ENTRY "L3KKEYED"
DATAMAP OFFSET 48 LENGTH 8
DATATYPE C
USE AS CHAR(8));
In CDA....
Figure 1 - Selecting a third level segment to map
Figure 2 - Mapping the key-only for the root segment
**Note: This window will appear 3 times (once for each segment in the hierarchy)

Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21974110