cancel
Showing results for 
Search instead for 
Did you mean: 

Simple transformation from XML to ABAP for google API

Former Member
0 Kudos

Hi All,

I am trying to convert the google api (http://maps.googleapis.com/maps/api/geocode/xml?address=5105 Issaquah Pine Lake RD SE, Issaquah, WA, 98029&sensor=false) XML response to ABAP, but it is failing to convert.

Please find the attached screen shots for reference. Please let me know how to proceed?

Thanks a lot.

Best Regards,

Vij

XML Transformation

ABAP Code :-

Google API XML Response :-

ABAP Structures

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi All,

Initially there is a problem with decimal field in XML to ABAP,  so now I make them of type string in ABAP to avoid conversion errors.

As of now I am able to convert Google API XML response or any XML response to ABAP compatible internal table using below Function modules.

Here there is no need to deal with XML to ABAP vice versa transformations.

Code :-


Internal table populated data :-

Here we need to do coding for populating target structure by playing with fields

                                          HIER    -> Hierarchy or field position in XML

                                          CNAME -> XML field name

                                          CVALUE -> XML field value

                                          TYPE      -> 'A' - Header node, 'V' - Value node, space - others

I am still trying on transformation and will let you know once got successful.

thanks,

Vij

Former Member
0 Kudos

Did you try like this, lv_xml is your xml in a string and ls_struc is your ABAP structure for XML metadata


TRY.
    CALL TRANSFORMATION id SOURCE XML lv_xml

        RESULT data = ls_stuc OPTIONS value_handling = 'accept_data_loss'.
     CATCH cx_root INTO DATA(lx_root).
ENDTRY.