Problem in uploading the file of internal table into appliaction server

i want to send the data of internal table to application server through selection screen and in selection screen and in selection screen parameter it should show the path of application server and through that path internal table data should go to application server , if possible give the code

Hi,
form download_file_appl_server.
  open dataset p_dlf2 for output
          in text mode encoding default .
  if sy-subrc ne 0.
    message:i005 with text-415 text-407.
  endif.
  loop at i_final into wa_final.
    transfer wa_final to p_dlf2.
  endloop.
  close dataset p_dlf2.
endform.                    " OPENDATA_CLOSE
where p_dlf2 is the seelction screen parameter which give the application server file path
You can use this code for ur purpose.
Reward if useful.
Regards
Shibin

Similar Messages

  • FM to select the file path for download into application server

    Hello,
    I need a FM to select the file path for download into application server. It is a F4 help .
    Its functionality should be simmilar to the one used for presentation server i.e. as fol
    CALL METHOD cl_gui_frontend_services=>file_save_dialog

    Hello,
    What about F4_DXFILENAME_TOPRECURSION? You can check other FMs of the group DX_FILE.
    BR,
    Suhas
    PS: I think these FMs are not released by SAP, so need to be cautious while using these

  • Is it possible  upload local file to internal table in background mode?

    Hi, all,
    Is it possbile to  upload local file(not server file) to internal table in background mode.
    If possbile ,please tell me detail . Thanks in advance.
    Regards,
    Lily

    Hello,
    This is possible.
    If you report has to be executed in background using schedule Job. Then the file path should be constant and it can be hard coded in the report itself while populationg the internal table.
    Then create a variant for your report and use that variant in the job.
    This will solve your problem I guess.
    Regards
    Arindam

  • Uploading a file to internal table

    Hi experts,
    I have a peculiar problem with loading a file into internal table.
    While loading the file the first record(line) only is getting uploaded in to the internal table, although i hve many records(lines).
    what could be the problem.
    thnx very much,
    the code is something like this:
    data: begin of t_line occurs 0,   
             data(150) type c,           
          end of t_line.
    OPEN DATASET FILENAME FOR INPUT IN TEXT MODE.
    if sy-subrc = 0.
    perform process_file_contents.
    FORM PROCESS_FILE_CONTENTS.
      DO.                       
         read dataset filename into t_line.        
        IF SY-SUBRC NE 0.
          IF REC_READ < 1.
            MESSAGE E009(ZM) WITH 'No records in the file' FILENAME.
          ENDIF.
          EXIT.
        ELSE.
           ADD 1 TO REC_READ.
        ENDIF.
           append t_line.
    ENDDO.

    Hi sey ni,
    check if this sample code can be of some help to u.:
    TABLES: kna1.
    TYPES: BEGIN OF s_file,
             customer TYPE kna1-kunnr,
             name     TYPE kna1-name1,
             country  TYPE kna1-land1,
             region   TYPE kna1-regio,
             post_code TYPE kna1-pstlz,
             street    TYPE kna1-stras,
          END OF s_file.
    DATA: it_file TYPE s_file OCCURS 0 WITH HEADER LINE.
    *-- selection screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_file TYPE rlgrap-filename DEFAULT 'Customer_download.txt'
    OBLIGATORY.
    *SELECT-OPTIONS s_cust FOR kna1-kunnr.
    SELECTION-SCREEN END OF BLOCK b1.
    *-- start processing
    at selection-screen on value-request for p_file.
    perform file_help using p_file.
    START-OF-SELECTION.
    **-- Extract data from DB
    PERFORM extract_data.
    *-- Transfer data to file
      PERFORM file_transfer USING p_file.
    *-- write to o/p
    END-OF-SELECTION.
      LOOP AT it_file.
    WRITE:/ it_file-customer, it_file-name, it_file-country, it_file-region,
    it_file-post_code, it_file-street.
      ENDLOOP.
    *&      Form  extract_data
    FORM extract_data .
    SELECT kunnr
            name1
            land1
            regio
            pstlz
            stras
       APPENDING TABLE it_file
       FROM kna1
       WHERE kunnr IN s_cust.
    ENDFORM.                    " extract_data
    *&      Form  file_transfer
    FORM file_transfer  USING    p_p_file.
      DATA: l_message(30).
    *-- Open File for write
      OPEN DATASET p_p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE
    l_message.
      IF sy-subrc NE 0.
        MESSAGE i002 WITH p_p_file.
      ENDIF.
    *-- Transfer data from FILE TO internal table
      DO.
        READ DATASET p_p_file  INTO it_file.
        IF sy-subrc = 0.
          APPEND it_file.
          CLEAR it_file.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
    *-- Close file
      CLOSE DATASET p_p_file.
      endform.
    *&      Form  file_hepl
          text
         -->P_P_FILE  text
    form file_help  using    p_p_file.
    data:l_filepath type ibipparms-path.
    CALL FUNCTION 'F4_FILENAME'
                     EXPORTING
                       PROGRAM_NAME        = SYST-CPROG
                       DYNPRO_NUMBER       = SYST-DYNNR
                       FIELD_NAME          = ' '
                      IMPORTING
                        FILE_NAME           = l_filepath
    p_p_file = l_filepath .
    endform.                    " file_hepl
    regards,
    keerthi.

  • Problem in upload the file...

    Hi Gurus,
    I am new  in ABAP. I want to upload a file to Application Server.
    1. I create a file in Excel and give extension .prn and save on desktop so i think this file is on my presentation server.
    2. Now thru ABAP Editor i want to upload this file to Application Server
       Because i have to use this file in BDC.
    please give me the process..
    Thanks in Advance..
    Kind Regards
    Yogesh

    Hi Yogesh,
       As per the above suggestion you can use CG3Z tcode to upload your file directly from PS(Prersentation Server) to AS (Application Server).
       Otherwise if you need the procedure for coding, then first sav the file in .xls or .csv  or any format and upload the file into an internal table using any standard FM as per the extension ehich you use. Later use OPEN DATASET stmt. and open a file in AS and pass the data from your Internal table into this file through TRANFSER  stmt and after completing the required process use CLOSE DATASET stmt accordingly.
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards
    Nagaraj T

  • Problem while uploading the file page is not forwarding

    Hi,
    Please tell me the solution for this.
    I'm uploading the file, i'm getting the values very thing, but the page is not forwarding what happening i don't no.
    Here is the code.
    <HTML>
    <%@ page language="java" import="javazoom.upload.*,java.util.*" %>
    <%@ page errorPage="ExceptionHandler.jsp" %>
    <HEAD>
    <BODY style="font:'Bookman Old Style' size="3"">
    <jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
    </jsp:useBean>
    <%
    // Uploading file code
    if (MultipartFormDataRequest.isMultipartFormData(request))
    // Uses MultipartFormDataRequest to parse the HTTP request.
         MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
    String todo = null;
         if (mrequest != null) todo = mrequest.getParameter("todo");
         if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
                        Hashtable files = mrequest.getFiles();
         UploadFile file = (UploadFile) files.get("uploadfile");
              if ((file != null) && (file.getFileSize() <= 82000))
                        {System.out.println("<li>Form field : uploadfile"+"<BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"<BR> Content Type : "+file.getContentType());
                    // Uses the bean now to store specified by jsp:setProperty at the top.
                        upBean.store(mrequest, "uploadfile");
                        else
                        System.out.println("Not Uploaded");
    if (mrequest != null)
         String Schoolname= mrequest.getParameter("schoolname");
         session.setAttribute("saSchoolname", Schoolname);
    System.out.println("Schoolname     "+Schoolname);
    %>
                        <jsp:forward page="FileTransfer.jsp"/>
    <%     
         else out.println("<BR> todo="+todo);
    //System.out.println(session.getAttribute("saswrite"));
    String amessage = request.getParameter("passmsg");
    %>
    <form name='subregiform' method="POST" onsubmit='return checkForm()' action ="FileSubmit2.jsp" ENCTYPE="multipart/form-data">
    <table width="491" border="0" cellpadding="2" >
    <tr>
    <td width="171" align="right"><br> S.S.C  :</td>
    <td width="103" align="center">Institution Name
         <input type="text" name="schoolname" size = 12 maxlength = 35 value = <%
              if(session.getAttribute("saSchoolname")!= null){%>
         <%=session.getAttribute("saSchoolname")%><%}%>>     </td>
    <tr><td width="165"><div align="right">Upload Resume :<br> <br> <br></div></td>
    <td width="356"><input type="file" name="uploadfile" size = 20>
    <font size=1><br>    <I>(Only .doc,.rtf,.txt,.html)</I></font><BR>
       <% if (amessage !=null){ %><FONT SIZE="" COLOR="RED"><strong><%= amessage %></strong></FONT><% }%> </td>
    </tr>
    <tr>
    <td colspan="2">
    <p align="center">
         <input type="hidden" name="todo" value="upload">
    <input type="submit" name="Submit" value="Submit">
         </p>
    </td>
    </tr>
    </table>
    </form>
    </BODY>
    </HTML>

    This code is a mess! Don't put your logic and control into your JSP; use the JSP only for display!
    As for your error, it's because you can't forward after the response has been committed. An illegal state exception will be thrown except you can't see it in the browser because the server has already committed the response and can't change it now. You need to get rid of the forward action. Put in a link to that page instead. Or use a a meta tag to redirect.
    But really, this code cannot be modified to get rid of the problem. It should be scrapped and you should rethink your design. Have a servlet do your control and all this uploading code should also be put into a servlet; never in a JSP
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    Edited by: nogoodatcoding on Oct 5, 2007 2:56 PM

  • How to upload the files of a directory to a server at one time?

    in a jsp page ,the user choose a directory ,then I want to upload the files of the directory to a server at one time.How to do this?Thanks!

    You create multiple file input fields and you have them select each file they want.
    Or tell the user to zip the directory and upload the zip file.
    Or use a signed applet to get all the files and send them.
    There's no way for the browser to select a directory.

  • Help to upload xml file to internal table

    hi all,
          i am still stuck at the same issue , please try to help to resolve this issue.
        thanks in advance
    report  zmybapi1        .
    data : my_order_header_in like bapisdhd1 occurs 0 with header line,
           my_order_header_ix like bapisdhd1x occurs 0 with header line.
    data : my_orderitemsin like bapisditm  occurs 0 with header line,
           my_orderitemsix like bapisditmx occurs 0 with header line.
    data : my_order_partners like bapiparnr occurs 0 with header line.
    data : my_return like bapiret2 occurs 0 with header line.
    data : w_vbeln like bapivbeln-vbeln.
    data:
         my_orderschedulesin like bapischdl occurs 0 with header line,
         my_orderschedulesinx like bapischdlx occurs 0 with header line.
    data : my_orderconditionsin like bapicond occurs 0 with header line,
           my_orderconditionsinx like bapicondx occurs 0 with header line.
    start-of-selection.
    this is to assign values to internal table my_order_header_in
      my_order_header_in-doc_type   = 'TA'.
      my_order_header_in-sales_org  = 'JNJ1'.
      my_order_header_in-distr_chan = '02'.
      my_order_header_in-division   = 'J1'.
      my_order_header_in-sales_off  = 'JNJ1'.
      my_order_header_in-purch_no_c = 'testbapipo'.
      my_order_header_in-purch_date = sy-datum.
      my_order_header_in-req_date_h = sy-datum.
      append my_order_header_in.
    this is to assign values to internal table my_orderitemsin
      my_orderitemsin-material      = '000000000000000727'.
      my_orderitemsin-plant         = 'JNJ1'.
      my_orderitemsin-target_qu     = 'EA'.
      my_orderitemsin-target_qty    = '10'.
      append my_orderitemsin.
    this is to assign values to internal table my_order_partners
      my_order_partners-partn_role = 'AG'.
      my_order_partners-partn_numb = '0000000011'.
      append my_order_partners.
      my_order_partners-partn_role = 'WE'.
      my_order_partners-partn_numb = '0000000011'.
      append my_order_partners.
    This is to assign values to internal table my_orderschedulesin
    my_orderschedulesin-itm_number = '10'.
      my_orderschedulesin-req_qty   = '10'.
      my_orderschedulesin-SCHED_LINE = '0001'.
      append my_orderschedulesin.
    *This is to assign values to internal table my_orderconditionin
      my_orderconditionsin-cond_type = 'ZPR1'.
      my_orderconditionsin-cond_value = '40.00'.
      append my_orderconditionsin.
      my_order_header_ix-updateflag = 'I'.
      my_order_header_ix-doc_type   = 'X'.
      my_order_header_ix-sales_org  = 'X'.
      my_order_header_ix-distr_chan = 'X'.
      my_order_header_ix-division   = 'X'.
      my_order_header_ix-sales_off  = 'X'.
      my_order_header_ix-purch_no_c = 'X'.
      my_order_header_ix-purch_date = 'X'.
      my_order_header_ix-req_date_h = 'X'.
      append my_order_header_ix.
      my_orderitemsix-updateflag    = 'I'.
      my_orderitemsix-material      = 'X'.
      my_orderitemsix-target_qty    = 'X'.
      my_orderitemsix-plant         = 'X'.
      my_orderitemsix-target_qu     = 'X'.
      append my_orderitemsix.
      my_orderschedulesinx-updateflag = 'I'.
      my_orderschedulesinx-sched_line = '0001'.
      my_orderschedulesinx-req_qty    = 'x'.
      append my_orderschedulesinx.
      my_orderconditionsinx-updateflag = 'U'.
      my_orderconditionsinx-cond_type = 'X'.
      my_orderconditionsinx-cond_value = 'X'.
      append my_orderconditionsinx.
      call function 'BAPI_SALESORDER_CREATEFROMDAT2'
        exporting
      SALESDOCUMENTIN               =
          order_header_in               = my_order_header_in
          order_header_inx              = my_order_header_ix
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       =
      INT_NUMBER_ASSIGNMENT         =
      BEHAVE_WHEN_ERROR             =
      LOGIC_SWITCH                  =
      TESTRUN                       =
      CONVERT                       = ' '
        importing
          salesdocument                 = w_vbeln
        tables
          return                        = my_return
          order_items_in                = my_orderitemsin
          order_items_inx               = my_orderitemsix
          order_partners                = my_order_partners
        ORDER_SCHEDULES_IN            =  my_orderschedulesin
          order_schedules_inx           = my_orderschedulesinx
       ORDER_CONDITIONS_IN           =  my_orderconditionsin
       ORDER_CONDITIONS_INX          =  my_orderconditionsinx
      ORDER_CFGS_REF                =
    if sy-subrc ne 0.
        write: my_return-message, my_return-number, my_return-type.
      else.
         call function 'BAPI_TRANSACTION_COMMIT'
         EXPORTING
           WAIT          =
         IMPORTING
           RETURN        =
          write: my_return-message, my_return-number, my_return-type.
    endif.
    regards,
    pavan

    Hi,
    is your question is related to upload xls fiel to ITAB.if so you can check this link , here you can find 3 examples..
    http://www.sapdevelopment.co.uk/file/file_upexcel.htm
    http://www.sapdevelopment.co.uk/file/file_upexcelalt1.htm
    http://www.sapdevelopment.co.uk/file/file_upexcelalt2.htm
    Regards
    vijay

  • Upload .xls file in internal table in web dynpro abap

    Hi everyone,
    i want to upload .xls(excel file) into an internal table.....after lots of attempts i came to a conclusion that web dynpro only supports .CSV(another format of excel file) to be uploaded into internal table....i tried many ways....is there a way i can upload .xls file...kindly help me in the same. following is the code i m using
      DATA LO_EL_CONTEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT.
      DATA LS_CONTEXT TYPE WD_THIS->ELEMENT_CONTEXT.
      DATA ITEM_FILE TYPE WD_THIS->ELEMENT_CONTEXT-EXCEL_UPLOAD.
      get element via lead selection
      LO_EL_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).
      @TODO handle not set lead selection
      IF LO_EL_CONTEXT IS INITIAL.
      ENDIF.
      get single attribute
      LO_EL_CONTEXT->GET_ATTRIBUTE(
        EXPORTING
          NAME =  `EXCEL_UPLOAD`
        IMPORTING
          VALUE = ITEM_FILE ). "xstring format
    DATA S_CONT TYPE STRING.
    DATA CONVT TYPE REF TO CL_ABAP_CONV_IN_CE.
    DATA: FIELDS1 TYPE STRING_TABLE.
    1st tried this code-> using "cl_abap_conv_in_ce"
    CALL METHOD cl_abap_conv_in_ce=>create
    EXPORTING
    *encoding = c_encoding "optional
    input = ITEM_FILE
    RECEIVING
    conv = CONVT.
    CALL METHOD CONVT->read
    IMPORTING
    data = S_CONT.
    when it didnt work out...then tried followin function module
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          IN_XSTRING        = ITEM_FILE "xsrting
       IMPORTING
         OUT_STRING          = S_CONT
    TYPES: BEGIN OF TY_TAB,
           NAME_CHAR TYPE  STRING,
           DESCR_CHAR TYPE  STRING,
           NUMBER_DIGITS TYPE  STRING,
           END OF TY_TAB.
    DATA: FIELDS TYPE STRING_TABLE.
    DATA: LV_FIELD TYPE STRING.
    DATA: S_TABLE TYPE STRING_TABLE.
    DATA: ITAB TYPE TABLE OF TY_TAB.
    DATA: STR_ITAB TYPE TY_TAB.
    *splits string based on new line
    SPLIT S_CONT 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>.
    splits string on basis of tabs
      SPLIT <WA_TABLE> AT ',' INTO
                      STR_ITAB-NAME_CHAR
                      STR_ITAB-DESCR_CHAR
                      STR_ITAB-NUMBER_DIGITS.
      APPEND STR_ITAB TO ITAB.
    ENDLOOP.
    I am able to do the uploading if the file is in .CSV format and not .XLS format....
    there are lots of forums on SDN for the same....but at the end there is no solution provided.....
    experts kindly solve it this time...thanks in advance

    Hi,
    It is not possible to upload an xls file because it will be having some binary characters. better to go with .csv file format.
    Refer this [link too|Re: Excel File Uplaod] it will explain you clearly.
    Regards
    Arun.P

  • Simple Transformation ST, upload xml file to internal table

    Hi.
    I want to upload some parts of an xml file into an sap internal table, especially the part "trackingnumber" which can occur several times.
    the xml looks like this:
    <?xml version="1.0" encoding="windows-1252"?>
    <OpenShipments xmlns="x-schema:OpenShipments.xdr">
         <OpenShipment ProcessStatus="Processed">
              <ShipTo>
              </ShipTo>
              <ShipFrom>
              </ShipFrom>
              <ShipmentInformation>
              </ShipmentInformation>
              <Package>
              </Package>
              <InternationalDocumentation>
              </InternationalDocumentation>
              <Goods>
              </Goods>
              <ProcessMessage>
                   <TrackingNumbers>
                        <TrackingNumber>1Z1234563330702444</TrackingNumber>
                        <TrackingNumber>1Z1234566644402555</TrackingNumber>
                   </TrackingNumbers>
              </ProcessMessage>
         </OpenShipment>
    </OpenShipments>
    The ST looks like this:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="ROOT"/>
    <tt:template>
    <OpenShipments xmlns="x-schema:OpenShipments.xdr">
    <OpenShipment>
    <ShipTo>
    <tt:skip/>
    </ShipTo>
    <ShipFrom>
    <tt:skip/>
    </ShipFrom>
    <ShipmentInformation>
    <tt:skip/>
    </ShipmentInformation>
    <tt:group>
    <tt:cond frq="*">
    <Package>
    <tt:skip/>
    </Package>
    </tt:cond>
    </tt:group>
    <InternationalDocumentation>
    <tt:skip/>
    </InternationalDocumentation>
    <tt:group>
    <tt:cond frq="*">
    <Goods>
    <tt:skip/>
    </Goods>
    </tt:cond>
    </tt:group>
    <ProcessMessage>
    <ShipmentRates>
    <tt:skip/>
    </ShipmentRates>
    <TrackingNumbers>
    <tt:group>
    <tt:cond frq="*">
    <TrackingNumber>
    <tt:loop ref="ROOT">
    <tt:value ref="ROOT" />
    </tt:loop>
    </TrackingNumber>
    </tt:cond>
    </tt:group>
    </TrackingNumbers>
    <ImportID>
    <tt:skip/>
    </ImportID>
    <Reference1>
    <tt:skip/>
    </Reference1>
    <Reference2>
    <tt:skip/>
    </Reference2>
    </ProcessMessage>
    </OpenShipment>
    </OpenShipments>
    </tt:template>
    </tt:transform>
    The ABAP Code looks like this:
    REPORT  z_xml_to_abap_test.
    TYPES: t_xmllin_src(4096) TYPE x,
           t_xmltab_src TYPE STANDARD TABLE OF t_xmllin_src.
    DATA: xmlstr_src TYPE xstring,
          xmltab_src TYPE t_xmltab_src,
          result1(254) TYPE c,
          BEGIN OF ROOT,
            TrackingNumber(254) type c,
          END OF ROOT.
    FIELD-SYMBOLS: <xmlline> LIKE LINE OF xmltab_src.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
       filename                      = 'e:\20100601_132212.Out'
       filetype                      = 'BIN'
       has_field_separator           = ''
       header_length                 = 0
       read_by_line                  = 'X'
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
    TABLES
       data_tab                      = xmltab_src
    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.
    LOOP AT xmltab_src ASSIGNING <xmlline>.
      CONCATENATE xmlstr_src <xmlline> INTO xmlstr_src IN BYTE MODE.
    ENDLOOP.
    CALL TRANSFORMATION z_ups_xml_upload
      SOURCE XML xmlstr_src
      RESULT ROOT = ROOT.
    When i run the program i got the following error message:
    "The goal was to access variable "ROOT". However, this access was not possible.
    Anybody has an idea, why this happens, this is my first ST and have no clue at the moment why this happens?

    Hi.
    I want to upload some parts of an xml file into an sap internal table, especially the part "trackingnumber" which can occur several times.
    the xml looks like this:
    <?xml version="1.0" encoding="windows-1252"?>
    <OpenShipments xmlns="x-schema:OpenShipments.xdr">
         <OpenShipment ProcessStatus="Processed">
              <ShipTo>
              </ShipTo>
              <ShipFrom>
              </ShipFrom>
              <ShipmentInformation>
              </ShipmentInformation>
              <Package>
              </Package>
              <InternationalDocumentation>
              </InternationalDocumentation>
              <Goods>
              </Goods>
              <ProcessMessage>
                   <TrackingNumbers>
                        <TrackingNumber>1Z1234563330702444</TrackingNumber>
                        <TrackingNumber>1Z1234566644402555</TrackingNumber>
                   </TrackingNumbers>
              </ProcessMessage>
         </OpenShipment>
    </OpenShipments>
    The ST looks like this:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="ROOT"/>
    <tt:template>
    <OpenShipments xmlns="x-schema:OpenShipments.xdr">
    <OpenShipment>
    <ShipTo>
    <tt:skip/>
    </ShipTo>
    <ShipFrom>
    <tt:skip/>
    </ShipFrom>
    <ShipmentInformation>
    <tt:skip/>
    </ShipmentInformation>
    <tt:group>
    <tt:cond frq="*">
    <Package>
    <tt:skip/>
    </Package>
    </tt:cond>
    </tt:group>
    <InternationalDocumentation>
    <tt:skip/>
    </InternationalDocumentation>
    <tt:group>
    <tt:cond frq="*">
    <Goods>
    <tt:skip/>
    </Goods>
    </tt:cond>
    </tt:group>
    <ProcessMessage>
    <ShipmentRates>
    <tt:skip/>
    </ShipmentRates>
    <TrackingNumbers>
    <tt:group>
    <tt:cond frq="*">
    <TrackingNumber>
    <tt:loop ref="ROOT">
    <tt:value ref="ROOT" />
    </tt:loop>
    </TrackingNumber>
    </tt:cond>
    </tt:group>
    </TrackingNumbers>
    <ImportID>
    <tt:skip/>
    </ImportID>
    <Reference1>
    <tt:skip/>
    </Reference1>
    <Reference2>
    <tt:skip/>
    </Reference2>
    </ProcessMessage>
    </OpenShipment>
    </OpenShipments>
    </tt:template>
    </tt:transform>
    The ABAP Code looks like this:
    REPORT  z_xml_to_abap_test.
    TYPES: t_xmllin_src(4096) TYPE x,
           t_xmltab_src TYPE STANDARD TABLE OF t_xmllin_src.
    DATA: xmlstr_src TYPE xstring,
          xmltab_src TYPE t_xmltab_src,
          result1(254) TYPE c,
          BEGIN OF ROOT,
            TrackingNumber(254) type c,
          END OF ROOT.
    FIELD-SYMBOLS: <xmlline> LIKE LINE OF xmltab_src.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
       filename                      = 'e:\20100601_132212.Out'
       filetype                      = 'BIN'
       has_field_separator           = ''
       header_length                 = 0
       read_by_line                  = 'X'
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
    TABLES
       data_tab                      = xmltab_src
    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.
    LOOP AT xmltab_src ASSIGNING <xmlline>.
      CONCATENATE xmlstr_src <xmlline> INTO xmlstr_src IN BYTE MODE.
    ENDLOOP.
    CALL TRANSFORMATION z_ups_xml_upload
      SOURCE XML xmlstr_src
      RESULT ROOT = ROOT.
    When i run the program i got the following error message:
    "The goal was to access variable "ROOT". However, this access was not possible.
    Anybody has an idea, why this happens, this is my first ST and have no clue at the moment why this happens?

  • Upload excel file to internal table in web dynpro program

    Hi friend's
    In web dynpro program how to upload excel file into  internal table and finally data will be save Y table.

    hi,
    See the properties of File Upload UI element..
    Link: [http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/732f0510d83ff6e10000000a42189c/frameset.htm]
    Goto References -> User Interface Elements -> Integration Category -> File upload..
    After creating the 'FILE UPLOAD' element in a view.. Bind a datasource(a context attribute with STRING) with the data property..
    Double click on ONACTION_UPLOAD method. Write a code as given below.
    METHOD onactionon_upload .
    TYPES :   BEGIN OF str_itab,
           name(10) TYPE c,
           age(10) TYPE c,
           END OF str_itab.  DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
             i_data TYPE STANDARD TABLE OF string,
             l_string TYPE string,
             fs_table TYPE str_itab,
             l_xstring TYPE xstring,
             fields TYPE string_table,
             lv_field TYPE string.
    DATA : t_table TYPE if_main=>elements_data_tab,
             data_table TYPE if_main=>elements_data_tab.
    * get single attribute 
    wd_context->get_attribute(  
    EXPORTING    
    name =  `DATASOURCE`  
    IMPORTING    
    value = l_xstring ).
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          in_xstring = l_xstring
        IMPORTING
          out_string = l_string. 
    SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
    * Bind With table Element.
    LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
       READ TABLE fields INTO lv_field INDEX 1.
        fs_table-name = lv_field.  
    READ TABLE fields INTO lv_field INDEX 2.
        fs_table-age = lv_field.   
    APPEND fs_table TO t_table1.     "Append to  the internal  table
      ENDLOOP.
    Edited by: Rameshkumar Raamasamy on Feb 9, 2010 9:39 AM

  • Program to upload csv file to internal table and insert into database table

    Hi I'm writing a program where I need to upload a csv file into an internal table using gui_upload, but i also need this program to insert the data into my custom database table using the split command.  Anybody have any samples to help, its urgent!

    Hi,
    Check this table may be it will give u an hint...
    REPORT z_table_upload LINE-SIZE 255.
    Data
    DATA: it_dd03p TYPE TABLE OF dd03p,
          is_dd03p TYPE dd03p.
    DATA: it_rdata  TYPE TABLE OF text1024,
          is_rdata  TYPE text1024.
    DATA: it_fields TYPE TABLE OF fieldname.
    DATA: it_file  TYPE REF TO data,
          is_file  TYPE REF TO data.
    DATA: w_error  TYPE text132.
    Macros
    DEFINE write_error.
      concatenate 'Error: table'
                  p_table
                  &1
                  &2
             into w_error
             separated by space.
      condense w_error.
      write: / w_error.
      stop.
    END-OF-DEFINITION.
    Field symbols
    FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
                   <data>  TYPE ANY,
                   <fs>    TYPE ANY.
    Selection screen
    SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
    PARAMETERS: p_file  TYPE localfile DEFAULT 'C:\temp\' OBLIGATORY,
                p_separ TYPE c DEFAULT ';' OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK b01.
    SELECTION-SCREEN: BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
    PARAMETERS: p_table TYPE tabname OBLIGATORY
                                     MEMORY ID dtb
                                     MATCHCODE OBJECT dd_dbtb_16.
    SELECTION-SCREEN: END OF BLOCK b02.
    SELECTION-SCREEN: BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
    PARAMETERS: p_create TYPE c AS CHECKBOX.
    SELECTION-SCREEN: END OF BLOCK b03,
                      SKIP.
    SELECTION-SCREEN: BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
    PARAMETERS: p_nodb RADIOBUTTON GROUP g1 DEFAULT 'X'
                                   USER-COMMAND rg1,
                p_save RADIOBUTTON GROUP g1,
                p_dele RADIOBUTTON GROUP g1.
    SELECTION-SCREEN: SKIP.
    PARAMETERS: p_test TYPE c AS CHECKBOX,
                p_list TYPE c AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN: END OF BLOCK b04.
    At selection screen
    AT SELECTION-SCREEN.
      IF sy-ucomm = 'RG1'.
        IF p_nodb IS INITIAL.
          p_test = 'X'.
        ENDIF.
      ENDIF.
    At selection screen
    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.
      PERFORM f_table_definition USING p_table.
      PERFORM f_upload_data USING p_file.
      PERFORM f_prepare_table USING p_table.
      PERFORM f_process_data.
      IF p_nodb IS INITIAL.
        PERFORM f_modify_table.
      ENDIF.
      IF p_list = 'X'.
        PERFORM f_list_records.
      ENDIF.
    End of selection
    END-OF-SELECTION.
          FORM f_table_definition                                       *
    -->  VALUE(IN_TABLE)                                               *
    FORM f_table_definition USING value(in_table).
      DATA: l_tname TYPE tabname,
            l_state TYPE ddgotstate,
            l_dd02v TYPE dd02v.
      l_tname = in_table.
      CALL FUNCTION 'DDIF_TABL_GET'
           EXPORTING
                name          = l_tname
           IMPORTING
                gotstate      = l_state
                dd02v_wa      = l_dd02v
           TABLES
                dd03p_tab     = it_dd03p
           EXCEPTIONS
                illegal_input = 1
                OTHERS        = 2.
      IF l_state NE 'A'.
        write_error 'does not exist or is not active' space.
      ENDIF.
      IF l_dd02v-tabclass NE 'TRANSP' AND
         l_dd02v-tabclass NE 'CLUSTER'.
        write_error 'is type' l_dd02v-tabclass.
      ENDIF.
    ENDFORM.
          FORM f_prepare_table                                          *
    -->  VALUE(IN_TABLE)                                               *
    FORM f_prepare_table USING value(in_table).
      DATA: l_tname TYPE tabname,
            lt_ftab TYPE lvc_t_fcat.
      l_tname = in_table.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name = l_tname
           CHANGING
                ct_fieldcat      = lt_ftab
           EXCEPTIONS
                OTHERS           = 1.
      IF sy-subrc NE 0.
        WRITE: / 'Error while building field catalog'.
        STOP.
      ENDIF.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = lt_ftab
        IMPORTING
          ep_table        = it_file.
      ASSIGN it_file->* TO <table>.
      CREATE DATA is_file LIKE LINE OF <table>.
      ASSIGN is_file->* TO <data>.
    ENDFORM.
          FORM f_upload_data                                            *
    -->  VALUE(IN_FILE)                                                *
    FORM f_upload_data USING value(in_file).
      DATA: l_file    TYPE string,
            l_ltext   TYPE string.
      DATA: l_lengt   TYPE i,
            l_field   TYPE fieldname.
      DATA: l_missk   TYPE c.
      l_file = in_file.
      l_lengt = strlen( in_file ).
      FORMAT INTENSIFIED ON.
      WRITE: / 'Reading file', in_file(l_lengt).
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                filename = l_file
                filetype = 'ASC'
           TABLES
                data_tab = it_rdata
           EXCEPTIONS
                OTHERS   = 1.
      IF sy-subrc <> 0.
        WRITE: /3 'Error uploading', l_file.
        STOP.
      ENDIF.
    File not empty
      DESCRIBE TABLE it_rdata LINES sy-tmaxl.
      IF sy-tmaxl = 0.
        WRITE: /3 'File', l_file, 'is empty'.
        STOP.
      ELSE.
        WRITE: '-', sy-tmaxl, 'rows read'.
      ENDIF.
    File header on first row
      READ TABLE it_rdata INTO is_rdata INDEX 1.
      l_ltext = is_rdata.
      WHILE l_ltext CS p_separ.
        SPLIT l_ltext AT p_separ INTO l_field l_ltext.
        APPEND l_field TO it_fields.
      ENDWHILE.
      IF sy-subrc = 0.
        l_field = l_ltext.
        APPEND l_field TO it_fields.
      ENDIF.
    Check all key fields are present
      SKIP.
      FORMAT RESET.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Key fields'.
      FORMAT RESET.
      LOOP AT it_dd03p INTO is_dd03p WHERE NOT keyflag IS initial.
        WRITE: /3 is_dd03p-fieldname.
        READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname
                             TRANSPORTING NO FIELDS.
        IF sy-subrc = 0.
          FORMAT COLOR COL_POSITIVE.
          WRITE: 'ok'.
          FORMAT RESET.
        ELSEIF is_dd03p-datatype NE 'CLNT'.
          FORMAT COLOR COL_NEGATIVE.
          WRITE: 'error'.
          FORMAT RESET.
          l_missk = 'X'.
        ENDIF.
      ENDLOOP.
    Log other fields
      SKIP.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Other fields'.
      FORMAT RESET.
      LOOP AT it_dd03p INTO is_dd03p WHERE keyflag IS initial.
        WRITE: /3 is_dd03p-fieldname.
        READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname
                             TRANSPORTING NO FIELDS.
        IF sy-subrc = 0.
          WRITE: 'X'.
        ENDIF.
      ENDLOOP.
    Missing key field
      IF l_missk = 'X'.
        SKIP.
        WRITE: /3 'Missing key fields - no further processing'.
        STOP.
      ENDIF.
    ENDFORM.
          FORM f_process_data                                           *
    FORM f_process_data.
      DATA: l_ltext TYPE string,
            l_stext TYPE text40,
            l_field TYPE fieldname,
            l_datat TYPE c.
      LOOP AT it_rdata INTO is_rdata FROM 2.
        l_ltext = is_rdata.
        LOOP AT it_fields INTO l_field.
          ASSIGN COMPONENT l_field OF STRUCTURE <data> TO <fs>.
          IF sy-subrc = 0.
          Field value comes from file, determine conversion
            DESCRIBE FIELD <fs> TYPE l_datat.
            CASE l_datat.
              WHEN 'N'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                WRITE l_stext TO <fs> RIGHT-JUSTIFIED.
                OVERLAY <fs> WITH '0000000000000000'.           "max 16
              WHEN 'P'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING ',.'.
                <fs> = l_stext.
              WHEN 'F'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING ',.'.
                <fs> = l_stext.
              WHEN 'D'.
                SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
                TRANSLATE l_stext USING '/.-.'.
                CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
                     EXPORTING
                          date_external = l_stext
                     IMPORTING
                          date_internal = <fs>
                     EXCEPTIONS
                          OTHERS        = 1.
              WHEN 'T'.
                CALL FUNCTION 'CONVERT_TIME_INPUT'
                     EXPORTING
                          input  = l_stext
                     IMPORTING
                          output = <fs>
                     EXCEPTIONS
                          OTHERS = 1.
              WHEN OTHERS.
                SPLIT l_ltext AT p_separ INTO <fs> l_ltext.
            ENDCASE.
          ELSE.
            SHIFT l_ltext UP TO p_separ.
            SHIFT l_ltext.
          ENDIF.
        ENDLOOP.
        IF NOT <data> IS INITIAL.
          LOOP AT it_dd03p INTO is_dd03p WHERE datatype = 'CLNT'.
          This field is mandant
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-mandt.
          ENDLOOP.
          IF p_create = 'X'.
            IF is_dd03p-rollname = 'ERDAT'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-datum.
            ENDIF.
            IF is_dd03p-rollname = 'ERZET'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-uzeit.
            ENDIF.
            IF is_dd03p-rollname = 'ERNAM'.
              ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                            TO <fs>.
              <fs> = sy-uname.
            ENDIF.
          ENDIF.
          IF is_dd03p-rollname = 'AEDAT'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-datum.
          ENDIF.
          IF is_dd03p-rollname = 'AETIM'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-uzeit.
          ENDIF.
          IF is_dd03p-rollname = 'AENAM'.
            ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
                                                          TO <fs>.
            <fs> = sy-uname.
          ENDIF.
          APPEND <data> TO <table>.
        ENDIF.
      ENDLOOP.
    ENDFORM.
          FORM f_modify_table                                           *
    FORM f_modify_table.
      SKIP.
      IF p_save = 'X'.
        MODIFY (p_table) FROM TABLE <table>.
      ELSEIF p_dele = 'X'.
        DELETE (p_table) FROM TABLE <table>.
      ELSE.
        EXIT.
      ENDIF.
      IF sy-subrc EQ 0.
        FORMAT COLOR COL_POSITIVE.
        IF p_save = 'X'.
          WRITE: /3 'Modify table OK'.
        ELSE.
          WRITE: /3 'Delete table OK'.
        ENDIF.
        FORMAT RESET.
        IF p_test IS INITIAL.
          COMMIT WORK.
        ELSE.
          ROLLBACK WORK.
          WRITE: '- test only, no update'.
        ENDIF.
      ELSE.
        FORMAT COLOR COL_NEGATIVE.
        WRITE: /3 'Error while modifying table'.
        FORMAT RESET.
      ENDIF.
    ENDFORM.
          FORM f_list_records                                           *
    FORM f_list_records.
      DATA: l_tleng TYPE i,
            l_lasti TYPE i,
            l_offst TYPE i.
    Output width
      l_tleng = 1.
      LOOP AT it_dd03p INTO is_dd03p.
        l_tleng = l_tleng + is_dd03p-outputlen.
        IF l_tleng LT sy-linsz.
          l_lasti = sy-tabix.
          l_tleng = l_tleng + 1.
        ELSE.
          l_tleng = l_tleng - is_dd03p-outputlen.
          EXIT.
        ENDIF.
      ENDLOOP.
    Output header
      SKIP.
      FORMAT COLOR COL_HEADING.
      WRITE: /3 'Contents'.
      FORMAT RESET.
      ULINE AT /3(l_tleng).
    Output records
      LOOP AT <table> ASSIGNING <data>.
        LOOP AT it_dd03p INTO is_dd03p FROM 1 TO l_lasti.
          IF is_dd03p-position = 1.
            WRITE: /3 sy-vline.
            l_offst = 3.
          ENDIF.
          ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>.
          l_offst = l_offst + 1.
          IF is_dd03p-decimals LE 2.
            WRITE: AT l_offst <fs>.
          ELSE.
            WRITE: AT l_offst <fs> DECIMALS 3.
          ENDIF.
          l_offst = l_offst + is_dd03p-outputlen.
          WRITE: AT l_offst sy-vline.
        ENDLOOP.
      ENDLOOP.
    Ouptut end
      ULINE AT /3(l_tleng).
    ENDFORM.
    Regards,
    Joy.

  • GUI_UPLOAD to upload flat file to internal table

    Hi Experts,
    I have to upload a flat file which has multiple records ,from a local server.The fields in records are ~ saperated.
    Presently i am only looking into uploading the flat file into internal table.
    I have done the following coding;
    TYPES: BEGIN OF gt_frmgt ,
           tablety  type c length 10 ,
           tablenm  type c length 30,
           numin  type  c length 2,
           END OF gt_frmgt.
    TYPES: begin of gt_frmgto,
             rec(1000) type c,
            end of gt_frmgto.
    DATA: Itgt_frmgt type table of gt_frmgt with header line.
    DATA: itgt_frmgto type table of gt_frmgto with header line.
    DATA: lfile_path type string.
    PARAMETERS: f_path type localfile.
    at selection-screen on value-request for f_path.
      call function 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          static    = 'X'
        CHANGING
          file_name = f_path.
    start-of-selection.
      lfile_path = f_path.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                      = lfile_path
          FILETYPE                      = 'ASC'
         HAS_FIELD_SEPARATOR           = 'X'
        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                      =  itgt_frmgto
      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.
      delete itgt_frmgto index 1.
      loop at itgt_frmgto.
        clear Itgt_frmgt.
        split itgt_frmgto-rec at cl_abap_char_utilities=>vertical_tab
        into Itgt_frmgt-tablety
        Itgt_frmgt-tablenm
        Itgt_frmgt-numin.
        append Itgt_frmgt.
      endloop.
      loop at Itgt_frmgt.
        write:/ Itgt_frmgt-tablety, Itgt_frmgt-tablenm, Itgt_frmgt-numin.
    The input file in Local path is ;
    XXXXXXX~~Export the invoice
    2~19980501~19980531
    // The first invoice:
    0~00130698114000010004119980512059611000276233.350.1711076.66????321000789010005???????????????????130601000000000??????????18? 3352051????532611-3357211???~~~
    0~????????176233.350.1711076.6676233.350~1510
    // The second invoice:
    0~00130698114000010007219980512059611000440482.000.175882.00????110108078901007?????????61? 68744479?????????????462088-07?????130601000000000??????????18? 3352051????532611-3357211???????????~~~
    0~????????139780.000.175780.0039780.000~1510
    0~????3.5"10702.000.17102.0070.20~1510
    and the output is :
    XXXXXXX~~
    2~~1998050
    // The fir
    0~00~1
    0~????~?
    // The sec
    0~00~1
    0~????~?
    0~????
    I am unable to understand why this split is happening .According to me the first 3 fields should be displayed without field saperater.
    It would be very much appreciated if any body has little idea about this.
    Thankx,
    Priya
    Message was edited by:
            Priya Parmeshwar Shiggaon
    Message was edited by:
            Priya Parmeshwar Shiggaon

    if it is one time upload then u can use transaction CG3Z n upload file on application server.
    u can tno use Gui_upload in background.
    Program to upload file via gui_upload in foreground  -(open fiel in Excel format and then make changes and save it as text tab file and upload tht file) -
    REPORT  Z_AMIT_BAPI
    no standard page heading line-size 255.
    parameters: p_file like rlgrap-filename default 'C:\temp\emp.txt'.
    data :begin of itab occurs 0,
             pernr(8),
             bdate(10),
             edate(10),
             mail(30) ,
            end of itab.
    Start-of-selection.
    Perform read_file.
    *&      Form  read_file
          text
    -->  p1        text
    <--  p2        text
    FORM read_file .
    DATA: full_file_name    TYPE string.
    full_file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = full_file_name
        FILETYPE                      = 'ASC'
        HAS_FIELD_SEPARATOR           = ','
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        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
       OTHERS                        = 17
    IF SY-SUBRC <> 0.
      MESSAGE e000(000) WITH 'Upload-Error; RC:' sy-subrc.
    ENDIF.
    ENDFORM.                    " read_file
    reward points if helpfull
    amit

  • Uploading Excel file to Internal Table

    Hi,
    I need to upload an excel file into my internal table. Can we use GUI_UPLOAD Function module for this purpose? if Yes What are all the parameters we need to pass?
    Can anybody give the related function modules list.
    egards,
    Sudheer

    hi,
    check this,
    *& Report  ZTESTPROG002
    REPORT  ZTESTPROG002.
    tables: mara.
    PARAMETERS: p_file LIKE rlgrap-filename default 'C:\Documents and Settings\venkatapp\Desktop\venkat.xls'.
    data:begin of it_mara occurs 0,
         matnr like mara-matnr,
         meins like mara-meins,
         mtart like mara-mtart,
         mbrsh like mara-mbrsh,
         end of it_mara.
    SELECT matnr
           meins
           mtart
           mbrsh
           FROM mara
           INTO corresponding fields of TABLE it_mara.
    CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
      EXPORTING
        i_filename     = p_file
      TABLES
        i_tab_sap_data = it_mara.
    regards,
    venkat.

  • Uploading excell file to internal table

    HI every body,
           Here I am uploading the excel file into the internal table but it is uploading special
      charecters  ÐÏ#ࡱ#á##    like this  , what i have to do?
    my code is
    PARAMETERS:  fn LIKE rlgrap-filename OBLIGATORY.
    DATA: FN1 TYPE STRING,
         l .
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR fn. "p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                field_name = 'FN'
           IMPORTING
                file_name  = fn.
       START-OF-SELECTION.
      FN1 = FN.
      PERFORM upload.
       FORM upload.
      CALL function 'GUI_UPLOAD'
      exporting
        filename                      = FN1
       FILETYPE                      = 'DAT'
      tables
        data_tab                      = ITAB.

    Hi Srinivasa ,
    Here is the solution with other FM . Its working fine with my application and also easy to use!
    REPORT  ztest_upload       .
    TYPE-POOLS : truxs.
    DATA : BEGIN OF i_data OCCURS 0,
              auart(4) TYPE c,
              vbeln(10) TYPE n,
              plant(4) TYPE c,
              item_no(6) TYPE c,
              qty TYPE p,
              uom_qty(3) TYPE c,
              value1 TYPE p DECIMALS 2,
              value2 TYPE p DECIMALS 2,
              text(20) TYPE c,
            END OF i_data.
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_fname LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          program_name = sy-repid
          static       = 'X'
        CHANGING
          file_name    = p_fname.
    START-OF-SELECTION.
      PERFORM get_excel_data.
    *&      Form  get_excel_data
          text
    -->  p1        text
    <--  p2        text
    FORM get_excel_data .
    <b>
      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_fname
          TABLES
            i_tab_converted_data     = i_data[]    "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-msgv4.
      ENDIF.</b>
    ENDFORM.                    " get_excel_data
    After That You can Use i_data internal table directly , you can loop on that and extract the data.
    It uploads the data same as in the excel format.
    Reward with points if usefull.
    Thanks & Regards,

Maybe you are looking for