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: 

How to loop in a BDC?

Former Member
0 Kudos
984

Dear Experts

I have a series of transactions in T-Code F-02, where i am making more than one entry calling the same screen for journal entries? Is it possible if so how do i do it?

Tatenda Chaibva

3 REPLIES 3

Former Member
0 Kudos
256

Hi,

try SHDB and generate a report, than you can see if it works.

Regards, Dieter

Former Member
0 Kudos
256

Check this sample code..........

FORM populate_data .

data: lv_po(35) type c,

gv_num(3) type n value '001',

gv_fname1(132) type c,

gv_fname2(132) type c,

gv_fname3(132) type c,

GV_FNAME4(132) TYPE C.

Sort gt_sdata by BSTKD POSNR.

describe table gt_sdata lines l1_num.

Loop at gt_sdata INTO gs_sdata.

if lv_po ne gs_sdata-bstkd.

lv_po = gs_sdata-bstkd.

clear: gv_fname1, gv_fname2, gv_fname3, GV_FNAME4.

perform bdc_dynpro using 'SAPMV45A' '0101'.

perform bdc_field using 'BDC_CURSOR' 'VBAK-AUART'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'VBAK-AUART' 'OR'.

perform bdc_field using 'VBAK-VKORG' '300'.

perform bdc_field using 'VBAK-VTWEG' '20'.

perform bdc_field using 'VBAK-SPART' '01'.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE' '=KKAU'.

perform bdc_field using 'VBKD-BSTKD' gs_sdata-BSTKD.

perform bdc_field using 'VBKD-BSTDK' gs_sdata-BSTDK.

perform bdc_field using 'KUAGV-KUNNR' '1195'.

perform bdc_field using 'KUWEV-KUNNR' gs_sdata-KUNNR1.

perform bdc_field using 'RV45A-KETDAT' GS_SDATA-KETDAT.

perform bdc_field using 'RV45A-KPRGBZ' 'D'.

perform bdc_field using 'RV45A-DWERK' 'INDY'.

if gv_num = gs_sdata-POSNR.

concatenate 'RV45A-KWMENG(' gv_num ')' INTO GV_FNAME1.

concatenate 'VBAP-POSNR(' gv_num ')' INTO GV_FNAME2.

concatenate 'RV45A-MABNR(' gv_num ')' INTO GV_FNAME3.

concatenate 'KOMV-KBETR(' gv_num ')' INTO GV_FNAME4.

perform bdc_field using 'BDC_CURSOR' 'GV_FNAME1'.

perform bdc_field using GV_FNAME1 gs_sdata-POSNR.

perform bdc_field using GV_FNAME2 gs_sdata-MABNR.

perform bdc_field using GV_FNAME3 gs_sdata-KWMENG.

perform bdc_field using GV_FNAME4 gs_sdata-KBETR.

gv_num = gv_num + 1.

  • APPEND gs_sdata.

  • Clear gs_sdata.

endif.

perform bdc_dynpro using 'SAPMV45A' '4002'.

perform bdc_field using 'BDC_OKCODE' '=SICH'.

perform bdc_field using 'BDC_CURSOR' 'VBAK-GWLDT'.

perform bdc_field using 'VBAK-AUDAT' '08/24/2006'.

perform bdc_field using 'VBAK-VKBUR' '30'.

perform bdc_field using 'VBAK-GWLDT' GS_SDATA-GWLDT.

perform bdc_field using 'VBAK-WAERK' 'USD'.

perform bdc_field using 'VBKD-PRSDT' '08/24/2006'.

perform bdc_field using 'VBKD-KDGRP' '03'.

clear gs_sdata.

continue.

endif.

AT END of BSTKD.

perform bdc_transaction using 'VA01'.

clear gs_sdata.

ENDAT.

Endloop.

ENDFORM. " populate_data

Regards,

Pavan

0 Kudos
256

Well i want to recall the same screen before i end the transaction! I don't see that happening in the program, for example i want to back to

perform bdc_dynpro using 'SAPMV45A' '4001'.

in your program, after going thru the program!

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE' '=KKAU'.

perform bdc_field using 'VBKD-BSTKD' gs_sdata-BSTKD.

perform bdc_field using 'VBKD-BSTDK' gs_sdata-BSTDK.

perform bdc_field using 'KUAGV-KUNNR' '1195'.

perform bdc_field using 'KUWEV-KUNNR' gs_sdata-KUNNR1.

perform bdc_field using 'RV45A-KETDAT' GS_SDATA-KETDAT.

perform bdc_field using 'RV45A-KPRGBZ' 'D'.

perform bdc_field using 'RV45A-DWERK' 'INDY'.