Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 4 Defining Import Tables for Files with Multiple Record Formats : Second Sample File – Inventory

Second Sample File – Inventory
Types of Records in File
This Inventory System sample has a transaction file with several record types. Each record is of a specific format (A to D):

 
----+----1----+----2----+----3----+----4----+----5----+----6----+---
AWIDGET VENDOR WIDGET-001
AGLUE MAKER ADHESIVE-001
ABOARD MAKER BOARD-001
B0000100WIDGET-001
B0000010ADHESIVE-001
B0000500BOARD-001
C0000005WIDGET-001 BUILD-001
C0000002ADHESIVE-001 BUILD-001
C0000005BOARD-001 BUILD-001
D0000005PRODUCT-001

 
The record types are:
 
Table Definitions
Parent Table
The following example illustrates an import table definition for the header common to all the inventory records:

 
COMMAND==> TABLE DEFINITION

Table: INVENTORY Type: IMP Unit: USR40 IDgen: Y

File: USR40.INVENTORY.IMPORT
DDname: External Routine Name:
ServerID:

Parameter Name Typ Syn Len Dec Class Src ' Event Rule Typ Acc
---------------- - -- --- -- - - ' ---------------- - -
_ LOCATION I C 16 0 L ' _
_ ' _
-------- IMP --------|--------- Metadata Definition ------
Field Name Xsyn Xlen Xdec Offset Key Typ Syn Len Dec Ord Rqd Default
---------------- ---- ---- -- ----- - - -- ---- -- - - ----------
_ GENKEY B 4 0 0 P I B 4 0
_ RCDTYPE C 1 0 4 S C 1 0
_
_
_
_
_ PFKEYS:3=END 12=CANCEL 22=DELETE 13=PRT 14=FIELDS 6=OFFSET 21=DATA 2=DOC

 
Record Type A
The following example illustrates an import table definition for record type A:

 
COMMAND==> TABLE DEFINITION

Table: INV_SUPPLIER Type: IMP Unit: USR40 IDgen: Y

File: USR40.INVENTORY.IMPORT
DDname: External Routine Name:
ServerID:

Parameter Name Typ Syn Len Dec Class Src ' Event Rule Typ Acc
---------------- - -- --- -- - - ' ---------------- - -
_ GENKEY I B 4 0 D ' _
_ LOCATION I C 16 0 L ' _
-------- IMP --------|--------- Metadata Definition ------
Field Name Xsyn Xlen Xdec Offset Key Typ Syn Len Dec Ord Rqd Default
---------------- ---- ---- -- ----- - - -- ---- -- - - ----------
_ INV_SUP_KEY B 4 0 0 P I B 4 0
_ SUPPLIER_NAME C 30 0 4 S C 30 0
_ PART_NAME C 30 0 34 S C 30 0
_
_
 _
 _
 _
  PFKEYS: 3=END 12=CANCEL 22=DELETE 13=PRT 14=FIELDS 6=OFFSET 21=DATA 2=DOC

 
Record Type B
The following example illustrates an import table definition for record type B:

 
COMMAND==> TABLE DEFINITION

Table: INV_REC_PARTS Type: IMP Unit: USR40 IDgen: Y

File: USR40.INVENTORY.IMPORT
DDname: External Routine Name:
ServerID:

Parameter Name Typ Syn Len Dec Class Src ' Event Rule Typ Acc
---------------- - -- --- -- - - ' ---------------- - -
_ GENKEY I B 4 0 D ' _
_ LOCATION I C 16 0 L ' _
-------- IMP --------|--------- Metadata Definition ------
Field Name Xsyn Xlen Xdec Offset Key Typ Syn Len Dec Ord Rqd Default
---------------- ---- ---- -- ----- - - -- ---- -- - - ----------
_ INV_REC_PART_KEY B 4 0 0 P I B 4 0
_ QTY N 7 0 4 C B 4 0
_ PART C 30 0 11 S C 30 0
_
_
_
_

_ PFKEYS: 3=END 12=CANCEL 22=DELETE 13=PRT 14=FIELDS 6=OFFSET 21=DATA 2=DOC

 
Record Type C
The following example illustrates an import table definition for record type C:

 
COMMAND==> TABLE DEFINITION
 
Table: INV_WD_PARTS Type: IMP Unit: USR40 IDgen: Y
 
File: USR40.INVENTORY.IMPORT
DDname: External Routine Name:
ServerID:
 
Parameter Name Typ Syn Len Dec Class Src ' Event Rule Typ Acc
---------------- - -- --- -- - - ' ---------------- - -
_ GENKEY I B 4 0 D ' _
_ LOCATION I C 16 0 L ' _
-------- IMP --------|--------- Metadata Definition ------
Field Name Xsyn Xlen Xdec Offset Key Typ Syn Len Dec Ord Rqd Default
---------------- ---- ---- -- ----- - - -- ---- -- - - ----------
_ INV_WD_PART_KEY B 4 0 0 P I B 4 0
_ QTY_OUT N 7 0 4 C B 4 0
_ PART_OUT C 30 0 11 S C 30 0
_ COMPONENT_NAME C 30 0 41 S C 30 0
_
_
_
 
_ PFKEYS: 3=END 12=CANCEL 22=DELETE 13=PRT 14=FIELDS 6=OFFSET 21=DATA 2=DOC

 
Record Type D
The following example illustrates an import table definition for record type D:

 
COMMAND==> TABLE DEFINITION

Table: INV_ASSBLY Type: IMP Unit: USR40 IDgen: Y

File: USR40.INVENTORY.IMPORT
DDname: External Routine Name:
ServerID:

Parameter Name Typ Syn Len Dec Class Src ' Event Rule Typ Acc
---------------- - -- --- -- - - ' ---------------- - -
_ GENKEY I B 4 0 D ' _
_ LOCATION I C 16 0 L ' _
-------- IMP --------|--------- Metadata Definition ------
Field Name Xsyn Xlen Xdec Offset Key Typ Syn Len Dec Ord Rqd Default
---------------- ---- ---- -- ----- - - -- ---- -- - - ----------
_ INV_ASSBLY_KEY B 4 0 0 P I B 4 0
_ QTY_ASSBLY N 7 0 4 C B 4 0
_ PART_ASSBLY C 30 0 11 S C 30 0
_
_
_
_

_ PFKEYS: 3=END 12=CANCEL 22=DELETE 13=PRT 14=FIELDS 6=OFFSET 21=DATA 2=DOC

 
Processing
Programming Considerations
For the parent record, which defines the header, the table definition contains IDgen = Y, no parameters, and a B4 field at the beginning for the key.
For the child records, the table definition contains IDgen = Y, a parameter of the parent primary key, and a B4 field at the beginning for the key.
The offsets in both the parent and child record table definitions start at 0 for the IDgen key and continue at 4 for the first field from the external file.
Sample Rules

 
RULE EDITOR ===> SCROLL: P
READ_PARENT;
_
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ FORALL INVENTORY : | 1
_ CALL INVENTORY_PROC(INVENTORY.RCDTYPE, INVENTORY.GENKEY);|
_ END; |
_ |
_ ---------------------------------------------------------------------------

 
This is a portion of the called rule, which calls other rules for more detail processing:

 
RULE EDITOR ===> SCROLL: P
INVENTORY_PROC (RCD, KEY);
_
_ ---------------------------------------------------------------------------
_ RCD = ’A’ : | Y N N N N
_ RCD = ’B’ : | Y N N N
_ RCD = ’C’ : | Y N N
_ RCD = ’D’ : | Y N
_ ------------------------------------------------------------+--------------
_ CALL MSGLOG(’Record type ’ || QUOTE(RCD)); | 1 1 1 1 1
_ GET INV_SUPPLIER (KEY); | 2
_ CALL MSGLOG(’Supp: ’ || QUOTE(INV_SUPLIER.SUPPLIER_NAME)); | 3
_ CALL MSGLOG(’Part: ’ || QUOTE(INV_SUPLIER.PART_NAME)); | 4
_ CALL INV_SUPP_PART_PROC; | 5
_ GET INV_REC_PARTS (KEY); | 2
_ CALL MSGLOG(’Qty: ’ || QUOTE(INV_REC_PARTS.QTY)); | 3
_ CALL MSGLOG(’Part: ’ || QUOTE(INV_REC_PARTS.PART)); | 4
_ CALL INV_REC_PARTS_PROC; | 5
_ GET INV_WD_PARTS (KEY); | 2
_ CALL MSGLOG(’Qty: ’ || QUOTE(INV_WD_PARTS.QTY_OUT)); | 3
_ CALL MSGLOG(’Part: ’ || QUOTE(INV_WD_PARTS.PART_OUT)); | 4
_ CALL MSGLOG(’Comp: ’ || QUOTE(INV_WD_PARTS.COMPONENT_NAME));| 5
_ CALL INV_WD_PARTS_PROC; | 6
_ GET INV_ASSBLY (KEY); | 2
_ CALL MSGLOG(’Qty: ’ || QUOTE(INV_ASSBLY.QTY_ASSBLY)); | 3
_ CALL MSGLOG(’Assembly: ’ || QUOTE(INV_ASSBLY.PART_ASSBLY)); | 4
_ CALL INV_ASSBLY_PROC; | 5
_ SIGNAL UNEXPECTED_REC; | 2
_ ---------------------------------------------------------------------------
_

PFKEYS: 1=HELP 3=END 12=CANCEL 13=PRINT 14=EXPAND 2=DOCUMENT 22=DELETE

 
This is the output from this rule with the file shown under Types of Records in File:

 
--------------------------------------INFORMATION LOG -------------------------
COMMAND ===> SCROLL ===> P
Record Type 'A'
Supp.:'WIDGET VENDOR'
Part:'WIDGET-001'
Record Type 'A'
Supp.:'GLUE MAKER'
Part:'ADHESIVE-001'
Record Type 'A'
Supp:'BOARD MAKER'
Part:'BOARD-001'
Record Type 'B'
Qty:'0000100'
Part:'WIDGET-001'
Record Type 'B'
Qty:'0000010'
Part:'ADHESIVE-001'
Record Type 'B'
Qty:'0000500'
Part:'BOARD-001'
Record Type 'C'
Qty:'0000005'
Part:'WIDGET-001'
Comp:'BUILD-001'
Record Type 'C'
Qty:'0000002'
Part:'ADHESIVE-001'
Comp:'BUILD-001'
Record Type 'C'
Qty:'0000005'
Part:'BOARD-001'
Comp:'BUILD-001'
Record Type 'D'
Qty:'0000005'
Assembly ’PRODUCT-001’

PFKEYS: 2=NEXT LOG 3=EXIT 5=REPEAT FIND 12=EXIT 13=PRINT 9=RECALL

 

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved