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


Chapter 3 Tools : $GETPACKED

$GETPACKED
Stores character data in packed decimal format. (F)
Invocation
result = $GETPACKED(string, offset, length)
 
The character string containing the number to be stored in packed decimal format. Its syntax can be C (fixed-length character string), V (variable-length character string), or W (double-byte character).
The offset from which to start converting the string. It must be greater than or equal to zero (0), and smaller than the length of the string.
Usage
Examples
Table SOURCE is an import table (IMP) mapped to an external file with a record length of 56. Each record of this external file contains numeric data in binary, packed, and floating point formats:

 
COMMAND ==> TABLE DEFINITION
Table: SOURCE Type: IMP Unit: USERID IDgen: N
File: userid.dataset
DDname: External Routine Name:
 
Parameter Name Type Syn Len Dec Class Src ' Event Rule Typ Acc
--------------- - - --- -- - ' ---------- - -
_ ' _
_ ' _
-----------IMP-----------|-------------MetaStor Definition-------
Field Name Xsyn Xlen Xdec Offset Key Typ Syn Len Dec Ord Rqd Default
------------- - --- -- ----- - - - --- - - - ------------
RECORD V 56 0 0 P S V 56 0
_
_
_

 
Table TARGET is a TDS table to which this external data is to be copied:

 
COMMAND ==> TABLE DEFINITION
Table: TARGET Type: TDS Unit: USERID IDgen: Y
Parameter Name Type Syn Len Dec Class ' Event Rule Typ Acc
--------------- - - --- -- - ' ---------- - -
_ ' _
_ ' _
Field Name Type Syn Len Dec Key Ord Rqd Default Reference
------------- - - --- -- - - - ------------------ ---------------
KEY 1 B 4 0 P
BIN1 C B 4 0
BIN2 C B 4 0
PACK1 Q P 5 0
PACK2 Q P 8 0
PACK3 Q P 3 0
FLOAT1 Q F 8 0
FLOAT2 Q F 8 0
FLOAT3 Q F 16 0

 
The following rule uses $GETPACKED to copy packed decimal values from an external file to an TIBCO Object Service Broker table:

 
COPYNUMDATA;
_
_ ------------------------------------------------------------------------
_ ------------------------------------------------------------+-----------
_ FORALL SOURCE: | 1
_ TARGET.BIN1=$GETBINARY(SOURCE.RECORD,0,4); |
_ TARGET.BIN2=$GETBINARY(SOURCE.RECORD,4,4); |
_ TARGET.PACK1=$GETPACKED(SOURCE.RECORD,8,5); |
_ TARGET.PACK2=$GETPACKED(SOURCE.RECORD,13,8); |
_ TARGET.PACK3=$GETPACKED(SOURCE.RECORD,21,3); |
_ TARGET.FLOAT1=$GETFLOAT(SOURCE.RECORD,24,8); |
_ TARGET.FLOAT2=$GETFLOAT(SOURCE.RECORD,32,8); |
_ TARGET.FLOAT3=$GETFLOAT(SOURCE.RECORD,40,16); |
_ INSERT TARGET; |
_ END; |
_ ------------------------------------------------------------------------

 

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