cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding Match transformation python code error

venkataramana_paidi
Contributor
0 Kudos

Hi,

i build the flow for post the maximum value from match group to master record based on SAP NOTES 1458289

here the script i wriiten in the python editor of match transformation.

1. Always perform the best record action

RET.SetBuffer( SRC.GetBuffer('MAX_VALUE') )

1. If a record has an empty value in the field being operated on, treat the value

2. as zero; do not issue an error

def getValue(Amount):

try:

temp = float(Amount)

except:

temp = 0

return temp

1. Source represents all but the first record in each data collection

2. The Match output tab must include the Group_Order field.

3. Set the field name in the Python syntax here to the same name created in output tab.

SOURCE_GROUP_ORDER = int(SRC.GetField(u'Set1_NEW_LEVEL_GRP_STATS_GROUP_ORDER'))

SOURCE_VALUE = getValue(SRC.GetField(u'Amount'))

1. Represents the field containing the values in the first record

MASTER_RECORD_VALUE = getValue(DST.GetField(u'Amount'))

1. Represents the new field in the first record, the field that will contain the maximum

DESTINATION = getValue(DST.GetField(u'Max_value'))

1. For the first post (from the second record in the collection to the first),

#    compare the 2 values and place the largest in the new field

1. For all subsequent posts (third to first, fourth to first, etc.),

#    compare the new value and the previous maximum, and place the largest

#    in the new field

if SOURCE_GROUP_ORDER == 2:

RET.SetBuffer(unicode(str(max(SOURCE_VALUE, MASTER_RECORD_VALUE))))

else:

RET.SetBuffer(unicode(str(max(SOURCE_VALUE, DESTINATION))))

1. delete temporary variables

del SOURCE_GROUP_ORDER

del SOURCE_VALUE

del MASTER_RECORD_VALUE

del DESTINATION

but i am getting the error like this .

6976 8032 DQX-058306 7/23/2010 6:31:09 PM |Data flow DF_MATCH_TEST|Transform Base_Match

6976 8032 DQX-058306 7/23/2010 6:31:09 PM Transform . More detailed

6680 5228 DQX-058302 7/23/2010 6:31:19 PM information may be obtained from previous errors.

please help me out how to solve this problem .

Thanks&Regards.

Ramana

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

It looks to me like the error message

Transform Base_Match 6976 8032 DQX-058306 7/23/2010 6:31:09 PM Transform : 'return' outside function.

is indicating that the "return" statement in your getValue() function is not at the same indent level as the other statements in the function?