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(upload more than 1 transaction)

Former Member
0 Kudos
58

hi friends,

could u plz tell me how to upload more than one transaction in BDC.

send me some programs.

thanks in advance,

regards,

priya.s

3 REPLIES 3

former_member386202
Active Contributor
0 Kudos
40

Hi,

U can use both CT & session methods to upload two transaction.

But be careful about BDCDATA int table. better use 2 BDCDATA int tab for 2 transactions.

first use BDC_OPEN_GROUP

if u have same nos of records to upload loop at any int tab and read the SY-TABIX of the other.

then BDC_INSERT for Tcode1 with int tab BDCDATA1

then BDC_INSERT for Tcode 2 with int tab BDCDATA2

end of loop.

BDC_CLOSE_GROUP.

or u can do it by using two loops after BDC_OPEN_GROUP

in 1st loop BDC_INSERT for Tcode1 with int tab BDCDATA1

& in the 2nd loop BDC_INSERT for Tcode2 with int tab BDCDATA2

BDC_CLOSE_GROUP

Regards,

Prashant

Former Member
0 Kudos
40

Hi,

U can use both CT & session methods to upload two transaction.

.first use BDC_OPEN_GROUP

then BDC_INSERT for Tcode1 with int tab BDCDATA1

then BDC_INSERT for Tcode 2 with int tab BDCDATA2

end of loop.

BDC_CLOSE_GROUP.

For CT also use call transaction syntax two times each for one transaction.

regards,

swetha.

Former Member
0 Kudos
40

hi priya,

The below can give u some idea of bdc n transaction upload.

BDC Sample Program

&----


*& Report ZPROG65_11 *

*& *

&----


REPORT zprog65_11 .

TABLES : lfa1.

TYPES : BEGIN OF ven ,

lifnr LIKE rf02k-lifnr,

bukrs LIKE rf02k-bukrs ,

ekorg LIKE rf02k-ekorg,

ktokk LIKE rf02k-ktokk,

name1 LIKE lfa1-name1,

sortl LIKE lfa1-sortl,

land1 LIKE lfa1-land1,

spars LIKE lfa1-spras,

akont LIKE lfb1-akont,

fdgrv LIKE lfb1-fdgrv,

waers LIKE lfm1-waers,

anred LIKE lfa1-anred ,

END OF ven .

DATA : t_ven TYPE TABLE OF ven WITH HEADER LINE ,

t_bdc LIKE TABLE OF bdcdata WITH HEADER LINE .

DATA : v_file TYPE string ,

v_temp TYPE i ,

v_lifnr(10) TYPE n,

v_hdate LIKE sy-datum.

DATA : c_tcode LIKE sy-tcode ."value 'XK01'.

PARAMETERS : p_file(30) DEFAULT 'c:\vendor1_11.txt',

p_group LIKE apqi-groupid.

START-OF-SELECTION .

MOVE p_file TO v_file .

PERFORM file_upload TABLES t_ven USING v_file .

v_hdate = sy-datum - 1.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

  • DEST = FILLER8

group = p_group

holddate = v_hdate

keep = 'X'

user = sy-uname

*

  • IMPORTING

  • QID =

EXCEPTIONS

client_invalid = 1

destination_invalid = 2

group_invalid = 3

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.

LOOP AT t_ven .

clear lfa1.

v_temp = 0.

MOVE t_ven-lifnr TO v_lifnr.

SELECT SINGLE * FROM lfa1 INTO lfa1 WHERE lifnr =

v_lifnr.

IF sy-subrc = 0.

WRITE 😕 'found'.

v_temp = 1.

else.

write: / 'not found'.

ENDIF.

IF v_temp = 0.

c_tcode = 'xk01'.

PERFORM fill_ddc_table .

ELSEIF v_temp = 1.

c_tcode = 'xk02'.

PERFORM fill_bdc_table .

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = c_tcode

TABLES

dynprotab = t_bdc

EXCEPTIONS

internal_error = 1

OTHERS = 7.

REFRESH t_bdc .

ENDLOOP .

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

not_open = 1

queue_error = 2

OTHERS = 3.

&----


*& Form file_upload

&----


  • text

----


  • -->P_T_VEN text

  • -->P_V_FILE text

----


FORM file_upload TABLES p_tven STRUCTURE t_ven

USING p_vfile.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = p_vfile

filetype = 'ASC'

has_field_separator = 'X'

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = p_tven

EXCEPTIONS

file_open_error = 1

file_read_error = 2

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.

ENDFORM. " file_upload

&----


*& Form FILL_DDC_TABLE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_ddc_table .

  • SCREN 100

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0100'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'RF02K-LIFNR'.

t_bdc-fval = t_ven-lifnr .

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'RF02K-BUKRS'.

t_bdc-fval = t_ven-bukrs.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'RF02K-EKORG'.

t_bdc-fval = t_ven-ekorg.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'RF02K-KTOKK'.

t_bdc-fval = t_ven-ktokk.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 110

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0110'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFA1-NAME1'.

t_bdc-fval = t_ven-name1 .

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFA1-SORTL'.

t_bdc-fval = t_ven-sortl.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFA1-LAND1'.

t_bdc-fval = t_ven-land1.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFA1-SPRAS'.

t_bdc-fval = t_ven-spars.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 120

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0120'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 130

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0130'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '=ENTR'.

APPEND t_bdc. CLEAR t_bdc.

  • 210

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0210'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFB1-AKONT'.

t_bdc-fval = t_ven-akont .

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFB1-FDGRV'.

t_bdc-fval = t_ven-fdgrv.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 215

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0215'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 220

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0220'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 310

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0310'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFM1-WAERS'.

t_bdc-fval = t_ven-waers .

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 320

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0320'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '=UPDA'.

APPEND t_bdc. CLEAR t_bdc.

ENDFORM. "FILL_DDC_TABLE

" FILL_DDC_TABLE

&----


*& Form FILL_BDC_TABLE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_bdc_table .

  • SCREN 101

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0101'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'RF02K-LIFNR'.

t_bdc-fval = t_ven-lifnr .

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'RF02K-BUKRS'.

t_bdc-fval = t_ven-bukrs.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'RF02K-EKORG'.

t_bdc-fval = t_ven-ekorg.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 110

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0110'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'lfa1-anred'.

t_bdc-fval = t_ven-anred .

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFA1-NAME1'.

t_bdc-fval = t_ven-name1 .

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFA1-SORTL'.

t_bdc-fval = t_ven-sortl.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFA1-LAND1'.

t_bdc-fval = t_ven-land1.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'LFA1-SPRAS'.

t_bdc-fval = t_ven-spars.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '/00'.

APPEND t_bdc. CLEAR t_bdc.

  • 300

t_bdc-program = 'SAPMF02K'.

t_bdc-dynpro = '0300'.

t_bdc-dynbegin = 'X'.

APPEND t_bdc. CLEAR t_bdc.

t_bdc-fnam = 'BDC_OKCODE'.

t_bdc-fval = '=YES'.

APPEND t_bdc. CLEAR t_bdc.

ENDFORM. " FILL_BDC_TABLE

Reward if useful.

Thank you,

Regards.