cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to map with multiple fields of a BAPI

Former Member
0 Kudos

Hi All,

My scenario is like this:

I have the external defintion structure containing the node which will have the set of fields selected in its external format as shown below:-

<records>

<acc_no>123</acc_no>

<comp_code>450</comp_code>

</records>

I need to serach for the field name and then map it to the corresponding field of the BAPI.

i,e my UDF should return multiple outputs which will be assigned to my BAPI interface.

Can this be done through UDF or is there any other better way of getting things done.

Please advise.

Thanks in advance,

Sai

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sai,

What is the source and target structure?

If your input is xml and you need to search for a specific field, you can write an UDF.

Can you provide some more details

Best Regards,

Lakshmi

Former Member
0 Kudos

HI Lakshmi,

Yes my source is in XML format.

My XML structure looks like this:

<records>

<fields>

</records>

The <fields> node gets replaced with the fields that i select. lets say i select account no ; comp code and plant

and the no. of entries that satisfies the select query be 2 then,

At run time the structure will look some thing similar to this :-

<records>

<acc_no>123</acc_no>

<comp_code>450</comp_code>

<plant>10</plant>

</records>

<records>

<acc_no>456</acc_no>

<comp_code>230</comp_code>

<plant>10</plant>

</records>

As we can see above the records tag gets repeated as many no of times the rows selected and the 'fields' tag gets replaced by the fields that i select.

Now, I need to search for each field name and then map their values to the corresponding fields of BAPI which will have the Acc_no, Comp_code and plant fields in it.

Thanks,

Sai

former_member200962
Active Contributor
0 Kudos

Why you need a UDF? If I am not wrong you just need to do a 1:1 mapping from source field to coresponding target field...is there any other complexity involved?

Former Member
0 Kudos

Hi Abhishek,

The <fields> gets replaced with my selected fields only at runtime.

In other words my <fields> will have those acc no;compcode and plant details in it.

So, i need to search for these fieldnames and then map it to my corresponding BAPI structure.

Thanks,

Sai

former_member200962
Active Contributor
0 Kudos
At run time the structure will look some thing similar to this :-
<records>
<acc_no>123</acc_no>
<comp_code>450</comp_code>
<plant>10</plant>
</records>
<records>
<acc_no>456</acc_no>
<comp_code>230</comp_code>
<plant>10</plant>
</records>

When the above is the actual payload structure that you will be getting, why have this as structure:

My XML structure looks like this:
<records>
<fields>
</records>

Why not have the runtime structure itself defined in IR (as DT) or is there any restriction on it?

Former Member
0 Kudos

Hi Abhishek,

I tried creating the structure but the problem here is the structure created does not seem to be compatible to the XML data passed in to this. More over we have similar scenarios where in i will have to build structures for differnt XML data which has the similar kind of mapping to be done. Hence if i go for an UDF i can make use of the same of all the scenarios.

Is it possible to achieve this through an UDF.

Thanks,

Sai

Former Member
0 Kudos

Sai,

I don't think you can accomplish this using the grapical mapping, since you only have those fields available that are specified in the message type.

In order to meet your requirements, I think you will need a Java or ABAP mapping.

Regards,

Koen