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

Converting Single Line XML Data to SAP Internal Table

Former Member
0 Likes
1,670

Hi Experts,

I have converted the SAP Internal Table to XML Format using below code

CALL TRANSFORMATION zemp_t_leaves
   SOURCE newdataset = lt_source[]
   RESULT XML  xml_result.

Here I am able to get the XML_RESULT which is in XML format but the complete data is in single line and it is in XML format.

Now I want to upload this to Application Server - the single line.


So, how to convert this single line XML data to multiple lines for transferring into to a file on application server.


Please suggest if any ways.



Regards,

Rafi



Hi Experts,

I have converted the SAP Internal Table to XML Format using below code

CALL TRANSFORMATION zemp_t_leaves
   SOURCE newdataset = lt_source[]
   RESULT XML  xml_result.

Here I am able to get the XML_RESULT which is in XML format but the complete data is in single line and it is in XML format.

Now I want to upload this to Application Server - the single line.


So, how to convert this single line XML data to multiple lines for transferring into to a file on application server.


Please suggest if any ways.



Regards,

Rafi



3 REPLIES 3
Read only

Former Member
0 Likes
916

The single string has entire content, and it can be written to application server file without splitting to multiple lines.

Choose Open Dataset For Output in Binary Mode and Transfer statements for doing it.

Read only

Former Member
0 Likes
916

Hi,

Check out my program.. I donno how much it can help you anyways just take it as reference,

TYPES : BEGIN OF TY_CHAR,
           TEXT(500) TYPE C,
         END OF TY_CHAR.

DATA : LT_TAB TYPE STANDARD TABLE OF TY_CHAR WITH HEADER LINE.

DATA : XML_TABLE  TYPE STANDARD TABLE OF  SMUM_XMLTB,
       RETURN  TYPE STANDARD TABLE OF  BAPIRET2.

DATA : STR  TYPE STRING,
        XSTR TYPE XSTRING.

CALL FUNCTION 'GUI_UPLOAD'
   EXPORTING
     filename                      = 'C:\ALEN\webservice-xml\test.txt'
     FILETYPE                      = 'ASC'
*   HAS_FIELD_SEPARATOR           = ' '
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
*   ISDOWNLOAD                    = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
   tables
     data_tab                      = LT_TAB
* CHANGING
*   ISSCANPERFORMED               = ' '
  EXCEPTIONS
    FILE_OPEN_ERROR               = 1
    FILE_READ_ERROR               = 2
    NO_BATCH                      = 3
    GUI_REFUSE_FILETRANSFER       = 4
    INVALID_TYPE                  = 5
    NO_AUTHORITY                  = 6
    UNKNOWN_ERROR                 = 7
    BAD_DATA_FORMAT               = 8
    HEADER_NOT_ALLOWED            = 9
    SEPARATOR_NOT_ALLOWED         = 10
    HEADER_TOO_LONG               = 11
    UNKNOWN_DP_ERROR              = 12
    ACCESS_DENIED                 = 13
    DP_OUT_OF_MEMORY              = 14
    DISK_FULL                     = 15
    DP_TIMEOUT                    = 16
    OTHERS                        = 17
           .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

LOOP AT LT_TAB.

   CONCATENATE STR LT_TAB  INTO STR.

ENDLOOP.

*READ TABLE LT_TAB INDEX 1.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
   EXPORTING
     text           = STR
*   MIMETYPE       = ' '
*   ENCODING       =
  IMPORTING
    BUFFER         = XSTR
  EXCEPTIONS
    FAILED         = 1
    OTHERS         = 2
           .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'SMUM_XML_PARSE'
   EXPORTING
     xml_input       = XSTR
   tables
     xml_table       = XML_TABLE
     return          = RETURN
           .
BREAK-POINT.


Regards,

Alenlee MJ

Read only

0 Likes
916

Hi Alenlee,

Thanks for your reply.

Will follow your steps and let you know if any issues.

Regards,

Rafi