Skip to Content
author's profile photo Former Member
Former Member

bdc upload from excel

hai

any body tell how to upload data from excel to sap from bdc.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 06, 2007 at 08:57 AM

    use GUI_UPLOAD FM ..

    Refer

    http://www.sapdevelopment.co.uk/file/file_uptabpc.htm

    Regards,

    Santosh

    Message was edited by:

    Santosh Kumar Patha

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 06, 2007 at 08:59 AM

    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.

    PERFORM PROCESS_DATA.

    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 .

    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

    do reward if it helps,

    priya.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 06, 2007 at 09:00 AM

    Hi,

    Convert the Excel file into Tab Delimited Text file and use the function module GUI_upload and give the file path name: Record the transaction in SHDB and create the program and use the fiel.

    See the sample code:

    REPORT zmm_vendor_master_upload

    NO STANDARD PAGE HEADING

    LINE-SIZE 255.

    ***********************************************************************

    • ABAP Name : ZMM_VENDOR_MASTER_UPLOAD

    • Description : This Program is used to Upload the Vendor Master.

    ***********************************************************************

    • Standard Include for Selection Screen

    INCLUDE bdcrecx1.

    • Internal Table for Upload Data

    DATA: BEGIN OF i_vendor OCCURS 0,

    bukrs(004), " Company Code

    ekorg(004), " Purchase Orgn

    ktokk(004), " Account Group

    • Address Screen

    anred(015), " Title

    name1(035), " Name1

    sortl(010), " Sort Field

    name2(035), " Name2

    name3(035), " Contact Person1

    name4(035), " Contact Person 2

    stras(035), " Street

    pfach(010), " PO Box

    ort01(035), " City

    pstlz(010), " Postal Code

    land1(003), " Country

    spras(002), " Language

    telf1(016), " Telephone No

    telfx(031), " Fax Number

    lfurl(132), " URL-Mail Id

    • Material Group Characteristics

    • klart(003), " Class Type '010'

    • class(018), " Class 'Vendor'

    • mname_01(030), " Characteristic

    • mname_02(030), " Characteristic

    • mname_03(030), " Characteristic

    mwert_01(030), " Charct.Value

    mwert_02(030), " Charct.Value

    mwert_03(030), " Charct.Value

    • Control Data

    emnfr(010), " Manufact.Part No

    • Bank Details

    banks_01(003), " Country of Bank1

    banks_02(003), " Country of Bank2

    bankl_01(015), " Bank Key of 1

    bankl_02(015), " Bank Key of 2

    bankn_01(018), " Account No Bank1

    bankn_02(018), " Account No Bank2

    • Accounting Info

    akont(010), " Reconcillation Account

    zuawa(003), " Sort Key

    fdgrv(010), " Cash Management Group

    • Payment Transactions

    zterm(004), " Payment terms

    • reprf(001), " Check Double Inv.

    zwels(010), " Payment Method

    hbkid(005), " House Bank

    • xpore(001), " Individ.Payment

    • Correspondence

    mahns(001), " Dunning Level

    xausz(001), " Account Statement

    • Withholding Tax Details

    qland(003), " Withholding Tax Country

    witht_01(002), " WH tax Type

    • wt_withcd(002), " WH Tax Code

    • wt_subjct(001), " Indicator:WH Tax

    • Purchasing Data

    waers(005), " Currency

    zterm1(004), " Payment Terms

    END OF i_vendor.

    • Data Variables & Constants

    CONSTANTS : c_x VALUE 'X'. " Flag

    • Paramters

    PARAMETERS: p_file LIKE ibipparms-path. " Filename

    • At selection-screen on Value Request for file Name

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

    • Get the F4 Values for the File

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    program_name = syst-cprog

    dynpro_number = syst-dynnr

    IMPORTING

    file_name = p_file.

    • Start of Selection

    START-OF-SELECTION.

    • Open the BDC Session

    PERFORM open_group.

    • Upload the File into internal Table

    CALL FUNCTION 'UPLOAD'

    EXPORTING

    filename = p_file

    filetype = 'DAT'

    TABLES

    data_tab = i_vendor

    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.

    • Upload the Data from Internal Table

    LOOP AT i_vendor.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RF02K-KTOKK'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'RF02K-BUKRS'

    i_vendor-bukrs.

    PERFORM bdc_field USING 'RF02K-EKORG'

    i_vendor-ekorg.

    PERFORM bdc_field USING 'RF02K-KTOKK'

    i_vendor-ktokk.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFA1-SPRAS'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=KLAS'.

    PERFORM bdc_field USING 'LFA1-ANRED'

    i_vendor-anred.

    PERFORM bdc_field USING 'LFA1-NAME1'

    i_vendor-name1.

    PERFORM bdc_field USING 'LFA1-SORTL'

    i_vendor-sortl.

    PERFORM bdc_field USING 'LFA1-NAME2'

    i_vendor-name2.

    PERFORM bdc_field USING 'LFA1-NAME3'

    i_vendor-name3.

    PERFORM bdc_field USING 'LFA1-NAME4'

    i_vendor-name4.

    PERFORM bdc_field USING 'LFA1-STRAS'

    i_vendor-stras.

    PERFORM bdc_field USING 'LFA1-PFACH'

    i_vendor-pfach.

    PERFORM bdc_field USING 'LFA1-ORT01'

    i_vendor-ort01.

    PERFORM bdc_field USING 'LFA1-PSTLZ'

    i_vendor-pstlz.

    PERFORM bdc_field USING 'LFA1-LAND1'

    i_vendor-land1.

    PERFORM bdc_field USING 'LFA1-SPRAS'

    i_vendor-spras.

    PERFORM bdc_field USING 'LFA1-TELF1'

    i_vendor-telf1.

    PERFORM bdc_field USING 'LFA1-TELFX'

    i_vendor-telfx.

    PERFORM bdc_field USING 'LFA1-LFURL'

    i_vendor-lfurl.

    PERFORM bdc_dynpro USING 'SAPLCLCA' '0602'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RMCLF-KLART'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTE'.

    PERFORM bdc_field USING 'RMCLF-KLART'

    '010'. "i_vendor-klart.

    PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RMCLF-CLASS(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=AUSW'.

    PERFORM bdc_field USING 'RMCLF-CLASS(01)'

    'Vendor'."i_vendor-class.

    PERFORM bdc_dynpro USING 'SAPLCTMS' '0109'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RCTMS-MWERT(03)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=BACK'.

    PERFORM bdc_field USING 'RCTMS-MNAME(01)'

    'MATERIALGROUP'." i_vendor-mname_01.

    PERFORM bdc_field USING 'RCTMS-MNAME(02)'

    'MATERIALGROUP'." i_vendor-mname_02.

    PERFORM bdc_field USING 'RCTMS-MNAME(03)'

    'MATERIALGROUP'." i_vendor-mname_03.

    PERFORM bdc_field USING 'RCTMS-MWERT(01)'

    i_vendor-mwert_01.

    PERFORM bdc_field USING 'RCTMS-MWERT(02)'

    i_vendor-mwert_02.

    PERFORM bdc_field USING 'RCTMS-MWERT(03)'

    i_vendor-mwert_03.

    PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RMCLF-CLASS(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENDE'.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFA1-ANRED'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFA1-EMNFR'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_field USING 'LFA1-EMNFR'

    i_vendor-emnfr.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFBK-BANKN(02)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_field USING 'LFBK-BANKS(01)'

    i_vendor-banks_01.

    PERFORM bdc_field USING 'LFBK-BANKS(02)'

    i_vendor-banks_02.

    PERFORM bdc_field USING 'LFBK-BANKL(01)'

    i_vendor-bankl_01.

    PERFORM bdc_field USING 'LFBK-BANKL(02)'

    i_vendor-bankl_02.

    PERFORM bdc_field USING 'LFBK-BANKN(01)'

    i_vendor-bankn_01.

    PERFORM bdc_field USING 'LFBK-BANKN(02)'

    i_vendor-bankn_02.

    • PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

    • PERFORM bdc_field USING 'BDC_CURSOR'

    • 'LFBK-BANKS(01)'.

    • PERFORM bdc_field USING 'BDC_OKCODE'

    • '=VW'.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFB1-FDGRV'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_field USING 'LFB1-AKONT'

    i_vendor-akont.

    PERFORM bdc_field USING 'LFB1-ZUAWA'

    i_vendor-zuawa.

    PERFORM bdc_field USING 'LFB1-FDGRV'

    i_vendor-fdgrv.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFB1-XPORE'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_field USING 'LFB1-ZTERM'

    i_vendor-zterm.

    PERFORM bdc_field USING 'LFB1-REPRF'

    c_x. "i_vendor-reprf.

    PERFORM bdc_field USING 'LFB1-ZWELS'

    i_vendor-zwels.

    PERFORM bdc_field USING 'LFB1-HBKID'

    i_vendor-hbkid.

    PERFORM bdc_field USING 'LFB1-XPORE'

    c_x. "i_vendor-xpore.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFB5-MAHNS'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_field USING 'LFB5-MAHNS'

    i_vendor-mahns.

    PERFORM bdc_field USING 'LFB1-XAUSZ'

    i_vendor-xausz.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0610'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFBW-WT_SUBJCT(01)'.

    PERFORM bdc_field USING 'LFB1-QLAND'

    i_vendor-qland.

    PERFORM bdc_field USING 'LFBW-WITHT(01)'

    i_vendor-witht_01.

    • PERFORM bdc_field USING 'LFBW-WT_WITHCD(01)'

    • i_vendor-wt_withcd.

    PERFORM bdc_field USING 'LFBW-WT_SUBJCT(01)'

    c_x.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'LFM1-ZTERM'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_field USING 'LFM1-WAERS'

    i_vendor-waers.

    PERFORM bdc_field USING 'LFM1-ZTERM'

    i_vendor-zterm1.

    PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RF02K-LIFNR'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=VW'.

    PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=YES'.

    • Call the Transaction

    PERFORM bdc_transaction USING 'XK01'.

    ENDLOOP.

    • Close the BDc Session

    PERFORM close_group.

    Regards,

    Anji

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 06, 2007 at 09:00 AM

    you can even use 'TEXT_CONVERT_XLS_TO_SAP'

    Refer

    http://www.sapdevelopment.co.uk/file/file_upexcel.htm

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 06, 2007 at 09:02 AM

    hi Sudhan,

    U can upload Data from Excel however i would suggest u can save the document in CSV format and call Funtion Gui_upload and pass the parameters.

    the Function Module is shown Below

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = la_file

    • FILETYPE = 'ASC'

    has_field_separator = '|'

    • HEADER_LENGTH = 0

    • READ_BY_LINE = 'X'

    • DAT_MODE = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • CHECK_BOM = ' '

    • VIRUS_SCAN_PROFILE =

    • NO_AUTH_CHECK = ' '

    • IMPORTING

    • FILELENGTH =

    • HEADER =

    TABLES

    data_tab = itab1

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

    in the Above code La_file is the location of the file (excel) and itab is the internal table where the data is populated from the excel

    Hope this is useful to u

    Reagrds

    Srinivas

    • Reward Points if Useful.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.