Xml data into internal table

Hi Friends,
See the followong code which converts xml data into itab.
*& Report  ZTEST_XML1                                                  *
REPORT  ZTEST_XML1                              .
*PURPOSE: This program transfers XML data into SAP internal table format
*The nodes in DOM can be stored as fields in SAP Internal table
type pool definitions
TYPE-POOLS: ixml. "iXML Library Types
type definitions
TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xmldata TYPE string.
DATA: l_elem TYPE REF TO if_ixml_element,
l_root_node TYPE REF TO if_ixml_node,
l_next_node TYPE REF TO if_ixml_node,
l_name TYPE string,
l_iterator TYPE REF TO if_ixml_node_iterator.
DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
*t_xml_line
l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
l_xml_table_size TYPE i. " XML table size
DATA: l_filename TYPE string. " String to hold filename
data: begin of i_final occurs 0,
      pnumber(20),
      pname(50),
      pdes(70),
      end of i_final.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'C:\product.xml'.
Validation of XML file: Only DTD included in XML document is supported
PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
start of selection
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
Wrap the table containing the file into a stream.
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Creating a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
IF pa_val = 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
Parse the stream
IF l_parser->parse( ) <> 0.
IF l_parser->num_errors( ) <> 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
PERFORM process_dom USING l_document.
ENDIF.
*& Form get_xml_table
text
<--P_L_XML_TABLE_SIZE text
<--P_L_XML_TABLE text
FORM get_xml_table CHANGING p_l_xml_table_size
p_l_xml_table.
Local variable declarations
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = pa_file.
Upload file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement
= space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
ENDFORM. " get_xml_table
*& Form process_dom
text
-->P_L_DOCUMENT text
FORM process_dom USING document TYPE REF TO if_ixml_document.
DATA: node TYPE REF TO if_ixml_node,
iterator TYPE REF TO if_ixml_node_iterator,
nodemap TYPE REF TO if_ixml_named_node_map,
attr TYPE REF TO if_ixml_node,
name TYPE string,
prefix TYPE string,
value TYPE string,
indent TYPE i,
count TYPE i,
index TYPE i.
node ?= document.
CHECK NOT node IS INITIAL.
ULINE.
WRITE:/.
WRITE: /' DOM-TREE'.
WRITE: /.
IF node IS INITIAL.
EXIT.
ENDIF.
Create a node iterator
iterator = node->create_iterator( ).
Get current node
node = iterator->get_next( ).
Loop over all nodes
WHILE NOT node IS INITIAL.
indent = node->get_height( ) * 2.
indent = indent + 20.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
IF NOT nodemap IS INITIAL.
attributes
count = nodemap->get_length( ).
DO count TIMES.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
value COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
WRITE: / 'VALUE :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
Advance to next node
node = iterator->get_next( ).
ENDWHILE.
*delete adjacent duplicates from  i_final.
*loop at i_final.
*write:/ i_final-pnumber,i_final-pname,i_final-pdes.
*endloop.
*if not i_final[] is initial.
*modify ztestproduct from table i_final.
*endif.
ENDFORM. " process_dom
in the above code at line no: 268 there is a method:
value = node->get_value( ).in which actual data from XML file is coming.
So the varibale "Value" contains the data.
see line no: 270:
WRITE: AT indent value COLOR COL_GROUP INVERSE.
what ever values i am getting here i want to append to a Internal table ...
Can any body tell me how to do that?
i am sure of reward points.

Hai Ravi
REPORT abc.
DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
FIRST PHASE
FIRST PHASE
FIRST PHASE
Fetch Data
SELECT * FROM t001 INTO TABLE t001.
XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
Convert to TABLE
CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = xml_out
i_tabline_length = 100
TABLES
et_table = itab.
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:\xx.xml'
TABLES
data_tab = itab.
SECOND PHASE
SECOND PHASE
SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[].
Regards
Sreeni

Similar Messages

  • How to convert xml file into internal table in ABAP Mapping.

    Hi All,
    I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
      <BookingCode>2KY34R</BookingCode>
    - <Passenger>
      <Name>SARVESH</Name>
      <Address>THANE</Address>
      </Passenger>
    - <Passenger>
      <Name>RAJESH</Name>
      <Address>POWAI</Address>
      </Passenger>
    - <Passenger>
      <Name>CARRON</Name>
      <Address>JUHU</Address>
      </Passenger>
    - <Flight>
      <Date>03/03/07</Date>
      <AirlineID>UA</AirlineID>
      <FlightNumber>125</FlightNumber>
      <From>LAS</From>
      <To>SFO</To>
      </Flight>
      </ns0:MTO_ABAP_MAPPING>
    AT the receiver side I wnat to concatenate the NAME & ADDRESS.
    I tried Robert Eijpe's weblog (/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach)
    but couldnt succeed to convert the xml file into internal table perfectly.
    Can anybody help on this. 
    Thanks in advance!!
    Sarvesh

    Hi Sarvesh,
    The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
    Just in case you have not seen this
    regards
    Vijaya

  • Upload excel data into Internal table

    Hi,
    I'm trying to upload excel data into internal table, well the excel file layout will be different on each run of the report.
    Excel file will have 60 columns and 500 record limit. I can upload the excel data using 'ALSM_EXCEL_TO_INTERNAL_TABLE' and 'KCD_EXCEL_OLE_TO_INT_CONVERT' but the output table is generates 60 lines for each record i.e.., 60 * 500 = 30,000 which could cause performance.
    I try with the FM 'TEXT_CONVERT_XLS_TO_SAP', but this will only work if the file structure is static. It didn't work for dynamic file layout. Even GUI_UPLOAD doesn't work to upload excel file, it will work if I convert the file to Tab delimited file.
    Please advise if you know any alternate procedure to upload excel data into internal table.
    Thanks,
    Kumar.

    Moderator message - Cross post locked
    Rob

  • Problem in collecting Spool data into internal table

    Hi ,
    i need to download  spool request data into internal table,
    after collecting i need to loop it and delete some records,
    for this i am using  Fm  RSPO_RETURN_ABAP_SPOOLJOB
    but getting some extra spaces and lines,unable to get right format.
    please help me in this issue to prepare internal table like normal internal table with spool id.
    Regards
    sarath

    Hi ,
    Thanks for the reply,
    My requirement is like i need to collect all the records from the spool to Internal table and
    after that based on one field in the internal table i have to separate error records by deleting sucess records from that internal table(from spool),
    for that i have to loop the internal table and need to count the error records, after that download to excel and mail functionalities
    required for that .
    so please help me in this.
    Regards
    sarath

  • How to store XML data into Oracle Table

    I had trouble to store XML data into Oracle Table with XDK (Oracle 8.1.7 ). The error is:
    C:\XDK_Java_9_2\xdk\demo\java\Test>java testInsert Dept.xml
    <Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
    Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
    at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2263)
    at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1333)
    at testInsert.main(testInsert.java:8)
    Here is my xml file:
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <DEPTNO>10</DEPTNO>
    <DNAME>ACCOUNTING</DNAME>
    <LOC>NEW YORK</LOC>
    </ROW>
    <ROW num="2">
    <DEPTNO>20</DEPTNO>
    <DNAME>RESEARCH</DNAME>
    <LOC>DALLAS</LOC>
    </ROW>
    <ROW num="3">
    <DEPTNO>30</DEPTNO>
    <DNAME>SALES</DNAME>
    <LOC>CHICAGO</LOC>
    </ROW>
    <ROW num="4">
    <DEPTNO>40</DEPTNO>
    <DNAME>OPERATIONS</DNAME>
    <LOC>BOSTON</LOC>
    </ROW>
    </ROWSET>
    and here is structure of table:
    Name Null? Type
    DEPTNO NOT NULL NUMBER(2)
    DNAME VARCHAR2(14)
    LOC VARCHAR2(13)
    and here is my Java Code:
    import java.sql.*;
    import oracle.xml.sql.dml.OracleXMLSave;
    public class testInsert{
         public static void main(String[] args) throws SQLException{
              Connection conn = getConnection();
              OracleXMLSave sav = new OracleXMLSave(conn,"scott.tmp_dept");
              sav.insertXML(args[0]);
              sav.close();
              conn.close();
         private static Connection getConnection()throws SQLException{
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@amt-ebdev01:1521:mydept","scott","tiger");
              return conn;
    Could you help me ? Thanks !

    The problem is that you need to pass avalid URL , Document...
    Please try this code instead:
    import java.net.*;
    import java.sql.*;
    import java.io.*;
    import oracle.xml.sql.dml.OracleXMLSave;
    public class testInsert
    public static void main(String[] args) throws SQLException{
    Connection conn = getConnection();
    OracleXMLSave sav = new OracleXMLSave(conn,"scott.temp_dept");
    URL url = createURL(args[0]);
    sav.insertXML(url);
    sav.close();
    conn.close();
    private static Connection getConnection()throws SQLException{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dlsun1982:1521:jwxdk9i","scott","tiger");
    return conn;
    // Helper method to create a URL from a file name
    static URL createURL(String fileName)
    URL url = null;
    try
    url = new URL(fileName);
    catch (MalformedURLException ex)
    File f = new File(fileName);
    try
    String path = f.getAbsolutePath();
    // This is a bunch of weird code that is required to
    // make a valid URL on the Windows platform, due
    // to inconsistencies in what getAbsolutePath returns.
    String fs = System.getProperty("file.separator");
    if (fs.length() == 1)
    char sep = fs.charAt(0);
    if (sep != '/')
    path = path.replace(sep, '/');
    if (path.charAt(0) != '/')
    path = '/' + path;
    path = "file://" + path;
    url = new URL(path);
    catch (MalformedURLException e)
    System.out.println("Cannot create url for: " + fileName);
    System.exit(0);
    return url;

  • How to load text data into internal table

    I have a text file to load txt data into internal table. So how to read text data with validation and to load all text data into the internal table?
    Say this is the text file:
    IO_NAME, IO_TYPE, IO_SHTXT, IO_LONGTEXT, DATATYPE, DATA LENGTH
    ZIO_TEST1, CHA,      IO TEST1,      IO TEST 1,        CHAR,         20
    ZIO_TEST2, CHA,      IO TEST2,      IO TEST 2,        CHAR,         20
    Regards,
    Mau

    Hi,
    U can use GUI_UPLOAD for this...
    Declare an internal table like
    data: begin of itab occurs 0,
    string(1200),
    end of itab.
    check the sample code:
    cange as you need
    DATA: DATEI_PC TYPE STRING VALUE 'C:\MATNR.TXT'.
    DATA: BEGIN OF ITAB occurs 0,
    TXT(1024),
    END OF ITAB.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
    EXPORTING
    FILENAME = DATEI_PC
    FILETYPE = 'ASC'
    CHANGING
    DATA_TAB = ITAB[]
    EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_READ_ERROR = 2
    NO_BATCH = 3
    GUI_REFUSE_FILETRANSFER = 4
    INVALID_TYPE = 5
    NO_AUTHORITY = 6
    UNKNOWN_ERROR = 7
    BAD_DATA_FORMAT = 8
    HEADER_NOT_ALLOWED = 9
    SEPARATOR_NOT_ALLOWED = 10
    HEADER_TOO_LONG = 11
    UNKNOWN_DP_ERROR = 12
    ACCESS_DENIED = 13
    DP_OUT_OF_MEMORY = 14
    DISK_FULL = 15
    DP_TIMEOUT = 16
    NOT_SUPPORTED_BY_GUI = 17
    ERROR_NO_GUI = 18
    OTHERS = 19.
    IF SY-SUBRC NE 0. WRITE: / 'Error in Uploading'. STOP. ENDIF.
    WRITE: / 'UPLOAD:'.
    LOOP AT ITAB. WRITE: / ITAB-TXT. ENDLOOP.

  • Uploading  Excel sheet  data into internal table

    Hi All,
    I want to upload Excel file data into internal table. My problem is that my excel file  having more than one sheets. I want to upload  the data of particula Excel sheet..
    Please suggest me how can I upload particulat Excel sheet data .
    Thanks and regards
    Praveen

    check this link
    Uploading multiple excel sheets
    You can check Satish's answer in the above link
    Re: uploading data from excel sheets through BDC's into sap system
    <b>Award points if found helpful</b>

  • Loading Text data into internal table

    I have a text file to load txt data into internal table. So how to read text data with validation and to load all text data into the internal table?
    Say this is the text file:
    IO_NAME, IO_TYPE, IO_SHTXT, IO_LONGTEXT, DATATYPE, DATA LENGTH
    ZIO_TEST1, CHA, IO TEST1, IO TEST 1, CHAR, 20
    ZIO_TEST2, CHA, IO TEST2, IO TEST 2, CHAR, 20
    Regards,
    Mau

    hi Mau,
    look this code, maybe it's help u.
    <b>REPORT  ZTXTTOTABLE.</b>
    DATA: p_file   TYPE string value 'C:\teste.txt',
          BEGIN OF TI_table OCCURS 0,
            COD(5) TYPE C,
            NAME(40),
          END OF TI_table,
          a(2).
    PARAMETERS: sel_file(128) TYPE c
                default 'C:\teste.txt' OBLIGATORY LOWER CASE.
    p_file = sel_file.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename = p_file
      TABLES
        data_tab = ti_table[].
    format color COL_TOTAL INTENSIFIED ON.
    loop at ti_table.
      write: / sy-vline, ti_table-cod, at 10 sy-vline, ti_table-name,
             at 60 sy-vline.
    endloop.
    write: / sy-uline(60).
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_file.
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          def_filename     = ''
          def_path         = 'C:\'
          mask             = ',Documentos de texto (*.txt), *.txt.'
          mode             = ''
        IMPORTING
          filename         = p_file
        EXCEPTIONS
          inv_winsys       = 1
          no_batch         = 2
          selection_cancel = 3
          selection_error  = 4
          OTHERS           = 5.
      find '.txt' IN p_file.
      if sy-subrc <> 0.
        concatenate p_file '.txt' into sel_file.
      else.
        sel_file = p_file.
      endif.
    top-of-page.
      format color COL_HEADING INTENSIFIED ON.
      uline (60).
      write: / sy-vline, 'COD', at 10 sy-vline, 'NAME', at 60 sy-vline.
      write: / sy-uline(60).
    good luck!
    Regards
    Allan Cristian

  • Char data into internal table.

    Hi all,
    I will get data from the FTP (.TXT file) through FTP_SERVER_TO_R3.
    in chardata with separater Tab delimited.
    here i took one field symbol and assigning the data into internal table.
    till here every thing is ok.
    My problem is one data type is 13 char, if that field is more than 13 char in the file
    it is giving DUMP. (DUMP is OVERFLOW Field 999976767878.22)
    TYPES : BEGIN OF X_STRING,
                       LINE(150) TYPE STRING,
                  END OF X_STRING.
    data : IT_STRING TYPE STANDARD TABLE OF X_STRING,
              WA_STRING TYPE X_STRING.
                          FIELD-SYMBOLS : <fs> TYPE ANY.
                        LOOP AT chardata INTO wa_chardata.
                          REFRESH it_string.
                          SPLIT wa_chardataline AT cl_abap_char_utilities=>horizontal_tab INTO TABLE it_string.
                          LOOP AT it_string INTO wa_string FROM 1 TO 29.
                            ASSIGN COMPONENT sy-tabix OF STRUCTURE wa_data TO <fs>.
                            <fs> = wa_string-field1.
                            UNASSIGN <fs>.
                          ENDLOOP.
                          APPEND wa_data TO it_data.
                          CLEAR wa_data.
                        ENDLOOP.
    Please give me solution to over come this.
    Regards,
    Sri

    In Statement ASSIGN COMPONENT sy-tabix OF STRUCTURE wa_data TO <fs>.
    insted of using SY-TABIX  use the actual field name of the structre wa_data .
    Use a RTTS Method to get all the fields of the structre WA_DATA and then loop at all the fields and then manuplate teh that which has been splitted...!
    Hope it helps it will not cause any over flow..and ...( Try to condence the The splitted dat use condence addition while moveing the data to wa_data it will avoide the leading and trailing spaces.... )
    Edited by: Anup Deshmukh on Jun 17, 2010 8:31 AM

  • Extract the classification data into internal table

    Hi all,
    I having requirement to extract classification data for material number.
    1) Provide the selection option for material number (MATNR).
    2) Based on the material number, then extract all that data into internal table as below layout. My problem is how to retrieve the following data from different table based on the MATNR (material number).
    Please provide the sample code for select the following data. Thanks.
    Classification table
    OBJEK  (from AUSP table)
    MAFID (from AUSP table)
    KLART (from AUSP table)
    CLASS  (from KLAH table)
    ATWRT (from AUSP table)
    MSEHI  (from CABN table)
    OBTAB (check if class type=002, set it as “MARA”)
    STDCL (from KSSK table)

    Hi,
    if I understand, you´re trying to get information from the classification system for the material. You can use the following code:
    DATA: clases LIKE TABLE OF sclass WITH HEADER LINE,
          datos LIKE TABLE OF clobjdat WITH HEADER LINE.
    CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
         EXPORTING
              class              = 'DESK'               "clase a buscar
              classtype          = '001'                "tipo de la clase
              features           = 'X'
              language           = sy-langu
              object             = 'PM00A000C055'       "Material
              objecttable        = 'MARA'
              key_date           = sy-datum
              initial_charact    = 'X'
              change_service_clf = 'X'
         TABLES
              t_class            = clases
              t_objectdata       = datos
         EXCEPTIONS
              no_classification  = 1
              no_classtypes      = 2
              invalid_class_type = 3
              OTHERS             = 4.
    loop at datos.
    endloop.

  • 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

  • Problem to upload the data into internal table record length more than 6000

    Hi all
            I stuck with this problem from past 3 days. I have to upload the data from excel sheet. iam making it tab delimited and trying to upload from gui_upload. but in the structure of file, we have, one field of 4000 characters, and other fields of 255 characters.
    how can i upload this into internal table . From excel sheet or from tab delimeted or any other format? or any special function module is there?  while iam doing this its truncating the datat 255 characters and not uploading the other fields also...
    can any one of you help me out. ASAP
    thnks in advance

    from one of the forum iam just pasting code which it is used in lsmw, try the same logic in ur code hope it can work.
    you have to create multiple lines with do...enddo loop., like this:
    (assuming excel_long_text-text is 924 characters long, 7 lines X 132 char)
    __GLOBAL_DATA__
    data: offset type i,
    text_132(132) type c.
    __BEGIN_OF_RECORD__ Before Using Conversion Rules
    Rule : Default Settings Modified
    Code: /sapdmc/ltxtl = init_/sapdmc/ltxtl.
    CLEAR offset.
    DO 7 TIMES.
    text_132 = excel_long_text-text+offset(132).
    offset = offset + 132.
    __END_OF_RECORD__ After Using Conversion Rules
    Rule : Default Settings Modified
    Code: transfer_record.
    ENDDO.
    also check this
    COMMIT_TEXT
    To load long text into SAP
    READ_TEXT
    To load long text into SAP

  • Function module to get data into internal table from Excel file sheets

    Hi,
    I have to upload customers from excel file.
    we are donloading customer data excel file sheets.
    Customer data in 1 sheet, tax data the other sheet of same excel file, Customer master-Credit data in other sheet of same excel file.
    so i have 3-4 sheet in one excel file.
    now my requirement is to get the data from excel file into internal table.
    is there any function module.
    Thanks & Regards

    I am sending you the idea with an example how you can upload data from an EXCEL file into an internal table. I am not sure if you can take data from different sheet in the same EXCEL file. I think that this is not possible (try it )
    Upload the data into an internal table, like the way that I am describing in the above:
      DATA: L_MAX_COL_NB TYPE I.
      DATA: l_file_name LIKE RLGRAP-FILENAME.
    Just to be sure that is the correct type for the FM.
      l_file_name = P_FILE_NAME.
      L_MAX_COL_NB = 58.  "Maximum nb of colums that the FM can read.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                FILENAME                = l_file_name
                I_BEGIN_COL             = 1
                I_BEGIN_ROW             = 2
                I_END_COL               = L_MAX_COL_NB
                I_END_ROW               = 9999
           TABLES
                INTERN                  = PT_EXCEL
           EXCEPTIONS
                INCONSISTENT_PARAMETERS = 1
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
      ENDIF.
    Now you should upload the data into your own itab. The Function Module will return to you all the an itab
    from all fields and columns. Define the structure of the uploading file into SE11 - Data Dictionary. Then read the fieldcatalog of this structure. In the code that I am sending to you, I am insearting an empty line into the internal table and then I am assigning this line into a corresponding field-symbol. Then I am able to change the working area - so and the line of the itab. Propably you could you the statement APPEND INITIAL LINE TO (your_table_name) ASSIGNING <your_field_symbol>, but the example was written in an old SAP version.
      FIELD-SYMBOLS:
                     <F_REC> LIKE WA_UPLOAD_FILE,      "working are of the uploading file
                     <F_FIELD> TYPE ANY.
      DATA: COLUMN_INT TYPE I,
            C_FIELDNAME(30) TYPE C.
      PERFORM GET_FIELDCATOLG TABLES FIELDCAT
                               USING 'ZECO_CHARALAMBOUS_FILE'.
      LOOP AT PT_EXCEL.
        AT NEW ROW.
          ASSIGN WA_UPLOAD_FILE TO <F_REC>.
        ENDAT.
        COLUMN_INT = PT_EXCEL-COL.
        READ TABLE FIELDCAT INTO WA_FIELDCAT INDEX COLUMN_INT.
        CONCATENATE '<F_REC>-' WA_FIELDCAT-FIELDNAME INTO C_FIELDNAME.
        ASSIGN (C_FIELDNAME) TO <F_FIELD>.
        <F_FIELD> = PT_EXCEL-VALUE.
        AT END OF ROW.
          APPEND WA_UPLOAD_FILE TO GT_UPLOAD_FILE.
          CLEAR WA_UPLOAD_FILE.
        ENDAT.
      ENDLOOP.
    With Regards
    George
    Edited by: giorgos michaelaris on Mar 4, 2010 3:44 PM

  • Error in uploading excel sheet data into internal table

    Dear all,
    i am facing problem when uploading data from excel. i used KD_GET_FILENAME_ON_F4.i select the file and pass on to ALSM_EXCEL_INTO_INTERNAL_TABLE.and i get the ERROR....
      Illegal type when transferring an internal table to a FORM. this is my code .
    types : begin of ty_mm01,
            matnr like rmmg1-matnr,
            mbrsh like rmmg1-mbrsh,
            mtart like rmmg1-mtart,
            maktx like makt-maktx,
            meins like mara-meins,
            matkl like mara-matkl,
            bismt like mara-bismt,
            spart like mara-spart,
            mtpos like mara-mtpos_mara,
            end of ty_mm01.
    data :  tt_mm01 type standard table of ty_mm01,
            wa_mm01 like TT_MM01.
    data : t_bdcdata like standard table of bdcdata,
           t_bdcmsgcoll like standard table of bdcmsgcoll.
    constants:  begcol TYPE i value 1 ,
                begrow TYPE i value 1,
                endcol TYPE i value 100,
                endrow TYPE i value 32000.
    selection-screen : begin of block bdc with frame.
    parameter : tfile like rlgrap-filename obligatory.
    selection-screen : end of block bdc.
    at selection-screen on value-request for tfile.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
       PROGRAM_NAME        = 'ZMM_MAT_MAS_BASIC_DATA'
       DYNPRO_NUMBER       = '1000'
       FIELD_NAME          = 'TFILE'
       STATIC              = 'X'
      MASK                = ',*.xls,'
      CHANGING
        FILE_NAME           = tfile
    start-of-selection.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                      = tfile
        I_BEGIN_COL                   = begcol
        I_BEGIN_ROW                   = begrow
        I_END_COL                     = endcol
        I_END_ROW                     = endrow
      TABLES
        INTERN                        = tt_mm01
    EXCEPTIONS
      INCONSISTENT_PARAMETERS       = 1
      UPLOAD_OLE                    = 2
      OTHERS                        = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Thanks in advance

    Hi,
    Check these FM : KCD_EXCEL_OLE_TO_INT_CONVERT
    Report ZPSP_TEST.
    data: bdc_DATA like bdcdata occurs 0 with header line,
    mess_tab like bdcmsgcoll occurs 0 with header line.
    DATA: BEGIN OF ITAB OCCURS 0 ,
    tcnt TYPE i, "Table Counter &H0D
    WERKS LIKE T001W-WERKS,
    BNFPO LIKE EBAN-BNFPO,
    MATNR LIKE MARA-MATNR,
    MENGE LIKE EBAN-MENGE,
    END OF ITAB.
    start-of-selection.
    PERFORM upload_data.
    loop at itab.
    perform bdc_dynpro using 'SAPMM06B' '0100'.
    perform bdc_field using 'BDC_CURSOR'
    'EBAN-BSART'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'EBAN-BSART'
    'NB'.
    perform bdc_field using 'RM06B-LPEIN'
    'T'.
    perform bdc_field using 'EBAN-WERKS'
    ITAB-WERKS.
    perform bdc_dynpro using 'SAPMM06B' '0106'.
    perform bdc_field using 'BDC_CURSOR'
    'RM06B-EKGRP'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'RM06B-BNFPO'
    ITAB-BNFPO.
    perform bdc_dynpro using 'SAPMM06B' '0106'.
    perform bdc_field using 'BDC_CURSOR'
    'EBAN-MENGE(01)'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'EBAN-MATNR(01)'
    ITAB-MATNR.
    perform bdc_field using 'EBAN-MENGE(01)'
    ITAB-MENGE.
    perform bdc_dynpro using 'SAPMM06B' '0102'.
    perform bdc_field using 'BDC_CURSOR'
    'EBAN-MENGE'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    *perform bdc_field using 'RM06B-EEIND'
    record-EEIND_010.
    *perform bdc_field using 'RM06B-LPEIN'
    record-LPEIN_011.
    *perform bdc_field using 'EBAN-EKGRP'
    record-EKGRP_012.
    *perform bdc_field using 'EBAN-BADAT'
    record-BADAT_013.
    *perform bdc_field using 'EBAN-FRGDT'
    record-FRGDT_014.
    *perform bdc_field using 'EBAN-PREIS'
    record-PREIS_015.
    *perform bdc_field using 'EBAN-WAERS'
    record-WAERS_016.
    *perform bdc_field using 'EBAN-PEINH'
    record-PEINH_017.
    *perform bdc_field using 'EBAN-REPOS'
    record-REPOS_018.
    perform bdc_dynpro using 'SAPMM06B' '0106'.
    perform bdc_field using 'BDC_CURSOR'
    'EBAN-MENGE(02)'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    *perform bdc_field using 'RM06B-BNFPO'
    record-BNFPO_019.
    *perform bdc_field using 'EBAN-MATNR(02)'
    record-MATNR_02_020.
    *perform bdc_field using 'EBAN-MENGE(02)'
    record-MENGE_02_021.
    perform bdc_dynpro using 'SAPMM06B' '0102'.
    perform bdc_field using 'BDC_CURSOR'
    'EBAN-MENGE'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    *perform bdc_field using 'EBAN-MENGE'
    ITAB-MENGE_023.
    *perform bdc_field using 'RM06B-EEIND'
    record-EEIND_024.
    *perform bdc_field using 'RM06B-LPEIN'
    record-LPEIN_025.
    *perform bdc_field using 'EBAN-EKGRP'
    record-EKGRP_026.
    *perform bdc_field using 'EBAN-BADAT'
    record-BADAT_027.
    *perform bdc_field using 'EBAN-FRGDT'
    record-FRGDT_028.
    *perform bdc_field using 'EBAN-PREIS'
    record-PREIS_029.
    *perform bdc_field using 'EBAN-WAERS'
    record-WAERS_030.
    *perform bdc_field using 'EBAN-PEINH'
    record-PEINH_031.
    *perform bdc_field using 'EBAN-REPOS'
    record-REPOS_032.
    perform bdc_field using 'EBAN-TXZ01'
    'BEARING 2"X2"'.
    perform bdc_field using 'EBAN-MENGE'
    '65'.
    perform bdc_field using 'RM06B-EEIND'
    '2005/01/03'.
    perform bdc_field using 'RM06B-LPEIN'
    'D'.
    perform bdc_field using 'EBAN-EKGRP'
    'M11'.
    perform bdc_field using 'EBAN-BADAT'
    '2005/01/03'.
    perform bdc_field using 'EBAN-FRGDT'
    '2005/01/03'.
    perform bdc_field using 'EBAN-PREIS'
    ' 1,120.00'.
    perform bdc_field using 'EBAN-WAERS'
    'EUR'.
    perform bdc_field using 'EBAN-PEINH'
    '1'.
    perform bdc_field using 'EBAN-REPOS'
    'X'.
    perform bdc_dynpro using 'SAPMM06B' '0102'.
    perform bdc_field using 'BDC_CURSOR'
    'EBAN-MENGE'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'EBAN-TXZ01'
    'DRILLING PIPE 10"'.
    perform bdc_field using 'EBAN-MENGE'
    '75'.
    perform bdc_field using 'RM06B-EEIND'
    '2005/01/03'.
    perform bdc_field using 'RM06B-LPEIN'
    'D'.
    perform bdc_field using 'EBAN-EKGRP'
    'M11'.
    perform bdc_field using 'EBAN-BADAT'
    '2005/01/03'.
    perform bdc_field using 'EBAN-FRGDT'
    '2005/01/03'.
    perform bdc_field using 'EBAN-PREIS'
    ' 0.53'.
    perform bdc_field using 'EBAN-WAERS'
    'EUR'.
    perform bdc_field using 'EBAN-PEINH'
    '1'.
    perform bdc_field using 'EBAN-REPOS'
    'X'.
    perform bdc_dynpro using 'SAPMM06B' '0106'.
    perform bdc_field using 'BDC_CURSOR'
    'RM06B-BNFPO'
    perform bdc_field using 'BDC_OKCODE'
    '&H3DBU'.
    *perform bdc_field using 'RM06B-BNFPO'
    CALL TRANSACTION 'ME51' USING BDC_DATA MODE 'A'.
    endLOOP.
    FORM upload_data.
    *local variable declaration
    DATA : lv_index TYPE i,
    l_count TYPE i.
    *local constants declaration
    CONSTANTS:
    lc_start_col TYPE i VALUE '1' ,
    lc_start_row TYPE i VALUE '2' ,
    lc_end_col TYPE i VALUE '256' ,
    lc_end_row TYPE i VALUE '65536'.
    *local field symbol declaration
    FIELD-SYMBOLS : <lf_s>.
    *loacal internal table declaration
    DATA : li_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
    *refresh internal table for each loop
    CLEAR: li_intern,
    l_count .
    REFRESH li_intern.
    to upload the data in excel on the presentation server this function
    module converts the data from excel file into an internal table
    containing row no col no and value
    CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
    EXPORTING
    filename &H3D 'Give file location here'
    i_begin_col &H3D lc_start_col
    i_begin_row &H3D lc_start_row
    i_end_col &H3D lc_end_col
    i_end_row &H3D lc_end_row
    TABLES
    intern &H3D li_intern
    EXCEPTIONS
    inconsistent_parameters &H3D 1
    upload_ole &H3D 2.
    checking for data in internal table
    CHECK NOT li_intern[] IS INITIAL.
    sorting internal table
    SORT li_intern BY row col.
    collecting data into an internal table
    LOOP AT li_intern.
    MOVE: li_intern-col TO lv_index.
    lv_index &H3D lv_index + 1.
    ASSIGN COMPONENT lv_index OF STRUCTURE itab TO <lf_s>.
    MOVE : li_intern-value TO <lf_s>.
    AT END OF row.
    l_count &H3D l_count + 1.
    itab &H3D l_count.
    APPEND itab.
    ENDAT. " at end of row
    ENDLOOP. " loop at li_intern
    Reg,
    Siva
    Edited by: Siva Prasad on Jun 1, 2009 8:41 AM
    Edited by: Siva Prasad on Jun 1, 2009 4:25 PM

  • How to load xml data into a table

    Hi,
    i am a newbie. I want to insert the data of xml file into a table. I am doing this using XSU api for java.
    I am using oracle 9i and jdk 1.7.
    I am using OracleXmlSave class.
    but i am getting following error.
    java.lang.NoClassDefFoundError: oracle/jdbc2/Clob
    Please help in this regard. this is my first thread.
    thanks.
    Edited by: 979682 on Jan 3, 2013 3:39 AM

    Hi,
    You can insert XML data from XML file to Oracle database by this script :
    Hi,
    For reading and inserting the data from XML file to Oracle Database :
    1. CREATE A BLANK TABLE with same structure as XML file :
    select * from xml_test
    2. SELECT QUERY DIRECTLY ON XML FILE :
    SELECT XMLTYPE(bfilename('TEST_DIR', 'data_file.xml'), nls_charset_id('UTF8')) xml_data FROM dual
    3. CREATE ORACLE DIRECTORY AND PLACE XML FILE IN THIS DIRECTORY LOCATION:
    --CREATE DIRECTORY TEST_DIR as '/oracle/test';
    --grant all on directory TEST_DIR to public;
    4. INSERT THE XML DATA IN ORACLE TABLE:
    INSERT INTO xml_test(column1,coumn2)
    WITH t AS (SELECT XMLTYPE(bfilename('TEST_DIR', 'attachment.xml'), nls_charset_id('UTF8')) xml_col FROM dual)
    SELECT
    extractValue(value(x),'/ROW/COLUMN1') column1
    ,extractValue(value(x),'ROW/COLUMN2') column2
    FROM t,TABLE(XMLSequence(extract(t.xml_col,'/ROWSET/ROW'))) x;
    I have assumed a table with 2 columns.
    Regards,
    Rohit Chaudhari
    [email protected]

Maybe you are looking for