2018 Jul 06 7:10 AM
Hello, I'm using call transformation to convert xml to abap structure.
call transformation demo_id_upper_lower "id
parameters mode = 'UP'
source xml asxml_str
result paymentrequest = abap_out.
This works as expected and the data is mapped to abap structure successfully. 'paymentrequest' being the root tag here. Is there a way to specify a variable containing the tag name instead of the tag directly in the result.
Eg. data(my_var) = 'paymentrequest'.
call transformation demo_id_upper_lower "id
parameters mode = 'UP'
source xml asxml_str
result my_var = abap_out.
In this case there's no exception as such but then there's no conversion(I think it tries to find 'my_var'). I'm trying to encapsulate the conversion in a method/fm, hence the requirement.
Note: I have also tried assigning the element name to a field symbol. But that too didn't work.
2018 Jul 06 9:43 AM
Lets try this:
DATA MAPP TYPE ABAP_TRANS_RESBIND_TAB.
MAPP = VALUE #( ( NAME = 'PAYMENTREQUEST' VALUE = REF #( abap_out ) ) ).
CALL TRANSFORMATION ID SOURCE XML l_xml
RESULT (MAPP) .
2018 Jul 06 9:43 AM
Lets try this:
DATA MAPP TYPE ABAP_TRANS_RESBIND_TAB.
MAPP = VALUE #( ( NAME = 'PAYMENTREQUEST' VALUE = REF #( abap_out ) ) ).
CALL TRANSFORMATION ID SOURCE XML l_xml
RESULT (MAPP) .
2018 Jul 09 4:55 AM
Excellent. Thanks a lot. Exactly what I was looking for.
data(result_tab) = value abap_trans_resbind_tab( ( name = root value = ref #( abap_out ) ) ).
call transformation demo_id_upper_lower "id
parameters mode = 'UP'
source xml asxml_str
result (result_tab).
if result_tab is not initial.
read table result_tab into data(result_wa) index 1.
if sy-subrc = 0.
assign result_wa-value->* to field-symbol(<abap_out>).
if <abap_out> is assigned.
abap_out = <abap_out>.
endif.
endif.
endif.