Problems in uploading from excel sheet to internal table

hi experts,
i got one problem regarding uploading data from excel sheet to int.table. I used FM ALSM_EXCEL_TO_INTERNAL_TABLE but in that the value is char of 50. but i need a case where i have to send value more than 50 characters. please suggest me any other FM to overcome this problem.
advanced thanks
vijay

Hi,
>
Vijay Krishna Arvapalli wrote:
> hi tarun,
>
> thank you for your reply
>
> but when i tried to use FM TEXT_CONVERT_XLS_TO_SAP it is giving error actually that 'Error generating the test frame'.
>
> so can you suggest me with some other option where i can upload the field with more than 50 character length.
>
> thank you
> regards
> vijay
Yes, when you execute the FM from SE37, then it displays a message.
Just copy the below code and paste it in a report (SE38) and execute.
Create a file in C:/ with name test.xls and execute it will display the records even with more than 50 characters of length.
I have tested and its working.
I have taken three fields in the excel file empid, name and doj.
TYPE-POOLS : truxs.
PARAMETERS : p_file TYPE rlgrap-filename DEFAULT 'C:\TEST.XLS'.
DATA : BEGIN OF itab OCCURS 0,
         empid(150) TYPE c,
         name(150) TYPE c,
         doj(150) TYPE c,
       END OF itab.
DATA: it_raw TYPE truxs_t_text_data.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM f4_file_process USING p_file.
AT SELECTION-SCREEN.
  PERFORM validate_file_path USING p_file.
START-OF-SELECTION.
  PERFORM upload_data.
END-OF-SELECTION.
  PERFORM display_data.
*&      Form  F4_FILE_PROCESS
*       text
*      -->P_FILE_PATH  text
FORM f4_file_process USING p_file.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
      field_name    = 'P_FILE'
    IMPORTING
      file_name     = p_file.
  IF sy-subrc NE 0.
    MESSAGE e000(zsd).
  ENDIF.
ENDFORM.                    " F4_FILE_PROCESS
*&      Form  VALIDATE_FILE_PATH
*       text
*      -->P_FILE  text
FORM validate_file_path USING p_file.
  DATA : lv_dir TYPE string,
         lv_file TYPE string,
         lv_result(1) TYPE c.
  DATA : lv_filename TYPE string.
  lv_filename = p_file.
  CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
    EXPORTING
      full_name     = p_file
    IMPORTING
      stripped_name = lv_file
      file_path     = lv_dir
    EXCEPTIONS
      x_error       = 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 METHOD cl_gui_frontend_services=>directory_exist
    EXPORTING
      directory            = lv_dir
    RECEIVING
      result               = lv_result
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      wrong_parameter      = 3
      not_supported_by_gui = 4
      OTHERS               = 5.
  IF lv_result IS INITIAL.
    MESSAGE 'Invalid Directory' TYPE 'E'.
  ENDIF.
  CLEAR lv_result.
  CALL METHOD cl_gui_frontend_services=>file_exist
    EXPORTING
      file                 = lv_filename
    RECEIVING
      result               = lv_result
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      wrong_parameter      = 3
      not_supported_by_gui = 4
      OTHERS               = 5.
  IF lv_result IS INITIAL.
    MESSAGE 'Invalid File' TYPE 'E'.
  ENDIF.
ENDFORM.                    " VALIDATE_FILE_PATH
*&      Form  UPLOAD_DATA
*       text
*  -->  p1        text
*  <--  p2        text
FORM upload_data .
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_field_seperator    = 'X'
      i_line_header        = 'X'
      i_tab_raw_data       = it_raw
      i_filename           = p_file
    TABLES
      i_tab_converted_data = itab[]
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    " UPLOAD_DATA
*&      Form  DISPLAY_DATA
*       text
*  -->  p1        text
*  <--  p2        text
FORM display_data .
  LOOP AT itab.
    WRITE : / itab-empid, itab-name, itab-doj.
  ENDLOOP.
ENDFORM.                    " DISPLAY_DATA
Hope this helps you.
Regards,
Tarun

Similar Messages

  • How to transfer data more than 255 char from excel sheet to internal table.

    Hello Experts,
    I have a requirement where i have a text field in the excel sheet of more than 255 char and need to be updated in the text element. To do that i need to transfer the excel sheet data to an internal table where one of the field is more than 255 char.
    in the standard function module it works only upto 255 char. Can you help me if we have some other way to get more than 255 char in the internal table from excel sheet.
    Thanks in Advance.
    BR,
    RaJ.

    Using .xls, it is not possible transfer data more than 255 characters from excel sheet. However if the excel sheet is saved as Comma Delimited format or Tab Delimited format, then using GUI_DOWNLOAD function module data more than 255 characters can be transferred.
    File name should be : .csv (Comma Delimited format)  or .txt (Tab Delimited format)
    File Type would still remain 'ASC' while calling function module GUI_DOWNLOAD
    Also In the internal table declare the field type as String or LCHAR.
    Eg:
    TYPES: begin of ty_file,
            col_a TYPE string,
          end of ty_file.
    DATA: i_file type standard table
                   of ty_file
                 with header line
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      =  'C:\test.csv'
      TABLES
        DATA_TAB                      = i_file

  • Regarding uploading data from excel sheet to internal table

    hi,
    while executing the code im getting the output one by one but i want it to be displayed in a table format can any one help me regarding this issue.
    thanks and regards,
    siri

    Hi Sirisha,
    Through this FM we can't get the data in tabular format. After getting data from this FM we have to convert to tabular format. As far as i know there is no FM for Excel upload which directly gives data in tabular format.
    Check below sample code which uploads 3 columns from excel file.
    U can add as many case statements as the number of fields.
    PARAMETERS: po_file TYPE rlgrap-filename DEFAULT 'E:test.xls'.
    TYPES: BEGIN OF t_final,
              empno(10) TYPE c,
              name(30) TYPE c,
              state(25) TYPE c,
           END OF t_final.
    DATA: i_tab    TYPE STANDARD TABLE OF alsmex_tabline,
          i_final  TYPE STANDARD TABLE OF t_final,
          wa_tab   TYPE alsmex_tabline,
          wa_final TYPE t_final.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR po_file.
    PERFORM open_folder.
    START-OF-SELECTION.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
         EXPORTING
              filename                = po_file
              i_begin_col             = 1
              i_begin_row             = 1
              i_end_col               = 3
              i_end_row               = 65256
         TABLES
              intern                  = i_tab
         EXCEPTIONS
              inconsistent_parameters = 1
              upload_ole              = 2
              OTHERS                  = 3.
    CHECK NOT i_tab[] IS INITIAL.
    LOOP AT i_tab INTO wa_tab.
      CASE wa_tab-col.
        WHEN 1.
          wa_final-empno = wa_tab-value.
        WHEN 2.
          wa_final-name = wa_tab-value.
        WHEN 3.
          wa_final-state = wa_tab-value.
      ENDCASE.
      AT END OF row.
        APPEND wa_final TO i_final.
        CLEAR wa_final.
      ENDAT.
    ENDLOOP.
    FORM open_folder .
      DATA: li_file  TYPE TABLE OF sdokpath,
            lwa_file TYPE sdokpath.
      CLEAR: po_file, lwa_file.
      REFRESH li_file[].
      CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
           TABLES
                file_table = li_file
           EXCEPTIONS
                cntl_error = 1
                OTHERS     = 2.
      IF sy-subrc IS INITIAL.
        READ TABLE li_file INTO lwa_file INDEX 1.
        IF sy-subrc IS INITIAL.
          po_file = lwa_file-pathname.
        ENDIF.
      ENDIF.
    ENDFORM.                    " open_folder
    Just try executing above code in debug mode. U will understand the functionality.
    Thanks,
    Vinod.

  • How to read only particualr columns from excel sheet to internal table

    Hi,
    I have and excel sheet which has around 20 columns, in which i want to read only 6 columns. They are at different column positions, means the 1st column, 6thcolumn, 8th column so on..
    Can we do this in sap? do we have any FM to do this?
    Thanks.
    Praveena.

    hi,
    Use the below logic to fetch the data into internal table..You need to read the data cell by cell and update the internal table,
    DATA l_count TYPE sy-tabix.
       CONSTANTS: lc_begin_col TYPE i VALUE '1',
                  lc_begin_row TYPE i VALUE '2',
                  lc_end_col   TYPE i VALUE '2',
                  lc_end_row   TYPE i VALUE '3000'.
      CLEAR p_i_excel_data. REFRESH p_i_excel_data.
    * Function module to read excel file and convert it into internal table
       CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
         EXPORTING
           filename                = p_p_file
           i_begin_col             = lc_begin_col
           i_begin_row             = lc_begin_row
           i_end_col               = lc_end_col
           i_end_row               = lc_end_row
         TABLES
           intern                  = i_data
         EXCEPTIONS
           inconsistent_parameters = 1
           upload_ole              = 2
           OTHERS                  = 3.
    * Error in file upload
       IF sy-subrc NE 0 .
         MESSAGE text-006 TYPE 'E'.
         EXIT.
       ENDIF.
       IF i_data[] IS INITIAL .
         MESSAGE text-007 TYPE 'E'.
         EXIT.
       ELSE.
         SORT i_data BY row col .
    * Loop to fill data in Internal Table
         LOOP AT i_data .
           MOVE i_data-col TO l_count .
           ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO <fs_source> .
           MOVE i_data-value TO <fs_source> .
           AT END OF row .
    * Append data into internal table
             APPEND p_i_excel_data.
             CLEAR p_i_excel_data.
           ENDAT .
         ENDLOOP .
       ENDIF .

  • Upload long text from excel file into internal table

    I need to upload service master(T-code : AC02) data alongwith long text.Now i have data in excel as: Service no(ASMD-ASNUM) and corresponding long text for it.
    I am facing problem in getting entire lontext from excel into my internal table.It only takes till 255 characters i think.Any help in this regard woulg be highly appreciable.

    hi,
    what is the maximum length of your long text.
    and you can try with more than 255 chars. in the internal table it will take , if you want check it.
    i'm in 4.7 ,5.0 version, what about you ..
    please check , you can upload even more than 255.
    try
    regards
    vijay

  • FM to upload the Excel file to internal table

    Hi
    Is any FM available to upload the Excel file to internal table.
    Thanks
    Anbu

    Hi
    se this code
    EXCEL to INTERNAL TABLE and then to APPLICATION SERVER
    *& Report  ZSD_EXCEL_INT_APP
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       STATIC              = 'X'
      MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 1
       OTHERS              = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    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 it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • Retrieving data from Excel format to internal table(deep structure)

    hi all,
    can anybody help me how to Retrieving data from Excel format to internal table(deep structure)
    and if u have any sample code for that please send it.
    my internal table is like this
    DATA: BEGIN OF ty_text,
    vbeln TYPE vbeln,
    posnr TYPE posnr,
    seqno TYPE seqno,
    textid TYPE tdid,
    tdline TYPE tdline,
    END OF ty_text.
    DATA: BEGIN OF ty_item,
    vbeln TYPE vbeln,
    posnr TYPE posnr,
    dispct1(16),
    dispct2(16),
    dispct3(16),
    text LIKE table of ty_text,
    END OF ty_item.

    hi,
    check this code
    TABLES:zmatnr.
    TYPE-POOLS  truxs.
    DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    DATA row LIKE alsmex_tabline-row.
    data : gi_final like zmatnr occurs 0 with header line.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.
      PERFORM search.
    START-OF-SELECTION.
    perform process.
    form process.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = pfname
          i_begin_col             = 1
          i_begin_row             = 2
          i_end_col               = 12
          i_end_row               = 65000
        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.
      describe table itab lines itab_count.
       row = 1.
      loop at itab.
        if itab-row <> row.
          append gi_final.
          clear gi_final.
        endif.
        case itab-col.
          when '1'.
          gi_final-MATNR = itab-value.
          when '2'.
           gi_final-Maktx = itab-value.
          endcase.
        row = itab-row.
      endloop.
      append gi_final.
      clear gi_final.
    endform.
    FORM search .
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          static    = 'X'
        CHANGING
          file_name = pfname.
    ENDFORM.
    regards
    siva

  • Uploading from excel sheet

    can anyone tel me how 2 upload data from a excel sheet ??
    can it be done using gui_upload or os there any other funtion module ??

    Hi Vignesh,
    Steps to create a BDC program.
    1. Create an internal table with fields same as Excel sheet fields.
    2. Declare an internal table with BDCDATA table to store the BDC recording.
    3. Declare an internal table with BDCMSGCOL to store the error messages after
    the execution of the BDC.
    4. Write the code using the fun. module ALSM_EXCEL_TO_INTERNAL_TABLE
    to upload the data from the excel sheet.
    5. loop that internal table and write the Subroutines to fill the internal table
    BDCDATA with the recording of a specified Transaction Code.
    6. Using Call Transaction execute the BDC recording.
    7. Check Sy-subrc = 0 and store the error messages in the internal table.
    8. If you want you can pass those error records to a session using the SESSION method.
    Here is an example of a BDC program, but this program is from a text file. Change the function module WS_UPLOAD with ALSM_EXCEL_TO_INTERNAL_TABLE
    to upload an excel and write the program with your BDC recording. You can do recording using t-code SHDB.
    Sample Program:
    REPORT ZRAJ_DATASET_XD01 NO STANDARD PAGE HEADING LINE-SIZE 132
    LINE-COUNT 60
    MESSAGE-ID Z00.
    Table/Structure declarations. *
    TABLES : KNA1. "Customer master
    Constants declarations. *
    CONSTANTS : C_MODE VALUE 'N',
    C_UPDATE VALUE 'S',
    C_X VALUE 'X',
    C_SESS TYPE APQI-GROUPID VALUE 'ZCUSTOMER', "Session Name
    C_XD01 LIKE TSTC-TCODE VALUE 'XD01'.
    Variable declarations. *
    DATA : V_FNAME(15) VALUE SPACE, " Name of file to be created
    V_FAILREC TYPE I, " No of failed records
    V_MSG(255), " Message Text
    V_ERRREC TYPE I, " No of failed records
    V_LINES TYPE I. " No of records
    *-- FLAG DECLARATIONS
    DATA : FG_DATA_EXIST VALUE 'X', " Check for data
    FG_SESSION_OPEN VALUE ' '. " Check for Session Open
    Structures / Internal table declarations *
    *-- Structure to hold BDC data
    TYPES : BEGIN OF T_BDCTABLE.
    INCLUDE STRUCTURE BDCDATA.
    TYPES END OF T_BDCTABLE.
    *-- Structure to trap BDC messages
    TYPES : BEGIN OF T_MSG.
    INCLUDE STRUCTURE BDCMSGCOLL.
    TYPES : END OF T_MSG.
    *-- Structure to trap ERROR messages
    TYPES : BEGIN OF T_ERR_MSG,
    MESSAGE(255),
    END OF T_ERR_MSG.
    *--Internal table to store flat file data
    DATA:BEGIN OF IT_KNA1 OCCURS 0,
    KUNNR LIKE KNA1-KUNNR,
    KTOKD LIKE T077D-KTOKD,
    NAME1 LIKE KNA1-NAME1,
    SORTL LIKE KNA1-SORTL,
    ORT01 LIKE KNA1-ORT01,
    PSTLZ LIKE KNA1-PSTLZ,
    LAND1 LIKE KNA1-LAND1,
    SPRAS LIKE KNA1-SPRAS,
    LZONE LIKE KNA1-LZONE,
    END OF IT_KNA1.
    *-- Internal table to hold BDC data
    DATA: IT_BDCDATA TYPE STANDARD TABLE OF T_BDCTABLE WITH HEADER LINE,
    *-- Internal Table to store ALL messages
    IT_MSG TYPE STANDARD TABLE OF T_MSG WITH HEADER LINE,
    *-- Internal Table to store error messages
    IT_ERR_MSG TYPE STANDARD TABLE OF T_ERR_MSG WITH HEADER LINE.
    Selection Screen. *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS : P_FLNAME(15) OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS : R_LIST RADIOBUTTON GROUP GRP1.
    SELECTION-SCREEN COMMENT 5(20) TEXT-003.
    PARAMETERS : R_SESS RADIOBUTTON GROUP GRP1.
    SELECTION-SCREEN COMMENT 30(20) TEXT-004.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK B2.
    Event:Initialization *
    INITIALIZATION.
    AT Selection Screen. *
    AT SELECTION-SCREEN.
    Event: Start-of-Selection *
    START-OF-SELECTION.
    V_FNAME = P_FLNAME.
    PERFORM GET_DATA.
    PERFORM GENERATE_DATASET.
    Event: End-of-Selection *
    END-OF-SELECTION.
    IF FG_DATA_EXIST = ' '.
    MESSAGE I010 WITH TEXT-009.
    EXIT.
    ENDIF.
    PERFORM GENERATE_BDCDATA.
    PERFORM DISPLAY_ERR_RECS.
    Event: top-of-page
    TOP-OF-PAGE.
    FORM DEFINITIONS *
    *& Form get_data
    Subroutine to get the data from mard
    --> p1 text
    <-- p2 text
    FORM GET_DATA.
    CALL FUNCTION 'UPLOAD'
    EXPORTING
    CODEPAGE = ' '
    FILENAME = 'C:\XD01.TXT'
    FILETYPE = 'DAT'
    ITEM = ' '
    FILEMASK_MASK = ' '
    FILEMASK_TEXT = ' '
    FILETYPE_NO_CHANGE = ' '
    FILEMASK_ALL = ' '
    FILETYPE_NO_SHOW = ' '
    LINE_EXIT = ' '
    USER_FORM = ' '
    USER_PROG = ' '
    SILENT = 'S'
    IMPORTING
    FILESIZE =
    CANCEL =
    ACT_FILENAME =
    ACT_FILETYPE =
    TABLES
    DATA_TAB = IT_KNA1
    EXCEPTIONS
    CONVERSION_ERROR = 1
    INVALID_TABLE_WIDTH = 2
    INVALID_TYPE = 3
    NO_BATCH = 4
    UNKNOWN_ERROR = 5
    GUI_REFUSE_FILETRANSFER = 6
    OTHERS = 7
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    IF IT_KNA1[] IS INITIAL.
    FG_DATA_EXIST = ' '.
    ENDIF.
    ENDFORM. " get_data
    *& Form GENERATE_DATASET
    text
    --> p1 text
    <-- p2 text
    FORM GENERATE_DATASET.
    MESSAGE I010 WITH 'OPENING FILE IN APPLICATION SERVER'.
    **--Creating a data set in application server
    OPEN DATASET V_FNAME FOR OUTPUT IN TEXT MODE.
    **---Transfering data from internal table to dataset
    MESSAGE I010 WITH 'TRANSFERING DATA FROM INETERAL TABLE TO THE FILE'.
    LOOP AT IT_KNA1.
    TRANSFER IT_KNA1 TO V_FNAME.
    ENDLOOP.
    **--Closing the dataset
    MESSAGE I010 WITH 'CLOSING THE FILE'.
    CLOSE DATASET V_FNAME.
    ENDFORM. " GENERATE_DATASET
    *& Form BDC_DYNPRO
    text
    -->P_0467 text
    -->P_0468 text
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
    CLEAR IT_BDCDATA.
    IT_BDCDATA-PROGRAM = PROGRAM.
    IT_BDCDATA-DYNPRO = DYNPRO.
    IT_BDCDATA-DYNBEGIN = 'X'.
    APPEND IT_BDCDATA.
    ENDFORM.
    *& Form BDC_FIELD
    text
    -->P_0472 text
    -->P_0473 text
    FORM BDC_FIELD USING FNAM FVAL.
    IF NOT FVAL IS INITIAL.
    CLEAR IT_BDCDATA.
    IT_BDCDATA-FNAM = FNAM.
    IT_BDCDATA-FVAL = FVAL.
    APPEND IT_BDCDATA.
    ENDIF.
    ENDFORM.
    *& Form GENERATE_BDCDATA
    text
    --> p1 text
    <-- p2 text
    FORM GENERATE_BDCDATA.
    REFRESH IT_KNA1.
    Opening dataset for reading
    OPEN DATASET V_FNAME FOR INPUT IN TEXT MODE.
    Reading the file from application server
    DO.
    CLEAR: IT_KNA1,IT_BDCDATA.
    REFRESH IT_BDCDATA.
    READ DATASET V_FNAME INTO IT_KNA1.
    IF SY-SUBRC <> 0.
    EXIT.
    ELSE.
    Populate BDC Data for Initial Screen
    PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0100',
    BDC_FIELD USING 'BDC_CURSOR' 'RF02D-KUNNR',
    BDC_FIELD USING 'BDC_OKCODE' '/00',
    BDC_FIELD USING 'RF02D-KUNNR' IT_KNA1-KUNNR,
    BDC_FIELD USING 'RF02D-KTOKD' IT_KNA1-KTOKD.
    Populate BDC Data for Second Screen
    PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0110',
    BDC_FIELD USING 'BDC_CURSOR' 'KNA1-NAME1',
    BDC_FIELD USING 'BDC_OKCODE' '/00',
    BDC_FIELD USING 'KNA1-NAME1' IT_KNA1-NAME1,
    BDC_FIELD USING 'KNA1-SORTL' IT_KNA1-SORTL,
    BDC_FIELD USING 'KNA1-ORT01' IT_KNA1-ORT01,
    BDC_FIELD USING 'KNA1-PSTLZ' IT_KNA1-PSTLZ,
    BDC_FIELD USING 'KNA1-LAND1' IT_KNA1-LAND1,
    BDC_FIELD USING 'KNA1-SPRAS' IT_KNA1-SPRAS.
    Populate BDC Data for Third Screen
    PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0120',
    BDC_FIELD USING 'BDC_CURSOR' 'KNA1-LZONE',
    BDC_FIELD USING 'BDC_OKCODE' '=UPDA',
    BDC_FIELD USING 'KNA1-LZONE' IT_KNA1-LZONE.
    CALL TRANSACTION C_XD01 USING IT_BDCDATA
    MODE C_MODE
    UPDATE C_UPDATE
    MESSAGES INTO IT_MSG.
    IF SY-SUBRC <> 0.
    *--In case of error list display
    IF R_LIST = C_X.
    V_ERRREC = V_ERRREC + 1.
    PERFORM FORMAT_MESSAGE.
    IT_ERR_MSG-MESSAGE = V_MSG.
    APPEND IT_ERR_MSG.
    CLEAR : V_MSG,IT_ERR_MSG.
    ENDIF.
    *--In case of session log
    IF R_SESS = C_X.
    *-- In case of transaction fails.
    IF FG_SESSION_OPEN = ' '.
    FG_SESSION_OPEN = C_X.
    PERFORM BDC_OPEN_GROUP.
    ENDIF. " IF FG_SESSION_OPEN = ' '.
    *-- Insert BDC Data..
    PERFORM BDC_INSERT_DATA.
    ENDIF. " IF R_SESS = C_X.
    ENDIF. " IF SY-SUBRC <> 0.
    ENDIF. " IF SY-SUBRC <> 0.
    ENDDO.
    Closing the dataset
    CLOSE DATASET V_FNAME.
    *-- Close the session if opened
    IF FG_SESSION_OPEN = C_X.
    PERFORM BDC_CLOSE_GROUP.
    CALL TRANSACTION 'SM35'.
    ENDIF.
    ENDFORM. " GENERATE_BDCDATA
    *& Form BDC_OPEN_GROUP
    text
    --> p1 text
    <-- p2 text
    FORM BDC_OPEN_GROUP.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    DEST = FILLER8
    GROUP = C_SESS
    HOLDDATE = FILLER8
    KEEP = C_X
    USER = SY-UNAME
    RECORD = FILLER1
    IMPORTING
    QID =
    EXCEPTIONS
    CLIENT_INVALID = 1
    DESTINATION_INVALID = 2
    GROUP_INVALID = 3
    GROUP_IS_LOCKED = 4
    HOLDDATE_INVALID = 5
    INTERNAL_ERROR = 6
    QUEUE_ERROR = 7
    RUNNING = 8
    SYSTEM_LOCK_ERROR = 9
    USER_INVALID = 10
    OTHERS = 11
    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. " BDC_OPEN_GROUP
    *& Form BDC_INSERT_DATA
    text
    --> p1 text
    <-- p2 text
    FORM BDC_INSERT_DATA.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = C_XD01
    POST_LOCAL = NOVBLOCAL
    PRINTING = NOPRINT
    TABLES
    DYNPROTAB = IT_BDCDATA
    EXCEPTIONS
    INTERNAL_ERROR = 1
    NOT_OPEN = 2
    QUEUE_ERROR = 3
    TCODE_INVALID = 4
    PRINTING_INVALID = 5
    POSTING_INVALID = 6
    OTHERS = 7
    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. " BDC_INSERT_DATA
    *& Form BDC_CLOSE_GROUP
    text
    --> p1 text
    <-- p2 text
    FORM BDC_CLOSE_GROUP.
    CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
    NOT_OPEN = 1
    QUEUE_ERROR = 2
    OTHERS = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " BDC_CLOSE_GROUP
    *& Form FORMAT_MESSAGE
    text
    --> p1 text
    <-- p2 text
    FORM FORMAT_MESSAGE.
    CLEAR V_LINES.
    DESCRIBE TABLE IT_MSG LINES V_LINES.
    READ TABLE IT_MSG INDEX V_LINES.
    CLEAR V_MSG.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
    ID = IT_MSG-MSGID
    LANG = IT_MSG-MSGSPRA
    NO = IT_MSG-MSGNR
    V1 = IT_MSG-MSGV1
    V2 = IT_MSG-MSGV2
    V3 = IT_MSG-MSGV3
    V4 = IT_MSG-MSGV4
    IMPORTING
    MSG = V_MSG
    EXCEPTIONS
    NOT_FOUND = 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. " FORMAT_MESSAGE
    *& Form DISPLAY_ERR_RECS
    text
    --> p1 text
    <-- p2 text
    FORM DISPLAY_ERR_RECS.
    LOOP AT IT_ERR_MSG.
    WRITE: / IT_ERR_MSG-MESSAGE.
    ENDLOOP.
    ENDFORM. " DISPLAY_ERR_RECS
    And
    To simply load Excel to Internal table follow this :
    First of all , before you move your data from excel sheet to the internal table, you need to specify a location for uploading the excel sheet into your internal table.
    for this u need to use two specific FM's .
    the first one for file selection : WS_FILENAME_GET.
    The second one for data upload : TEXT_CONVERT_XLS_TO_SAP.
    After doing this the regular part of mapping comes and then we can run the session and then execute and release it.
    Hope this resolves your query.
    <b>Reward all the helpful answers.</b>
    Regards

  • FROM EXCEL FILE TO INTERNAL TABLE

    HI GURU'S,
    i'm using the following code to conver the excel file into internal table.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
         I_FIELD_SEPERATOR          = 'X'
        I_LINE_HEADER              =
          I_TAB_RAW_DATA             = IT_TAB_RAW_DATA
          I_FILENAME                 = P_FILE
        TABLES
          I_TAB_CONVERTED_DATA       = IT_MM01
       EXCEPTIONS
         CONVERSION_FAILED          = 1
         OTHERS                     = 2
    What is the exact format for the to send the Excel File.
    My requirement is the Excel file contains the several fields , that should be stored as a records in the internal table
    My problem is when i send the data in the excel file as one column, i'm getting all the data in the first column of the Internal Table.
    If i send the data in the excel file as a record it is not filling the internal table.
    what is the problem??/
    if the Excel files contain multiple records is it able to convert the data into internal table records.
    Regards,
    Adi.

    **Internal Table to hold the records in the text file
    Hello Adi,
    Put the fields in excel in the same format in which u want in ur internal table(here record)
    U can refer the following code.
    data: begin of record occurs 0,
          General Data
    data element: BUKRS
            bukrs_001(004), " Company Code
    data element: EKORG
            ekorg_002(004), " Purchase Orgn
    data element: KTOKK
            ktokk_003(004), " Account Group
        end of record.
    Internal Table
    data:it_excel like table of alsmex_tabline with header line.
    **SELECTION-SCREEN**
    selection-screen begin of  block blk.
    parameters: p_file like rlgrap-filename default 'c:\vendor_creation.xls'
    selection-screen end of block blk.
    A T   S E L E C T I O N - S C R E E N   O U T P U T
    ***************START*********************** F4 Help for field p_file
    at selection-screen on value-request for p_file.
    call function 'KD_GET_FILENAME_ON_F4'
    exporting
       program_name        = syst-repid
       dynpro_number       = syst-dynnr
      FIELD_NAME          = ' '
      STATIC              = ' '
      MASK                = ' '
      changing
        file_name           = p_file
    EXCEPTIONS
      MASK_TOO_LONG       = 1
      OTHERS              = 2
    if sy-subrc <>  0.
    message e006(zhnc).
    endif.
    S T A R T - O F - S E L E C T I O N
    start-of-selection.
    data : vf_index type i.
    data : vf_start_col type i value '1',      "start column
             vf_start_row type i value '4',    "start row
             vf_end_col   type i value '200',  "maximum column
             vf_end_row   type i value '2500', "maximum row
             p_text(20).                       "stores error messages
    */ Work Area
    data: wa_intern like it_excel.
    */ Field symbol
    field-symbols : <fs>.
    *********Fn Module to convert the excel file data into internal table
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                      =  'c:\vendor_creation.xls'
        i_begin_col                   =  vf_start_col
        i_begin_row                   =  vf_start_row
        i_end_col                     =  vf_end_col
        i_end_row                     =  vf_end_row
      tables
        intern                        = it_excel
    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.
      if it_excel[] is initial.
        p_text = 'No Data Uploaded'.
      else.
      sort it_excel by row col.
          loop at it_excel.
          move : it_excel-col to vf_index.
          assign component vf_index of structure record to <fs>.
          move : it_excel-value to <fs>.
          at end of row.
            append record.
            clear record.
          endat.
          endloop.
      endif.
    In case of any problem u  can revert back.
    Aastha

  • Not uploading more than 150 rows from Excel file to Internal table.

    Hi All,
    We have a Z program to upload initial stock from excel file to SAP using BAPI. The problem is we have defined row to '65536'. But it is not uploading more than 150 rows at a time. The piece of code is given below.
    DATA : it_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    DATA: xcel TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
    DATA : gd_scol   TYPE i VALUE '1',
           gd_srow   TYPE i VALUE '3',
           gd_ecol   TYPE i VALUE '256',
           gd_erow   TYPE i VALUE '65536'.
    PERFORM upload_excel_file TABLES   gt_out
                                  USING   p_file
                                          gd_scol
                                          gd_srow
                                          gd_ecol
                                          gd_erow.
    FORM upload_excel_file  TABLES   gt_out
                                       "Insert correct name for <...>
                            USING    p_p_file
                                     p_gd_scol
                                     p_gd_srow
                                     p_gd_ecol
                                     p_gd_erow.
      DATA : lt_intern TYPE  kcde_cells OCCURS 0 WITH HEADER LINE.
      DATA : ld_index TYPE i.
      FIELD-SYMBOLS: <fs> TYPE ANY.
      CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
        EXPORTING
          filename    = p_p_file
          i_begin_col = p_gd_scol
          i_begin_row = p_gd_srow
          i_end_col   = p_gd_ecol
          i_end_row   = p_gd_erow
        TABLES
          intern      = lt_intern[].
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF lt_intern[] IS INITIAL.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'No Data Uploaded'.
        EXIT.
      ELSE.
        SORT lt_intern BY row col.
        LOOP AT lt_intern.
          MOVE lt_intern-col TO ld_index.
          ASSIGN COMPONENT ld_index OF STRUCTURE gt_out TO <fs>.
          MOVE lt_intern-value TO <fs>.
          AT END OF row.
            APPEND gt_out.
            CLEAR gt_out.
          ENDAT.
        ENDLOOP.
      ENDIF.
    ENDFORM.           
    Plz tell me, what is the problem here. I want to upload all the rows at a time.
    Thanks,
    With regards,
    Rosaline.

    Hi Rob, I confirm, you're nitpicking! :-D For information, I've noted a few SAP comments about releasing and released objects, for people who like reading: [SAP Library - Documenting and Releasing a Function Module|http://help.sap.com/saphelp_nw70/helpdata/en/d1/801f50454211d189710000e8322d00/frameset.htm], [Note 109533 - Use of SAP function modules|https://service.sap.com/sap/support/notes/109533], [Note 415983 - Modification/customer developments of SAP function modules|https://service.sap.com/sap/support/notes/415983]; Example of an unreleased BAPI -> [Note 577453 - Using BAPI BAPI_DELIVERYPROCESSING_EXEC|https://service.sap.com/sap/support/notes/577453]
    Sandra

  • Upload openoffice excel file into internal table

    Hi Everyone,
    I have a requirement where in we need to upload vendor master data into SAP.
    The data is available in excel format. But the excel sheet was created in openoffice s/w and client is not allowing
    us to install MS-Office so that we cut and paste the data by creating anexcel file.
    Now there is an option of saving the excel file in openoffice s/w as MS-Excel 95 format with .xls extension.
    But since we are saving this in openoffice enivoronment   the FM ALSM_EXCEL..... data is not improting this excel file into
    Did somebody faced this issue before. Pls share the approach to solve this issue.
    Regards,
    Vinay

    Hi !
    you can use the Function module TEXT_CONVERT_XLS_TO_SAP to upload xcel file to internal table
    please go through 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
    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-msgv4.
    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.
    hope this will help you.
    Regards,
    Kiran

  • Data to upload for excel into the internal table

    Hi Friends,
    iam getting the run error when i wrote this code,
    can any one help me please.
    data : begin of itab occurs 3,
           a type i,
           b type i,
           end of itab.
           CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
             EXPORTING
               FILENAME  = 'D:\Siemens\asd.xls'
               I_BEGIN_COL                   = 1
               I_BEGIN_ROW                   = 1
               I_END_COL                     = 2
               I_END_ROW                     = 3
             TABLES
               INTERN                        = itab
            EXCEPTIONS
              INCONSISTENT_PARAMETERS       = 1
              UPLOAD_OLE                    = 2
              OTHERS                        = 3
           IF SY-SUBRC <> 0.
    write : / 'this is not executed'.
    exit.
           ENDIF.
           loop at itab.
           write : / itab-a,itab-b.
           endloop.
    and the data in the excel sheet  is
    1   2
    3   4
    5   5

    Check the following ex:
    REPORT ZFI_EXCEL .
    *Read the data from the locally held spreadsheet
    *Once read using this FM, the data will be held like:-
    *ROW  |COL  |VALUE
    *---|-|---
    *0001 |0001 |2
    *0001 |0002 |00000000001
    *0001 |0003 |1
    *0001 |0004 |
    *0001 |0005 |2
    *0001 |00010|SHORT TEXT for a/c
    *0001 |00011|LONG TEXT a/c 0000000001
    *0002 |0001 |2
    *0002 |0002 |00000000002
    *0002 |0003 |1
    *0002 |0004 |
    *0002 |0005 |2
    *0002 |00010|SHORT TEXT for a/c
    *0001 |00011|LONG TEXT a/c 0000000002
    *etc........
    data: begin of excel_tab occurs 0.
            include structure alsmex_tabline.
    data: end of excel_tab .
    data: begin of itab occurs 0,
            bldat like bkpf-bldat,
            blart like bkpf-blart,
            bukrs like bkpf-bukrs,
            budat like bkpf-budat,
            waers like bkpf-waers,
            bschl like bseg-bschl,
            hkont like bseg-hkont,
            sgtxt like bseg-sgtxt,
          end of itab.
    data: process_tab_struct_tmp like itab.
    field-symbols: <fs1>.
    selection-screen: begin of block blk.
    parameters: fname type rlgrap-filename.
    selection-screen: end of block blk.
    at selection-screen on value-request for fname.
          CALL FUNCTION 'F4_FILENAME'
           EXPORTING
             PROGRAM_NAME        = 'ZFI_EXCEL'
             DYNPRO_NUMBER       = '1000'
             FIELD_NAME          = 'FNAME'
           IMPORTING
             FILE_NAME           = FNAME.
    START-OF-SELECTION.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                      = FNAME
          i_begin_col                   = 1
          i_begin_row                   = 1
          i_end_col                     = 24
          i_end_row                     = 60000
        tables
          intern                        = EXCEL_TAB
    LOOP AT EXCEL_TAB.
    assign component excel_tab-col of structure
                                          process_tab_struct_tmp to <fs1>.
      <fs1> = excel_tab-value.
    at end of row.
    move-corresponding: process_tab_struct_tmp to itab.  “Move values to itab
    append itab.
    endat.
    ENDLOOP.
    LOOP AT ITAB.
      WRITE:/2 ITAB-BLDAT,14(8) ITAB-BLART,20(10) ITAB-BUDAT.
    ENDLOOP.

  • Uploading of Excel data in Internal Table in WebUI

    Hello All ,
    I have Requirment to Upload the .xls or .xlxs file into Excel . Can any one explain me me how to do i have followed
    i have used the following code
    1. In the application use file upload to upload the file.
    2. caputure the content and length
    DATA: data TYPE REF TO CL_HTMLB_FILEUPLOAD.
    data ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'fileUpload'
    id = 'xx').
    name = data->file_name.
    content = data->file_content.
    length = data->file_length.
    content_type = data->file_content_type.
    3. Then read the data using the class
    DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.
    conv = CL_ABAP_CONV_IN_CE=>CREATE( input = CONTENT ).
    conv->READ( importing data = Variable len = length ).
    Here in Read its throughing some junk data which is not in a readable format.
    Done this with reference to the link below
    Upload Excel Files to ITable
    Regards,
    Kiran Posanapalli
    Edited by: posanapalli kiran on Jan 6, 2010 8:27 AM
    Edited by: posanapalli kiran on Jan 6, 2010 8:32 AM

    this is a trial method and right now i am trying to read only the first cell of the excel sheet and return that value and show it in the UI when the user presses the button but this code is not returning any value.
    METHOD read_excel.
      INCLUDE ole2incl.
      DATA: filename(128) TYPE c,
                excel TYPE ole2_object,
                cell TYPE ole2_object,
                workbook TYPE ole2_object,
               pfile TYPE localfile VALUE
               'C:\Documents and Settings\I047323\Desktop\new.xls',
                name TYPE string.
      CREATE OBJECT excel 'EXCEL.APPLICATION'.
      SET PROPERTY OF excel 'VISIBLE' = 0.
      CALL METHOD OF excel 'WORKBOOKS' = workbook.
      CALL METHOD OF workbook 'OPEN'
        EXPORTING  #1       = pfile.
        CALL METHOD OF excel  'CELLS' = cell
          EXPORTING
            #1      = 1
            #2      = 1
        GET PROPERTY OF cell 'VALUE' = value.
      CALL METHOD OF workbook 'SAVE'.
      CALL METHOD OF workbook 'CLOSE'.
      CALL METHOD OF excel 'QUIT'.
      FREE OBJECT excel.
    ENDMETHOD.
    Edited by: neelima v on Jan 14, 2008 4:06 PM

  • Flat file upload (from local system) to internal table

    I am trying to use BAPI to create sales order. for that I have to upload flat file containing header and item data from the local system (not from application server). please suggest me if any functional module is available for this.
    Thanks,
    Rajan

    Hi rajan,
    Try this,
    CALL FUNCTION 'GUI_UPLOAD'
            EXPORTING
              filename                        = lv_filename              " File name
              filetype                         = 'ASC'
           has_field_separator          = cl_abap_char_utilities=>horizontal_tab
      HEADER_LENGTH             = 0
      READ_BY_LINE                 = G_MARKED
      DAT_MODE                       = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                 = ABAP_TRUE
      REPLACEMENT                = '#'
      CHECK_BOM                    = ' '
      VIRUS_SCAN_PROFILE     = VIRUS_SCAN_PROFILE
      NO_AUTH_CHECK             = ' '
    IMPORTING
      FILELENGTH                     = FILELENGTH
      HEADER                           = HEADERf
            TABLES
              data_tab                      = gt_table         "internal table with fields from the flat file.
           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
    Regards,
    Shobana.K

  • Error in uploading from excel sheet

    i am working on sap crm so i am not able 2 use the fm ALSM_EXCEL_TO_INTERNAL_TABLE . i tried using gui_upload . it exists . wats should i give to the value for 'HAS_FIELD_SEPERATOR' in order to read from the excel file ?? i tried giving a tab space and it dumped my prog saying type conflict erroe while calling function module

    Hi Vignesh,
    Plz use this function module.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
        I_FIELD_SEPERATOR        =
          i_line_header            =  'X'
          i_tab_raw_data           =  it_raw
          i_filename               =  p_file1
        TABLES
          i_tab_converted_data     = it_itab
       EXCEPTIONS
          conversion_failed        = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    Rewords some points .
    Rgds,
    P.Naganaja Reddy

Maybe you are looking for