Task: The IMAGE dataset GL-TRANSACTIONS contains field GL-ACCOUNT. We would like to add the field GL-ACCOUNT-TYPE to the target SQL table. The value of GL-ACCOUNT-TYPE is determined programatically, during extraction, based on the value of GL-account.
Step1: In user exit one, TIPSConvertTableLayout, add new field GL-TYPE to the end of the table, as follows:
ENTRY “TIPSConvertTableLayout” USING LNK-IMAGE-SETNAME.
IF LNK-IMAGE-SETNAME = “GL-TRANSACTIONS”
* Set up name, type and length of new field
MOVE ‘GLA-ACCOUNT-TYPE’ TO FIELD-NAME OF FIELD-ATTRIBUTES
MOVE ‘X’ TO FIELD-TYPE OF FIELD-ATTRIBUTES
MOVE 20 TO FIELD-LENGTH OF FIELD-ATTRIBUTES
CALL “TIPSInsertField” USING FIELD-ATTRIBUTES
END-IF.
Step 2: In user exit two, TIPSConvertRecord, set the value of GLA-ACCOUNT-TYPE, based on the value GLA-ACCOUNT, by invoking paragraph B300-DETERMINE-ACCOUNT-TYPE. This paragraph would typically contain logic you already use in your HP3000 application. For example, the account type may be looked up in another data structure, hard-coded with a case statement, etc.
ENTRY “TIPSConvertRecord” USING LNK-IMAGE-SETNAME.
IF LNK-IMAGE-SETNAME = “GL-TRANSACTIONS”
* Get value of GLA-ACCOUNT field from this record
MOVE ‘GLA-ACCOUNT’ TO WS-FIELD-NAME
CALL “TIPSGetFieldValue” USING WS-FIELD-NAME, HOLD-GLA-ACCOUNT
PERFORM B3000-DETERMINE-ACCOUNT-TYPE
MOVE ‘GLA-ACCOUNT-TYPE’ TO WS-FIELD-NAME
CALL”TIPSPutFieldValue” USING WS-FIELD-NAME, HOLD-GLA-ACCOUNT-TYPE
END-IF.
GOBACK.
B-300-DETERMINE-ACCOUNT-TYPE.
* Input: HOLD-GLA-ACCOUNT
* Output: HOLD-GLA-ACCOUNT-TYPE
*
*
Determines value of GLA-ACCOUNT-TYPE, by looking up account
*
in KSAM file, using HOLD-GLA-ACCOUNT as key
*
If not found, set to SALES if first character of account number is 5,
*
Otherwise, set to UNKNOWN
MOVE SPACES TO HOLD-GLA-ACCOUNT-TYPE.
PERFORM B350-READ-KSAM.
IF KSAM-NOTFOUND
IF HOLD-GLA-ACCOUNT (1:1) =”5″
MOVE “SALES” TO HOLD-GLA-ACCOUNT-TYPE
ELSE
MOVE “UNKNOWN” TO HOLD-GLA-ACCOUNT-TYPE
END-IF
END-IF.