Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Simple example of a simple transformation?

paul_bakker2
Active Contributor
0 Kudos

Hi,

I'm trying to understand how 'simple transformations' work, but I'm struggling a bit.

I would like to convert a very simple ABAP structure (header, item, trailer) into an XML string.

I have the following ABAP code:

REPORT  ZTMP_FILE_TEST.

types: begin of ty_req_file,
         header type string,
         item type string,
         trailer type string,
       end of ty_req_file.

data: ls_file type ty_req_file.

DATA ls_xml type string.

ls_file-header = 'MyHeader'.
ls_file-item = 'MyItem'.
ls_file-trailer = 'MyTrailer'.

CALL TRANSFORMATION ZFILE_TEST1
SOURCE FILE = ls_file
RESULT XML ls_xml.

break-point.

write: / ls_xml.

===============================================

Can someone please provide me with simple 'transformation' code that would handle the above?

I get nothing but obscure shortdumps...

thanks

Paul

1 ACCEPTED SOLUTION

arindam_m
Active Contributor
0 Kudos

Hi,

Have you checked the TRANSFORMATION ID for this. Check the link below might be helpful.

http://help.sap.com/abapdocu_702/en/abenst_table_abexa.htm

Cheers,

Arindam

5 REPLIES 5

arindam_m
Active Contributor
0 Kudos

Hi,

Have you checked the TRANSFORMATION ID for this. Check the link below might be helpful.

http://help.sap.com/abapdocu_702/en/abenst_table_abexa.htm

Cheers,

Arindam

custodio_deoliveira
Active Contributor
0 Kudos

Hi Paul,

Unless you have created a transformation called ZFILE_TEST1, you should chjange your code to:

CALL TRANSFORMATION id

      SOURCE file = ls_file

      RESULT XML ls_xml.

cheers,

Custodio

@zcust01

0 Kudos

Hi,

To my great surprise ,when I subsituted 'id' like you suggested, it worked! I see that it is some kind of default transformation program provided by SAP

But I still need to find out how to write a transformation myself.(to handle more complex scenarios). Or is it possible to generate them from a given structure?

I did attempt to create a transformation called ZFILE_TEST1, but it seems to be incorrect. I'm not surprised because I don't really understand how it works

thanks

Paul

 

<?sap.transform simple?>

<tt:transform template="test1"

xmlns:tt="http://www.sap.com/transformation-templates">

<tt:root name="FILE"/>

<tt:template name="test1">

<header>

  <tt:value ref="FILE"/>

</header>

<item>

  <tt:value ref="FILE"/>

</item>

<trailer>

  <tt:value ref="FILE"/>

</trailer>

</tt:template>

</tt:transform>

0 Kudos

We are in the same boat, I don't know how it works either. Always use the default transformation. good luck with that!