Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 5 Manipulating Import Data Using TIBCO Object Service Broker : External Routines (Pre-processing the Data)

External Routines (Pre-processing the Data)
Manipulating Data with External Routines (z/OS Only)
When accessing an external data set through an import table in z/OS, you can write an external routine to manipulate the data. The external routine must be written in assembler and can:
You can concatenate the library in the CLIST that you use to log in to TIBCO Object Service Broker or if you are importing the data in batch, you can concatenate the library in the batch JCL DD statement HRNEXTR.
Parameters Passed to the External Routine
To write an external routine, use the IMPXPARM macro found in the MACRO data set distributed with TIBCO Object Service Broker to describe the DSECT of the parameters that are passed to the external routine.
Represents the record length. If the record length is changed by the external routine, the server uses the changed length for input or output. HRNXRLEN is set to zero upon entry to the import external routine when the end of the file is reached. You can use this to insert additional records into TIBCO Object Service Broker.
Points to the I/O record buffer. If the buffer pointer is changed by the external routine, the server uses the new buffer for input or output. Do not change the data in this buffer.
A 4 KB work area that is preserved between calls to the external routine. It is cleared to X’00’ at the start of the FORALL.
A 4 KB work area that is not preserved between calls to the external routine. It is also not cleared before the external routine call. It can be used as the work area where you compose the record to be inserted.
Valid Return Codes
At the end of the external routine, Register 15 contains a return code that indicates the action the server should take. The valid return codes whose description follows are located in the IMPXPARM macro.
Do not call the external routine again for this transaction. No more physical records are read or written and the external routine is not called again for this transaction. For an import table, end of file is indicated when HRNXRLEN is zero and you should return @HRNXDON to prevent its external routine from being called again.
A new record is to be inserted. The external routine must set HRNXRECA to the address of the new record and HRNXRLEN to the length of the new record.
Example of an Exit
The following is a simple example of an external routine. A file is being imported but only records having a length of 32 are imported; other records are ignored.

 
COPY EQUATES STANDARD EQUATES.
COPY IMPXPARM EXIT PARAMETERS.
IMPEXIT CSECT
SAVE (14,12),,* SAVE THEM ... STANDARD LINKAGE
USING IMPEXIT,R12 R12 ...
LR R12,R15 BASE REGISTER
USING HRNXPARM,R1 ADDR CALLING PARMS.
L R2,HRNXRLEN R2 = RECORD LENGTH
LTR R2,R2 IS IT A NORMAL RECORD?
BNZ NORMAL YES
*----------------------------------------------------------------------
* WE’VE BEEN CALLED AT THE END OF ALL NORMAL RECORDS. *
*----------------------------------------------------------------------
LA R15,@HRNXDON RC = DON’T CALL ANY MORE
B RETURN RETURN
*----------------------------------------------------------------------
* IGNORE INPUT RECORDS THAT HAVE LENGTHS NOT EQUAL TO 32. *
*----------------------------------------------------------------------
NORMAL LA R15,@HRNXKEP SET ’KEEP’ RC.
C R2,=F’32’ GET VARIABLE STRING LENGTH
BE RETURN RETURN.
LA R15,@HRNXDEL SET ’IGNORE’ RC.
RETURN DS 0H
RETURN (14,12),,RC=(15)
LTORG
END

 
Example of an Exit that Normalizes Data
The following example illustrates a more complex example of an external routine. All records in the data set to be imported begin with a fixed portion but then have a repeating portion on the same record. The number of occurrences of the repeating portion is stored in two bytes after the fixed portion. For a table to describe the data presented to it, the external routine attaches the fixed portion to the beginning of each repeating portion in the same record and each becomes an occurrence in the table.

 
COPY EQUATES STANDARD EQUATES.
COPY IMPXPARM EXIT PARAMETERS.
EJECT
WORKA DSECT
VARPOINT DS F
TIMEFLAG DS CL1
OCCURS DS PL2
FIXEDDTA DS CL20
VARDTA DS CL40
IMPEXIT CSECT
SAVE (14,12),,* SAVE THEM ... STANDARD LINKAGE
USING IMPEXIT,R12 R12 ...
LR R12,R15 BASE REGISTER
USING HRNXPARM,R1 ADDR CALLING PARMS.
L R2,HRNXWRKA R2 = WORK AREA
USING WORKA,R2
CLI TIMEFLAG,X’01’ SECOND TIME FOR THIS RECORD?
BE SECOND SECOND TIME FOR THIS RECORD
L R7,HRNXRLEN R7 = RECORD LENGTH
LTR R7,R7 IS IT A NORMAL RECORD?
BNZ NORMAL YES
*----------------------------------------------------------------------
* WE’VE BEEN CALLED AT THE END OF ALL NORMAL RECORDS. *
*----------------------------------------------------------------------
LA R15,@HRNXDON RC = DON’T CALL ANY MORE
B RETURN RETURN
*----------------------------------------------------------------------
* BUILD FIRST OCCURRENCE FROM VARIABLE OCCURRENCE RECORD *
*----------------------------------------------------------------------
NORMAL LA R15,@HRNXINS SET ’INSERT’ RC.
L R4,HRNXRECA GET ADDRESS OF RECORD
MVC OCCURS,20(R4) GET NUMBER OF VARIABLE OCCURS
CP OCCURS,=P’0’ COMPARE NUMBER OF OCCURS TO ZERO
BE IGNORE IGNORE THIS RECORD
SP OCCURS,=P’1’ SUBTRACT ONE OCCURANCE FROM COUNTER
MVI TIMEFLAG,X’01’ SET FLAG FOR SECOND TIME PROCESS
L R8,=F’60’ R8 = NEW RECORD LENGTH
ST R8,HRNXRLEN SAVE NEW RECORD LENGTH
MVC FIXEDDTA,0(R4) MOVE FIXED PART OF RECORD
LA R4,22(R4) INCREMENT R4 TO FIRST OCCUR
MVC VARDTA,0(R4) FIRST VARIABLE PART OF RECORD


ST R4,VARPOINT SAVE THE VARIABLE POINTER
LA R8,FIXEDDTA GET THE ADDRESS OF THE FIXED PART
ST R8,HRNXRECA SAVE POINTER TO RECORD
B RETURN
*----------------------------------------------------------------------
* BUILD SUBSEQUENT OCCURRENCE FROM VARIABLE OCCURRENCE RECORD *
*----------------------------------------------------------------------
SECOND CP OCCURS,=P’0’ COMPARE REMAINING OCCURS TO ZERO
BE IGNORE YES IGNORE IT.
SP OCCURS,=P’1’ SUBTRACT ONE OCCURANCE FROM COUNTER
LA R15,@HRNXINS SET ’INSERT’ RC.
L R8,=F’60’ R8 = NEW RECORD LENGTH
ST R8,HRNXRLEN SAVE NEW RECORD LENGTH
L R4,VARPOINT R4 = VARIABLE DATA POINTER
LA R4,40(R4) INCREMENT R4 TO NEXT OCCUR
MVC VARDTA,0(R4) NEXT VARIABLE PART OF RECORD
ST R4,VARPOINT SAVE THE VARIABLE POINTER
LA R8,FIXEDDTA GET THE ADDRESS OF THE FIXED PART
ST R8,HRNXRECA SAVE POINTER TO RECORD
B RETURN
*----------------------------------------------------------------------
* IGNORE THE CURRENT RECORD AND SETUP FOR FIRST TIME PROCESS *
*----------------------------------------------------------------------
IGNORE LA R15,@HRNXDEL SET ’DELETE’ RC.
MVI TIMEFLAG,X’00’ SET FLAG FOR FIRST TIME PROCESS
RETURN DS 0H
RETURN (14,12),,RC=(15)
LTORG
END

 

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved