Application Development and Automation 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: 
Read only

ABAP to XML

Former Member
0 Likes
676

Hi All

We need to "send" or convert an ABAP transaction into XML without XI server.

Any suggestion ?

Many thanks.

Cristina

5 REPLIES 5
Read only

Former Member
0 Likes
620

Hi Cristina,

If you intend to download data into XML format, then refer sample code:

Here a successful implementation of Function module "SAP_CONVERT_TO_XML_FORMAT" for users of SAP 46c. It converts an internal table to an xml-table and downloads it.

This code needs 3 variables: FILENAME, XML-document-Name DOC_NAME(freetext) and the internal table (TAB) which you want to convert to XML.

TYPES: TRUXS.

TYPES : BEGIN OF TRUXS_XML_LINE,

DATA(256) TYPE X,

END OF TRUXS_XML_LINE.

TYPES: TYPE_XMLTAB TYPE TABLE OF TRUXS_XML_LINE.

DATA: XMLTAB TYPE TYPE_XMLTAB, BIN_SIZE TYPE I.

data: xml_tab type table of truxs_xml_line,

Xml_tab2 type

CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'

EXPORTING

  • I_FIELD_SEPERATOR = ''

  • I_LINE_HEADER = ''

I_FILENAME = FILENAME

  • I_APPL_KEEP = ''

I_XML_DOC_NAME = DOC_NAME

IMPORTING

PE_BIN_FILESIZE = BIN_SIZE

TABLES

I_TAB_SAP_DATA = TAB

CHANGING

I_TAB_CONVERTED_DATA = XMLTAB

EXCEPTIONS

CONVERSION_FAILED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

BIN_FILESIZE = BIN_SIZE

  • CODEPAGE = ' '

FILENAME = FILENAME

FILETYPE = 'BIN'

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = XMLTAB

  • FIELDNAMES =

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_WRITE_ERROR = 2

INVALID_FILESIZE = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

<b>SECOND PROGRAM:</b>

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

*----


Fetch Data

SELECT * FROM t001 INTO TABLE t001.

*----


XML

CALL TRANSFORMATION ('ID')

SOURCE tab = t001[]

RESULT XML xml_out.

CALL FUNCTION 'SCMS_STRING_TO_FTEXT'

EXPORTING

TEXT = xml_out

  • IMPORTING

  • LENGTH =

TABLES

FTEXT_TAB = itab.

.

*----


Download

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filetype = 'BIN'

filename = 'd:\xx.xml'

TABLES

data_tab = itab.

                                                              • 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.

Reward points if this Helps.

Manish

Read only

0 Likes
620

Hi Manish

Many thanks for your reply. It is very useful but my main problem actually is how can I "catch" this file without a XI server.

Many thanks again.

Br.

Cristina

Read only

0 Likes
620

what do you want to do with the generated XML? send it to another system?

Read only

0 Likes
620

Hi

Thanks for you help.

I´m new to WS, I was asked to find out how we can populate an ALV report in the web without a XI server.

Im working in the SAP4.6C version.

Any idea how can I do this ? Do I need to work with the RFC ? Or SAP BC(business conector) ?

Many thanks.

Read only

0 Likes
620

you want to show an ALV report on the web? is it

if you want to have all the features of ALV on the web as well, its better to use ITS

otherwise, if you are builind the alv features for web with your own dev and only want the data from SAP system, you can use activeX RFC calls to sap system from the browser and get the data back.

Regards

Raja