Originally posted by: SystemAdmin
Think the last reply might have been from a DataStage perspective rather than DataStage TX.
There are two ways to utilize the
LAST capability in DSTX, in a Type Tree component rule or in a Map rule.
In a Type Tree component rule you create a group to contain the related rows. This has the advantage of the data being pre-parsed for you and being able to treat the related rows as a group (launch a functional map, reset a counter, etc.) and creates a control break on input.
File Group
--> Data Group (1:s)
------> SSN Group (1:s) Rule= SSN:$=SSN:$
LAST -----------> SSN (1:1)
-----------> Column2 (1:1)
-----------> etc.
If the data file contains multiple record types the coding changes a little as you may need to create a group that is made up of other groups and the placement of the
LAST rule affects processing. Can't remember what manual this is in but if you contact support and tell them you need documentation on the use of "control break logic" in Type Trees they may be able to assist.
In a Map you can also use
LAST, with a little different placement, to test the value of an element but it only works in reference to output objects built. (If you want a control break on the input, use the Type Tree.) It is important to note that the value you check is within the context of the data "object" you are working with. For example, if you are defining a rule on an output card and you are in a functional map you will only be testing the values of data objects built within a single iteration of that functional map. If you want to test if the SSN# is the same as the last one built you need to perform the test one level up before entering the functional map, or pass the value of the last SSN into the functional map as a parameter.
Output File
----> OutputRow (1:s)
---------> SSN (1:1)
---------> Column2 (1:1)
---------> etc.
The Map rule for "Row" could be:
1) IF (SSN:InputRow = SSN
LAST IN OutputRow, F_SameSSN(InputRow), F_NewSSN(InputRow))
2) F_EachRow(InputRow, SSN
LAST IN OutputRow)
Refer to the Function Reference for a discussion of the "IN" function. You might also want to check out the Ascential course L2-MC-605 "Advanced Transformation Techniques".
#DataExchange#IBM-Websphere-Transformation-Extender#IBMSterlingTransformationExtender