cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service - XML Fragment to ABAP table

Former Member
0 Kudos

Hi Friends,

I consumed external Web Services in our SAP successfully and i observed output structure in External View / Internal View is in XSDANY which is nothing but XML Fragment.

How to read such format and develop a ABAP report?

Regards
Ali

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi raza,

After getting the XML format, we need to parse by using function module "SMUM_XML_PARSE"

Pass XML as input and read the node value in table format, processing that according to your requirement.

regards

goudham

Former Member
0 Kudos

Hi Goudham,

Could you please explain bit more ... how to read data from xsdany ?

eg:

data:  output1 type XSDANY.

TRY.
    CALL METHOD l_proxy->SEARCH_ACCOUNT
      EXPORTING
        INPUT  = INPUT
      IMPORTING
        OUTPUT = OUTPUT1.
  Catch cx_ai_system_fault.
  Catch CX_AI_APPLICATION_FAULT.
endtry


How to convert XSDANY to XML?

CALL FUNCTION 'SMUM_XML_PARSE'
  EXPORTING
    xml_input       = xmldata
  TABLES
    xml_table       = result_xml
    return          = return .

Regards

Raza

Former Member
0 Kudos

dear raza,

Nothing more needed.

XML has been parsed in the output table result_xml, inside the table all the values are bind with node name .

eg:  if xml contains material and plant no XML looks like

<XML urf = version 8 >

<material code> 100-100 </material code>

<plant> 1000 </plant>

</>

if you want to read material code  i'll write following code:

data : lv_matnr type matnr.

loop at  result_xml into workarea.

case cname.

when 'material code'.

lv_matnr = workarea-cvalue.

endcase.

endloop.

after that write code depend on your requirements.

regards

goudham

Former Member
0 Kudos

Hi Goutham

I'm getting the errors OUTPUT1 can not be converted to the type XMLDATA.

      . . .

      . . .

      IMPORTING

        OUTPUT = OUTPUT1.

xmldata = OUTPUT1.    ---> Eorrors :  OUTPUT1 can not be converted to the type XMLDATA

CALL FUNCTION 'SMUM_XML_PARSE'
  EXPORTING
    xml_input       = xmldata

     . . .

     . . .

Regards

Raza

Former Member
0 Kudos

dear raza,

I hope no need below code:

data:  output1 type XSDANY.

TRY.
    CALL METHOD l_proxy->SEARCH_ACCOUNT
      EXPORTING
        INPUT  = INPUT
      IMPORTING
        OUTPUT = OUTPUT1.
  Catch cx_ai_system_fault.
  Catch CX_AI_APPLICATION_FAULT.
endtry

because already you are having XML data, straightway pass into above FM.

If iam wrong, please post your complete code.

regards

goudham

Answers (0)