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: 

xml TO idoc

Former Member
0 Kudos

Hi Everyone,

I am trying to send the XML data into IDOC. For this according to my analysis in SDN first i need to convert

the XML file into internal and table and then pass to the respective tables using IDOC_INBOUND_WRITE_TO_DB.

Am i going in the correct way if not please guide me.

I have used this link (https://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table ) to convert my

XML to internal table.

Anyone can you help me to acheive XML to iDOC conversion. I have searched the same in SDN but it was not helpful for me.

Remind you i am not considered with any XI system and my current SAP version is 4.7.

Regards

VENk@

10 REPLIES 10

GauthamV
Active Contributor
0 Kudos

Use this FM.

IDX_XML_TO_IDOC

Former Member
0 Kudos

hii venkat,

use FM IDOC_XML_FROM_FILE.

Mandatory parameters:

XML_DATA TYPE XSTRING

EDIDC40 TYPE EDI_DC40

IDX_XMB TYPE IDX_XMB

GUID TYPE SXMSMGUID

regards,

Shweta

Former Member
0 Kudos

hello venkat,

you can do like this also

1. Read XML file using XSLT (Create a XSLT file using XML Schema) and CALL TRANSFORMATION .

2. Call function module IDOC_WRITE_AND_START_INBOUND

3. Call your application thru BDC or Function module

4. Call function module IDOC_STATUS_WRITE_TO_DATABASE to update the status to IDoc

regards,

Shweta

Former Member
0 Kudos

Hi,

Just go through this links.It might solves ur issue

[XML to IDOC|;

Regards

Kiran

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Venkat,

In that wiki i have suggested a generic way of reading an XML file. Please note that you need to debug the code & capture the field & values which you need to capture.


CASE v_node->get_type( ).
  WHEN if_ixml_node=>co_node_element. "Node Element
            IF NOT v_nodemap IS INITIAL.

          v_count = v_nodemap->get_length( ).

          DO v_count TIMES.
            v_index = sy-index - 1.
            v_attr = v_nodemap->get_item( v_index ).
            v_attr_name = v_attr->get_name( ).
            v_prefix = v_attr->get_namespace_prefix( ).
            v_attr_value = v_attr->get_value( ).
          ENDDO.

    WHEN if_ixml_node=>co_node_text OR
             if_ixml_node=>co_node_cdata_section. "Node Text
        v_node_name = v_node->get_name( ).
        v_node_value = v_node->get_value( ).    
ENDCASE.

The most important part of the code is the one given above. Use the data you get from these variables to manipulate your XML.

The handling will depend entirely on your XML structure. You cannot make a generic code, which will read any XML.

BR,

Suhas

Former Member
0 Kudos

Hi Suhs,

As the author of the wiki which i am using is you so you can help help me in my issue.

Can you suggest me where to put my write ststement to check whether my internal

table is filled correctly or not. This piece of code is from the wiki...

APPEND wa TO itab.

CLEAR wa.

ENDIF.

ENDCASE.

  • advance to next node

v_node = v_iterator->get_next( ).

ENDWHILE.

LOOP AT itab INTO wa.

ENDLOOP.

So suggest me a write statement. By which i can proceed further.

This message is for all other answers i have already gone through all the link given by you before posting my query

anyways thks for the links.

Regards

VEnk@

Edited by: Venkat Reddy on Sep 11, 2009 1:13 PM

0 Kudos

Hello Venkat,

Please refer to my previous post. You have to do some debugging & check the values which are getting populated in the variables & based on that you can populate your internal table.

Look your XML structure may be different from the one i have used to build the code. And you cannot make a generic code to read any XML file format. So no point in copy pasting the same code & expecting it to run correctly :-((

Please debug & check that the variables are getting populated correctly.

BR,

Suhas

Former Member
0 Kudos

Suhas

Its not the matter of copy pasteing the code. i am not aware of OO-ABAP so thats why i have not kept my effort on debugging.

Anyways i will debugg and getback to you.

Former Member
0 Kudos

Suhas I just went back to the basics by stopping myself thinking big.

I have tried to use gui_upload function module and now I am able to fetch the complete XML file into my internal table. I have debugged and find the internal table and even I am able to display my complete XML file using a write statement.

Now I am planning to read the records from the XML file by deleting the tags and properties of the XML file remember I am manipulating the internal table now.

Any comments on this.

0 Kudos

Hello Venkat,

But i feel that it will be very very tedious to do so.

I think that either go for a Simple Transformation or use the class as mentioned in the Wiki.

I wont suggest you to use this technique.

Anyways good luck.

Suhas