Skip to Content
author's profile photo Former Member
Former Member

sap to xml

Hi all,

iam working on SAp 4.7 version.

the source code is going to dump. the purpose of this to convert data to XML file and store in presentation server. but i hv to use FM SAP_CONVERT_TO_XML_FORMAT. (No other options).

i'm providing source code also.plz any one help me out. its urgent.

TABLES: VEKP,

LIKP,

VBAK.

TYPE-POOLS: IXML.

DATA: BEGIN OF ITAB OCCURS 0,

BRGEW LIKE VEKP-BRGEW,

LAENG LIKE VEKP-LAENG,

BREIT LIKE VEKP-BREIT,

EXIDV LIKE VEKP-EXIDV,

HOEHE LIKE VEKP-HOEHE,

VBELN LIKE LIKP-VBELN,

KUNNR LIKE LIKP-KUNNR,

VDATU LIKE VBAK-VDATU,

END OF ITAB.

TYPES: BEGIN OF MY_XML ,

DATA(256) TYPE X,

END OF MY_XML.

DATA: XML_TABLE TYPE TABLE OF MY_XML.

DATA: L_XML_SIZE TYPE I,

LD_FULLPATH TYPE STRING.

PARAMETERS: HU LIKE VEKP-EXIDV.

START-OF-SELECTION.

SELECT A~BRGEW

A~LAENG

A~BREIT

A~EXIDV

A~HOEHE

B~VBELN

B~KUNNR

C~VDATU

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM VEKP AS A INNER JOIN LIKP AS B

ON AERDAT = BERDAT INNER JOIN VBAK AS C

ON BERDAT = CERDAT

WHERE A~EXIDV = HU.

CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'

  • EXPORTING

  • I_FIELD_SEPERATOR = ','

  • I_LINE_HEADER =

  • I_FILENAME =

  • I_APPL_KEEP = ' '

  • I_XML_DOC_NAME =

IMPORTING

PE_BIN_FILESIZE = L_XML_SIZE

TABLES

I_TAB_SAP_DATA = ITAB

CHANGING

I_TAB_CONVERTED_DATA = XML_TABLE

  • 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 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = L_XML_SIZE

FILENAME = LD_FULLPATH

FILETYPE = 'BIN'

IMPORTING

FILELENGTH = L_XML_SIZE

TABLES

DATA_TAB = XML_TABLE

  • FIELDNAMES =

.

IF SY-SUBRC <> 0.

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

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

Thanks.

Girish M

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 02:23 PM

    Hi,

    there is one error in ur code.

    TABLES: VEKP,

    LIKP,

    VBAK.

    TYPE-POOLS: IXML.

    DATA: BEGIN OF ITAB OCCURS 0,

    BRGEW LIKE VEKP-BRGEW,

    LAENG LIKE VEKP-LAENG,

    BREIT LIKE VEKP-BREIT,

    EXIDV LIKE VEKP-EXIDV,

    HOEHE LIKE VEKP-HOEHE,

    VBELN LIKE LIKP-VBELN,

    KUNNR LIKE LIKP-KUNNR,

    VDATU LIKE VBAK-VDATU,

    END OF ITAB.

    TYPES: BEGIN OF MY_XML ,

    DATA(256) TYPE X,

    END OF MY_XML.

    DATA: XML_TABLE TYPE TABLE OF MY_XML.

    DATA: L_XML_SIZE TYPE I,

    <b>LD_FULLPATH TYPE STRING value 'C:\test.txt'</b>.

    PARAMETERS: HU LIKE VEKP-EXIDV.

    START-OF-SELECTION.

    SELECT A~BRGEW

    A~LAENG

    A~BREIT

    A~EXIDV

    A~HOEHE

    B~VBELN

    B~KUNNR

    C~VDATU

    INTO CORRESPONDING FIELDS OF TABLE ITAB

    FROM VEKP AS A INNER JOIN LIKP AS B

    ON AERDAT = BERDAT INNER JOIN VBAK AS C

    ON BERDAT = CERDAT

    WHERE A~EXIDV = HU.

    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'

    • EXPORTING

    • I_FIELD_SEPERATOR = ','

    • I_LINE_HEADER =

    • I_FILENAME =

    • I_APPL_KEEP = ' '

    • I_XML_DOC_NAME =

    IMPORTING

    PE_BIN_FILESIZE = L_XML_SIZE

    TABLES

    I_TAB_SAP_DATA = ITAB

    CHANGING

    I_TAB_CONVERTED_DATA = XML_TABLE

    • 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 'GUI_DOWNLOAD'

    EXPORTING

    BIN_FILESIZE = L_XML_SIZE

    FILENAME = LD_FULLPATH

    FILETYPE = 'BIN'

    IMPORTING

    FILELENGTH = L_XML_SIZE

    TABLES

    DATA_TAB = XML_TABLE

    • FIELDNAMES =

    .

    IF SY-SUBRC <> 0.

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

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

    Regs

    Manas

    Pls reward the points.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 02:20 PM

    Hi

    i did the same thing in ECC6.0 and its running smoothly and working fine.

    &----


    *& Report ZTESTSDN

    *&

    &----


    *&

    *&

    &----


    REPORT ztestsdn.

    TABLES: vekp,

    likp,

    vbak.

    TYPE-POOLS: ixml.

    DATA: itab LIKE but000 OCCURS 0 WITH HEADER LINE.

    TYPES: BEGIN OF my_xml ,

    data(256) TYPE x,

    END OF my_xml.

    DATA: xml_table TYPE TABLE OF my_xml.

    DATA: l_xml_size TYPE i,

    ld_fullpath TYPE string.

    START-OF-SELECTION.

    SELECT * FROM but000 INTO TABLE itab UP TO 10 ROWS.

    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'

    • EXPORTING

    • I_FIELD_SEPERATOR = ','

    • I_LINE_HEADER =

    • I_FILENAME =

    • I_APPL_KEEP = ' '

    • I_XML_DOC_NAME =

    IMPORTING

    pe_bin_filesize = l_xml_size

    TABLES

    i_tab_sap_data = itab

    CHANGING

    i_tab_converted_data = xml_table

    • 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 'GUI_DOWNLOAD'

    EXPORTING

    bin_filesize = l_xml_size

    filename = 'C:\test.txt'

    filetype = 'BIN'

    IMPORTING

    filelength = l_xml_size

    TABLES

    data_tab = xml_table

    • FIELDNAMES =

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    Regs

    Manas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 02:22 PM

    You can use ST. Here is a sample code for your program.

    Instead of SAP_CONVERT_TO_XML_FORMAT

    use the following code.

    data : xmlstr type string,

    date like syst-datum,

    time like syst-uzeit.

    call transformation id

    source xmldat = syst-datum "Optional

    xmltim = syst-uzeit "Optional

    ref = itab[]

    result xml xmlstr.

    to convert is back

    call transformation

    source xml xmlstr

    result xmldat = date

    xmltim = time

    ref = itab[].

    Albert

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 02:23 PM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.