Transfer IDOC File in a Internal Table

Hi all,
I need to Transfer IDOC File in a Internal Table.
Anybody have any idea how  can I do this???
Regards,

HI,
is the IDoc exist in SAP?if IDoc exist in SAP you can use one function module to read the idoc and store tha content in internal table.
IDOC_READ_COMPLETELY function module will read the specified idoc number.you can retrieve the control records ,status records and the data record of the idoc.for this you have to declare 3 internal tables (check the function modules for the type of inerna table).you can then loop the internal table and read the data.let us know if u have any problems
regards
shibu

Similar Messages

  • Code to transfer xml file to abap internal table using transformation

    Hi friends
    Given the following xml file .the requirementis to  display and transfer the xml file to internal table usin transformation and gui_upload.If any onehaving simple code on this please send .
    Can any one sugest the steps to be followed to write source code using simple transformation.
    <?xml version="1.0" encoding="utf-8" ?>
    - <Negara>
    - <item>
    - <COUNTRY>
      <MANDT>600</MANDT>
      <ZCODE>500</ZCODE>
      <ZDESC>Pening Lalat</ZDESC>
      <ZSAPCD>T1</ZSAPCD>
      </COUNTRY>
      </item>
    - <item>
    - <COUNTRY>
      <MANDT>600</MANDT>
      <ZCODE>600</ZCODE>
      <ZDESC>Pening Lalat2</ZDESC>
      <ZSAPCD>T2</ZSAPCD>
      </COUNTRY>
      </item>
      </Negara>
    Thaking You

    hi..
    1. itab --- > xml
    xml ---> itab.
    2. This program will do both.
    (just copy paste in new program)
    3.
    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
    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[].
    <b>Reward points if useful</b>
    Regards
    Ashu

  • Want to convert .CSV file into an internal table

    Hi Experts,
    I have a file for eg. data.csv on the application server and i want to transfer its contents to an internal table.
    i tried using function module 'KCD_CSV_FILE_TO_INTERN_CONVERT' but it gives the UPLOAD_CSV exception.
    Please suggest..
    Thanks and Regards.

    you can do something like this..
    DATA: BEGIN OF itab OCCURS 0,
            vbeln LIKE vbak-vbeln,
            ernam LIKE vbak-ernam,
          END OF itab.
    DATA itab2 LIKE TABLE OF KCDE_CELLS WITH HEADER LINE.
    CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
      EXPORTING
        i_filename            = 'D:\data\upl.txt'
        i_separator           = ','
      tables
        e_intern              = itab2
    EXCEPTIONS
      UPLOAD_CSV            = 1
      UPLOAD_FILETYPE       = 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 itab2.
      SPLIT itab2-value AT ',' INTO itab-vbeln itab-ernam.
      APPEND itab.
      CLEAR itab.
    ENDLOOP.

  • How to Extract Data from the PDF file to an internal table.

    HI friends,
    How can i Extract data from a PDF file to an internal table....
    Thanks in Advance
    Shankar

    Shankar,
    Have a look at these threads:-
    extracting the data from pdf  file to internal table in abap
    Adobe Form (data extraction error)
    Chintan

  • How to transfer data from a dynamic internal table

    Hi All
    I want to transfer data from a dynamic internal table<dyn_table>
    to a non dynamic internal table itab which should have the same structure as <dyn_table>.
    How can this be done?
    Regards,
    Harshit Rungta

    As stated earlier this can be done only through field symbols...
    You cannot create an non dynamic internal table with ANY structure...using DATA statement
    If the strucutre is defined well and good...you can create an non-dynamic internal table...
    If you do not know the structure then the internal table has to be dynamic...and to be generated using field symbols
    DATA: lv_ref TYPE REF TO data.
    FIELD-SYMBOLS: <fs_dyn_table> TYPE STANDARD TABLE.
    * You create a dynamic internal table...
    CREATE DATA lv_ref LIKE (your_dynamic_internal_table).
    ASSIGN lv_ref->* TO <fs_dyn_table>.
    Now...do the transfer.
    <fs_dyn_table> = "your_dynamic_internal_Table
    Hope it helps!

  • XML and XSD file to an internal table

    I had read a lot of thread  but i don't understand how to deal with xml/xsd in R3.
    I need someone that have a definite example for this escenary please.
    With OPEN DATASET took from the server XML and XSD file, and put it in two internal tables type string.
    What functions or method have to use, and how to use them, to charge the XML file in an internal table?
    This is an example of XML and XDS:
    XML
    AND CONTINUE
    Best Regards,

    I just tried to interpret your question, it was not obvious what you wanted.
    I guess what you mean is that you have defined (statically) a deep structure, and you want to decode the XML into it. That is called a transformation (transaction STRANS, statement CALL TRANSFORMATION). You have the choice between 2 transformation languages: XSLT and ST. Of course, it depends what release you are running.
    I advise you to play first with the ID transformation, to convert an ABAP deep structured data object into XML, so that you see what XML is generated, this one is called asXML. If you create your own transformation, when you call it, it will first convert automatically the data object to asXML, and the transformation has to do the rest of the job.
    You can do the opposite, i.e. converting from XML to a data object, according to the same principle (intermediate asXML).
    Well, there are lots of things to say, I recommend you to read articles and documentation on XSLT and ST (search on SDN).
    About XSD, it won't help (and I did never see any possibility to use it) to decode the XML, as you must anyway define the target data object statically (and there's no tool to generate the ABAP code of the data object definition from the XSD).
    Note that you may also use iXML libraries to parse the XML.
    Please tell us more.
    BR
    Sandra

  • 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

  • Reading XML file to ABAP internal table

    Hi all,
    Iam trying to convert a XLM file into abap internal table , am using XSLT transformation to parse the XML file and i am using "CALL METHOD cl_gui_frontend_services=>gui_upload" for reading the XML file.
    below is the XML file.
    ===========================================================================
    - <PIXBridge version="2.2" timestamp="2003-04-09T15:27:00">
    - <PIX>
      <TransactionType>605</TransactionType>
      <TransactionCode>98</TransactionCode>
      <TransactionNumber>6888965</TransactionNumber>
      <SequenceNumber>40001</SequenceNumber>
    - <SKUDefinition>
      <Company>GZL</Company>
      <Division>BMD</Division>
      <Season />
      <SeasonYear />
      <Style>ORT002A</Style>
      <StyleSuffix />
      <Color>K13</Color>
      <ColorSuffix />
      <SecDimension />
      <Quality />
      <SizeRangeCode />
      <SizeDesc>M</SizeDesc>
      <SkuID>200140577</SkuID>
      </SKUDefinition>
      </PIX>
      </PIXBridge>
    =================================================================
    and my Transformation code is as below
    <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>
            <IPIX>
              <xsl:apply-templates select="//PIX"/>
            </IPIX>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="PIX">
        <item>
          <TRANSACTIONTYPE>
            <xsl:value-of select="TransactionType"/>
          </TRANSACTIONTYPE>
          <TRANSACTIONCODE>
            <xsl:value-of select="TransactionCode"/>
          </TRANSACTIONCODE>
          <TRANSACTIONNUMBER>
            <xsl:value-of select="TransactionNumber"/>
          </TRANSACTIONNUMBER>
          <SEQUENCENUMBER>
            <xsl:value-of select="SequenceNumber"/>
          </SEQUENCENUMBER>
          <SKUDEFINITION>
            <COMPANY>
              <xsl:value-of select="Company"/>
            </COMPANY>
            <DIVISION>
              <xsl:value-of select="Division"/>
            </DIVISION>
            <SEASON/>
            <SEASONYEAR/>
            <STYLE>
              <xsl:value-of select="Style"/>
            </STYLE>
            <STYLESUFFIX/>
            <COLOR>
            <xsl:value-of select="Color"/>
            </COLOR>
            <COLORSUFFIX/>
            <SECDIMENSION/>
            <QUANTITY/>
            <SIZERANGECODE/>
            <SIZEDESC>
              <xsl:value-of select="SizeDesc"/>
            </SIZEDESC>
            <SKUID>
              <xsl:value-of select="SkuID"/>
            </SKUID>
          </SKUDEFINITION>
          </item>
        </xsl:template>
    When i run my program i am getting the values only till the sequence number part and im not getting any values  that is read in between <SKUDEFINITION> ..... </SKUDEFINITION>
    I need help to sort this , kindly help me in this.
    regs,
    raja

    I am not able to get a clue out of that, can Get Durairaj Athavan Raja in to loop for sorting this out.
    I made changes to my transformation program , but still not getting the output of the components inside the
    <SKUDefinition> , but when i debug  the transformation i can able to see the output values for those components but when i get the values in the result table im not getting values of those components.
    <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>
            <IPIX>
              <xsl:apply-templates select="//PIX"/>
            </IPIX>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="PIX">
        <item>
          <TRANSACTIONTYPE>
            <xsl:value-of select="TransactionType"/>
          </TRANSACTIONTYPE>
          <TRANSACTIONCODE>
            <xsl:value-of select="TransactionCode"/>
          </TRANSACTIONCODE>
          <TRANSACTIONNUMBER>
            <xsl:value-of select="TransactionNumber"/>
          </TRANSACTIONNUMBER>
          <SEQUENCENUMBER>
            <xsl:value-of select="SequenceNumber"/>
          </SEQUENCENUMBER>
          <xsl:for-each select="SKUDefinition">
          <SKUDEFINITION>
          <COMPANY>
              <xsl:value-of select="Company"/>
          </COMPANY>
          <DIVISION>
              <xsl:value-of select="Division"/>
          </DIVISION>
          <SEASON/>
          <SEASONYEAR/>
          <STYLE>
            <xsl:value-of select="Style"/>
          </STYLE>
          <STYLESUFFIX/>
          <COLOR>
            <xsl:value-of select="Color"/>
          </COLOR>
          <COLORSUFFIX/>
          <SECDIMENSION/>
          <QUANTITY/>
          <SIZERANGECODE/>
          <SIZEDESC>
              <xsl:value-of select="SizeDesc"/>
          </SIZEDESC>
          <SKUID>
              <xsl:value-of select="SkuID"/>
          </SKUID>
          </SKUDEFINITION>
          </xsl:for-each>
        </item>
      </xsl:template>
    </xsl:transform>
    ==================
    Below is my main program
    ===================
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\XMLABAP1.xml'.
    This is the structure for the data from the XML file
    TYPES: BEGIN OF ty_text,
             TransactionType(3) type n,
             TransactionCode(2) type n,
             TransactionNumber(7) type n,
             SequenceNumber(5) type n,
             Company(3) type c,
             Division(3) type c,
             Season(3) type c,
             SeasonYear(4) type c,
             Style(8) type c,
             Color(3) type c,
             SecDimension(3) type c,
             Quality(3) type n,
             SizeRangeCode(2) type c,
             SizeDesc(1) type c,
             SkuID(10) type c,
           END OF ty_text.
    Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    data: xmlstr        TYPE XSTRING.
    Table and work ares for the data from the XML file
    DATA: gt_person     TYPE STANDARD TABLE OF ty_text,
          gs_person     TYPE ty_text.
    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_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 <> 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
    "IPERSON".
    GET REFERENCE OF gt_person INTO gs_result_xml-value.
    gs_result_xml-name = 'IPIX'.
    APPEND gs_result_xml TO gt_result_xml.
    Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION ZAUM_MANH_SYNC_RPT
        SOURCE XML XMLSTR
        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_person INTO gs_person.
    WRITE: / 'Transaction Type:', gs_person-TransactionType.
      WRITE: / 'Transaction Code :', gs_person-TransactionCode.
      WRITE: / 'Transaction Number :', gs_person-TransactionNumber.
       WRITE: / 'SequenceNumber :', gs_person-SequenceNumber.
       WRITE: / 'Company : ', gs_person-Company.
      WRITE : /.
    ENDLOOP. "gt_person.

  • 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

  • Reading long text from excel file to an internal table

    Hi
    Can any body tell me how to read long text from excel file to an internal table.
    When i am using this FM KCD_EXCEL_OLE_TO_INT_CONVERT then it is reading only 32 characters from each cell.
    But in my excel sheet in one of the cell has very long text which i need to upload into a internal table.
    may i know which FM or what logic i need to use for this problem.
    Regards

    Hi,
    Here is an example program.  It will upload an Excel file with two columns.  You could also assign the Excel structure dynamically, but I wanted to keep the example simple.  The main point is that the internal table (it_excel in this example) must match the Excel structure that you want to convert.
    Remember, this is just an example to help you figure out how to properly use the technique.  It will certainly need to be modified to fit your requirements, and as always there may be a better way to get the Excel converted... this is just one possibility that has worked for me in the past.
    *& Report  zexcel_upload_test                            *
    REPORT  zexcel_upload_test.
    TYPE-POOLS: truxs.
    TYPES: BEGIN OF ty_excel,
             col_a(10) TYPE n,
             col_b(35) TYPE c,
           END OF ty_excel.
    DATA: l_data_tab         TYPE TABLE OF string,
          l_text_data        TYPE truxs_t_text_data,
          l_gui_filename     TYPE string,
          it_excel           TYPE TABLE OF ty_excel.
    FIELD-SYMBOLS: <wa_excel>  TYPE ty_excel.
    PARAMETERS: p_file TYPE rlgrap-filename.
    * Pass the file name in the correct format
    l_gui_filename = p_file.
    * Upload data from PC
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = l_gui_filename
        filetype                = 'ASC'
        has_field_separator     = 'X'
      CHANGING
        data_tab                = l_data_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.
    *   MESSAGE ...
      EXIT.
    ENDIF.
    * Convert from Excel into the appropriate itab
    l_text_data[] = l_data_tab[].
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
        i_field_seperator    = 'X'
        i_tab_raw_data       = l_text_data
        i_filename           = p_file
      TABLES
        i_tab_converted_data = it_excel
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
    *   MESSAGE ...
      EXIT.
    ENDIF.
    LOOP AT it_excel ASSIGNING <wa_excel>.
    *  Do something here...
    ENDLOOP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM filename_get CHANGING p_file.
    *       FORM filename_get                                             *
    FORM filename_get CHANGING p_in_file TYPE rlgrap-filename.
      DATA: l_in_file  TYPE string,
            l_filetab  TYPE filetable,
            wa_filetab TYPE LINE OF filetable,
            l_rc       TYPE i,
            l_action   TYPE i,
            l_init_dir TYPE string.
    * Set the initial directory to whatever you want it to be
      l_init_dir = 'C:\'.
    * Call the file open dialog without multiselect
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = 'Load file'
          default_extension       = '.XLS'
          default_filename        = l_in_file
          initial_directory       = l_init_dir
          multiselection          = 'X'
        CHANGING
          file_table              = l_filetab
          rc                      = l_rc
          user_action             = l_action
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          OTHERS                  = 4.
      IF sy-subrc <> 0.
        REFRESH l_filetab.
      ENDIF.
    * Read the selected filename
      READ TABLE l_filetab INTO wa_filetab INDEX 1.
      IF sy-subrc = 0.
        p_in_file = wa_filetab-filename.
      ENDIF.
    ENDFORM.                    " filename_get
    Regards,
    Jamie

  • I have problem of uploading excel file to my internal table

    Hi,
    I trying to upload data from excel file to my internal table and when i tried to debug the program and check the data in internal table and iam gettin # in all the fields and the data in not populated in internal table , as we are using 4.0b version and we are using UPLOAD FUNCTION.
            BUKRS(4) TYPE C,     
             PONO(8) TYPE C,     
             GRNNO(8) TYPE C,   
             DELNOTE(16) TYPE C,
             RECPTDT(10) TYPE C,  
             SUPPCODE(20) TYPE C, 
              RECPT(12) TYPE C,  
              GLACCT(10) TYPE C, 
             CCTR(6) TYPE C,      
      CALL FUNCTION 'UPLOAD'
        TABLES DATA_TAB = STRU.
      IF SY-SUBRC NE 0.
        WRITE: /'Data file error'.
      ENDIF.
    i am using the same sequeuence in the above structure in excel.

    Hi KODAMANCHILI,
    Refer following link :
    http://help.sap.com/saphelp_40b/helpdata/en/fc/eb3d9d358411d1829f0000e829fbfe/frameset.htm
    This will surely solve your problem.
    Regards,
    Vivek

  • 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.

  • 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.

  • Excel file upload to internal table

    Hi Guys,
    I want to upload excel file into an internal table in BW. I am using the FM TEXT_CONVERT_XLS_TO_SAP in the code below.
    REPORT  ZUPLOAD_EXCEL_TO_ITAB.
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
            col1(30) TYPE c,
            col2(30) TYPE c,
            col3(30) TYPE c,
           END OF t_datatab.
    DATA: it_datatab TYPE STANDARD TABLE OF t_datatab,
          wa_datatab TYPE t_datatab.
    DATA: it_raw TYPE truxs_t_text_data.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'P_FILE'
        IMPORTING
          file_name  = p_file.
    ****START-OF-SELECTION******
    START-OF-SELECTION.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
    I_FIELD_SEPERATOR =
            i_line_header = 'X'
            i_tab_raw_data = it_raw  "WORK TABLE
            i_filename = p_file
        TABLES
        i_tab_converted_data = it_datatab[] "ACTUAL DATA
        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-smgv4.
      ENDIF.
    *****END-OF-SELECTION*******
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3.
      ENDLOOP.
    But I am getting the error "The TYPE-POOL "TRUXS" is unknown.
    Can somebody please tell me the mistake in the code?
    Thanks in advance

    Hi azeem,
    Regarding ur case ..
    Why don't u make ur own function ??
    I also used it here as MD data upload ..
    The steps as follows to make it :
    1. Create RFC: it will be called by ur Excel.
    - Since my purpose was to upload MD, so in the RFC, i called Process Chain.
    - This RFC is made as ur purpose.
    2. You create Code in Excel by Macro.
    The techniques to make it as follows:
    Accessing SAP Functions from Excel using Visual Basic Applications
    Hopefully it can help you a lot.
    Best regards,
    Niel.

  • Upload XML file data into internal table

    Hi,
    I need help from you.
    I am uploading XML file from Application server.
    1.In application server under directory it may have several XML files and i need to upload all the XML files  when we gave only directory name. So, what is the function module for that logic . If possible code also.
    2.Once we get the files into some internal table we need to upload data from that files to internal table.
    So what is the logic for that , if possible code also.
    I am giving sample directory:    
    For example in this directory assume 3 xml files are there.
    I need to upload those files and data from that in to internal table.
    Thanks & Regards
    VSR

    Below code will give you an idea.
    TYPE-POOLS: ixml. "iXML Library Types
    *TABLES : rbkp.
    TYPE DECLERATIION
    TYPES: BEGIN OF type_tabpo,
    ebeln TYPE ekko-ebeln, "PO document number
    ebelp TYPE ekpo-ebelp, "PO line item
    END OF type_tabpo.
    TYPES: BEGIN OF type_ekbe,
    belnr TYPE rbkp-belnr, "Invoice document
    gjahr TYPE rbkp-gjahr, "fiscal year
    END OF type_ekbe.
    TYPES: BEGIN OF type_invoice,
    belnr TYPE rbkp-belnr, "PO document number
    gjahr TYPE rbkp-gjahr, "Fiscal Year
    rbstat TYPE rbkp-rbstat, "invoice status
    END OF type_invoice.
    TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
    data(256) TYPE x,
    END OF t_xml_line.
    INTERNAL TABLE DECLERATIION
    DATA: gi_tabpo TYPE STANDARD TABLE OF type_tabpo,
    gi_ekbe TYPE STANDARD TABLE OF type_ekbe,
    gi_invoice TYPE STANDARD TABLE OF type_invoice,
    gi_bapiret2 TYPE STANDARD TABLE OF bapiret2.
    DATA: l_ixml TYPE REF TO if_ixml,
    l_streamfactory TYPE REF TO if_ixml_stream_factory.
    DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
    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.
    WORK AREA DECLARATION
    DATA: gw_tabpo TYPE type_tabpo,
    gw_ekbe TYPE type_ekbe,
    gw_invoice TYPE type_invoice,
    gw_bapiret2 TYPE bapiret2.
    BEGIN OF SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    PARAMETERS: p_file TYPE pathintern LOWER CASE DEFAULT '/usr/sap/tmp/'.
    Validation of XML file: Only DTD included in XML document is supported
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION SCREEN VALIDATION
    AT SELECTION-SCREEN.
    To validate p_file is not initial
    PERFORM sub_validate_file.
    PERFORM sub_validate_path.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Request for filename for xml file from the application server
    PERFORM sub_get_filename_appl USING p_file.
    START OF SELECTION SCREEN
    START-OF-SELECTION.
    PERFORM sub_fetch_po_details.
    PERFORM sub_get_invoice.
    PERFORM sub_rel_invoice.
    END OF SELECTION SCREEN
    END-OF-SELECTION.
    *& Form sub_validate_file
    To Validate the file
    FORM sub_validate_file .
    IF p_file IS INITIAL.
    MESSAGE e000. "specify the file path
    ENDIF.
    ENDFORM. " sub_validate_file
    *& Form sub_get_filename_appl
    form sub_get_filename_appl USING l_fname TYPE any.
    DATA: l_fname TYPE filename-fileintern. " File name
    *GET THE FILENAME FROM THE APPLICATION SERVER
    CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
    EXPORTING
    directory = l_fname
    filemask = '*'
    IMPORTING
    serverfile = l_fname
    EXCEPTIONS
    canceled_by_user = 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.
    ENDFORM. " sub_get_filename_appl
    *& Form sub_fetch_po_details
    To fetch the PO details from the application server
    Format of file is XML
    FORM sub_fetch_po_details .
    TYPE DECLERATIION
    l_ixml = cl_ixml=>create( ).
    Creating a stream factory
    l_streamfactory = l_ixml->create_stream_factory( ).
    PERFORM get_xml_table.
    LOOP AT gi_tabpo INTO gw_tabpo.
    WRITE:/ gw_tabpo.
    ENDLOOP.
    ENDFORM. " sub_fetch_po_details
    *& Form get_xml_table
    Read from the xml file
    FORM get_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 = p_file.
    code to upload data from application server
    OPEN DATASET l_filename FOR INPUT IN BINARY MODE.
    IF sy-subrc 0.
    WRITE:/ 'invalid file path'.
    ENDIF.
    DO.
    READ DATASET l_filename INTO l_xml_line.
    IF sy-subrc EQ 0.
    APPEND l_xml_line TO l_xml_table.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET l_filename.
    code to find the table size
    DESCRIBE TABLE l_xml_table.
    l_xml_table_size = ( sy-tleng ) * ( sy-tfill ).
    *code to convert hexadecimal to XML
    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.
    LOOP AT l_itab INTO l_str1.
    REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
    l_str1 WITH space.
    ENDLOOP.
    CALL TRANSFORMATION ('ID') " code to put in internal table
    SOURCE XML l_str1
    RESULT tab = gi_tabpo[].
    ENDFORM. " get_xml_table

Maybe you are looking for

  • Gtx 780 ti 3GB msi gaming GOp UEFI BIOS

    I just received my new MSI GTX 780Ti GAMING 3G,  but now windows 8.1 pro won't do the ultra fast uefi boot! I need a uefi/gop vbios for this card please! s/n: 602-v298-110B1404029741 filedropper.com/gk110_1

  • How to delete an asset with a capitalization date inefaceable and no value?

    Hi all, An asset was created on the wrong asset class. I would like to erase it but this is impossible because of the capitalization date. Indeed, I cannot change the fields status variant of the capitalization date, it is compulsory. Furthermore, as

  • Installment invoice layout

    Hi All, I have a requirement whereby the invoice is separated into 2 installment. Let's say 90% on 30 days and remaining 10% is 60 days. If i setup in the payment terms, it is able to produce 2 installament invoice that having the same invoice number

  • Applying custom master page on layout pages

    I am applying my custom master page on application layout pages which I am deploying using visual studio. My issue is; I have to copy my custom master page in the same directory where my layout pages exist otherwise its not working. I want to deploy

  • Which notebook to buy for bad eyesight

    Hi I am thinking of purchasing a notebook but I am really unsure as to which one. I hope that somebody can advise me. Yesterday, I visited an Apple store and was advised by a sales rep, that what I required for my needs (internet browsing, storing ph