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 query

Former Member
0 Kudos

<<This question has been asked and answered many times. Please search, read the documentation. This is not a training forum>>

Hi Team,

I am involved in a development project to develop a BDC program. I need to upload the data, so could anyone let me know the steps to upload a BDC data.

Thank you.

Best regards,

Vivek

Edited by: Matt on Dec 9, 2008 10:36 AM

7 REPLIES 7

Former Member
0 Kudos

Hi

Pls check the below code which gives you basic idea of BDC uploading data by two methods.

this prog is uploading data to XK01 transaction.

let me know any furthure quries.

REPORT yjay_bdc_split NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE bdcrecx1.

DATA : BEGIN OF it_itab OCCURS 0,

  • SCREEN 100

lifnr LIKE rf02k-lifnr,

bukrs LIKE rf02k-bukrs,

ekorg LIKE rf02k-ekorg,

ktokk LIKE rf02k-ktokk,

*SCREEN 110

anred LIKE lfa1-anred,

name1 LIKE lfa1-name1,

sortl LIKE lfa1-sortl,

ort01 LIKE lfa1-ort01,

pstlz LIKE lfa1-pstlz,

land1 LIKE lfa1-land1,

spras LIKE lfa1-spras,

*SCREEN 130

banks(150) TYPE c,

bankl(150) TYPE c,

bankn(150) TYPE c,

*SCREEN 210

akont LIKE lfb1-akont,

fdgrv LIKE lfb1-fdgrv,

*SCREEN 310

waers LIKE lfm1-waers,

END OF it_itab.

DATA: BEGIN OF banks OCCURS 0,

banks LIKE lfbk-banks,

END OF banks.

DATA: BEGIN OF bankl OCCURS 0,

bankl LIKE lfbk-bankl,

END OF bankl.

DATA: BEGIN OF bankn OCCURS 0,

bankn LIKE lfbk-bankn,

END OF bankn.

DATA: fld(20) TYPE c,

cnt(2) TYPE c.

START-OF-SELECTION.

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = 'C:\BDC30102008.txt'

filetype = 'ASC'

has_field_separator = 'X'

CHANGING

data_tab = it_itab[].

PERFORM open_group.

LOOP AT it_itab[] INTO it_itab.

REFRESH bdcdata.

REFRESH: banks ,bankl,bankn.

SPLIT it_itab-banks AT ',' INTO TABLE banks.

SPLIT it_itab-bankl AT ',' INTO TABLE bankl.

SPLIT it_itab-bankn AT ',' INTO TABLE bankn.

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-LIFNR'

it_itab-lifnr.

PERFORM bdc_field USING 'RF02K-BUKRS'

it_itab-bukrs.

PERFORM bdc_field USING 'RF02K-EKORG'

it_itab-ekorg.

PERFORM bdc_field USING 'RF02K-KTOKK'

it_itab-ktokk.

PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-SPRAS'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'LFA1-ANRED'

it_itab-anred.

PERFORM bdc_field USING 'LFA1-NAME1'

it_itab-name1.

PERFORM bdc_field USING 'LFA1-SORTL'

it_itab-sortl.

PERFORM bdc_field USING 'LFA1-ORT01'

it_itab-ort01.

PERFORM bdc_field USING 'LFA1-PSTLZ'

it_itab-pstlz.

PERFORM bdc_field USING 'LFA1-LAND1'

it_itab-land1.

PERFORM bdc_field USING 'LFA1-SPRAS'

it_itab-spras.

PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-KUNNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

DATA: x(2) ,n(2) TYPE n.

n = 0.

LOOP AT banks.

n = n + 1.

ENDLOOP.

x = 1.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'LFBK-BANKS(01)'

'IN'.

cnt = 1.

DO n TIMES.

IF cnt > 5.

PERFORM bdc_field USING 'BDC_CURSOR'

'=P+'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKN(01)'.

cnt = 1.

ENDIF.

LOOP AT banks FROM x TO x.

CONCATENATE 'LFBK-BANKS(' cnt ')' INTO fld.

PERFORM bdc_field USING fld banks-banks.

ENDLOOP.

LOOP AT bankl FROM x TO x.

CONCATENATE 'LFBK-BANKL(' cnt ')' INTO fld.

PERFORM bdc_field USING fld bankl-bankl.

ENDLOOP.

LOOP AT bankn FROM x TO x.

CONCATENATE 'LFBK-BANKN(' cnt ')' INTO fld.

PERFORM bdc_field USING fld bankn-bankn.

ENDLOOP.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

cnt = cnt + 1.

x = x + 1.

ENDDO.

*perform bdc_dynpro using 'SAPLBANK' '0100'.

*perform bdc_field using 'BDC_CURSOR'

  • 'BNKA-BANKA'.

*perform bdc_field using 'BDC_OKCODE'

  • '=ENTR'.

*perform bdc_field using 'BNKA-BANKA'

  • 'SBH'.

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-FDGRV'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'LFB1-AKONT'

it_itab-akont.

PERFORM bdc_field USING 'LFB1-FDGRV'

it_itab-fdgrv.

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 'SAPMF02K' '0310'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFM1-WAERS'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'LFM1-WAERS'

it_itab-waers.

PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF02K-LIFNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=YES'.

PERFORM bdc_transaction USING 'XK01'.

ENDLOOP.

PERFORM close_group.

Former Member

GauthamV
Active Contributor
0 Kudos

SEARCH in SCN before posting basic questions or else your id may be locked.

There are so many posts with examples so search for them.

if you just mention * bdc upload* in search option you will get lot of posts.

Former Member
0 Kudos

Hi,

For a BDC upload you need to write a program which created BDC sessions.

Steps:

1. Work out the transaction you would use to create the data manually.

2. Use transaction SHDB to record the creation of one material master data.

Click the New recording button or the Menu - Recording - Create

3. Save the recording, and then go back a screen and go to the overview.

4. Select the recording and click on Edit - Create Program. Give the program a Z name, and select transfer from recording.

5. Edit the program. You will see that all the data you entered is hard-coded into the program. You need to make the following changes:

5.1 After the start-of-selection, Call gui_upload to upload the file (the excel file needs to be saved as TAB separated).

5.2 After the open-group, Loop on the uploaded data. For each line, perform validation checks on the data, then modify the perform bdc_field commands to use the file data.

5.3. After perform bdc_transaction, add the endloop.

Execute the program. It will have options to create a batch session or to process directly.

Regards,

Indu

0 Kudos

Bad move buddy...

Now you can DEFINATELY expect your ID to be deleted.

pk

former_member184657
Active Contributor
0 Kudos

>

> I am involved in a development project to...

And according to this thread

you are working in an Upgradation Project.

Looks like you are confused. Or are You??

And as Gautam said.. SEARCH if you dont want your id to get deleted.

Reported to SCN

pk

Former Member
0 Kudos

Hi,

1.First u know for which transaction u want to do BDC,

2. Then go to that Transaction and find out all mandatiry fields......in all screen of that transaction.

now u hav any test data or u ask ur fun consultant giv some input for that transation include all mandetory field...

3. now Use transaction SHDB to record the Transaction with all mandotary fields. for this goto t.code SHDB in that

Click the New recording button or the Menu - Recording - Create

4. Save the recording,

5. then go back a screen and go to the overview.

6.Select the recording -> Click on Program. Give the program a Z name, and select transfer from recording.

7. Edit the program. You will see that all the data you entered is hard-coded into the program.

8. Declare one internal table with how many field in ur flate file.

9. After the start-of-selection, Call gui_upload to upload the file (the excel file needs to be saved as TAB separated).

10.ur flate file upload to u r internal table

11 After the open-group, Loop on the uploaded data. For each line, perform validation checks on the data, then modify the perform bdc_field commands to use the file data. delete Hard code and writr internaltable-field like that for all entreis....

12. After perform bdc_transaction, add the endloop.

Execute the program. It will have options to create a batch session or to process directly.

13. then goto SM35 for run ur program..

Hope this is useful to u....