Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BDC Program for customer master data

Former Member
0 Kudos

Hi Experts,

Please provide me the BDC Program to upload the customer master data.....

Thanks in advance,

Saleem.

1 REPLY 1

Former Member
0 Kudos

See the BDC sample code Customer Master Upload:

report ZSDBDCP_CUSTOMER_VD01

no standard page heading

line-size 255.

----


*Includes

----


include zbdcrecx1.

----


*Internal Tables

----


*-- Internal Table to hold customer data

Data : begin of it_customer occurs 0,

f1(4), " Sales Org.

f2(2), " Distribution Channel

f3(2), " Division

f4(4), " Acct Group

f5(30), " Tittle

f6(40), " Name1

f7(40), " Name2

f8(20), " Search Term 1

f9(20), " Search Term 2

f10(10), " Postal Code

f11(40), " City

f12(3), " Country

f13(2), " Language

f14(2), " Shipping Condition

end of it_customer.

----


*Start of selection

----


start-of-selection.

Clear it_customer.

Refresh it_customer.

*To Upload Flat file

  • CALL FUNCTION 'UPLOAD'

  • EXPORTING

  • filename = 'C:\WINDOWS\Desktop\cst_vd01.txt'

  • filetype = 'DAT'

  • TABLES

  • data_tab = it_customer

  • EXCEPTIONS

  • conversion_error = 1

  • invalid_table_width = 2

  • invalid_type = 3

  • no_batch = 4

  • unknown_error = 5

  • gui_refuse_filetransfer = 6

  • OTHERS = 7.

WRITE : / 'Upload of Customer Ext. from ', P_FNAME, ' on ', SY-DATUM.

perform open_group.

OPEN DATASET P_FNAME FOR INPUT IN TEXT MODE.

if sy-subrc ne 0.

write : / 'File could not be uploaded.. Check file name.'.

stop.

endif.

CLEAR : IT_CUSTOMER[], IT_CUSTOMER.

DO.

READ DATASET P_FNAME INTO V_STR.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

  • write v_str.

  • translate v_str using '#/'.

SPLIT V_STR AT ',' INTO IT_CUSTOMER-F1 IT_CUSTOMER-F2 IT_CUSTOMER-F3

IT_CUSTOMER-F4 IT_CUSTOMER-F5 IT_CUSTOMER-F6

IT_CUSTOMER-F7 IT_CUSTOMER-F8 IT_CUSTOMER-F9

IT_CUSTOMER-F10

IT_CUSTOMER-F11 IT_CUSTOMER-F12

IT_CUSTOMER-F13 IT_CUSTOMER-F14.

APPEND IT_CUSTOMER.

CLEAR IT_CUSTOMER.

ENDDO.

IF IT_CUSTOMER[] IS INITIAL.

WRITE : / 'No data found to upload'.

STOP.

ENDIF.

loop at it_customer.

perform bdc_dynpro using 'SAPMF02D' '0107'.

perform bdc_field using 'BDC_CURSOR'

'USE_ZAV'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02D-VKORG'

it_customer-f1.

perform bdc_field using 'RF02D-VTWEG'

it_customer-f2.

perform bdc_field using 'RF02D-SPART'

it_customer-f3.

perform bdc_field using 'RF02D-KTOKD'

it_customer-f4.

perform bdc_field using 'RF02D-REF_KUNNR'

''.

perform bdc_field using 'RF02D-REF_VKORG'

''.

perform bdc_field using 'RF02D-REF_VTWEG'

''.

perform bdc_field using 'RF02D-REF_SPART'

''.

perform bdc_field using 'USE_ZAV'

'X'.

perform bdc_dynpro using 'SAPMF02D' '0111'.

perform bdc_field using 'BDC_OKCODE'

'=VW'.

perform bdc_field using 'BDC_CURSOR'

'ADDR1_DATA-POST_CODE1'.

perform bdc_field using 'SZA1_D0100-TITLE_MEDI'

it_customer-f5.

perform bdc_field using 'ADDR1_DATA-NAME1'

it_customer-f6.

perform bdc_field using 'ADDR1_DATA-NAME2'

it_customer-f7.

perform bdc_field using 'ADDR1_DATA-SORT1'

it_customer-f8.

perform bdc_field using 'ADDR1_DATA-SORT2'

it_customer-f9.

perform bdc_field using 'ADDR1_DATA-POST_CODE1'

it_customer-f10.

perform bdc_field using 'ADDR1_DATA-CITY1'

it_customer-f11.

perform bdc_field using 'ADDR1_DATA-COUNTRY'

it_customer-f12.

perform bdc_field using 'ADDR1_DATA-LANGU'

it_customer-f13.

perform bdc_dynpro using 'SAPMF02D' '0120'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'=VW'.

perform bdc_dynpro using 'SAPMF02D' '0125'.

perform bdc_field using 'BDC_CURSOR'

'KNA1-NIELS'.

perform bdc_field using 'BDC_OKCODE'

'=VW'.

perform bdc_dynpro using 'SAPMF02D' '0340'.

perform bdc_field using 'BDC_CURSOR'

'KNVA-ABLAD(01)'.

perform bdc_field using 'BDC_OKCODE'

'=VW'.

perform bdc_dynpro using 'SAPMF02D' '0370'.

perform bdc_field using 'BDC_CURSOR'

'KNEX-LNDEX(01)'.

perform bdc_field using 'BDC_OKCODE'

'=VW'.

perform bdc_field using 'KNA1-CIVVE'

'X'.

perform bdc_dynpro using 'SAPMF02D' '0360'.

perform bdc_field using 'BDC_CURSOR'

'KNVK-NAMEV(01)'.

perform bdc_field using 'BDC_OKCODE'

'=VW'.

perform bdc_dynpro using 'SAPMF02D' '0310'.

perform bdc_field using 'BDC_CURSOR'

'KNVV-BEGRU'.

perform bdc_field using 'BDC_OKCODE'

'=VW'.

perform bdc_dynpro using 'SAPMF02D' '0315'.

perform bdc_field using 'BDC_CURSOR'

'KNVV-ANTLF'.

perform bdc_field using 'BDC_OKCODE'

'=VW'.

perform bdc_field using 'KNVV-KZAZU'

'X'.

perform bdc_field using 'KNVV-VSBED'

it_customer-f14.

perform bdc_field using 'KNVV-ANTLF'

''.

perform bdc_dynpro using 'SAPMF02D' '0324'.

perform bdc_field using 'BDC_CURSOR'

'KNVP-PARVW(01)'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

*--To call Transaction

perform bdc_transaction using 'VD01'.

endloop.

perform close_group.