Uploading data in exel sheet

hi,
how to upload data from excel sheet to sap using call tranaction or session input or lsmw ?

Hi ,
In LSMW it is not possible to upload the data in Excel format, you need to save the excel sheet data as a tab delimeted file and then upload the data using LSMW.
For BDC or Call transaction you can upload the Excel file by using the function module ''ALSM_EXCEL_TO_INTERNAL_TABLE''.
See the foloowing sample code:
UPLOAD OF EXCEL FILE:
REPORT  ZRAJESH..
TYPE-POOLS : slis.
DATA : BEGIN OF it_fin OCCURS 1,
        f1(20),
        f2(30),
        f3(20),
        f4 TYPE i,
       END OF it_fin.
DATA : intern1 TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
REFRESH it_fin[].CLEAR it_fin.
CLEAR intern1.
PARAMETERS fl_name TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR fl_name.
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
   EXPORTING
  PROGRAM_NAME        = SYST-REPID
  DYNPRO_NUMBER       = SYST-DYNNR
  FIELD_NAME          = ' '
     static              = 'X'
  MASK                = ' '
    CHANGING
      file_name           = fl_name
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.
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename                = fl_name
      i_begin_col             = '1'
      i_begin_row             = '1'
      i_end_col               = '4'
      i_end_row               = '35'
    TABLES
      intern                  = intern1
    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 fl_name.
  FIELD-SYMBOLS : <fs1> TYPE ANY,
                  <fs2> TYPE ANY.
  data: v_col(3) type n ,
        v_col2(3) type n value '003'.
  LOOP AT intern1.
    v_col = intern1-col.
    ASSIGN component v_col2 of structure intern1 TO <fs1>.
    ASSIGN component v_col  of structure it_fin TO <fs2>.
    <fs2> = <fs1>.
   CASE INTERN1-COL.
     WHEN '001'.
       IT_FIN-F1 = INTERN1-VALUE.
     WHEN '002'.
       IT_FIN-F2 = INTERN1-VALUE.
     WHEN '003'.
       IT_FIN-F3 = INTERN1-VALUE.
     WHEN '004'.
       IT_FIN-F4 = INTERN1-VALUE.
   ENDCASE.
    AT END OF row.
      APPEND it_fin.
      CLEAR: it_fin,v_col.
    ENDAT.
  ENDLOOP.
  DATA : v_prgname TYPE sy-repid VALUE sy-repid,
         it_fldcat TYPE slis_fieldcat_alv OCCURS 1,
         wa_fldcat TYPE slis_fieldcat_alv,
         it_sort TYPE slis_sortinfo_alv OCCURS 1,
         wa_sort TYPE slis_sortinfo_alv.
  wa_fldcat-fieldname = 'F1'.
  wa_fldcat-col_pos   = 1.
  wa_fldcat-tabname  = 'IT_FIN'.
  wa_fldcat-seltext_m = 'VENDOR NO'.
  APPEND wa_fldcat TO it_fldcat.
  CLEAR wa_fldcat.
  wa_fldcat-fieldname = 'F2'.
  wa_fldcat-col_pos   = 2.
  wa_fldcat-tabname  = 'IT_FIN'.
  wa_fldcat-seltext_m = 'VENDOR NAME'.
  APPEND wa_fldcat TO it_fldcat.
  CLEAR wa_fldcat.
  wa_fldcat-fieldname = 'F3'.
  wa_fldcat-col_pos   = 3.
  wa_fldcat-tabname  = 'IT_FIN'.
  wa_fldcat-seltext_m = 'VENDOR CITY'.
  APPEND wa_fldcat TO it_fldcat.
  CLEAR wa_fldcat.
  wa_fldcat-fieldname = 'F4'.
  wa_fldcat-col_pos   = 4.
  wa_fldcat-tabname  = 'IT_FIN'.
  wa_fldcat-seltext_m = 'AMOUNT'.
*wa_fldcat-do_sum = 'X'.
  APPEND wa_fldcat TO it_fldcat.
  CLEAR wa_fldcat.
*wa_sort-fieldname = 'F3'.
*wa_sort-tabname = 'IT_FIN'.
*wa_sort-up = 'X'.
*wa_sort-subtot = 'X'.
*append wa_sort to it_sort.
*clear wa_sort.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
  I_INTERFACE_CHECK                 = ' '
  I_BYPASSING_BUFFER                = ' '
  I_BUFFER_ACTIVE                   = ' '
     i_callback_program                =  v_prgname
  I_CALLBACK_PF_STATUS_SET          = ' '
  I_CALLBACK_USER_COMMAND           = ' '
  I_CALLBACK_TOP_OF_PAGE            = ' '
  I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
  I_CALLBACK_HTML_END_OF_LIST       = ' '
  I_STRUCTURE_NAME                  =
  I_BACKGROUND_ID                   = ' '
  I_GRID_TITLE                      =
  I_GRID_SETTINGS                   =
  IS_LAYOUT                         =
     it_fieldcat                       = it_fldcat[]
  IT_EXCLUDING                      =
  IT_SPECIAL_GROUPS                 =
    it_sort                           =  it_sort[]
  IT_FILTER                         =
  IS_SEL_HIDE                       =
  I_DEFAULT                         = 'X'
  I_SAVE                            = ' '
  IS_VARIANT                        =
  IT_EVENTS                         =
  IT_EVENT_EXIT                     =
  IS_PRINT                          =
  IS_REPREP_ID                      =
  I_SCREEN_START_COLUMN             = 0
  I_SCREEN_START_LINE               = 0
  I_SCREEN_END_COLUMN               = 0
  I_SCREEN_END_LINE                 = 0
  I_HTML_HEIGHT_TOP                 = 0
  I_HTML_HEIGHT_END                 = 0
  IT_ALV_GRAPHICS                   =
  IT_HYPERLINK                      =
  IT_ADD_FIELDCAT                   =
  IT_EXCEPT_QINFO                   =
  IR_SALV_FULLSCREEN_ADAPTER        =
IMPORTING
  E_EXIT_CAUSED_BY_CALLER           =
  ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = it_fin
   EXCEPTIONS
     program_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.

Similar Messages

  • Uploading data from excel sheets through BDC's into sap system

    hi guys,
    can you please help me with this. As we use gui_upload to upload data from flat file to sap system, which function module you use to upload data from Excel sheet to sap system through bdc's

    hello pavan,
    welcome to SDN
    check the below program
    REPORT ZEXCEL_TO_INTERNAL .
    data: begin of itab occurs 0,
          name(20) type c,
          addre(20) type c,
          end of itab.
    DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    DATA : B1 TYPE I VALUE 1,
           C1 TYPE I VALUE 1,
           B2 TYPE I VALUE 100,
           C2 TYPE I VALUE 9999.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                   =
        'C:\Documents and Settings\administrator\Desktop\ppcon001bd_24.xls'
        I_BEGIN_COL                   = B1
        I_BEGIN_ROW                   = C1
        I_END_COL                     = B2
        I_END_ROW                     = C2
      TABLES
        INTERN                        = itab1
    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 itab1.
    write:/ itab1.
    Endlop.
    Regards,
    Naveen

  • How to upload datas in excel sheet through BDC

    Hi,
        I know how to upload datas in Text format  through BDC...Suppose even when datas are in .xls format,I saved that file as Text(tab delimited) format...then file become text format and it can be easily uploaded....
        So, I want to know How to upload datas in excel sheet through BDC

    hi,
    try this Example, hope useful to u, assign me point.
    report ZMSV1_BDC_CALL
           no standard page heading line-size 255.
    *include bdcrecx1.
    *parameters: dataset(132) lower case.
       DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
      If it is nessesary to change the data section use the rules:
      1.) Each definition of a field exists of two lines
      2.) The first line shows exactly the comment
          '* data element: ' followed with the data element
          which describes the field.
          If you don't have a data element use the
          comment without a data element name
      3.) The second line shows the fieldname of the
          structure, the fieldname must consist of
          a fieldname and optional the character '_' and
          three numbers and the field length in brackets
      4.) Each field must be type C.
    Generated data section with specific formatting - DO NOT CHANGE  ***
    data: begin of record,
    data element: BUKRS
            BUKRS_001(004),
    data element: KTOKK
            KTOKK_002(004),
    data element: NAME1_GP
            NAME1_003(035),
    data element: SORTL
            SORTL_004(010),
    data element: ORT01_GP
            ORT01_005(035),
    data element: LAND1_GP
            LAND1_006(003),
    data element: SPRAS
            SPRAS_007(002),
    data element: BANKS
            BANKS_01_008(003),
    data element: BANKK
            BANKL_01_009(015),
    data element: BANKN
            BANKN_01_010(018),
          end of record.
    End generated data section ***
    data: itab like record occurs 0 .
    data: it_bdc type bdcdata occurs 0 with header line.
    data: it_msg type bdcmsgcoll occurs 0 with header line.
    parameter p_file type rlgrap-filename default 'c:\vendor.txt' obligatory
    start-of-selection.
    perform open_dataset using p_file.
    perform open_group.
    *perform close_group.
    *perform close_dataset using dataset.
    *&      Form  open_dataset
          text
         -->P_P_FILE  text
    form open_dataset  using    p_p_file.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      CODEPAGE                      = ' '
      FILENAME                      = p_file
      FILETYPE                      = 'DAT'
      HEADLEN                       = ' '
      LINE_EXIT                     = ' '
      TRUNCLEN                      = ' '
      USER_FORM                     = ' '
      USER_PROG                     = ' '
      DAT_D_FORMAT                  = ' '
    IMPORTING
      FILELENGTH                    =
      TABLES
        data_tab                      = itab
    EXCEPTIONS
      CONVERSION_ERROR              = 1
      FILE_OPEN_ERROR               = 2
      FILE_READ_ERROR               = 3
      INVALID_TYPE                  = 4
      NO_BATCH                      = 5
      UNKNOWN_ERROR                 = 6
      INVALID_TABLE_WIDTH           = 7
      GUI_REFUSE_FILETRANSFER       = 8
      CUSTOMER_ERROR                = 9
      NO_AUTHORITY                  = 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.                    " open_dataset
    *&      Form  open_group
          text
    -->  p1        text
    <--  p2        text
    form open_group .
    loop at itab into record.
    perform bdc_dynpro      using 'SAPMF02K' '0105'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-KTOKK'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RF02K-BUKRS'
                                  record-BUKRS_001.
    perform bdc_field       using 'RF02K-KTOKK'
                                  record-KTOKK_002.
    perform bdc_dynpro      using 'SAPMF02K' '0110'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-ORT01'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFA1-NAME1'
                                  record-NAME1_003.
    perform bdc_field       using 'LFA1-SORTL'
                                  record-SORTL_004.
    perform bdc_field       using 'LFA1-ORT01'
                                  record-ORT01_005.
    perform bdc_field       using 'LFA1-LAND1'
                                  record-LAND1_006.
    perform bdc_field       using 'LFA1-SPRAS'
                                  record-SPRAS_007.
    perform bdc_dynpro      using 'SAPMF02K' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-KUNNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-KOINH(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'LFBK-BANKS(01)'
                                  record-BANKS_01_008.
    perform bdc_field       using 'LFBK-BANKL(01)'
                                  record-BANKL_01_009.
    perform bdc_field       using 'LFBK-BANKN(01)'
                                  record-BANKN_01_010.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-BANKS(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPMF02K' '0210'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-AKONT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0215'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-ZTERM'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0220'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB5-MAHNA'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    call transaction 'FK01' using it_bdc mode 'A' update 'S'
                                 messages into it_msg.
      write:/ sy-subrc.
        perform message_formatwrite.
    refresh it_bdc.
    clear it_bdc.
    endloop.
    endform.                    " open_group
    *&      Form  message_formatwrite
          text
    -->  p1        text
    <--  p2        text
    form message_formatwrite .
    data:l_msg(10).
    loop at it_msg.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
       ID              = SY-MSGID
       LANG            = sy-langu
       NO              = SY-MSGNO
       V1              = SY-MSGV1
       V2              = SY-MSGV2
       V3              = SY-MSGV3
       V4              = SY-MSGV4
    IMPORTING
       MSG             = l_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.
    endloop.
    endform.                    " message_formatwrite
    *&      Form  bdc_dynpro
          text
         -->P_0112   text
         -->P_0113   text
    form bdc_dynpro  using    value(p_0112)
                              value(p_0113).
    it_bdc-program = p_0112.
      it_bdc-dynpro = p_0113.
      it_bdc-dynbegin = 'X'.
      append it_bdc.
      clear it_bdc.
    endform.                    " bdc_dynpro
    *&      Form  bdc_field
          text
         -->P_0117   text
         -->P_0118   text
    form bdc_field  using    value(p_0117)
                             value(p_0118).
    it_bdc-fnam = p_0117.
      it_bdc-fval = p_0118.
      append it_bdc.
      clear it_bdc.
    endform.                    " bdc_field
    Regards
    fareedas

  • 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 data from XL sheet

    Hi,
    How to upload data from XL sheet to internal table , can u please provide the sample code.
    thanks
    krishna

    HI Krishna
    See this code where i had writen to UPLOAD A EXCEL SHEET AND again pass that to APPLICATION server
    i think it wil be very useful for you
    you can understand this very easily
    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.

  • Upload data from excel sheet into md61

    Hi Gurus,
                    Can anybody please tell me the solution like how to upload the data from excel sheet into the MD61
    if u suggest me to write an ABAP code then its fine or any other way would be great
    and can u also send me the abap code i would be thankful to all

    Hi,
    I can be done in 2 ways.
    1. Using LSMW you can upload your MD61 demand thru Excel sheet.
    2. You can use BDC to upload the demand from Excel. For this you need to take help from the ABAP. You need to record the macro usinf SHDB and the table maintenance will be taken care by the developer.
    For LSMW you need not depend on your developer, as a functional consultant you can do it yourself.
    Regards,
    V. Suresh

  • Upload data to excel sheet- make columns read only

    I would like to upload my internal table data-10 columns into excel sheet.
    I know how to upload my data into excel sheet.
    I want 2 of the columns in excel sheet to be read only out of the 10 columns.
    Is there any way that i can control the properties of excel sheet from SAP.
    Thanks in advance

    done

  • Creation of Q-Info record from data in exel sheet published in cfolder

    Hi
    Can any body help to give solution to create Q-Info Record from the data published in exel sheet under collaboration folder.
    This we require for triggering the event for creation of Q-Info from the data available in cfolder in exel sheet which will be furnished by the user who can access organisation's network i.e. R3 network.
    Thanks
    YPB

    Hello Rao,
    My objective is to create/change Q-Info Record through event trigger mechanish from the input data submitted by the vendor in excel sheet input format in cfolder.Details of steps are as follows:-
    1. Input data from the organisation like PO No. Item no, Material Code and all probable vendor code with details of vendor like address, city will be published in the cfolder in excel sheet. This sheet will be availble to vendor as Input data.\
    2. Input data will be updated by the vendor in following manner
        A- Material code of PO, Vendor code(Manufacturer code), Drawing No agreed between Organisation and vendor.
    3. System will pick up the data updated in excel sheet and will trigger the event for creation of Q-Info which will check first existence of the Record, if exists then system will change the record.
    How can I do this? Can any body help me. 
    YPB

  • Uploading data from Excel sheet into SAP.

    Dear All,
    I want to upload data existing in Excel sheet into SAP. Is there any possibility with the following requirements?
    1) Excel file contains serial numbers with different values.Like power(230Wp),Voc,Isc,Vmp and Imp.
    2) We need to upload the same data into SAP with validations.
    3) Validations are like no serial number should be repeated.
    4) And depending on the Power value, the serial number should be assigned to different batches.Eg:The batches are as follows:
         201 - 210
         210 - 220
         220 - 230
       and if the Pmax of the serial number is 205.It should be assigned to batch 201 - 210 .
    5) At present we are using MB31 to post the serial numbers which are existing in the flat file.
    Thanks and Regards,
    Varun Siddharth

    Hi,
    Refer to the following code:
    DATA: lv_filetype(10) TYPE c,
            lv_gui_sep TYPE c,
            lv_file_name TYPE string.
      lv_filetype = 'ASC'.
      lv_gui_sep = 'X'.
      lv_file_name = pa_dfile.
    FM call to upload file
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = lv_file_name
          filetype                = lv_filetype
          has_field_separator     = lv_gui_sep
        TABLES
          data_tab                = gi_zhralcon_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.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    The excel file must be a tab delimited file.
    Hope it helps.
    Regards,
    Rajesh Kumar

  • BDC for Uploading data from XL sheet with unknown order of fields

    Hi SAP Gurus,
    My requirement is as follows,
    A BDC is to be developed for uploading data from an XL sheet, but the problem here is , the order of fileds in the sheet can be changed .
    ie,  for example the fields in the XL sheet are :-
      matnr    maktx   menge  amount
    but the user can give as
      matnr  amount  menge  maktx
      or
    maktx   matnr  amount  menge
    how i can solve this problem.
    Thanks and Regards,
    pavan.

    Hi Pavan,
    You need to handle it by your self, you can create a dynamic table based on the file value.
    The field name pass from file with the record as a header, and based on the header name create your dynamic table.
    afterward you can pass your value to BDC.
    for creating dynamic table you can use this method
    call method cl_alv_table_create=>create_dynamic_table
      exporting
       i_style_table             =
        it_fieldcatalog           = it_field[]
       i_length_in_byte          =
      importing
        ep_table                  = dyn_tab
       e_style_fname             =
      exceptions
        generate_subpool_dir_full = 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.
    -Dhirendra

  • Uploading Datas From Spread sheet to Database Table

    I went to URL http://htmldb.oracle.com/pls/otn/f?p=38131:1 and download Vikas' CSV Upload application (a zip file) as well as the script to create the HTMLDB_TOOLS package.
    I follow the steps in the link : Re: File Browse, File Upload
    The application is created,Preview shows that the datas in the form of Excel sheet,but I cant upload the spread sheet.
    If I click the Upload button It shows the Error:
    ORA-01861: literal does not match format string
    Error ORA-01861: literal does not match format string
    OK
    Kindly let me know the reason for the error.
    Please help me to solve this Issue.
    Thanks in Advance
    by
    Suresh

    Hi Gussay,
    Thanks for ur reply.
    I found the error,it was due to the date format.
    If i drop the date column from the table and also from spread sheet,then it uploads.
    How can we load dates in spread sheet to database column.
    Thanks in advance
    Suresh

  • Uploading data from excel sheet

    HI,
         Can anyone provide me the details to upload vendor data from excel sheet to database through bdc?
    Thankyou.

    upload the excel file in your internal table and then use BDC to updated the database table.
    FM's to upload Excel:
    GUI_UPLOAD
    KCD_EXCEL_OLE_TO_INT_CONVERT
    ALSM_EXCEL_TO_INTERNALTABLE
    refer to the link:
    http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table-2/
    http://www.sap-img.com/abap/learning-bdc-programming.htm
    With luck,
    Pritam.

  • Uploading Data From Excel Sheet to SAP Database Tables

    Dear Friends,
    We are having an Excel Sheet with 90 different columns. Now we want only 2 of the columns to be uploaded in the database tables. So, Plz tell me which function module will be suitable for this. And plz help me with the code also.
    Thanks,
    Nishant Jain

    Hi Nishu,
    A sample for the same..
    data it_excel like table of ALSMEX_TABLINE with header line.
    here we retrieve only 2 cols directly..
    now itab will contain only 2 cols of all rows seperated by comma ..
    data str(1000).
    data itab like table of str with  header line.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = 'C:sample1.xls'
        i_begin_col                   = 1
        i_begin_row                   = 1
        i_end_col                     = 2
        i_end_row                     = 100
      tables
        intern                        =  it_excel
      LOOP AT it_excel.
        AT NEW row.
          CLEAR itab.
        ENDAT.
        IF itab IS INITIAL.
          MOVE it_excel-value TO itab.
        ELSE.
          CONCATENATE itab ',' it_excel-value INTO itab.
        ENDIF.
        AT END OF row.
          APPEND itab.
        ENDAT.
      ENDLOOP.
    regards
    satesh

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

  • Uploading data from excel sheet using BAPI (BAPI_ACC_MANUAL_ALLOC_POST)

    Hi,
    I am Using BAPI_ACC_MANUAL_ALLOC_POST (Manual cost allocation) for uploading into database. But i am getting the error "DO NOT USE COST ELEMENT xxxxxxxx FOR REPOST COSTS".
    can anyone explain me the possible reasons for  this error.
    any help will be rewarded.
    Thanks and Regards,
    Gautham Paspala

    Hi,
    Refer to the following code:
    DATA: lv_filetype(10) TYPE c,
            lv_gui_sep TYPE c,
            lv_file_name TYPE string.
      lv_filetype = 'ASC'.
      lv_gui_sep = 'X'.
      lv_file_name = pa_dfile.
    FM call to upload file
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = lv_file_name
          filetype                = lv_filetype
          has_field_separator     = lv_gui_sep
        TABLES
          data_tab                = gi_zhralcon_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.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    The excel file must be a tab delimited file.
    Hope it helps.
    Regards,
    Rajesh Kumar

Maybe you are looking for

  • ERROR MESSAGE:  ITUNES HAS STOPPED WORKING

    Hi guys n girls, i was wondering if antonehas had the same probs as me, and ill try to explain what happens, After buying an ipod classic 120gb, i downloaded itune 8 for the firs time and it installs, then windows installer asks you "wouldyou like to

  • How to change validity period of cost centre or activity type

    Hi How to change validity period for an Activity type or Cost centre? Can we change the validity period once created? regards Prakash

  • Best Practice on querying Data from Database

    Hello and I was wondering what is the preferred and best practice for querying data from an SQL database inside a JSP page. Is it using the JSTL library or another method? Thanks

  • File Adapter is not picking few files

    Hi All, I am facing some issue in file adapter. Below are the possible file format that we need to pick. File format sample 1: 865|FieldOrder|AK|620005168|1|Reject|Line Qty can not be Canceled,xyz,abc|The line has been shipped,fgh,hjk File format sam

  • I need a method for ignoring empty lines

    Hi to all, i need a method for ignoring empty lines when my program reades a file like that start of file print "xoxox" //ignore this line println"xaxaxa" //ignore this line end of file cheers