Error during uploading into an internal table

Hi all,
I am uploading flat files of either type excel and text. i have used the appropriate function modules(Gui_upload and Text_raw_excel to sap) but while testing it i found the following two things:
1. In excel file if it has 3 records , only 2 get updated. if there are 2 only 1 gets updated.
2. IN text file if it has more than 1 record only the first one gets updated and for the others it gives bad file format.
Please help me out
Regards,
Varun

Hi,
    Refer
https://forums.sdn.sap.com/click.jspa?searchID=8909280&messageID=4126977
Regards
Kiran Sure

Similar Messages

  • Error when inserting into a internal table

    hello.
    I get the fowolling error.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
      and
    therefore caused a runtime error.
    The reason for the exception is:
    In a SELECT access, the read file could not be placed in the target
    field provided.
    Either the conversion is not supported for the type of the target field,
    the target field is too small to include the value, or the data does not
    have the format required for the target field.
    I did a join of 5 table and it is inseting into an interal table wich tpye is al the fields that i am pulling from the other tables. can someone please help. thanks

    Performance wise its not suggested to use CORRESPONDING FIELDS so better take care of the fields u are selecting into table by having the structure of internal table exactly like the fields u are selecting, in the same order.
    ex:
    types: begin of ty_vbap,
               vbeln  type vbeln,
               posnr type posnr,
              end of ty_vbap.
    data: it_vbap type standard table of ty_vbap.
    select vbeln posnr into table it_vbap from vbap where ...
    кu03B1ятu03B9к

  • Upload an XML file into the Internal table

    Hi Guys,
    I want to know, how to upload an xml file into the Internal table through ABAP programming

    you just wanted to load the xml file into internal table (as a table of binary strings)or load the xml data mapped to itab row columns
    for the first one you can simply use gui_upload
    and for the second one you need to load the xml file using gui_upload and use XLST program to transform into an itab
    Regards
    Raja

  • Upload a .CSV File into an Internal table

    Hi,
    What are the parameters to be filled into the Function Modules "GUI_UPLOAD" and "ALSM_EXCEL_TO_INTERNAL_TABLE" to Upload a .CSV File into an internal table.
    Please send a sample code to support this....
    Regards,
    Aadhi.

    Hi,
            Check the below code.
    TYPE-POOLS: truxs.
    TYPES:
      BEGIN OF ty_line,
        vbeln LIKE vbap-vbeln,
        posnr LIKE vbap-posnr,
      END OF ty_line.
    *data:  ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
    DATA: itab   TYPE STANDARD TABLE OF ty_line WITH DEFAULT KEY.
    DATA: itab1  TYPE truxs_t_text_data.
    SELECT
      vbeln
      posnr
      UP TO 10 ROWS
      FROM vbap
      INTO TABLE itab.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
      EXPORTING
        i_field_seperator    = ';'
      TABLES
        i_tab_sap_data       = itab
      CHANGING
        i_tab_converted_data = itab1
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = 'd:\TEMP\test1.txt'
      TABLES
        data_tab = itab1
      EXCEPTIONS
        OTHERS   = 1.
    IF sy-subrc eq 0.
      WRITE: 'Data downloaded successfully'.
    ENDIF.
    DATA: BEGIN OF IEXCEL OCCURS 0.
          INCLUDE STRUCTURE ALSMEX_TABLINE.
    DATA: END OF IEXCEL.
    PARAMETERS: FILENM   LIKE rlgrap-filename MEMORY ID M01,
                NOHEADER AS CHECKBOX.
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                      = FILENM
        i_begin_col                   = 1
        i_begin_row                  = 1
        i_end_col                     = 100
        i_end_row                     = 30000
      tables
        intern                        = IEXCEL
      EXCEPTIONS
        INCONSISTENT_PARAMETERS       = 1
        UPLOAD_OLE                    = 2
        OTHERS                        = 3.
    if sy-subrc <> 0.
       WRITE: / 'EXCEL UPLOAD FAILED ', FILENM, SY-SUBRC.
    endif.

  • CRM ABAP How to upload an Excel file into an internal table?

    How to upload an Excel file using GUI_UPLOAD?? what should be the values of the parameters? The function modules ALSM_EXCEL_TO_INTERNAL_TABLE and KCD_EXCEL_OLE_TO_INT are not present in CRM. Please suggest me a way out!

    Hi saurabh,
    you can try the folowing sample..
    and make modifications according to your requirement..
    TYPE-POOLS: truxs.
    DATA: i_text_data TYPE truxs_t_text_data,
    v_filename_string TYPE string.
    DATA: BEGIN OF itab OCCURS 0,
    Name(30),
    Phone(15),
    Fax(500).
    DATA: END OF itab.
    PARAMETERS: p_file LIKE rlgrap-filename.
    START-OF-SELECTION.
    v_filename_string = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_filename_string
    filetype = 'ASC'
    has_field_separator = 'X'
    * HEADER_LENGTH = 0
    * READ_BY_LINE = 'X'
    dat_mode = ''
    * IMPORTING
    * FILELENGTH =
    * HEADER =
    TABLES
    data_tab = i_text_data
    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
    OTHERS = 17.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    i_field_seperator = 'X'
    * I_LINE_HEADER =
    i_tab_raw_data = i_text_data
    i_filename = p_file
    TABLES
    i_tab_converted_data = itab
    EXCEPTIONS
    conversion_failed = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    this is a sample code that uploads a excel file using GUI_UPLOAD, but uses another function module to convert that uploaded data into an internal table..
    regards
    satesh

  • Upload an Excel file into an Internal Table

    Hi,
    I want to upload an Excel file into an internal table but it doesn't work. I'd appreciate if someone could tell me what is wrong.
    My excel file has the following format:
          Col1  Col2
    Row1    1    2
    Row2    2    3
    Row3    3    4
    And the report code is the following one:
    REPORT ZFI_PROKON_PROCESOS.
    DATA: BEGIN OF itab OCCURS 0,
            num1(1),
            num2(1).
    DATA: END OF itab.
    PARAMETERS: p_file LIKE rlgrap-filename obligatory.
    AT SELECTION-SCREEN.
    AT SELECTION-SCREEN on value-request for p_file.
      call function 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                static    = 'X'
           CHANGING
                file_name = p_file.
    START-OF-SELECTION.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
         EXPORTING
              FILENAME                = p_file
              I_BEGIN_COL             = 1
              I_BEGIN_ROW             = 1
              I_END_COL               = 2
              I_END_ROW               = 5
         TABLES
              INTERN                  = itab
        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.
    LOOP AT itab.
      WRITE: / itab-num1, 10 itab-num2.
    ENDLOOP.
    Thanks in advance,
    Gerard

    Try function module
    ALSM_EXCEL_TO_INTERNAL_TABLE
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           exporting
                filename                = p_path
                i_begin_col             = 1
                i_begin_row             = 2
                i_end_col               = 70
                i_end_row               = 10000
           tables
                intern                  = i_excel
           exceptions
                inconsistent_parameters = 1
                upload_ole              = 2
                others                  = 3.
    P_PATH is file name with path.
    I_EXCEL is internal table to store data.
    declaration is "i_excel like structure alsmex_tabline"
    then loop at i_Excel and populate your table
    for eg
      loop at i_excel.
        case  i_excel-col.
          when '0001'.
            i_data-compcode              = i_excel-value.
          when '0002'.
            i_data-rcpttyp               = i_excel-value.
          when '0003'.
            i_data-pocimpro              = i_excel-value.
          when '0004'.
            i_data-tranno                = i_excel-value.
          when '0005'.
            i_data-msrpo                 = i_excel-value.
          when '0006'.
            i_data-mporel                = i_excel-value.
        endcase.
        at end of row.
          append i_data.
          clear  i_data.
        endat.
      endloop.

  • 1 duplicate key error during insert into table

    Dear Guru's
    While upgrading the SAP_HR patch, I am facing this issue
    Current level is SAPKE60455
    Trying to apply patch - SAPKE60456
    This is seen in the import log
    Start import R3TRVDATV_512W_O ...
    client 000:   1
    client 001:   1
    client 070:   1
    client 080:   1
    client 100:   1
    client 320:   1
    1 duplicate key error during insert into table T512T occured
    End import R3TRVDATV_512W_O (with warnings)
    Please help, thank in advance
    R3trans is at version 6.19
    Regards,
    Omkar

    Hello,
    Issue was resolved after upgrading the R3trans
    Regards,
    Omkar

  • Upload XML to internal table and vice versa in SAP 4.6C

    Hi,
       Happy New Year to you all!
       We are using 46C and I am beginning to learn about XML. We have a requirement to (1) upload an XML file into an internal table as well as (2) create an XML file from an internal table.
       I read some of the posted messages about this but they didn't seem to be applicable in 46C (I could be wrong).
       Could someone please help me using the sample file below?
      <?xml version="1.0" ?>
    - <AUCTIONBLOCK>
    - <ITEM>
      <TITLE>Still Life / Onions</TITLE>
      <ARTIST>Linda Mann</ARTIST>
      <DIMENSIONS>20x30 inches</DIMENSIONS>
      <MATERIALS>Oil</MATERIALS>
      <YEAR>1997</YEAR>
      <DESCRIPTION>Still Life</DESCRIPTION>
      <TIMESTAMP>1974</TIMESTAMP>
      </ITEM>
      </AUCTIONBLOCK>
    Many thanks,
    Rosemarie

    Hi,
    Yes I'm on 4.6c. I've to comment several lines. Here is an example:
    *& Report  z_xit_xml_check
      report  z_xit_xml_check.
      class cl_ixml definition load.
      type-pools: ixml.
      types: begin of t_xml_line,
              data(256) type x,
            end of t_xml_line,
            begin of tsfixml,
              data(1024) type c,
            end of tsfixml.
      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,
            l_xml_line        type t_xml_line,
            l_xml_table_size  type i.
      data: l_filename        type string.
      parameters: pa_file type char1024 default
      'd:joaodesenvolvimentos i act     este.xml'.
    Validation of XML file: Only DTD included in xml document is supported
      parameters: pa_val  type char1 as checkbox.
      start-of-selection.
      Creating the main iXML factory
        l_ixml = cl_ixml=>create( ).
      Creating a stream factory
        l_streamfactory = l_ixml->create_stream_factory( ).
    Regards,
    Maria João Rocha
        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( ).
      Create a Parser
        l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
      Validate a document
        if pa_val eq 'X'.
       l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
        endif.
      Parse the stream
        if l_parser->parse( ) ne 0.
          if l_parser->num_errors( ) ne 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
      form get_xml_table changing l_xml_table_size type i
                                  l_xml_table      type standard table.
      Local variable declaration
        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 a 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
      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.
    data: name2 type string,
          name_root type string,
          node_parent      type ref to if_ixml_node,
          node_root        type ref to if_ixml_node,
          num_children     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.
    num_children = node->num_children( ).
          case node->get_type( ).
            when if_ixml_node=>co_node_element.
            element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
              node_root = node->get_root( ).
              name_root = node_root->get_name( ).
                        write: / 'ELEMENT  :'.
              write: at indent name color col_positive inverse.
              write: 'NUM_CHILDREN:', num_children.
              write: 'ROOT:', name_root.
              node_parent = node->get_parent( ).
              name2    = node_parent->get_name( ).
              write: 'NAME2: ' , name2.
              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     :'.
    mjprocha
              node_parent = node->get_parent( ).
              write: at indent value color col_group inverse.
              name2    = node_parent->get_name( ).
              write: 'NAME2: ' , name2.
          endcase.
        advance to next node
          node = iterator->get_next( ).
        endwhile.
      endform.                    "process_dom

  • Collect data from a dynamic XML file into multiple internal tables

    I need to convert the XML file into multiple internal tables. I tried many links and posts in SDN but still was facing difficulty in achieving this. Can some one tell me where I am going wrong.
    My XML file is of the following type.It is very complex and the dynamice.
    The following tags occur more than once in the XML file. The "I" and "L" tags and its child tags can occur ones or more than once for each XML file and it is not constant. i.e in one file they can occur 1 time and in another they can occur 100 times.
    "I" and "L" are child tags of <C>
    <I>
           <J>10</J>
             <K>EN</K>
      </I>
    <L>
             <J>20</J>
              <N>BB</N>
      </L>
    Tags <C> and <F> occur only ones for each XML file. <C> is the child tag of "A" and "F" is the child tag of <C>.
    I need to collect <D>, <E> in one internal table ITAB.
    I need to collect <G>, <H> in one internal table JTAB.
    I need to collect <J>, <K> in one internal table KTAB.
    I need to collect <J>, <N> in one internal table PTAB.
    Below is the complete XML file.
    ?xml version="1.0" encoding="iso-8859-1" ?>
    <A>
        <B/>
        <C>
           <D>RED</D>
           <E>999</E>
        <F>
           <G>TRACK</G>
           <H>PACK</H>
        </F>
        <I>
           <J>10</J>
           <K>EN</K>
        </I>
        <I>
           <J>20</J>
           <K>TN</K>
        </I>
        <I>
           <J>30</J>
           <K>KN</K>
        </I>
        <L>
           <J>10</J>
           <N>AA</N>
        </L>
        <L>
           <J>20</J>
           <N>BB</N>
        </L>
        <L>
           <J>30</J>
           <N>CC</N>
        </L>
        </C>
      </A>
    With the help of SDN I am able to gather the values of <D> <E> in one internal table.
    Now if I need to gather
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    I am unable to do. I am following  XSLT transformation method. If some one has some suggestions. Please help.
    Here is my ABAP program
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\TEMP\ABCD.xml'.
    * This is the structure for the data from the XML file
    TYPES: BEGIN OF ITAB,
             D(10) TYPE C,
             E(10) TYPE C,
           END OF ITAB.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    * Table and work ares for the data from the XML file
    DATA: gt_ITAB     TYPE STANDARD TABLE OF ts_ITAB,
          gs_ITAB     TYPE ts_ITAB.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
          gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = gs_file
      CHANGING
        data_tab                = gt_itab1
      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 <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IITAB".
    GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
    gs_result_xml-name = 'IITAB'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION zxslt
        SOURCE XML gt_itab1
        RESULT (gt_result_xml).
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    * Now let's see what we got from the file
    LOOP AT gt_ITAB INTO gs_ITAB.
      WRITE: / 'D:', gs_ITAB-D.
      WRITE: / 'E :', gs_ITAB-E.
    ENDLOOP.
    Transformation
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <IITAB>
              <xsl:apply-templates select="//C"/>
            </IITAB>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <item>
          <D>
            <xsl:value-of select="D"/>
          </D>
          <E>
            <xsl:value-of select="E"/>
          </E>
        </item>
      </xsl:template>
    </xsl:transform>
    Now the above pgm and transformation work well and I am able to extract data into the ITAB. Now what changes should I make in transformation and in pgm to collect
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    Please help..i am really tring hard to figure this out. I am found lot of threads addressing this issue but not my problem.
    Kindly help.
    Regards,
    VS

    Hi Rammohan,
    Thanks for the effort!
    But I don't need to use GUI upload because my functionality does not require to fetch data from presentation server.
    Moreover, the split command advised by you contains separate fields...f1, f2, f3... and I cannot use it because I have 164 fields.  I will have to split into 164 fields and assign the values back to 164 fields in the work area/header line.
    Moreover I have about 10 such work areas.  so the effort would be ten times the above effort! I want to avoid this! Please help!
    I would be very grateful if you could provide an alternative solution.
    Thanks once again,
    Best Regards,
    Vinod.V

  • For uploading Excel to Internal Table??????

    Hello All,
    Can anybody give me the details for uploading Excel to Internal Table.
    Plz give me the FMs with parameters (Eg).
    I need to use this inside a BDC Program.
    Urgent
    Thanks in Advance,
    Regards,
    LIJO.

    Hi,
    refer the below code.
    DATA:xl_sheet LIKE kcde_cells OCCURS 0 WITH HEADER LINE.
    DATA : scol   TYPE i VALUE '1',
           srow   TYPE i VALUE '1',
           ecol   TYPE i VALUE '256',
           erow   TYPE i VALUE '65536'.
    DATA :  index TYPE i.
            FIELD-SYMBOLS : <fs>.
      CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
        EXPORTING
          filename                =  'file path'
          i_begin_col             = scol
          i_begin_row             = srow
          i_end_col               = ecol
          i_end_row               = erow
        TABLES
          intern                  = xl_sheet
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
    Write:/ 'Not a valid Excel file'.
      ENDIF.
      IF xl_sheet[] IS INITIAL.
        WRITE:/ 'Error:Data not Uploadeded'.
        EXIT.
      ELSE.
        SORT xl_sheet BY row col.
        LOOP AT xl_sheet.
          MOVE xl_sheet-col TO index.
          ASSIGN COMPONENT index OF STRUCTURE ittab TO <fs>.
          MOVE xl_sheet-value TO <fs>.
          AT END OF row.
            APPEND ittab.
            CLEAR ittab.
          ENDAT.
        ENDLOOP.
      ENDIF.
    Note:- after reading excel sheet to our internal table, each excel cell will be stored as a reocrd into yout internal table,let us i suppose if you have 3 fields in first reocrd, it will stores 3 fields data as 3 records into your internal table, each field contains row number and column number, then you have to take care to from this information as a record.
    Reward if useful.
    Thanks,
    Sreeram.

  • How to read data in correct format from EXCEL file into an internal table??

    Hi Experts,
    My requirement is to upload data from an excel file on presentation server into an internal table on <b>SRM</b> server.
    I used 'GUI_UPLOAD' function module to achieve the same but all the the data is getting uploaded in # only.I had set in the 'HAS_FIELD_SEPARATOR' to 'X' to overcome this problem.
    But all the efforts are in vain. The function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' doesn't exist on SRM Server and I am not getting any other function module having similar functionality available on SRM server.
    I have written the following code:-
    TYPES: BEGIN OF ty_addr_loc,
             userid    TYPE xubname,      "User Id
             addr_code TYPE char4,        "3 Digit Site Location Code/4 Digit
                                                       "Alternate Address
             loc_id    TYPE bbp_location, "Indicator: Address is standard address
            END OF ty_addr_loc.
    *Retrieving file name
    parameters: p_file type rlgrap-filename.
      DATA:
        Local variable holding file name
          l_file TYPE string,
        Local Variable holding the file type,
          l_type TYPE filetype VALUE 'ASC',
        Local Variable holding the field separator
          l_sep  TYPE char01,
          i_tab type standard table of ty_addr_loc.
    Clearing local variables
      CLEAR:
            l_file,
            l_sep.
    Initializing the local variables
      MOVE p_file TO l_file.
      l_sep = 'X'.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = l_file
          filetype                      = l_type
          has_field_separator           = l_sep
       HEADER_LENGTH                 = 0
       READ_BY_LINE                  = 'X'
       DAT_MODE                      = ' '
       CODEPAGE                      = ' '
       IGNORE_CERR                   = ABAP_TRUE
       REPLACEMENT                   = '#'
       CHECK_BOM                     = ' '
       VIRUS_SCAN_PROFILE            =
       NO_AUTH_CHECK                 = ' '
    IMPORTING
       FILELENGTH                    =
       HEADER                        =
        TABLES
          data_tab                     = i_tab
       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
         OTHERS                        = 17
      IF sy-subrc <> 0.
      Throwing an information message
        MESSAGE i003. "Data Upload Failed
        LEAVE LIST-PROCESSING.
      ENDIF.
    Please tell me a way out. I have to make a delivery urgently.
    Thanks in advance,
    Swati Gupta

    Hi
    Try the FM <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b>
    Sample:
      call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
           exporting
                filename                = i_filename
                i_begin_col             = l_begin_col
                i_begin_row             = l_begin_row
                i_end_col               = l_end_col
                i_end_row               = l_end_row
           tables
                intern                  = xt_intern
           exceptions
                INCONSISTENT_PARAMETERS = 201
                UPLOAD_OLE              = 201.
      if sy-subrc <> 0.
        e_subrc = sy-subrc.
        exit.
      endif.
    <b>reward if Helpful.</b>

  • Uploading Excel to Internal Table

    Hi,
      Can anyone please look into the code and suggest me the changes in uploading Excel to Internal Table. Code is as below in OnInputProcessing.
    DATA: event TYPE REF TO CL_HTMLB_EVENT.
    event =
    CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
    DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD,
           fcontent type xstring,
           fstring  type string,
                  len TYPE I.
    fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'fileUpload'
    id = 'myFileUpload1').
    len = fileUpload->file_length.
    IF event->id = 'submitButton' AND
        event->event_type = 'click'.
       fileUpload ?=
    CL_HTMLB_MANAGER=>GET_DATA( request = request
                               id = 'myFileUpload1'
                               name = 'fileUpload' ).
       IF ( fileUpload->file_name NE '' ) AND
       ( fileUpload->file_length GT 0 ).
         IF fileUpload->file_content_type
         = 'application/vnd.ms-excel'.
           DATA: content TYPE ZTABLE,
           conv TYPE REF TO CL_ABAP_CONV_IN_CE,
           viewoff TYPE REF TO CL_ABAP_VIEW_OFFLEN,
           it_off TYPE ABAPOFFLENTAB,
           wa_off TYPE ABAPOFFLEN,
           dd_fields TYPE DDFIELDS,
           wa_fields TYPE DFIES.
    data: codepage type CPCODEPAGE.
    CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
    EXPORTING
    external_name       = 'utf-16le'
      KIND                = 'H'
      IMPORTING
      SAP_CODEPAGE        = codepage.
    conv = CL_ABAP_CONV_IN_CE=>CREATE( encoding = '4103'
    endian = 'L'
    input =   fileUpload->file_content
    ignore_cerr = 'X').
           CALL FUNCTION 'TR_NAMETAB_GET'
             EXPORTING
               IV_TABNAME                 = 'ZTABLE'
               IV_GET_LENGTHS_IN_CHARMODE = 'X'
               IV_GET_TEXTS               = ' '
             IMPORTING
               ET_DFIES                   = dd_fields.
            LOOP AT dd_fields INTO wa_fields.
             MOVE wa_fields-offset TO wa_off-ioff.
             MOVE wa_fields-intlen TO wa_off-ilen.
             APPEND wa_off TO it_off.
            ENDLOOP.
           viewoff = CL_ABAP_VIEW_OFFLEN=>CREATE( tab = it_off ).
            call method conv->read( importing data = fstring ).
           fcontent = conv->get_buffer( ).
           call function 'HR_KR_XSTRING_TO_STRING'
               exporting
                   from_codepage = '4103'
                   in_xstring    = fcontent
              importing
                   out_string    = fstring.
          data: input_string type string.
          data: fields  type string_table.
          data: s_table type string_table.
    split fstring at cl_abap_char_utilities=>cr_lf into table s_table.
    field-symbols: <wa_table> like line of s_table.
    loop at s_table assigning <wa_table>.
      split <wa_table> at cl_abap_char_utilities=>HORIZONTAL_TAB into table
    fields.
    endloop.
      endif.
      endif.
      endif.
    thanks in advance,
    anjani.

    Hi anjani,
    it doesn't help much if you just post some code and request changes, if you don't state the kind of problem you are having ... in order to receice helpful replies, you have to give detailed information, what you want to do, what is not working as expected ... so please post more details.
    Meanwhile I recommend doing a search for your excel problem in the forum and also read the excel weblogs from <a href="https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/u/1918">Thomas Jung</a>.
    Regards,
    Max

  • Excel data transfer into SAP internal table with GUI_UPLOAD

    hi all,
      i m using SRM4 system and i wanted to develop one report which will upload data from excel and convert it into IT.
    i know that many threads are posted on this topic.
    but my requirement is slight different. in the system only one function module is available that is "GUI_UPLOAD" and we want that user shd not save file as tab delimited before calling this fm. instead, program shd take care of all these things...
    please suggest something asap..
    helpful ans will be rewarded..
    thanks,
    jigs.

    Dear Jigs,
    Please go though the following lines of code:
    D A T A D E C L A R A T I O N *
    TABLES: ANEP,
    BKPF.
    TYPES: BEGIN OF TY_TABDATA,
    MANDT LIKE SY-MANDT, " Client
    ZSLNUM LIKE ZSHIFTDEPN-ZSLNUM, " Serial Number
    ZASSET LIKE ZSHIFTDEPN-ZASSET, " Original asset that was transferred
    ZYEAR LIKE ZSHIFTDEPN-ZYEAR, " Fiscal Year
    ZPERIOD LIKE ZSHIFTDEPN-ZPERIOD, " Fiscal Period
    ZSHIFT1 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 1
    ZSHIFT2 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 2
    ZSHIFT3 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 3
    END OF TY_TABDATA.
    Declaration of the Internal Table with Header Line comprising of the uploaded data.
    DATA: BEGIN OF IT_FILE_UPLOAD OCCURS 0.
    INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data
    DATA: END OF IT_FILE_UPLOAD.
    S E L E C T I O N - S C R E E N *
    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME,
    BEGIN OF BLOCK B2 WITH FRAME.
    PARAMETERS: P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK B2,
    END OF BLOCK B1.
    E V E N T : AT S E L E C T I O N - S C R E E N *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    PROGRAM_NAME = SYST-REPID
    DYNPRO_NUMBER = SYST-DYNNR
    FIELD_NAME = ' '
    STATIC = 'X'
    MASK = '.'
    CHANGING
    FILE_NAME = P_FNAME
    EXCEPTIONS
    MASK_TOO_LONG = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    E V E N T : S T A R T - O F - S E L E C T I O N *
    START-OF-SELECTION.
    Upload Excel file into Internal Table.
    PERFORM UPLOAD_EXCEL_FILE.
    Organize the uploaded data into another Internal Table.
    PERFORM ORGANIZE_UPLOADED_DATA.
    E V E N T : E N D - O F - S E L E C T I O N *
    END-OF-SELECTION.
    *& Form UPLOAD_EXCEL_FILE
    text
    --> p1 text
    <-- p2 text
    FORM UPLOAD_EXCEL_FILE .
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = P_FNAME
    I_BEGIN_COL = 1
    I_BEGIN_ROW = 3
    I_END_COL = 7
    I_END_ROW = 32000
    TABLES
    INTERN = IT_FILE_UPLOAD
    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.
    ENDFORM. " UPLOAD_EXCEL_FILE
    *& Form ORGANIZE_UPLOADED_DATA
    text
    --> p1 text
    <-- p2 text
    FORM ORGANIZE_UPLOADED_DATA .
    SORT IT_FILE_UPLOAD BY ROW
    COL.
    LOOP AT IT_FILE_UPLOAD.
    CASE IT_FILE_UPLOAD-COL.
    WHEN 1.
    WA_TABDATA-ZSLNUM = IT_FILE_UPLOAD-VALUE.
    WHEN 2.
    WA_TABDATA-ZASSET = IT_FILE_UPLOAD-VALUE.
    WHEN 3.
    WA_TABDATA-ZYEAR = IT_FILE_UPLOAD-VALUE.
    WHEN 4.
    WA_TABDATA-ZPERIOD = IT_FILE_UPLOAD-VALUE.
    WHEN 5.
    WA_TABDATA-ZSHIFT1 = IT_FILE_UPLOAD-VALUE.
    WHEN 6.
    WA_TABDATA-ZSHIFT2 = IT_FILE_UPLOAD-VALUE.
    WHEN 7.
    WA_TABDATA-ZSHIFT3 = IT_FILE_UPLOAD-VALUE.
    ENDCASE.
    AT END OF ROW.
    WA_TABDATA-MANDT = SY-MANDT.
    APPEND WA_TABDATA TO IT_TABDATA.
    CLEAR: WA_TABDATA.
    ENDAT.
    ENDLOOP.
    ENDFORM. " ORGANIZE_UPLOADED_DATA
    In the subroutine --> ORGANIZE_UPLOADED_DATA, data are organized as per the structure declared above.
    Regards,
    Abir
    Don't forget to award points *

  • Urgent: Error while uploading into pdf file

    Hi ,
    I got a requirement that converting smartform into pdf file and sending into application server, And uploading the that pdf file into presentation server once a day am geting error when uploading into pdf format from application server .
    Error : There was an  error while tryinging to parse an image.
    Please help me out its urgent.
    Thanks in advance
    Regards
    krishna
    Edited by: krishna rao on Feb 13, 2008 12:05 PM

    U can use this code
    Reward if useful
    REPORT  ZMN_PDF_UPLOAD.
    data: begin of itab occurs 0,
    field(256),
    end of itab.
    data: dsn(100) value '\usr\sap\DEV\DVEBMGS00\work\testpdf',
    length like sy-tabix,
    lengthn like sy-tabix.
    call function 'GUI_UPLOAD'
    exporting
    filename = 'c:\temp\test.pdf'
    filetype = 'BIN'
    importing
    filelength = length
    tables
    data_tab = itab.
    open dataset dsn for output in binary mode.
    loop at itab.
    transfer itab-field to dsn.
    endloop.
    close dataset dsn.
    clear itab.
    refresh itab.
    *To crosscheck if it went well
    open dataset dsn for input in binary mode.
    do.
    read dataset dsn into itab-field.
    if sy-subrc = 0.
    append itab.
    else.
    exit.
    endif.
    enddo.
    call function 'GUI_DOWNLOAD'
    exporting
    filename = 'c:\temp\testn.pdf'
    filetype = 'BIN'
    bin_filesize = length
    importing
    filelength = lengthn
    tables
    data_tab = itab.
    *Or
    *Use the TCode
    *CG3Z or CG3Y
    *for downloading to Application Server.

  • How to extract data from info cube into an internal table using ABAP code

    HI
    Can Anyone plz suggest me
    How to extract data from info cube into an internal table using ABAP code like BAPI's or function modules.
    Thankx in advance
    regds
    AJAY

    HI Dinesh,
    Thankq for ur reply
    but i ahve already tried to use the function module.
    When I try to Use the function module RSDRI_INFOPOV_READ
    I get an information message "ERROR GENERATION TEST FRAME".
    can U plz tell me what could be the problem
    Bye
    AJAY

Maybe you are looking for