Using Transformation PeopleCode
This section provides sample code delivered with your PeopleSoft product and discusses how to use transformation PeopleCode.
Note: If you need to create your own package and class, ensure that they adhere to the same format as shown here.
The FUNCLIB object must be imported and your methods must take this object as its only parameter. The HashTable class is a utility providing some of the internal information that you need to code your PeopleCode transformation. PeopleSoft Data Transformer creates a temporary table at runtime to store the fields from your source data object and from which you can access your PeopleCode transformation. In addition, the name of this temporary table is dynamically assigned and cannot be hard-coded into your program. For these reasons, PeopleSoft delivers helper methods for you to access and modify the content of your data:
GetSourceFieldList() method returns a HashTable object containing a name-value pair for accessing your Source Data Object fields.
GetTransformFieldList() method returns a HashTable object containing a name-value pair for accessing target fields that have transformations associated with them.
GetTempTableName() returns the name of the temporary table that is used by PeopleSoft Data Transformer.
Sample PeopleCode Transformation
The following example updates the EOEC_CCI_UNITPRICE field on the target with a value of the source data object PROD_PRICE field plus a constant of 100, by issuing an UPDATE statement on the PeopleSoft Data Transformer temporary table.
Because the target field, EOEC_CCI_UNITPRICE, has an associated transformation, the actual name on the temporary table is resolved with a GetValue(EOEC_CCI_UNIT_PRICE) call on the transformation field's hash table. Similarly, the PROD_PRICE source data object field is resolved by making a GetValue(PROD_PRICE) call on the source field's hash table.
import EOEW_ETLAPI:COMMON:FUNCLIB; import EOEW_ETLAPI:COMMON:HashTable; class PeopleCodeTransformation method SET_UNIT_PRICE(&COMM As FUNCLIB); method MY_OTHER_PCODE_TRANS(&COMM As FUNCLIB); end-class; method SET_UNIT_PRICE /+ &COMM as EOEW_ETLAPI:COMMON:FUNCLIB +/ Local HashTable &SDOFields, &TranFields; Local string &SQLStatement; /* Retrieve the hashtable containing ALIASNAME->TEMPFIELDNAME value pair */ &SDOFields = &COMM.GetSourceFieldList(); &TranFields = &COMM.GetTransformFieldList(); /* Update the EOEW_CCI_UNITPRICE to: SDO.PROD_PRICE + SomeNumber This would resolve into something like: UPDATE ETL_TEMP_TBL SET ETL_TEMP_1 = EOEW_FP_N3_0 + 100 */ &SQLStatement = "UPDATE " | &COMM.GetTempTableName() | " SET " | &TranFields.GetValue("EOEC_CCI_UNITPRICE") | " = " | &SDOFields.GetValue("PROD_PRICE") | " + 100"; SQLExec(&SQLStatement); end-method; method MY_OTHER_PCODE_TRANS . . . end-method;