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

Similar Messages

  • 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

  • Need to pass values to Internal table in Web dynpro ABAP

    Hi all,
    I need to pass table values for the below FM in web dynpro.
    CALL FUNCTION 'ZFMHR_RWF'
      TABLES
        PB0006        = 
    How do we declare and use Internal tables in WEBDYnpro.
    Regards,
    Vijayakumar S.

    hi,
    u mighnt need to show the internal table value in some table UI in the WebDynpro ABAP. So u can use the method bind_table for the same to bind ur context node with the internal table values.u can declare the internal table in the same  way as u do in the normal ABAP.
      DATA :itab TYPE STANDARD TABLE OF ztable.
    // itab is my internal table which can be of either ztable or standard table type
    now u can use the code wizrd(control+F7) and use the method bind_table .
      DATA: lo_nd_cn_node TYPE REF TO if_wd_context_node,
                lo_el_cn_node   TYPE REF TO if_wd_context_element,
               ls_cn_node        TYPE wd_this->element_cn_node.
    *     navigate from <CONTEXT> to <CN_NODE> via lead selection
      lo_nd_cn_node = wd_context->get_child_node(
      name = wd_this->wdctx_cn_node ).
      lo_nd_cn_node->bind_table( itab ).
    // where cn_node is the context node which is bind to ur table UI and itab is the value which is populated from ur FM
    regards,
    Amit

  • Upload a file in KM repository with Web dynpro for abap

    Hi gurus, i´m trying to create a KM repository and then upload a file into this repository with Web dynpro for abap , but i can´t find any info. Can anyone help me with this problem, i have to solve it ASAP...
    Thanks for all....
    Regards,
    Diego.

    Please referr to the ideas on this thread.
    Install Problems withe the NW04s ABAP Trial verssion
    You have installed the loopback adapter and made the propriate entries in the hosts file, right?
    Regards,
    Rich Heilman

  • How to display an status Icon in Table UI web dynpro ABAP?

    Hi Experts ,
    How to display an status Icon ( Traffic light ) in Table UI web dynpro ABAP? can somebody tell with a coding example. also I need to update status on condition so whats the best way?
    Thanks in advance.
    Regards,

    Hi Laeeq,
    click on table cntrol n place it on the screen..
    now click on the icon button n place it in the table control area.. a column of icons get created. name it (say) ICON.
    in the PBO..
    loop at internal table and call module in the loop (say) .
    MODULE ICON_DISP.
    now in the module try the foll code :
    module icon_display output.
    check some condition and assign the icon to the variable icon_r
      icon_R = 'ICON_GREEN_LIGHT'.
      CALL FUNCTION 'ICON_CREATE'
        EXPORTING
          name                        = ICON_R
        TEXT                        = ' '
        INFO                        = ' '
        ADD_STDINF                  = 'X'
       IMPORTING
         RESULT                      = ICON
      EXCEPTIONS
        ICON_NOT_FOUND              = 1
        OUTPUTFIELD_TOO_SHORT       = 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.
      endmodule.
    where icon(35) and icon_r(35) type c .
    hope this helps u..
    Regards
    Aparna

  • Getting Issue while uploading CSV file into internal table

    Hi,
    CSV file Data format as below
         a             b               c              d           e               f
    2.01E14     29-Sep-08     13:44:19     2.01E14     SELL     T+1
    actual values of column   A is 201000000000000
                     and  columen D is 201000000035690
    I am uploading above said CSV file into internal table using
    the below coding:
    TYPES: BEGIN OF TY_INTERN.
            INCLUDE STRUCTURE  KCDE_CELLS.
    TYPES: END OF TY_INTERN.
    CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
        EXPORTING
          I_FILENAME      = P_FILE
          I_SEPARATOR     = ','
        TABLES
          E_INTERN        = T_INTERN
        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.
    am getting all columns data into internal table,
    getting problem is columan A & D. am getting values into internal table for both; 2.01E+14. How to get actual values without modifying the csv file format.
    waiting for your reply...
    thanks & regards,
    abhi

    Hi Saurabh,
    Thanks for your reply.
    even i can't double click on those columns.
    b'se the program needs be executed in background there can lot of csv file in one folder. No manual interaction on those csv files.
    regards,
    abhi

  • 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

  • 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 excel file into internal table with field length more than 255

    I am trying to upload the data from an excel file through function module 'TEXT_CONVERT_XLS_TO_SAP'.
    I have tested by changing the field type from string, and char2000.
    But it is accepting only 255 chars from the cell content.
    How to get the total content of the field if it is more than 255 char.

    hi,
      you can use any of the following procedures:
    For uploading data from excel to internal table refer standard report  RC1TCG3Z  in se38 :
                                               or
    You can use the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' itself. Please check if you have done it this way . But,  this FM can be a little time consuming if the excel has large data, so you can use the FM u2018GUI_UPLOADu2019.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
            EXPORTING
              filename                = p_file1
              i_begin_col          = l_b1
              i_begin_row        = l_c1
             i_end_col               = l_b2
             i_end_row             = l_c2
           TABLES
              intern                  = lt_data
            EXCEPTIONS
             inconsistent_parameters = 1
            upload_ole              = 2
              OTHERS                  = 3.
          IF sy-subrc <> 0.
            MESSAGE e018 DISPLAY LIKE 'i'.
         ENDIF.
    *---Removing the first heading fields from the file.
          IF NOT lt_data[] IS INITIAL.
            LOOP AT lt_data INTO lwa_data WHERE row = '0001'.
              DELETE lt_data.
              CLEAR lwa_data.
            ENDLOOP.
    *---Inserting the data from file the internal table
            LOOP AT lt_data INTO lwa_data.
              CASE lwa_data-col.
                WHEN 1.
                  wa_file_wicopa-serial = lwa_data-value.
                WHEN 2.
                  wa_file_wicopa-blart = lwa_data-value.
                WHEN 3.
                  wa_file_wicopa-bldat = lwa_data-value.
                WHEN 4.
                  wa_file_wicopa-budat = lwa_data-value.
              ENDCASE.
              AT END OF row.
                APPEND wa_file_wicopa TO gt_file_wicopa.
                CLEAR wa_file_wicopa.
              ENDAT.
              CLEAR lwa_data.
            ENDLOOP.
          ENDIF.
        ENDIF.
                                                or
    DATA: it_test TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE.
    DATA :v_start_col TYPE i VALUE '1',
          v_start_row TYPE i VALUE '1',
          v_end_col TYPE i VALUE '256',
          v_end_row TYPE i VALUE '65536',
          v_text TYPE repti.
    * Funtion Module to upload values from excel to the Internal table
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = v_start_col
          i_begin_row             = v_start_row
          i_end_col               = v_end_col
          i_end_row               = v_end_row
        TABLES
          intern                  = it_test
        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.
                             Or
    You can use FM u201CTEXT_CONVERT_XLS_TO_SAPu201D.
    DATA : i_raw TYPE truxs_t_text_data.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_field_seperator          = 'X'
          i_tab_raw_data             = i_raw
          i_filename                 = p_path
        TABLES
          i_tab_converted_data       = itab
    EXCEPTIONS
       conversion_failed          = 1
       OTHERS                     = 2
    hope it will help u
    regards
    rahul

  • Uploading excel file into internal table

    Hi,
    Any function module is there to upload an excel file into internal table in CRM 7.0 system?
    Thanks.

    Hi Ginger,
    If u have access to ECC R/3 make use FM 'TEXT_CONVERT_XLS_TO_SAP' source code which is existing to convert to Excel to Internal table.  It will work in CRM also.
    As of Now I don't have access to SAP S/m. Mean while u can try as above said.
    Regards,
    Lokesh B

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

  • Uploading CSV file into internal table

    Hi,
    I want to upload a CSV file into internal table.The flat file is having values as below:
    'AAAAA','2003-10-11 07:52:37','167','Argentina',NULL,NULL,NULL,NULL,NULL,'MX1',NULL,NULL,'AAAA BBBB',NULL,NULL,NULL,'1',NULL,NULL,'AR ',NULL,NULL,NULL,'ARGENT','M1V','MX1',NULL,NULL,'F','F','F','F','F',NULL,'1',NULL,'MX','MMI ',NULL
    'jklhg','2004-06-25 08:01:57','456','hjllajsdk','MANAGUA   ',NULL,NULL,'265-5139','266-5136 al 38','MX1',NULL,NULL,'hjgkid GRÖBER','sdfsdf dfs asdfsdf 380 ad ased,','200 as ads, sfd sfd abajao y 50 m al sdf',NULL,'1',NULL,NULL,'NI ',NULL,NULL,NULL,'sdfdfg','M1V','dds',NULL,NULL,
    Here I can not even split at ',' because some of the values are having value like NULL and some have values with comma too,
    The delimiter is a quote and the separator is a comma here.
    Can anyone help on this?
    Thanks.
    Edited by: Ginger on Jun 29, 2009 9:08 AM

    As long as there can be a comma in a text literal you are right that the spilt command doesn't help. However there is one possibility how to attack this under one assumption:
    - A comma outside a text delimiter is always considered a separator
    - A comma inside a text delimiter is always considered a comma as part of the text
    You have to read you file line by line and then travel along the line string character by character and setting a flag or counter for the text delimiters:
    e.g.
    "Text","Text1, Text2",NULL,NULL,"Text"
    String Index  1: EQ " => lv_delimiter = 'X'
    String Index  2: EQ T => text literal (because lv_delimiter = 'X')
    String Index  3: EQ e => text literal (because lv_delimiter = 'X')
    String Index  4: EQ x => text literal (because lv_delimiter = 'X')
    String Index  5: EQ t => text literal (because lv_delimiter = 'X')
    String Index  6: EQ " => lv_delimiter = ' ' (because it was 'X' before)
    String Index  7: EQ , => This is a separator because lv_delimiter = ' '
    String Index  8: EQ " => lv_delimiter = 'X' (because it was ' ' before)
    String Index  9: EQ T => text literal (because lv_delimiter = 'X')
    String Index 10: EQ e => text literal (because lv_delimiter = 'X')
    String Index 11: EQ x => text literal (because lv_delimiter = 'X')
    String Index 12: EQ t => text literal (because lv_delimiter = 'X')
    String Index 13: EQ 1 => text literal (because lv_delimiter = 'X')
    String Index 14: EQ , => text literal (because lv_delimiter = 'X')
    String Index 15: EQ T => text literal (because lv_delimiter = 'X')
    Whenever you hit a 'real' separator (lv_delimiter = ' ') you pass the value of the string before that up to the previous separator into the next structure field.
    This is not an easy way to do it, but if you might have commas in your text literal and NULL values I gues it is probably the only way to go.
    Hope that helps,
    Michael

  • How can i read local excel file into internal table in webdynpro for abap a

    Could someone tell me how How can i read local excel file into an internal table in webdynpro for abap application.
    thank u for your reply

    Deep,
    File manuplations...............................
    1. At the presentation level:
    ->GUI_UPLOAD
    ->GUI_DOWNLOAD
    ->CL_GUI_FRONTEND
    2. At the application server level:
    ->OPEN DATASET : open a file in the application server for reading or writing.
    ->READ DATASET : used to read from a file on the application server that has been opened for reading
    -> TRANSFER DATASET : writing data to a file.
    -> CLOSE DATASET : closes the file
    -> DELETE DATASET : delete file
    If file is on the local PC,use the function module GUI_UPLOAD to upload it into an internal table by passing the given parameters......
    call function 'GUI_UPLOAD'
    exporting
    filename = p_file
    filetype = 'ASC'
    has_field_separator = '#'
    tables
    data_tab = t_data
    p_file : excel file path.
    t_data : internal table
    <b>reward points if useful.</b>
    regards,
    Vinod Samuel.

  • Uploading data from xls file to internal table

    Hello,
         I have an excel file with just one column that has phone numbers. I want to upload these phone numbers into an internal table.
        Now my question is: What is the method/function to do this? I tried GUI_UPLOAD but after upload the values in the internal table shows lots of # signs instead of the expected phone numbers.
    Regards,
    Prafful.

    Hello Prafful,
    If you successed to upload XLS into Internal Table and the only problem you have is a # signs try to the following:
    1) instead of the XLS file try to use CSV file (it's a TEXT file - C omma S eperated V alues).
    2) Check your Encoding (your FILE Encoding should be a same as GUI_UPLOAD encoding)
    Good Luck
    Eli Steklov

  • 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

Maybe you are looking for