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 generate this xml file?

Former Member
0 Kudos
360

Dear experts,

Could you please tell me how to generate to below xml file?

<?xml version="1.0" encoding="utf-8" ?>

- <faxmakerdata>

- <RECIPIENTS>

- <FAX>

- <RECIPIENT>

<FIRSTNAME>><![CDATA[]]></FIRSTNAME>

<LASTNAME><![CDATA[]]></LASTNAME>

<COMPANY><![CDATA[]]></COMPANY>

<DEPARTMENT><![CDATA[]]></DEPARTMENT>

<EMAILADDRESS><![CDATA[]]></EMAILADDRESS>

<NUMBER><![CDATA[2937]]></NUMBER>

<VOICENUMBER><![CDATA[]]></VOICENUMBER>

</RECIPIENT>

</FAX>

</RECIPIENTS>

</faxmakerdata>

I have used "SDIXML_DATA_TO_DOM " but there will appear <Item>

could you please tell me how to do?

5 REPLIES 5

Former Member
0 Kudos
184

Hi,

after SDIXML_DATA_TO_DOM fm Use SDIXML_DOM_TO_XML to convert DOM to XML

then u can use any download file FM .

DATA:

TABLESTATS LIKE MSSTABSIZEINFO,

IVALUE TYPE I,

BEGIN OF VERSIONTAB OCCURS 0,

VERSIONDAT LIKE SY-DATUM,

END OF VERSIONTAB,

CMD(384) TYPE C,

XML_AS_STRING TYPE XSTRING,

DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,

DOM TYPE REF TO IF_IXML_ELEMENT,

TABLENAME(128) TYPE C,

RC TYPE SY-SUBRC,

L_EXISTS LIKE DD02L-ACTFLAG.

  • convert table to a DOM

CALL FUNCTION 'SDIXML_DATA_TO_DOM'

EXPORTING

NAME = 'spinfo'

DATAOBJECT = SPINFO[]

IMPORTING

DATA_AS_DOM = DOM

CHANGING

DOCUMENT = DOCUMENT

EXCEPTIONS

OTHERS = 01.

IF SY-SUBRC = 0.

CALL METHOD DOCUMENT->APPEND_CHILD

EXPORTING

NEW_CHILD = DOM

RECEIVING

RVAL = RC.

IF RC = 0.

  • convert DOM to XML

CALL FUNCTION 'SDIXML_DOM_TO_XML'

EXPORTING

DOCUMENT = DOCUMENT

PRETTY_PRINT = 'X'

IMPORTING

XML_AS_STRING = XML_AS_STRING

SIZE = IVALUE

TABLES

XML_AS_TABLE = XML_AS_TABLE

EXCEPTIONS

OTHERS = 2.

IF SY-SUBRC = 0.

MOVE XML_AS_STRING TO XML_AS_STRING_OUT-XML_STRING.

MOVE IVALUE TO XML_AS_STRING_OUT-LENGTH.

ENDIF.

ENDIF.

ENDIF.

Salil...

0 Kudos
184

After i used SDIXML_DATA_TO_DOM and 'SDIXML_DOM_TO_XML',I get below XML information

<?xml version="1.0" encoding="utf-8"?>

<faxmakerdata>

<item>

<RECIPIENTS>

<FAX>

<RECIPIENT>

<FIRSTNAME>&lt;![CDATA[]]&gt;</FIRSTNAME>

<LASTNAME>&lt;![CDATA[]]&gt;</LASTNAME>

<COMPANY>&lt;![CDATA[]]&gt;</COMPANY>

<DEPARTMENT>&lt;![CDATA[]]&gt;</DEPARTMENT>

<EMAILADDRESS>&lt;![CDATA[]]&gt;</EMAILADDRESS>

<NUMBER>&lt;![CDATA[274]]&gt;</NUMBER>

<VOICENUMBER>&lt;![CDATA[]]&gt;</VOICENUMBER>

</RECIPIENT>

</FAX>

</RECIPIENTS>

</item>

</faxmakerdata>

How can I get information? How to delete <Item> </Item>?

<?xml version="1.0" encoding="utf-8" ?>

<faxmakerdata>

<recipients>

<fax>

<recipient>

<firstname><![CDATA[]]></firstname>

<lastname><![CDATA[]]></lastname>

<company><![CDATA[]]></company>

<department><![CDATA[]]></department>

<emailaddress><![CDATA[]]></emailaddress>

<number><![CDATA[274]]></number>

<voicenumber><![CDATA[]]></voicenumber>

</recipient>

</fax>

</recipients>

</faxmakerdata>

Former Member
0 Kudos
184

Hi,

After that you have to call 'SDIXML_DOM_TO_XML' FM also

try with this FM

Regards,

Jyothi CH.

Former Member
0 Kudos
184

Thank you very much

former_member71078
Discoverer
0 Kudos
184

Please, can you send me the program where you generate the xml file? I have to generate some similar file, but I don't know how to create the '!CDATA[]> from an internal table.

I generate for field data which is a text field, the xml file as:

.....

....

<DATA>-RETENCION</DATA>

....

....

but I need to generate it as:

....

....

<DATA><![CDATA[-RETENCION-]]></DATA>

...

...

Thanks in advance,

Regards,

Alice