Defining XSLT from Abap to XML and XML to Abap (Internal Table)

Hi Experts, I need help with this XSLT for call transformation. I have defined an internal table and intend to use it as a source for Call Tranformation. But I have a Problem defining its XSLT and help would be greatly appreciated! I also wonder if this XSLT can be used for XML to internal table? Or do I have to define another XSLT again.... Hope to hear from any of u soon!
CODES->>>
TYPES: BEGIN OF CONTENT,
         CONTENT1(20),
         CONTENT2(20),
       END OF CONTENT.
TYPES: T_CONTENT TYPE TABLE OF CONTENT.
DATA: BEGIN OF I_DATA OCCURS 0,
        KEY1(10),
        KEY2(10),
        CONT TYPE T_CONTENT,
      END OF I_DATA.
DATA: WA_TBL TYPE CONTENT.
DATA: LI_TBL TYPE T_CONTENT.
START-OF-SELECTION.
populate data 1
  CLEAR I_DATA.
  I_DATA-KEY1 = 'AMI'.
  I_DATA-KEY2 = 'LEE'.
  CLEAR WA_TBL.
  REFRESH LI_TBL.
  WA_TBL-CONTENT1 = 'PENHAS ROAD'.
  WA_TBL-CONTENT2 = 'SG'.
  APPEND WA_TBL TO LI_TBL.
  WA_TBL-CONTENT1 = 'GILLMAN ROAD'.
  WA_TBL-CONTENT2 = 'SG'.
  APPEND WA_TBL TO LI_TBL.
  I_DATA-CONT = LI_TBL.
  APPEND I_DATA.
populate data 1
  CLEAR I_DATA.
  I_DATA-KEY1 = 'KAI'.
  I_DATA-KEY2 = 'LEE'.
  CLEAR WA_TBL.
  REFRESH LI_TBL.
  WA_TBL-CONTENT1 = 'SUNSET WAY'.
  WA_TBL-CONTENT2 = 'SG'.
  APPEND WA_TBL TO LI_TBL.
  WA_TBL-CONTENT1 = 'BEDOK NORTH'.
  WA_TBL-CONTENT2 = 'SG'.
  APPEND WA_TBL TO LI_TBL.
  I_DATA-CONT = LI_TBL.
  APPEND I_DATA.
call transformation (xslt)
    source i_data = i_data
    result xml xmlstr.

here is the code sample using ixml library .
just create a report program and copy paste the following code.
if time permits, later on i will post the xslt program which you can use it call transformation.
REPORT  y_test_xml.
DATA: l_ixml                                 TYPE REF TO if_ixml,
        l_ixml_sf                              TYPE REF TO if_ixml_stream_factory,
        l_istream                              TYPE REF TO if_ixml_istream,
        l_ostream                              TYPE REF TO if_ixml_ostream,
        l_booklist                   TYPE REF TO if_ixml_element,
        l_document                             TYPE REF TO if_ixml_document,
        l_parser                               TYPE REF TO if_ixml_parser,
        l_root_element                         TYPE REF TO if_ixml_element,
        l_book_record                            TYPE REF TO if_ixml_element,
        l_date TYPE REF TO if_ixml_element ,
                l_time TYPE REF TO if_ixml_element ,
        l_book_group                            TYPE REF TO if_ixml_element,
        l_book_cat                            TYPE REF TO if_ixml_element ,
        others                                  TYPE REF TO if_ixml_element ,
        link                                    TYPE REF TO if_ixml_element ,
        description                            TYPE REF TO if_ixml_element ,
        xml                                    TYPE xstring ,
        size TYPE  i ,
         l_xml  TYPE REF TO cl_xml_document  .
DATA: xml_out TYPE string ,
      temp_string TYPE string .
TYPES: BEGIN OF add_category,
category_id(10),
category_desc(40),
END OF add_category,
add_t_category TYPE add_category OCCURS 0 .
TYPES: BEGIN OF add_book_grp,
book_category TYPE add_t_category,
END OF add_book_grp,
add_t_book_grp TYPE add_book_grp OCCURS 0.
TYPES: BEGIN OF add_book,
book_num(10) TYPE c,
short_desc(40) TYPE c,
book_group TYPE add_t_book_grp,
END OF add_book,
add_t_book TYPE add_book OCCURS 0.
TYPES: BEGIN OF type_data,
date TYPE sy-datum,
time TYPE sy-uzeit,
book_record TYPE add_t_book,
END OF type_data.
DATA: i_data TYPE type_data OCCURS 0 WITH HEADER LINE.
DATA: itab LIKE soli OCCURS 0 WITH HEADER LINE.
DATA: cat_wa TYPE add_category ,
      bk_gp_wa TYPE add_book_grp ,
      bk_rec_wa TYPE add_book ,
      bk_wa LIKE LINE OF i_data .
DATA: cat_tab TYPE STANDARD TABLE OF add_category ,
      bk_gp_tab TYPE STANDARD TABLE OF add_book_grp ,
      bk_rec_tab TYPE STANDARD TABLE OF add_book .
MOVE: '03' TO cat_wa-category_id  ,
      ' BK GP 3' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
MOVE: '02' TO cat_wa-category_id  ,
      ' BK GP 2' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
bk_gp_wa-book_category  = cat_tab.
APPEND bk_gp_wa TO bk_gp_tab .
MOVE: '0012345678' TO bk_rec_wa-book_num ,
      'OMS book' TO bk_rec_wa-short_desc .
bk_rec_wa-book_group = bk_gp_tab .
APPEND bk_rec_wa TO bk_rec_tab .
CLEAR:bk_gp_tab, cat_tab .
REFRESH :bk_gp_tab, cat_tab .
MOVE: '01' TO cat_wa-category_id  ,
      ' BK GP 1' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
MOVE: '09' TO cat_wa-category_id  ,
      ' BK GP 9' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
bk_gp_wa-book_category  = cat_tab.
APPEND bk_gp_wa TO bk_gp_tab .
MOVE: '00123456789' TO bk_rec_wa-book_num ,
      'SAP book' TO bk_rec_wa-short_desc .
bk_rec_wa-book_group = bk_gp_tab .
APPEND bk_rec_wa TO bk_rec_tab .
MOVE: sy-datum TO bk_wa-date ,
      sy-uzeit TO bk_wa-time .
bk_wa-book_record = bk_rec_tab .
APPEND bk_wa TO i_data .
CLEAR: cat_wa , bk_gp_wa ,bk_rec_wa , bk_wa .
l_ixml = cl_ixml=>create( ).
l_ixml_sf = l_ixml->create_stream_factory( ).
l_document = l_ixml->create_document( ).
l_root_element = l_document->create_element( name = 'asx:abap' ).
l_root_element->set_attribute( name = 'xmlns:asx' value = 'http://www.sap.com/abapxml' ) .
l_root_element->set_attribute( name = 'version' value = '1.0' ).
l_document->append_child( new_child = l_root_element ).
others = l_document->create_simple_element( parent = l_root_element name = 'asx:values' ).
l_booklist = l_document->create_simple_element( parent = others name = 'BOOKLIST' ).
LOOP AT i_data INTO bk_wa .
  CLEAR temp_string .
  MOVE: bk_wa-date TO temp_string .
  l_date = l_document->create_simple_element( parent = l_booklist name = 'DATE' value = temp_string  ).
  CLEAR temp_string .
  MOVE: bk_wa-time TO temp_string .
  l_time = l_document->create_simple_element( parent = l_booklist name = 'TIME' value = temp_string ).
  LOOP AT bk_wa-book_record INTO bk_rec_wa .
    l_book_record = l_document->create_simple_element( parent = l_booklist name = 'BOOK_RECORD' ) .
    CLEAR temp_string .
    MOVE: bk_rec_wa-book_num TO temp_string .
    l_date = l_document->create_simple_element( parent = l_book_record name = 'BOOK_NUM' value = temp_string ).
    CLEAR temp_string .
    MOVE: bk_rec_wa-short_desc TO temp_string .
    l_time = l_document->create_simple_element( parent = l_book_record name = 'SHORT_DESC' value = temp_string ).
    l_book_group = l_document->create_simple_element( parent = l_book_record name = 'BOOK_GROUP' ).
    LOOP AT bk_rec_wa-book_group INTO bk_gp_wa .
      LOOP AT bk_gp_wa-book_category INTO cat_wa .
        l_book_cat = l_document->create_simple_element( parent = l_book_group name = 'BOOK_CATEGORY' ).
        CLEAR temp_string .
        MOVE: cat_wa-category_id TO temp_string .
        l_date = l_document->create_simple_element( parent = l_book_cat name = 'CATEGORY_ID' value = temp_string ).
        CLEAR temp_string .
        MOVE: cat_wa-category_desc TO temp_string .
        l_time = l_document->create_simple_element( parent = l_book_cat name = 'CATEGORY_DESC' value = temp_string ).
      ENDLOOP .
    ENDLOOP .
  ENDLOOP .
ENDLOOP .
l_ostream = l_ixml_sf->create_ostream_xstring( xml ).
l_document->render( ostream = l_ostream ).
CREATE OBJECT l_xml.
CALL METHOD l_xml->parse_xstring
  EXPORTING
    stream = xml.
l_xml->render_2_string(
  EXPORTING
    pretty_print = 'X'
  IMPORTING
*    RETCODE      = RETCODE
    stream       = xml_out
    size         = size
CALL METHOD l_xml->display.
Hope this is helpful.
do let us know how it goes.
Regards
Raja

Similar Messages

  • How to fetch data from XML and store it in internal table

    Hi All,
    Can anyone help me out, in fetching data from xml and store it in an internal table. Is there any standard function module is there?
    Regards,
    Karthick

    to do this you can either develop a XSLT program and use it with CALL TRNSFORMATION key word to tranform the XML into itab .
    (search the ABAP General forum, i have posted few samples)
    or simply use the following FM which converts your XML into a itab of name value pair (name would holw the element name and value would hold the value of the element) which you can then loop and read it to your itb.
    data:             xmldata type xstring .
    data: result_xml type standard table of smum_xmltb .
    data: return type standard table of bapiret2 .
    CALL FUNCTION 'SMUM_XML_PARSE'
      EXPORTING
        xml_input       = xmldata
      TABLES
        xml_table       = result_xml
        return          = return .
    Regards
    Raja

  • Difference between Field symbols and work area for Internal tables

    Hi,
    In ECC versions we all know that we need to declare the internal tables without headerline, and for handling the internal tables we need to use exclusive work areas.
    Currently i have an issue that we have been asked to use field symbols instead of work areas...can any one help me how to use the field symbols and also let me know how it will improve the performance of the program..
    Thanks and Regards,
    Kathir

    Hi
    DATA: WA TYPE ITAB.
    LOOP AT ITAB INTO WA.
    IF WA-FIELD = .....
    ENDIF.
    ENDLOOP.[(code]
    FIELD-SYMBOLS <WA> TYPE ANY.
    LOOP AT ITAB ASSIGNING <WA>.
    ENDLOOP.
    Now the problem is you can't know the name of the fields of the table at runtime, so you can't write:
    IF <WA>-FIELD = .....
    ENDIF.
    Anyway you can create a field-symbols strcturated like the table:
    [code]FIELD-SYMBOLS <WA> TYPE ITAB.
    LOOP AT ITAB ASSIGNING <WA>.
      IF <WA>-FIELD = .....
      ENDIF.
    ENDLOOP.
    I don't know which are the differences for the performance between to use a field-symbol and to use a structure as work-area.
    The differnce between the field-symbols and work-area is the field-symbol is assigned directly to the record, so u don't need to do a MODIFY statament to change something:
    LOOP AT ITAB INTO WA.
      WA-FIELD =
      MODIFY ITAB FROM WA.
    ENDLOOP.
    LOOP AT ITAB ASSIGNING <WA>.
      <WA>-FIELD =
    ENDLOOP.
    These two pieces of abap code do the same action, so probably the field-symbol improve the performance because it do an access directly to the record without to use an external structure as workarea.
    Max

  • Runtime error:ABAP program lines are longer than the internal table

    Hi all,
    Below is the code I have written,when Iam running it Iam getting
    'ABAP program lines are longer than the internal table' runtime error.How can I resolve it.
    REPORT  ZTEST1  NO STANDARD PAGE HEADING LINE-SIZE 255.
    TABLES:MARC,CDHDR,CDPOS.
    TYPE-POOLS:SLIS.
    DATA:HEADER TYPE SLIS_T_FIELDCAT_ALV,
         WA TYPE SLIS_FIELDCAT_ALV,
         LAYOUT TYPE SLIS_LAYOUT_ALV.
    TYPES:BEGIN OF MARC_TY,
            MATNR LIKE MARC-MATNR,
            WERKS LIKE MARC-WERKS,
            EKGRP LIKE MARC-EKGRP,
            MINBE LIKE MARC-MINBE,
            EISBE LIKE MARC-EISBE,
            MABST LIKE MARC-MABST,
           END OF MARC_TY.
    TYPES:BEGIN OF MATNR1_TY,
            MATNR1 LIKE CDHDR-OBJECTID,
          END OF MATNR1_TY.
    TYPES:BEGIN OF CDHDR_TY,
             OBJECTCLAS LIKE CDHDR-OBJECTCLAS,
             OBJECTID   LIKE CDHDR-OBJECTID,
             CHANGENR   LIKE CDHDR-CHANGENR,
             USERNAME   LIKE CDHDR-USERNAME,
             UDATE      LIKE CDHDR-UDATE,
            END OF CDHDR_TY.
    TYPES:BEGIN OF CDPOS_TY,
             OBJECTCLAS LIKE CDPOS-OBJECTCLAS,
             OBJECTID   LIKE CDPOS-OBJECTID,
             CHANGENR   LIKE CDPOS-CHANGENR,
             TABNAME    LIKE CDPOS-TABNAME,
             FNAME      LIKE CDPOS-FNAME,
             CHNGIND    LIKE CDPOS-CHNGIND,
             VALUE_NEW  LIKE CDPOS-VALUE_NEW,
             VALUE_OLD  LIKE CDPOS-VALUE_OLD,
            END OF CDPOS_TY.
    **************TABLE TYPES********************************************
    TYPES: MARC_TAB   TYPE TABLE OF MARC_TY,
           MATNR1_TAB TYPE TABLE OF MATNR1_TY,
           CDHDR_TAB  TYPE TABLE OF CDHDR_TY,
           CDPOS_TAB  TYPE TABLE OF CDPOS_TY.
    *******************INTERNAL TABLES************************************
    DATA:MARC_ITAB   TYPE MARC_TAB,
         MATNR1_ITAB TYPE MATNR1_TAB,
         CDHDR_ITAB  TYPE CDHDR_TAB,
         CDPOS_ITAB  TYPE CDPOS_TAB.
    ****************WORK AREAS********************************************
    DATA:MARC_WA   TYPE MARC_TY,
         MATNR1_WA TYPE MATNR1_TY,
         CDHDR_WA  TYPE CDHDR_TY,
         CDPOS_WA  TYPE CDPOS_TY.
    *******************SELECTION-SCREEN***********************************
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.
      PARAMETERS:PLANT LIKE MARC-WERKS.
      SELECT-OPTIONS:MATERIAL FOR MARC-MATNR.
      SELECT-OPTIONS:DATE FOR CDHDR-UDATE.
    SELECTION-SCREEN END OF BLOCK B1.
    START-OF-SELECTION.
    SELECT MATNR
            WERKS
            EKGRP
            MINBE
            EISBE
            MABST
            FROM MARC INTO TABLE MARC_ITAB
            WHERE MATNR IN MATERIAL
            AND WERKS = PLANT.
      CHECK MARC_ITAB[] IS NOT INITIAL.
      LOOP AT MARC_ITAB INTO MARC_WA.
       MATNR1_WA-MATNR1 = MARC_WA-MATNR.
       APPEND MATNR1_WA TO MATNR1_ITAB.
       CLEAR MATNR1_WA.
    ENDLOOP.
    CHECK MATNR1_ITAB[] IS NOT INITIAL.
    SELECT OBJECTCLAS
            OBJECTID
            CHANGENR
            USERNAME
            UDATE
            FROM CDHDR INTO TABLE CDHDR_ITAB
            FOR ALL ENTRIES IN MATNR1_ITAB
            WHERE OBJECTCLAS = 'MATERIAL'
            AND OBJECTID = MATNR1_ITAB-MATNR1
            AND UDATE IN DATE.
    CHECK CDHDR_ITAB[] IS NOT INITIAL.
    SORT CDHDR_ITAB[]  DESCENDING BY OBJECTID  CHANGENR.
    DELETE ADJACENT DUPLICATES FROM CDHDR_ITAB[] COMPARING OBJECTID.
    SELECT OBJECTCLAS
           OBJECTID
           CHANGENR
           TABNAME
           FNAME
           CHNGIND
           VALUE_NEW
           VALUE_OLD
           FROM CDPOS INTO CORRESPONDING FIELDS OF TABLE CDPOS_ITAB
           FOR ALL ENTRIES IN CDHDR_ITAB
           WHERE OBJECTCLAS = CDHDR_ITAB-OBJECTCLAS
           AND OBJECTID = CDHDR_ITAB-OBJECTID
           AND CHANGENR = CDHDR_ITAB-CHANGENR
           AND TABNAME  = 'MARC'
           AND FNAME    IN ('MINBE','EISBE','MABST','LVORM')
           AND CHNGIND  = 'U'.
    CHECK CDPOS_ITAB[] IS NOT INITIAL.
    *LOOP AT CDPOS_ITAB INTO CDPOS_WA.
    WRITE: / CDPOS_WA-OBJECTCLAS,
             CDPOS_WA-OBJECTID,
             CDPOS_WA-CHANGENR,
             CDPOS_WA-TABNAME,
             CDPOS_WA-FNAME,
             CDPOS_WA-CHNGIND,
             CDPOS_WA-VALUE_NEW,
             CDPOS_WA-VALUE_OLD.
    *ENDLOOP.
    WA-SELTEXT_L = 'OBJECTCLAS'.
    WA-COL_POS   = '1'.
    WA-FIELDNAME = 'OBJECTCLAS'.
    WA-TABNAME   = 'CDPOS_ITAB'.
    WA-OUTPUTLEN = '15'.
    APPEND WA TO HEADER.
    CLEAR WA.
    WA-SELTEXT_L = 'OBJECTID'.
    WA-COL_POS   = '2'.
    WA-FIELDNAME = 'OBJECTID'.
    WA-TABNAME   = 'CDPOS_ITAB'.
    WA-OUTPUTLEN = '20'.
    APPEND WA TO HEADER.
    CLEAR WA.
    WA-SELTEXT_L = 'CHANGENR'.
    WA-COL_POS   = '3'.
    WA-FIELDNAME = 'CHANGENR'.
    WA-TABNAME   = 'CDPOS_ITAB'.
    WA-OUTPUTLEN = '8'.
    APPEND WA TO HEADER.
    CLEAR WA.
    WA-SELTEXT_L = 'TABNAME'.
    WA-COL_POS   = '4'.
    WA-FIELDNAME = 'TABNAME'.
    WA-TABNAME   = 'CDPOS_ITAB'.
    WA-OUTPUTLEN = '5'.
    APPEND WA TO HEADER.
    CLEAR WA.
    WA-SELTEXT_L = 'FNAME'.
    WA-COL_POS   = '5'.
    WA-FIELDNAME = 'FNAME'.
    WA-TABNAME   = 'CDPOS_ITAB'.
    WA-OUTPUTLEN = '7'.
    APPEND WA TO HEADER.
    CLEAR WA.
    WA-SELTEXT_L = 'CHANGING'.
    WA-COL_POS   = '6'.
    WA-FIELDNAME = 'CHANGING'.
    WA-TABNAME   = 'CDPOS_ITAB'.
    WA-OUTPUTLEN = '1'.
    APPEND WA TO HEADER.
    CLEAR WA.
    WA-SELTEXT_L = 'VALUE_NEW'.
    WA-COL_POS   = '7'.
    WA-FIELDNAME = 'VALUE_NEW'.
    WA-TABNAME   = 'CDPOS_ITAB'.
    WA-OUTPUTLEN = '5'.
    APPEND WA TO HEADER.
    CLEAR WA.
    WA-SELTEXT_L = 'VALUE_OLD'.
    WA-COL_POS   = '8'.
    WA-FIELDNAME = 'VALUE_OLD'.
    WA-TABNAME   = 'CDPOS_ITAB'.
    WA-OUTPUTLEN = '5'.
    APPEND WA TO HEADER.
    CLEAR WA.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
        I_PROGRAM_NAME               = SY-REPID
        I_INTERNAL_TABNAME           = 'CDPOS_ITAB'
        I_CLIENT_NEVER_DISPLAY       = 'X'
        I_INCLNAME                   = SY-REPID
      CHANGING
        CT_FIELDCAT                  = HEADER[]
    EXCEPTIONS
    IF SY-SUBRC <> 0.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM                = SY-REPID
        IT_FIELDCAT                       = HEADER[]
      TABLES
        T_OUTTAB                          = CDPOS_ITAB[]
    IF SY-SUBRC <> 0.
    ENDIF.

    Your select querry on MARC is not matching with MARC_TY.
    The field in the MARC table and MARC_TY should be same.
    and also, when you are making select querry on CDPOS table
    with all entries.
    When ever you are using all entries select statement, you should check whether the internal table is having value.
    you should check
    if CDPOS_IT[] is not initial.
    SELECT OBJECTCLAS
    OBJECTID
    CHANGENR
    TABNAME
    FNAME
    CHNGIND
    VALUE_NEW
    VALUE_OLD
    FROM CDPOS INTO CORRESPONDING FIELDS OF TABLE CDPOS_ITAB
    FOR ALL ENTRIES IN CDHDR_ITAB
    WHERE OBJECTCLAS = CDHDR_ITAB-OBJECTCLAS
    AND OBJECTID = CDHDR_ITAB-OBJECTID
    AND CHANGENR = CDHDR_ITAB-CHANGENR
    AND TABNAME = 'MARC'
    AND FNAME IN ('MINBE','EISBE','MABST','LVORM')
    AND CHNGIND = 'U'.
    endif.
    Regards
    Madhan D

  • The type of the database table and work area (or internal table)...

    Hello
    I am trying to use a database and select all records from it and store them into an internal table.
    My code:
    Select * from xixi_dbcurrency into table gt_currency.
    The error:
    "The type of the database table and work area (or internal table) "GT_CURRENCY" are not Unicode-convertible . . . . . . . . . .     "
    Any suggestions?
    Thank you

    Hi Thomas,
    Thank you for your inputs above.
    But as you suggested is we use INTO CORRESPONDING FIELDS OF TABLE then it resolve the error.
    But I have below piece of code:
    DATA:    it_new_source TYPE STANDARD TABLE OF _ty_s_sc_1,
                  wa_source TYPE _ty_s_sc_1,
                  wa_new_source TYPE _ty_s_sc_1,
                  ls_target_key TYPE t_target_key.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE it_new_source
           FROM /bic/afao06pa100
           FOR ALL ENTRIES IN SOURCE_PACKAGE
           where /bic/fcckjobno = SOURCE_PACKAGE-/bic/fcckjobno
           and /bic/fcckjitid = SOURCE_PACKAGE-/bic/fcckjitid.
    But since this is reading into corresponding fields of table the data load from one DSO to other DOS is running for long more that 15 hours and still not getting completed and giving dump.
    So if I switch the search to below:
    SELECT * FROM /bic/afao06pa100
       INTO TABLE it_new_source
           FOR ALL ENTRIES IN SOURCE_PACKAGE
           where /bic/fcckjobno = SOURCE_PACKAGE-/bic/fcckjobno
           and /bic/fcckjitid = SOURCE_PACKAGE-/bic/fcckjitid.
    Then I am getting below error:E:The type of the database table and work area (or internal table) "IT_NEW_SOURCE" are not Unicode convertible.
    Can you please advice on this, as performance need to improve in start routine code.
    Thank You.

  • Conversion of ABAP struct to XML and XML back to ABAP structure in ECC

    We would like to convert many ABAP structure and internal tables into an XML string and later on convert these XML strings back to ABAP structures and internal tables. Can someone let us know if there are any function modules in ECC which can import the structures or internal tables and export the XML. Also if there are any function modules which can do the reverse i.e. import the XML string and convert it back to Structure or internal table.
    We found the some method called "Call transformation" but it gives an error such as version not active. CRM has FMs which do these functionalities.
    Any guidance would be appreciated.
    Thanks.

    If you look into the FM's BANK_API_PP_UT_DATA_TO_XML and BANK_API_PP_UT_XML_TO_DATA they again use CALL TRANSFORMATION, so probably u might have to figure how to eliminate the errors ur getting using CALL TRANSFORMATION.

  • How to Convert internal table data into xml and xml data into internal tab

    Hi Guys,
          I have a requirement  that  i have to convert the internal table data into xml format and viceversa . for my requirement  i came to know that i have to use Transformations concept.  i done the converting the data from internal table into xml data by using standard Tranformations. My Question is 
    1) Can i use same Transformation to convert the xml data into abap internal table. if it is possible then how ???
    2) Is it possible using the standard Transformation  or I have to go for XSLT approach
    Please help me out from this guys,
    Thanks and Regards
    Koti

    Hi Koti,
    This is possible. There is a link. With the help of this link you can convert ABAP data to XML and vice versa.
    Link: http://www.heidoc.net/joomla/index.php?option=com_content&view=article&id=15:sapxslt&catid=22:sap-xslt&Itemid=31

  • How to parse XML and store the data in  tables using sql or plsql?

    I want to parse the xml
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <xmlListWrapper>
        <size>2</size>
    <AppTypeID>10</AppTypeID>
    </xmlListWrapper>
    and store in a table
    |pk|apptypeid|
    1     10

    You can extract data from your XML along these lines...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select xmltype('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      2  <xmlListWrapper>
      3    <size>2</size>
      4    <AppTypeID>10</AppTypeID>
      5    <AppTypeID>20</AppTypeID>
      6  </xmlListWrapper>') as xml from dual)
      7  --
      8  -- end of example data
      9  --
    10  select x.*
    11  from   t
    12        ,xmltable('/xmlListWrapper/AppTypeID'
    13                  passing t.xml
    14                  columns pk for ordinality
    15                         ,apptypeid number path '.'
    16*                ) x
    SQL> /
            PK  APPTYPEID
             1         10
             2         20
    SQL>
    Inserting it to a table is obviously achieved using an INSERT ... SELECT ... where the SELECT is extracting the data from the XML.

  • Using JCo : IDoc to XML and XML to IDoc

    Hey guys,
    I need some guidance on Creating an xml file out of an IDoc using JCo and vice versa.
    Can anybody please provide with the code samples or any kind of documentation on this topic.
    Points will be rewarded
    +| Eleana West

    Hi,
    what you are looking for is the sapidocjco.jar. You can get if from the service marketplace and it comes with a couple of example Java code which shows how to implement it. You will also need the normal JCo jar to use the sapidocjco.jar.
    Bye,
    Sameer

  • Generating itab- xml and xml- pdf

    i am generating a report program, content of a table is store in itab and i want my report program to generate xml file for the content of itab first and after that, by using that xml file i want to generate pdf file

    hi
    try this  ...
    tables:
      tsp01.
    *-- STRUCTURES
    data:
      mstr_print_parms like pri_params,
      mc_valid(1)      type c,
      mi_bytecount     type i,
      mi_length        type i,
      mi_rqident       like tsp01-rqident.
    *-- INTERNAL TABLES
    data:
      mtab_pdf    like tline occurs 0 with header line,
      mc_filename like rlgrap-filename.
    *-- SELECTION SCREEN
    data :
      p_repid like sy-repid value '<i><b>ur prg name havin the itab to b displayed</b></i>', " Report to execute
      p_linsz like sy-linsz value 132, " Line size
      p_paart like sy-paart value 'X_65_132'.  " Paper Format
    If user want use this as common program for all PDF Conversion
    then use the parameter option, which will get the report name
    Line size & Paper Format as input
    *parameters:
    p_repid like sy-repid, " Report to execute
    p_linsz like sy-linsz default 132, " Line size
    p_paart like sy-paart default 'X_65_132'.  " Paper Format
    start-of-selection.
    concatenate 'c:\'
                p_repid
                '.pdf'
      into mc_filename.
    *-- Setup the Print Parmaters
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
    exporting
         no_dialog = 'X'
      IMPORTING
        out_parameters       = mstr_print_parms
        valid                = mc_valid
      EXCEPTIONS
        invalid_print_params = 2
        OTHERS               = 4.
    *-- Make sure that a printer destination has been set up
    *-- If this is not done the PDF function module ABENDS
      if mstr_print_parms-pdest = space.
        mstr_print_parms-pdest = 'LOCL'.
      endif.
    *-- Explicitly set line width, and output format so that
    *-- the PDF conversion comes out OK
      mstr_print_parms-linsz = p_linsz.
      mstr_print_parms-paart = p_paart.
      submit (p_repid) to sap-spool without spool dynpro
                       spool parameters mstr_print_parms
                       via selection-screen
                       and return.
    *-- Find out what the spool number is that was just created
      perform get_spool_number using sy-repid
                 sy-uname
        changing mi_rqident.
    *-- Convert Spool to PDF
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid = mi_rqident
          no_dialog  = space
          dst_device = mstr_print_parms-pdest
        importing
          pdf_bytecount                  = mi_bytecount
        tables
          pdf        = mtab_pdf
        exceptions
          err_no_abap_spooljob           = 1
          err_no_spooljob                = 2
          err_no_permission              = 3
          err_conv_not_possible          = 4
          err_bad_destdevice             = 5
          user_cancelled                 = 6
          err_spoolerror                 = 7
          err_temseerror                 = 8
          err_btcjob_open_failed         = 9
          err_btcjob_submit_failed       = 10
          err_btcjob_close_failed        = 11
          others     = 12.
    call function 'DOWNLOAD'
         exporting
              bin_filesize            = mi_bytecount
              filename                = mc_filename
              filetype                = 'BIN'
         importing
              act_filename            = mc_filename
         tables
              data_tab                = mtab_pdf.
          FORM get_spool_number *
          Get the most recent spool created by user/report              *
    -->  F_REPID               *
    -->  F_UNAME               *
    -->  F_RQIDENT             *
    form get_spool_number using f_repid
         f_uname
                    changing f_rqident.
      data:
        lc_rq2name like tsp01-rq2name.
      concatenate f_repid+0(9)
                  f_uname+0(3)
        into lc_rq2name.  " separated by '_'.
      select * from tsp01 where  rq2name = lc_rq2name
      order by rqcretime descending.
        f_rqident = tsp01-rqident.
        exit.
      endselect.
      if sy-subrc ne 0.
        clear f_rqident.
      endif.
    endform." get_spool_number
    *reward if useful.
    Message was edited by:
            neha gupta

  • Reading Data from Unix file and write into an Internal table

    Dear all,
                     I am having an requirement of reading data from unix file and write the same into an internal table..how to do that ...experts please help me in this regard.

    Hi,
    do like this
    PARAMETERS: p_unix LIKE rlgrap-filename OBLIGATORY.
    DATA: v_buffer(2047) TYPE c.
    DATA: BEGIN OF i_buffer OCCURS 0,
            line(2047) TYPE c,
    END OF i_buffer.
    * Open the unix file..
    OPEN DATASET p_unix FOR INPUT IN TEXT MODE.
    <b>IF sy-subrc NE 0.
    *** Error Message "Unable to open file.
    ELSE.</b>
       DO.
         CLEAR: v_buffer.
         READ DATASET p_unix INTO v_buffer.
         IF sy-subrc NE 0.
            EXIT.
         ENDIF.
         MOVE v_buffer TO i_buffer.
         APPEND i_buffer.
      ENDDO.
    ENDIF.
    CLOSE DATASET p_unix.
    <b>Reward points if it helps,</b>
    Satish

  • Selecting multiple records from the list and append it into internal table.

    hi
    there is a list of 10 records in the output screen with check boxes. if the user select any 3 records then those records should get appended in some other internal table of same structure.
    this is the requirement. can anybody help me it is very urgent.
    regards
    sami

    Hi,
    Loop at the internal table which contains the value in table control and move it to a work area. apend the work area to the next internal table. Like:
    loop at it1 into wa1 where sel = 'X'.
    append wa1 to it2.
    endloop.
    or
    loop at it1 into wa1.
    if wa1-sel = 'X'.
    append wa1 to it2.
    endif.
    endloop.
    Regards,
    RM

  • Dynamic creation of variables and alv grid output/internal table

    Dear Experts
    I am stuck in an inventory ageing report which is to be done year wise. the scenario is as follow.
    selection screen i enter the year 2011 or 2010 or 2009.
    the output should show me 2011-2007 or 2010-2007 or 2009-2007. the alv grid should always start from 2007 and end at the year that is entered in the selection screen.
    Now how can i create a dynamic variables to store the values of the corresponding yr and also how can i create a dynamic internal table to store these values.
    Thanks & Regards
    Zamir Parkar

    Hi Zamir,
    if you are new to ABAP you may leave old and buggy techniques behind.
    If you want to create the table dynamically, please do not use l_alv_table_create=>create_dynamic_table because it is limited and always triggers a possibly unwanted database commit.
    You better use RTTS dynamic runtime type services, i.e. check the example for [Creating Flat and Complex Internal Tables Dynamically using RTTI|http://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI].
    As done here, leave all outdated ALV technologies behind and start with CL_SALV_TABLE. It is following the object-oriented approach and does not need a field catalog.
    You will get used to field-symbols that can be compared to the data referenced by a pointer. For dynamic fields, you may build the field names dynamically, i.e.
    DATA:
          lo_structdescr         TYPE REF TO cl_abap_structdescr,
          lo_typedescr           TYPE REF TO cl_abap_typedescr,
          lo_tabledescr          TYPE REF TO cl_abap_tabledescr,
          lr_data                TYPE REF TO data,
          lt_comp_all            TYPE cl_abap_structdescr=>component_table,
          lv_index               TYPE numc2.
        FIELD-SYMBOLS:
          <any>                  TYPE ANY,
          <component>            TYPE LINE OF abap_component_tab,
           <table>                TYPE table.
        DO nnn TIMES.
          lv_index = sy-index.
          lo_typedescr   =  cl_abap_typedescr=>describe_by_name( <name of data element> ).
          APPEND INITIAL LINE TO lt_comp_all ASSIGNING <component>.
          <component>-type ?= lo_typedescr.
          CONCATENATE 'YEARVAL' lc_underscore lv_index INTO <component>-name.
          <component>-as_include  = abap_true.
          CONCATENATE lc_underscore lv_index INTO <component>-suffix.
        ENDDO.
    * create description object for structured type
        lo_structdescr = cl_abap_structdescr=>create( lt_comp_all ).
    *  create table description object for this
        lo_tabledescr = cl_abap_tabledescr=>create(
                        p_line_type  = lo_structdescr
                        p_table_kind = cl_abap_tabledescr=>tablekind_std
                        p_unique     = abap_false ).
    * create data object
        CREATE DATA lr_data TYPE HANDLE lo_tabledescr.
    ASSIGN lr_data->* to <table>.
    This is a fragment. Please adapt to your needs.
    Regards,
    Clemens

  • Creation of view and use it as internal table

    dear community,
                   My questions is taht i am write a select quary in that data is very huge so that it cant inserted in to internal table(memory size of internal table) so i thing that i create aview same as data base table and when write the select quary use packsize and transfer recoerd ds in that view and use this view in my program
    is above logic can work or not
    also is size of view is greater than internal table memory size.

    Writing the large volume to another table(which a view is just a view of a table or group of tables) is not going to solve the problem.  You still have to select the data from the view(or table).  Like I said in your other threads, you need to read by package size, and do something with that subset, whether it is summaring, or writeing to another system via RFC.
    Regards,
    Rich Heilman

  • The ABAP program lines are wider than the internal table.

    Hello;
    i use FM REUSE_ALV_FIELDCATALOG_MERGE to fill in fieldcat from an internal table but i receive dump message  READ_REPORT_LINE_TOO_LONG. Is there smt. like a type mismatch or waht can that be?
    detail explanation of the dump is
    The internal table "\FUNCTION=K_KKB_FIELDCAT_MERGE\DATA=L_ABAP_SOURCE[]" is 72 characters wide. The program line is                                              
    81 characters wide.                                                                
    source of the call is like:
    DATA: ALV_FIELDCAT     TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          ALV_HEADER       TYPE SLIS_T_LISTHEADER WITH HEADER LINE,
          ALV_EVENTS       TYPE SLIS_T_EVENT WITH HEADER LINE,
          ALV_LAYOUT       TYPE SLIS_LAYOUT_ALV,
          ALV_PRINT        TYPE SLIS_PRINT_ALV,
          ALV_REPID        LIKE SY-REPID,    " program name
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          I_PROGRAM_NAME     = alv_repid
          I_INTERNAL_TABNAME = 'ITAB'
          I_INCLNAME         = alv_repid
        CHANGING
          CT_FIELDCAT        = alv_fieldcat[]
        EXCEPTIONS
          OTHERS             = 3.
    thx in advance
    Ali

    Hi,
    At least one line of the source text is longer than the lines of the internal table itab then,
    READ_REPORT_LINE_TOO_LONG.  error occurs.
    Cause: At least one line of the source text is longer than the lines of the internal table itab.
    Runtime Error: READ_REPORT_LINE_TOO_LONG
    check the link below for further info
    http://www.s001.org/ABAP-Hlp/abapread_report.htm
    one more thing, whether u have given report name
    ALV_REPID = 'ZXYZ'.  
    if ZXYZ is u r program name

Maybe you are looking for