Excel file in BDC

Hi,
Have a requirement to upload from an Excel file.I know txt file can be used for that, but the requirement is to use excel in .csv format.While uploading the data using gui_upload, it is not working properly.I hope there is some error in the field seperator.
Waiting for the appropriate reply...
Thankx in advance...

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

Similar Messages

  • How to upload a excel file using BDC

    how should i upload a file using BDC
    i have downloaded a excel file containing the values of  table A006 a X server.
    now i hav to upload it into new server Y server using BDC , how do i do it?
    wat all things one shud consider ?

    Hi,
    This is very simple, follow the below mention steps to do so:
    1.Declare an internal table having same structure as db table, but take all the fields type as 'C' and length same as defined in the table.
    TYPES:BEGIN OF it,
      key(20) TYPE c,
      indicator(20) TYPE c,
      bldat(20) TYPE c,"bkpf-bldat
      budat(20) TYPE c,"bkpf-budat
      END OF it.
    DATA: itab TYPE STANDARD TABLE OF it,
          wa TYPE it.
    2.Include TRUX as type pool and declare a variable of type trux_t_text_data to be passed in the FM that actually reads data from excel sheet into above declared intrenal table.
    TYPE-POOLS: truxs.
    DATA: it_raw TYPE truxs_t_text_data.
    3. Call the FM 'TEXT_CONVERT_XLS_TO_SAP' and pass the file name and the internal table name into the parameter
    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 "name of the excel file
        TABLES
          i_tab_converted_data       = itab[] "internal table where data will be stored
       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.
    4. loop at internal table and modify the ztable/dbtable where data to be upload .
    Hope this solve your problem.
    Pooja

  • Wht are the function modules for download upload excel files in bdc.

    hi all,
    this question seems to be silly but i had open office excel files i am getting problems to upload or down loading.  can you tell which function modules can upload or down load open office excel files.
    another dought this is not need full but i need to get some of graphics which are in se78  .
    how can we dowload them from sap.
    thanq,
    rajesh.k

    Hi,
      use  :   CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
       REPORT  YKC_XL_UPLOAD.
    TYPE-POOLS TRUXS.
    TABLES : ZMARA.
    * Selection screen
    PARAMETER P_FILE TYPE RLGRAP-FILENAME DEFAULT
    'C:\Kris\TEST_UPLOAD.xls'.
    TYPES:  BEGIN OF T_TAB,
            MATNR   LIKE ZMARA-MATNR,
            ERSDA  LIKE ZMARA-ERSDA,
            ERNAM  LIKE ZMARA-ERNAM,
            END OF T_TAB.
    DATA :  T_UPLOAD  TYPE STANDARD TABLE OF T_TAB WITH HEADER LINE ,
            WA_UPLOAD TYPE T_TAB,
            IT_RAW TYPE TRUXS_T_TEXT_DATA.  "work table internal table
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = 'P_FILE '
        IMPORTING
          FILE_NAME     = P_FILE.
    START-OF-SELECTION.
    * Uploading the data in the file into internal table
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
    *   I_FIELD_SEPERATOR =
    *   I_LINE_HEADER  = 'X'
        I_TAB_RAW_DATA = IT_RAW
        I_FILENAME     = P_FILE
      TABLES
        I_TAB_CONVERTED_DATA = T_UPLOAD[]
      EXCEPTIONS
        CONVERSION_FAILED = 1
        OTHERS            = 2.
      IF SY-SUBRC NE  0.
        MESSAGE ID SY-MSGID
                TYPE SY-MSGTY
                NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    END-OF-SELECTION.
    * Uploading the data into the database table
      LOOP AT T_UPLOAD INTO T_UPLOAD.
        ZMARA-MATNR = T_UPLOAD-MATNR.
        ZMARA-ERSDA = T_UPLOAD-ERSDA.
        ZMARA-ERNAM = T_UPLOAD-ERNAM.
        INSERT  ZMARA.
    Endloop.
    Tks,
    Krishna

  • How to use Excel file in BDC

    how to transfer data from an execel file to an internal file for a BDC program?

    Hi Prakash,
    hi,
    use the FM ALSM_EXCEL_TO_INTERNAL_TABLE.
    PARAMETERS:
    P_INFL like RLGRAP-FILENAME.
    DATA:
    BEGIN OF T_DATA1 OCCURS 0,
    RESOURCE(25) TYPE C,
    DATE(10) TYPE C,
    DURATION TYPE P DECIMALS 2,
    ACTIVITY(25) TYPE C,
    B_NBILL(1) TYPE C,
    END OF T_DATA1,
    T_DATA TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE,
    BEGIN OF T_FINAL OCCURS 0,
    RESOURCE(25) TYPE C,
    DATE(10) TYPE C,
    DURATION(15) TYPE C,
    ACTIVITY(25) TYPE C,
    B_NBILL(10) TYPE C,
    END OF T_FINAL.
    DATA : HEADER TYPE XSTRING.
    * Work Variables Declaration.
    CONSTANTS:
    W_Y TYPE C VALUE 'Y',
    W_N TYPE C VALUE 'N'.
    * Work area.
    DATA:
    WA_DATA LIKE T_FINAL.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_INFL.
    PERFORM GET_FILENAME CHANGING P_INFL.
    START-OF-SELECTION.
    PERFORM UPLOAD_DATA_FROMEXCEL.
    FORM UPLOAD_DATA_FROMEXCEL.
    * Downloading the data from presentation server
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = p_infl
    I_BEGIN_COL = 1
    I_BEGIN_ROW = 2
    I_END_COL = 8
    I_END_ROW = 1000
    TABLES
    INTERN = T_DATA
    EXCEPTIONS
    INCONSISTENT_PARAMETERS = 1
    UPLOAD_OLE = 2
    OTHERS = 3.
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " upload_data_fromexcel
    *& Form process_data
    * text
    FORM PROCESS_DATA .
    T_FINAL-RESOURCE = 'Resource'.
    T_FINAL-DATE = 'Date'.
    T_FINAL-DURATION = 'Duration'.
    T_FINAL-ACTIVITY = 'Activity'.
    T_FINAL-B_NBILL = 'Billable'.
    APPEND T_FINAL.
    SORT T_DATA BY ROW COL.
    LOOP AT T_DATA.
    CASE T_DATA-COL.
    WHEN 3.
    T_DATA1-RESOURCE = T_DATA-VALUE.
    WHEN 4.
    T_DATA1-DATE = T_DATA-VALUE.
    WHEN 5.
    T_DATA1-DURATION = T_DATA-VALUE.
    WHEN 6.
    * t_data1-activity = t_data-value.
    WHEN 7.
    T_DATA1-B_NBILL = T_DATA-VALUE.
    ENDCASE.
    AT END OF ROW.
    COLLECT T_DATA1.
    ENDAT.
    ENDLOOP.
    LOOP AT T_DATA1.
    T_FINAL-RESOURCE = T_DATA1-RESOURCE.
    T_FINAL-DATE = T_DATA1-DATE.
    T_FINAL-DURATION = T_DATA1-DURATION.
    T_FINAL-ACTIVITY = T_DATA1-ACTIVITY.
    T_FINAL-B_NBILL = T_DATA1-B_NBILL.
    APPEND T_FINAL.
    ENDLOOP.
    ENDFORM. " process_data
    *& Form get_filename
    FORM GET_FILENAME CHANGING P_FILENAME.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
    DEF_FILENAME = SPACE
    DEF_PATH = P_FILENAME
    MASK = ',*.* ,*.*.'
    MODE = 'O' " O = Open, S = Save
    * TITLE = BOX_TITLE
    IMPORTING
    FILENAME = P_FILENAME
    EXCEPTIONS
    INV_WINSYS = 1
    NO_BATCH = 2
    SELECTION_CANCEL = 3
    SELECTION_ERROR = 4
    OTHERS = 5.
    * CASE SY-SUBRC.
    * WHEN 1.
    * MESSAGE I999 WITH
    * 'File selector not available on this windows system'(046).
    * WHEN 2.
    * MESSAGE E999 WITH
    * 'Frontend function cannot be executed in background'(047).
    * WHEN 3.
    * MESSAGE I999 WITH 'Selection was cancelled'(048).
    * WHEN 4.
    * MESSAGE E999 WITH 'Communication error'(049).
    * WHEN 5.
    * MESSAGE E999 WITH 'Other error'(050).
    * ENDCASE.
    ENDFORM. " get_filename
    Regards
    Sudheer

  • Problem in downloading excel file

    Hi,
    I am downloading output of SQ01 into excel file using BDC, but windows system stores the whole data in one cell of sheet instead of all other cells.
      Please anybody tell me solution.
    Thanks & Regards,
    Umesh

    Hi,
    Check the followinf code:
      IF sy-ucomm = 'DOWNLOAD' AND sy-lsind = 1.
        DATA: fullpath      TYPE string,
            filename      TYPE string,
            path          TYPE string,
            user_action   TYPE i,
            encoding      TYPE abap_encoding.
        CALL METHOD cl_gui_frontend_services=>file_save_dialog
          EXPORTING
            window_title         = 'Gui_Download Demo'
            with_encoding        = 'X'
            initial_directory    = 'C:\'
          CHANGING
            filename             = filename
            path                 = path
            fullpath             = fullpath
            user_action          = user_action
            file_encoding        = encoding
          EXCEPTIONS
            cntl_error           = 1
            error_no_gui         = 2
            not_supported_by_gui = 3
            OTHERS               = 4.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        IF user_action <> cl_gui_frontend_services=>action_ok.
          EXIT.
        ENDIF.
    Ascii download
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = fullpath
       FILETYPE                        = 'DAT'
      tables
        data_tab                        = itab.
      ENDIF.
    Hope it will help you.
    Regards
    Rajesh Kumar

  • Create BDC group per uploading excel file to fill data in Tcode FB01l

    hi experts,
    i'm using BDC to run T-code FB01L . for this i'm uploading excel file for input data. my requiremenr=t is as follows : "
    only one BDC group should be created per uploading file."  But  At this moment BDC group is created per document. For user it is not possible to handle, say 1000 BDC groups.
    please suggest.
    Thanks
    Deepika

    The answer is simple and you should be able to work it out yourself but I am feeling generous today.
    I am assuming that each line in your excel spreadsheet is a document. The easiest way to do this is simply build up youd BDC table first then create the group.
        <- build your bdc table before opening the group ->
        call function 'BDC_OPEN_GROUP'
          exporting
            group = p_group
            keep  = p_keep
            user  = p_uname.
        call function 'BDC_INSERT'
          exporting
            tcode            = 'FB01'
          tables
            dynprotab        = gt_bdcdata
          exceptions
            internal_error   = 1
            not_open         = 2
            queue_error      = 3
            tcode_invalid    = 4
            printing_invalid = 5
            posting_invalid  = 6
            others           = 7.
    call function 'BDC_CLOSE_GROUP'
    In the future please do a search on SDN. I have also moved this thread to the ABAP General forum as this is not related to ABAP OO.

  • Uploading data from a particular column of a particular sheet from an excel file into internal table

    Hi,
    I have to upload data in the first coulmn of 7th sheet of an excel file.
    Can anyone please help me on this.
    This link works perfectly fine for excel files without Macros.
    Read multiple sheets of an Excel file into SAP through ABAP - Code Gallery - SCN Wiki
    But my excel file has some macros.
    And after the macro enable/disable popup is cleared, the system freezes.
    Can someone pease help me on this abd tell me an approach different from the one in the above link?

    Welcome to SCN
    Please search before you post next time:BDC, upload data from multi excel sheets

  • FM to get Data from Sheet of an excel file to Internal table??

    Hello Champs!!!
    I have a problem in Excel File's Data Getting.
    There are diffrent Sheets in a single Excel file. I need data of a perticular sheet into an internal Table.
    Like there are 2 Sheets in an Excel file EXCEL1, Sheet1 & Sheet2. Both Sheet have diffrent Data in it.
    Now i only need Data of Sheet1 of this Excel FIle Excel1.
    How can i get it?
    Can you please help me in this?
    Thanks in Advance!!!!
    Girija Shankar

    Welcome to SCN
    Please search before you post next time:BDC, upload data from multi excel sheets

  • Selection Screen Excel File Format

    Hi,
    I developed a BDC report to upload data. Data is uploaded Perfactly.
    parametrs: p_file TYPE rlgrap-filename.
    and Excel file format is Storage Location Matnr Stock_Qty
                                         1000    Mat_00001    50
    but i want to give eaxel file screen shot with sample data
    is it possible to give excel format screen shot on selection screen
    before   parametrs: p_file TYPE rlgrap-filename.

    Hi,
    I was telling if  its only  to tell user we can print like comment at the end .I have pasted the code for you .
    it will look at at the bottom of your screen.
    After you declare your slection screen parameters then paste the  code and first text you create text element which has- MS EXCEL format types
    Second textelemnt-Give column1 - "so and so ......
    was i clear this time...
    It not poss to give scrreen shot thriugh above way but throuh your text elemnt message you convery what is colum 1,2 .... to user
    Thank You
    Poornima
    Edited by: Pendyala_poornima on Oct 7, 2011 3:01 PM
    Edited by: Pendyala_poornima on Oct 7, 2011 3:01 PM
    Edited by: Pendyala_poornima on Oct 7, 2011 3:03 PM

  • How to import an Excel file

    Hi ,
    I amwriting a BDC Program..
    How to import a Excel File by Browsing the Excel file from the Directory and Storing that values in the internal table.
    Can any one send the code for this,
    Points will be awarded.
    Regards,
    Jayasimha Jangam.

    Hi,
          Create a select parameter. at selection screen, use FM F4_FILENAME to get the dialog box.
    see the sample code.
    *&      Form  display_dialog
          To display the pop up dialog box
    FORM display_dialog.
    Calling FM to display File Select dialog box
      CALL FUNCTION 'F4_FILENAME'
       EXPORTING
         program_name        = syst-cprog
         dynpro_number       = syst-dynnr
        FIELD_NAME          = ' '
       IMPORTING
         file_name           = p_file .
    ENDFORM.                    " display_dialog
    FORM upload_data.
      DATA : lt_itab   TYPE STANDARD TABLE OF alsmex_tabline,
             ls_itab   TYPE alsmex_tabline,
             ls_upload TYPE ty_upload_data.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = p_file
                i_begin_col             = 1
                i_begin_row             = 2
                i_end_col               = 5
                i_end_row               = 50000
           TABLES
                intern                  = lt_itab[]
           EXCEPTIONS
                inconsistent_parameters = 1
                upload_ole              = 2
                OTHERS                  = 3.
      IF sy-subrc <> 0.
        MESSAGE i000 WITH text-t04.
        LEAVE LIST-PROCESSING.
      ENDIF.
      CLEAR ls_itab.
      LOOP AT lt_itab INTO ls_itab.
        CASE ls_itab-col.
          WHEN 1.
            ls_upload-matnr = ls_itab-value.
          WHEN 2.
            PERFORM convert_to_decimal USING ls_itab-value.
            ls_upload-bmeng = ls_itab-value.
          WHEN 3.
            ls_upload-idnrk = ls_itab-value.
          WHEN 4.
            PERFORM convert_to_decimal USING ls_itab-value.
            ls_upload-menge = ls_itab-value.
          WHEN 5.
            ls_upload-meins = ls_itab-value.
        ENDCASE.
        AT END OF row.
          APPEND ls_upload TO gt_upload.
          CLEAR ls_upload.
        ENDAT.
        CLEAR ls_itab.
      ENDLOOP.
    Deleting the contents of internal table
    FREE lt_itab.

  • Upload an Excel file

    Hi guys,
    I am doing a BDC and i got an excel file that i need to upload into an internal table before i process it. I am defining an internal table as text and using GUI_UPLOAD with delimiter as '|' but i guess its not working. Can i try something else here??.
    Thanks in advance,
    David.

    Try this code.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM upload_help.
    *Start of selection
    START-OF-SELECTION.
      PERFORM upload_data.
    *&      Form  upload_help
          text
    FORM upload_help .
      CALL FUNCTION 'WS_FILENAME_GET'
             EXPORTING
                  def_filename     = p_file
              DEF_PATH         = DEF_PATH
                  mask             = ',.,..'
              MASK             = TMP_MASK
                   mode            = 'O'
               IMPORTING
                  filename         = p_file
             EXCEPTIONS
                  inv_winsys       = 01
                  no_batch         = 02
                  selection_cancel = 03
                  selection_error  = 04.
      IF sy-subrc = 0.
      ENDIF.
    ENDFORM.                    " upload_help
    *&      Form  upload_data
          text
    FORM upload_data .
      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_tab[]    "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.
      APPEND IT_TAB.
      CLEAR IT_TAB.
    describe table it_tab lines v_lines.
      LOOP AT it_tab.
    FROM 2 TO v_lines .
        move sy-mandt TO IT_TAB1-mandt.
        move it_tab-leg_bukrs to IT_TAB1-leg_bukrs.
        move it_tab-leg_sysid to IT_TAB1-leg_sysid.
        move it_tab-leg_saknr  to IT_TAB1-leg_saknr .
        move it_tab-db_cr to IT_TAB1-db_cr.
        move it_tab-con_bukrs to IT_TAB1-con_bukrs.
        move it_tab-CON_SYSID to IT_TAB1-CON_SYSID.
        move it_tab-con_c_saknr to IT_TAB1-con_c_saknr.
        move it_tab-con_c_summ to IT_TAB1-con_c_summ.
        move it_tab-con_d_saknr to IT_TAB1-con_d_saknr.
        move it_tab-con_d_summ to IT_TAB1-con_d_summ.
        move it_tab-exp_bukrs to IT_TAB1-exp_bukrs.
        move it_tab-exp_sysid  to IT_TAB1-exp_sysid .
        move it_tab-exp_c_saknr to IT_TAB1-exp_c_saknr.
        move it_tab-exp_c_summ to IT_TAB1-exp_c_summ.
        move it_tab-exp_d_saknr to IT_TAB1-exp_d_saknr.
        move it_tab-exp_d_summ  to IT_TAB1-exp_d_summ .
        APPEND IT_TAB1.
        CLEAR IT_TAB1.
      ENDLOOP.
      REFRESH IT_TAB.
      LOOP AT IT_TAB1.
        IF IT_TAB1-LEG_BUKRS <> SPACE.
          MODIFY ZFDLC_ALT_ACCT FROM IT_TAB1.
        ENDIF.
      ENDLOOP.
      FREE IT_TAB1.
      FORMAT COLOR COL_POSITIVE.
      WRITE: /  'NO.OF.RECORDS LOADED: ' , SY-TABIX.
    ENDFORM.                    " upload_dataendloop.

  • How to upload normal excell file to ztable

    Hi All there,
    Can anybody tell me how to upload normal excell file to ztable directly.
    pl provide detail coding
    Regards
    Sagar

    Hi Sagar,
       first upload the excel data into your internal table using a FM than upload the data to your ZTABLE using BDC.
    parameters:
      p_file type rlgrap-filename          " File name
      data:
        lw_file  type string.              " File Path
    data:
      t_bdcdata type
       standard table
             of bdcdata,
      fs_bdcdata type bdcdata.             " Work area for bdcdata
    * Messages of call transaction
    data:
      t_messtab type
       standard table
             of bdcmsgcoll,
      fs_messtab type bdcmsgcoll.          " Work area for messtab
    at selection-screen on value-request for p_file.
      call function 'F4_FILENAME'
       exporting
         program_name        = syst-cprog
         dynpro_number       = syst-dynnr
         field_name          = ' '
       importing
         file_name           = p_file.
      lw_file = p_file.
      call function 'GUI_UPLOAD'
        exporting
          filename                    = lw_file
          filetype                    = 'ASC'
          has_field_separator         = 'X'
          dat_mode                    = 'X'
        tables
          data_tab                    = t_final_data
        exceptions
          file_open_error              = 1
          file_read_error              = 2
          no_batch                     = 3
          gui_refuse_filetransfer      = 4
          invalid_type                 = 5
          no_authority                 = 6
          unknown_error                = 7
          bad_data_format              = 8
          header_not_allowed           = 9
          separator_not_allowed        = 10
          header_too_long              = 11
          unknown_dp_error             = 12
          access_denied                = 13
          dp_out_of_memory             = 14
          disk_full                    = 15
          dp_timeout                   = 16
          others                       = 17.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.                               " IF SY-SUBRC <> 0
      if t_final_data is initial.
        message 'File not found'(003) type 'E'.
      endif.                               " IF T_FINAL_DATA IS INITIAL
    end-of-selection.
      perform upload_0585_data_using_bdc.  " populate the bdcdata table using tcode SHDB
      call transaction 'PA30' using t_bdcdata
                               mode 'A'
                           messages into t_messtab.
    form upload_0585_data_using_bdc.
      loop at t_final_data into fs_final_data.
    perform bdc_field       using 'Q0585-ACNTR(07)'
                                   w_curr.
    perform bdc_field       using 'Q0585-ACOPC'
                                   lw_flag.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=UPD'.
    perform bdc_dynpro      using 'MP058500' '2000'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/EBCK'.
    perform bdc_dynpro      using 'SAPMP50A' '1000'.
    endloop.
    *        Start new screen                                              *
    form bdc_dynpro using program dynpro.
      clear fs_bdcdata.
      fs_bdcdata-program  = program.
      fs_bdcdata-dynpro   = dynpro.
      fs_bdcdata-dynbegin = 'X'.
      append fs_bdcdata to t_bdcdata.
    endform.                               " Form bdc_dynpro using program...
    *        Insert field                                                  *
    form bdc_field using fnam fval.
        clear fs_bdcdata.
        fs_bdcdata-fnam = fnam.
        fs_bdcdata-fval = fval.
        append fs_bdcdata to t_bdcdata.
    endform.                               " Form bdc_field using fnam fval
    With luck,
    Pritam.

  • Excel file upload possible?

    Hello BW Experts,
    Is it possible to upload Excel files into BW? not refereing to csv...
    i remember in one of the project they did this usingg bdc / lsmw or somethhing. can you please help me get the exact procedure..
    Thanks,
    BWer

    You can load the Excel file to a Table in SAP R/3 using LSMW and BDC but not to an infocube.
    The reason is that when you load an infocube or  master infoobjects the SID for each dimension is created automatically and you can't have any control over that.
    Only way to upload the data is going through formal way of creating infosource and infopack.
    Regs
    Gopi.
    Assign points if it helps ...

  • Upload data in excel sheet through BDC

    Dear all,
    How do we upload data in excel sheet through BDC?
    Thanks in advance.
    Regards,
    Sandra.

    Hi,
         The sample code is as given below:
    REPORT  upload_supply_area.
    *include for dispaying icons in error log
    INCLUDE <icon>.
    *Declaration of structure.
    TYPES:BEGIN OF x_struct,
          werks TYPE v_pvbe-werks,          "Plant
          prvbe TYPE v_pvbe-prvbe,          "Supply Area
          pvbtx TYPE v_pvbe-pvbtx,          "Production supply area description
          lgort TYPE v_pvbe-lgort,          "Storage Location
          rgver TYPE v_pvbe-rgver,          "Person responsible for one or more supply areas
          END OF x_struct.
    TYPES:BEGIN OF x_messages,
           msgtyp(1) type c,
           werks TYPE v_pvbe-werks,          "Plant
           prvbe TYPE v_pvbe-prvbe,          "Supply Area
           message(120) type c,
           END OF x_messages.
    DATA: it_messages  TYPE STANDARD TABLE OF x_messages .
    DATA: wa_messages TYPE x_messages.
    DATA:it_msgtab TYPE STANDARD TABLE OF bdcmsgcoll,
         wa_msgtab TYPE bdcmsgcoll.
    *internal table for BDC
    DATA: it_bdcdata TYPE STANDARD TABLE OF bdcdata.
    DATA: wa_bdcdata TYPE bdcdata.
    DATA:it_file TYPE STANDARD TABLE OF x_struct.        "internal table which has same structure as file
    DATA:wa_file TYPE x_struct.                          "work area which has same structure as file
    DATA: it_excel TYPE STANDARD TABLE OF alsmex_tabline,
          wa_excel TYPE alsmex_tabline.
    DATA: x_ctuprms TYPE ctu_params.
    DATA:nodata TYPE c VALUE '/'.
    data:con(50) type c.
    data:con1(50) type c.
    *selection screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    *Enter file name on presentation server
    PARAMETERS:  p_file TYPE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *Function which enables the user to browse the files on hard disk
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          program_name  = syst-repid
          static        = 'X'
        CHANGING
          file_name     = p_file
        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.
    *Subroutine to upload excel file and read it
      PERFORM upload.
    *Subroutine to upload supply area data
      PERFORM fill.
    *&      Form  bdc_dynpro
          Fill the BDC table
    FORM bdc_dynpro USING program dynpro.                       "#EC *
      CLEAR wa_bdcdata.
      wa_bdcdata-program  = program.
      wa_bdcdata-dynpro   = dynpro.
      wa_bdcdata-dynbegin = 'X'.
      APPEND wa_bdcdata TO it_bdcdata.
    ENDFORM.                    "BDC_DYNPRO
    *&      Form  bdc_field
           Fill the BDC table
    FORM bdc_field USING fnam fval.                             "#EC *
      IF fval <> nodata.
        CLEAR wa_bdcdata.
        wa_bdcdata-fnam = fnam.
        wa_bdcdata-fval = fval.
        APPEND wa_bdcdata TO it_bdcdata.                        "#EC
      ENDIF.
    ENDFORM.                    "BDC_FIELD
    *&      Form  collect_messages
          Collect the messages from transaction
    FORM collect_messages .                                     "#EC *
      DATA: w_msg(100).
      LOOP AT it_msgtab INTO wa_msgtab.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            id        = wa_msgtab-msgid
            lang      = wa_msgtab-msgspra
            no        = wa_msgtab-msgnr
            v1        = wa_msgtab-msgv1
            v2        = wa_msgtab-msgv2
          IMPORTING
            msg       = w_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.
        CONDENSE w_msg.
        CLEAR wa_messages.
        wa_messages-msgtyp = wa_msgtab-msgtyp.
        wa_messages-message = w_msg.
        wa_messages-werks = wa_file-werks.
        wa_messages-prvbe = wa_file-prvbe.
    if wa_messages-message eq 'Formatting error in the field V_PVBE-RGVER; see next message'.
    wa_messages-message = 'Invalid name of the person responsible'.
    endif.
    if wa_messages-message eq 'Formatting error in the field V_PVBE-LGORT; see next message'.
    wa_messages-message = 'Enter the storage location'.
    endif.
        APPEND wa_messages TO it_messages .
      ENDLOOP.
      REFRESH it_msgtab.
    ENDFORM.                    "collect_messages
    *&      Form  write_messages
          Display the messages
    FORM write_messages .
      DELETE ADJACENT DUPLICATES FROM it_messages COMPARING werks prvbe.
      LOOP AT it_messages INTO wa_messages .
        WRITE:/1 sy-vline.
        IF wa_messages-msgtyp = 'S'.
          WRITE: 10 icon_green_light.
        ELSEIF wa_messages-msgtyp = 'E'.
          WRITE: 10 icon_red_light.
        ELSEIF wa_messages-msgtyp = 'W'.
          WRITE: 10 icon_yellow_light.
        ENDIF.
        WRITE: 20 sy-vline.
        WRITE : 30 'Plant-', wa_messages-werks .                "#EC NOTEXT
        WRITE: 48 sy-vline.
        WRITE : 49 'Supply Area-', wa_messages-prvbe .          "#EC NOTEXT
        WRITE: 79 sy-vline.
        WRITE : 80 wa_messages-message .
        WRITE: 180 sy-vline.
        WRITE:/1 sy-vline.
        ULINE 1(180).
      ENDLOOP.
    ENDFORM.                    " write_m
    *&      Form  fill_params
          Processing mode for the transaction
    FORM fill_params .
      x_ctuprms-dismode = 'N'.
      x_ctuprms-updmode = 'A'.
      x_ctuprms-defsize = 'X'.
    ENDFORM.                    "fill_params
    *&      Form  upload
          Upload the excel file and read the data
    FORM upload .
    *Function to upload excel file
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = 1
          i_begin_row             = 2
          i_end_col               = 5
          i_end_row               = 9999
        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.
      CLEAR wa_file.
    *Read the file row-wise
      LOOP AT it_excel INTO wa_excel.
        CASE wa_excel-col .
    *Read plant
          WHEN '1'.
            wa_file-werks = wa_excel-value.
    *Read supply area
          WHEN '2'.
            wa_file-prvbe = wa_excel-value.
    *Read decription
          WHEN '3'.
            wa_file-pvbtx = wa_excel-value.
    *Read storage location
          WHEN '4'.
            wa_file-lgort = wa_excel-value.
    *Read Person responsible
          WHEN '5'.
            IF STRLEN( wa_excel-value ) = 1.
              CONCATENATE '00' wa_excel-value INTO con.
              wa_file-rgver = con.
            ELSEIF STRLEN( wa_excel-value ) = 2.
              CONCATENATE '0' wa_excel-value INTO con1.
              wa_file-rgver = con1.
            ELSE.
              wa_file-rgver = wa_excel-value.
            ENDIF.
        ENDCASE.
        AT END OF row.
          CONDENSE:wa_file-werks,wa_file-prvbe,wa_file-pvbtx,wa_file-lgort,wa_file-rgver.
          APPEND wa_file TO it_file.
          CLEAR wa_file.
        ENDAT .
      ENDLOOP.
    ENDFORM.                    " upload
    *&      Form  fill
          Call the transaction 'PK05'
    FORM fill .
    *Upload the data through transaction 'PK05'
      PERFORM fill_params.
      LOOP AT it_file INTO wa_file.
        PERFORM bdc_dynpro      USING 'SAPLSVIX' '0100'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'D0100_FIELD_TAB-LOWER_LIMIT(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=OKAY'.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0020'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-PVBTX(01)'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=NEWL'.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0021'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-RGVER'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM bdc_field       USING 'V_PVBE-WERKS'
                                      wa_file-werks.
        PERFORM bdc_field       USING 'V_PVBE-PRVBE'
                                      wa_file-prvbe.
        PERFORM bdc_field       USING 'V_PVBE-PVBTX'
                                      wa_file-pvbtx.
        PERFORM bdc_field       USING 'V_PVBE-LGORT'
                                      wa_file-lgort.
        PERFORM bdc_field       USING 'V_PVBE-RGVER'
                                      wa_file-rgver.
        PERFORM bdc_dynpro      USING 'SAPL0PK1' '0021'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'V_PVBE-WERKS'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=SAVE'.
        PERFORM bdc_field       USING 'V_PVBE-WERKS'
                                      wa_file-werks.
        PERFORM bdc_field       USING 'V_PVBE-PRVBE'
                                      wa_file-prvbe.
        PERFORM bdc_field       USING 'V_PVBE-PVBTX'
                                      wa_file-pvbtx.
        PERFORM bdc_field       USING 'V_PVBE-LGORT'
                                      wa_file-lgort.
        PERFORM bdc_field       USING 'V_PVBE-RGVER'
                                      wa_file-rgver.
        CALL TRANSACTION 'PK05'
                           USING it_bdcdata
                           OPTIONS FROM x_ctuprms
                           MESSAGES INTO it_msgtab.
        REFRESH it_bdcdata.
        PERFORM collect_messages.
        CLEAR wa_file.
      ENDLOOP.
      PERFORM write_messages.
    ENDFORM.                    " fill

  • Uploading Excel file in SRM server

    Dear Gurus,
    I am trying to upload the excel file in SRM 5.0 server. But the function modules that are present in R/3 like 'TEXT_CONVERT_XLS_TO_SAP',
    'KCD_EXCEL_DATE_CONVERT' and also ALSM_EXCEL_TO_INTERNAL_TABLE but these function modules are not present on SRM server.
    I need to upload a simple excel file and write an bdc on that.
    Is there any way.
    Thanka in advance,
    Saurabh Chhatre

    Hi,
    save the internal table as a desktop file and then use CG3Z transaction to put the data from desktop to application server.
    then to read the application file use the logic given below:
    DATA: wa_file_data TYPE text4096,
    lv_app_server_file TYPE string.
      lv_app_server_file = pa_afile.
    To read file from Application server
      OPEN DATASET lv_app_server_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      DO.
        READ DATASET lv_app_server_file INTO wa_file_data.
        IF sy-subrc = 0.
          APPEND wa_file_data TO gi_file_data.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET lv_app_server_file.
    DATA: lv_file_separator TYPE c.
      lv_file_separator = cl_abap_char_utilities=>horizontal_tab.
    To upload file in other formats(CSV, Tab delimited etc)
      CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
        EXPORTING
          i_field_seperator    = lv_file_separator
          i_tab_raw_data       = gi_file_data
        TABLES
          i_tab_converted_data = gi_zhralcon_file
        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.
    Hope it helps.
    Regards,
    Rajesh Kumar

Maybe you are looking for