cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle multiple source fields in message mapping

Former Member
0 Kudos

Hi,

My source message has the following structure for my source field:



<ParentSegment>
  <DAT01></DAT01>
  <DAT02></DAT02>
  <DAT03></DAT03>
  ...
  <DAT24></DAT24>
  <DAT25></DAT25>
</ParentSegment>

I need to check each of the DAT fields starting from field 1 to field 25 for the first field that contains a value and then map that field value to a single target field. I know this can be done using the available functions in the graphical mapping to check each field one at a time and map the field that contains a value. However, I wanted to know if there is a better way of doing it such as iterating over the total number of fields and accessing each of the field dynamically to determine which contains a value? If this is possible, can you please show me how this can be done?

Thanks in advance for any help.

Regards,

Elbert

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Elbert,

This can be done using both graphical mapping and udf... instead of checking each of the node for existence you can try using this mapping:



<DAT01> --> mapWithDefault: --> concat:  --> concat: --> concat: --> trim --> UDF --> copyValue[0] --> Target Field
<DAT02> --> mapWithDefault: --> /                        
<DAT03> --> mapWithDefault: -----------------> /
.
.
<DAT25> --> mapWithDefault: -------------------------------> /

please take note that there is a space for mapWithDefault and concat, This ensures that succeeding fields with values does not get concatted into a single word. The UDF stated here is a splitter, after the trim, 

hope this helps,

Former Member
0 Kudos

Thanks Mark for your suggestion! Points has been awarded.

For the others, thanks for your reply.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Elbert,

>starting from field 1 to field 25 for the first field that contains a value and then map that field value to a single target field

Can you give an example. Your questions is not complete. From field1 to field25 if you say you are looking for a value HI and lets say you have that value in field12 and field16 then do you want to take it from field12 and ignore the other one? or are we trying to see the first character value of the field?

Anyways in either cases you can go with a grapical mapping. You can also come up with a User defined funciton, but here also you have to check individual fields. If you can tell what you want exactly then somebody can help you out with UDF or graphcial mapping?

Regards,

---Satish

former_member750652
Contributor
0 Kudos

Hi Elbert,

You can acheive this by using the combination of both (Available functions and UDF) writing Java code iwich will check the value nside the UDF (of type Context) and map this to the target field.

<ParentSegment> -


> Removecontext -


>UDF(to chek the values) -


> target field.

Thanks,

Ram..