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: 

How to Create a Simple Transformation code Programatically

Former Member
0 Kudos
490

I have a requirement to convert an input xml string into a complex ABAP structure. I am thinking of using Simple Transformation (ST).

I want to find out if there is any program / function module which can "generate" the transformation code (ST program) by giving the ABAP structure name (ie, the SE11 name of the ABAP structure). That would save a lot of effort. Any ideas?

thanks

1 ACCEPTED SOLUTION

athavanraja
Active Contributor
0 Kudos
161

there is no standard FM/program to generate the ST code.

you have to manually create the ST code.

you can check out the following weblog for creating ST programs. (its a six part series)

/people/tobias.trapp/blog/2005/05/04/xml-processing-in-abap-part-1

Regards

Raja

17 REPLIES 17

Former Member
0 Kudos
161

not sure if it can help u , u can have it as a reference

http://www.geocities.com/victorav15/sapr3/examples/xml1.txt

0 Kudos
161

sorry, this is talking about SDIXML function modules. My question is specifically about generating ST transformation code.

Former Member
0 Kudos
161

What about using iXML?!

0 Kudos
161

yes, in fact I have tried a lot to get SDIXML_XML_TO_DOM & DOM_TO_DATA work together succcessfully to convert xml to ABAP data (ie, in 2 steps - 1. xml-to-dom & then 2. dom-to-data)....BUT..it does not work..in spite of all the hype about netweaver 6.40 etc etc..

0 Kudos
161

Hi,

check this thread..

it may help you..

regards

vijay

0 Kudos
161

no, no, no ... when saying iXML i mean making use of the IF_IXML_... classes / interfaces ...

0 Kudos
161

ok. I can try IF_XML..classes (that is what SDIXML function modules ultimately use).

DO you have any sample code (or a program within R/3) that uses if_xml classes for my purpose: to convert a xml string into a complex ABAP structure - just by giving the xml string & ABAP structure(or structure name) as parameters - and WITHOUT any further hard-work !

thanks

0 Kudos
161

No. I don´t have any example for your very case ... Sorry!

Former Member
0 Kudos
161

Hi Janet,

1. XML File -


> Internal table

2. I understand the above is ur requirement.

3. Below is my program.

It does three things :

a) selects data from T001 table

b) Converts into XML and puts it into a file.

c) In second phase,

It reads the file

and Populates the T001 table again (which has been cleareed explicitly)

4. See FIRST PHASE (itab to xml)

SECOND PHASE (xml to itab)

in my program

5.

REPORT abc.

*----


DATA

DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.

DATA : BEGIN OF itab OCCURS 0,

a(100) TYPE c,

END OF itab.

DATA: xml_out TYPE string .

DATA : BEGIN OF upl OCCURS 0,

f(255) TYPE c,

END OF upl.

DATA: xmlupl TYPE string .

                                                              • FIRST PHASE

                                                              • FIRST PHASE

                                                              • FIRST PHASE

*----


Fetch Data

SELECT * FROM t001 INTO TABLE t001 WHERE bukrs = '1000'.

*----


XML

CALL TRANSFORMATION ('ID')

SOURCE tab = t001[]

RESULT XML xml_out.

*----


Convert to TABLE

CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'

EXPORTING

i_string = xml_out

i_tabline_length = 100

TABLES

et_table = itab.

*----


Download

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filetype = 'BIN'

filename = 'd:\xx.xml'

TABLES

data_tab = itab.

                                                              • SECOND PHASE

                                                              • SECOND PHASE

                                                              • SECOND PHASE

BREAK-POINT.

REFRESH t001.

CLEAR t001.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'D:\XX.XML'

filetype = 'BIN'

TABLES

data_tab = upl.

LOOP AT upl.

CONCATENATE xmlupl upl-f INTO xmlupl.

ENDLOOP.

*----


XML

CALL TRANSFORMATION ('ID')

SOURCE XML xmlupl

RESULT tab = t001[]

.

BREAK-POINT.

regards,

amit .

0 Kudos
161

Hi Amit,

Which release of SAP you in? The FM 'HR_EFI_CONVERT_STRING_TO_TABLE' does not exist in 4.7 system! As a result program short-dumps.

Thanks,

Sougata.

0 Kudos
161

HR_EFI_CONVERT_STRING_TO_TABLE simply converts string to table format.

if you want similar functions you can check out the following FMs

CONVERT_STRING_TO_TABLE

SOTR_SERV_STRING_TO_TABLE

Regards

Raja

athavanraja
Active Contributor
0 Kudos
162

there is no standard FM/program to generate the ST code.

you have to manually create the ST code.

you can check out the following weblog for creating ST programs. (its a six part series)

/people/tobias.trapp/blog/2005/05/04/xml-processing-in-abap-part-1

Regards

Raja

0 Kudos
161

thanks for your reply. At least you understood my problem.

To me, it seems so obvious that SAP should have be supplying such code-generation tools. Another such example where I can't understand why SAP folks don't get it is: Just like wsdl2java in java world, there should have been a wsdl2abap- to automatically generate web-service client (or server) code in ABAP. anyways..thanks again

0 Kudos
161

I am not familiar with wsdl2java, but does it generate webservice client based on the WSDL at runtime?

in ABAP as of WAS6.40 you have desing time tools to generate webservice proxy client for a given WSDL.

for details check out this weblog. (particularly the section <b>Release 640</b>)

<a href="/people/thomas.jung3/blog/2004/11/17/bsp-a-developers-journal-part-xiv--consuming-webservices-with-abap">Consuming WebServices with ABAP</a>

Regards

Raja

athavanraja
Active Contributor
0 Kudos
161

Hi Janet,

check out this class, may be this could be of help

CL_PROXY_WSDL2ABAP

Regards

Raja

0 Kudos
161

thanks. cl_proxy_wsdl2abap is equivalent of wsdl2java in apache axis etc...