Skip to Content
0
Former Member
Jul 14, 2006 at 09:51 AM

Run a BDC for multiple times ........its urgent so plz give any solution

49 Views

hi friends,

i have two intenal table

one->

DATA: BEGIN OF it_bseg OCCURS 0,

bukrs LIKE bseg-bukrs,

belnr LIKE bseg-belnr,

gjahr LIKE bseg-gjahr,

kostl LIKE bseg-kostl,

koart LIKE bseg-koart,

buzei LIKE bseg-buzei,

paobjnr LIKE bseg-paobjnr,

prctr LIKE bseg-prctr,

wrbtr LIKE bseg-wrbtr,

END OF it_bseg.

second->

DATA: BEGIN OF ws_bsid OCCURS 0,

bukrs LIKE bsid-bukrs,

kunnr LIKE bsid-kunnr,

gjahr LIKE bsid-gjahr,

belnr LIKE bsid-belnr,

blart LIKE bsid-blart,

buzei LIKE bsid-buzei,

shkzg LIKE bsid-shkzg,

wrbtr LIKE bsid-wrbtr,

budat LIKE bsid-budat,

bldat LIKE bsid-bldat,

rstgr LIKE bsid-rstgr,

  • rebzg LIKE bsid-rebzg,

xref1 LIKE bsid-xref1,

zfbdt LIKE bsid-zfbdt,

zbd1t LIKE bsid-zbd1t,

END OF ws_bsid.

my bdc is ->

LOOP AT WS_BSID.

REFRESH bdc_tab.

PERFORM bdc_dynpro USING 'SAPMF05A' '0122'.

PERFORM bdc_field USING 'BDC_OKCODE' '=SL'.

PERFORM bdc_field USING 'BKPF-BLDAT' wsdatum.

PERFORM bdc_field USING 'BKPF-BUKRS' ws_bsid-bukrs.

IF ws_bsid-rstgr = 'Y15'. "uncomment this

PERFORM bdc_field USING 'BKPF-BLART' 'W4'.

ELSE. "uncomment this

PERFORM bdc_field USING 'BKPF-BLART' 'W1'.

ENDIF. "uncomment this

IF ws_bsid-bukrs = '3000'. "uncomment this

PERFORM bdc_field USING 'BKPF-WAERS' 'CAD'.

ELSE. "uncomment this

PERFORM bdc_field USING 'BKPF-WAERS' 'USD'.

ENDIF. "uncomment this

PERFORM bdc_field USING 'BKPF-BKTXT' text.

PERFORM bdc_field USING 'RF05A-AUGTX' sy-datum.

PERFORM bdc_field USING 'FS006-DOCID' '*'.

PERFORM bdc_field USING 'RF05A-XPOS1(05)' 'X'.

*LOOP AT it_bseg. "change added"

IF ws_bsid-shkzg = 'S'. "uncomment this "R3DK906956

PERFORM bdc_field USING 'RF05A-NEWBS' '40'.

ELSEIF ws_bsid-shkzg = 'H'. "uncomment this "R3DK906956

PERFORM bdc_field USING 'RF05A-NEWBS' '50'. "R3DK906956

ENDIF. "uncomment this "R3DK906956

*endloop.

if ws_bsid-bukrs = '3000' and ws_bsid-rstgr = 'Z13'.

PERFORM bdc_field USING 'RF05A-NEWKO' '3409001'.

elseif ws_bsid-bukrs = '3000' and ws_bsid-rstgr = 'Z15'.

PERFORM bdc_field USING 'RF05A-NEWKO' '2201100'.

else.

PERFORM bdc_field USING 'RF05A-NEWKO' '5609000'.

endif.

----


  • UNCOMMENT THIS PART IF REQUIRED

IF ws_bsid-rstgr = space.

ws_bsid-rstgr = 'Z72'.

ENDIF.

READ TABLE it_t030 WITH KEY

bwmod = ws_bsid-rstgr.

  • BINARY SEARCH.

----


  • Loop at it_bseg.

IF sy-subrc = 0.

MOVE it_t030-konts TO ws_konts.

PERFORM bdc_field USING 'RF05A-NEWKO' ws_konts.

ENDIF.

  • endloop.

Loop at it_bseg.

MOVE IT_BSEG-WRBTR TO WS_BSID-WRBTR.

ENDLOOP.

CLEAR ws_wrbtr.

ws_wrbtr = WS_BSID-wrbtr.

  • append bdc_tab.

LOOP AT it_bseg.

flag1 = flag1 + 1.

read table it_bseg index flag .

PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.

PERFORM bdc_field USING 'BSEG-WRBTR' ws_wrbtr.

endloop.

  • PERFORM bdc_field USING 'DKACB-FMORE' 'X'.

PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLKACB'.

PERFORM bdc_field USING 'BDC_OKCODE' '=SL'.

PERFORM bdc_field USING 'BSEG-WRBTR' ws_wrbtr.

  • PERFORM bdc_field USING 'DKACB-FMORE' 'X'.

PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLKACB'.

PERFORM bdc_field USING 'BDC_OKCODE' '=SL'.

  • endloop.

----


  • READ TABLE it_skb1 WITH KEY

  • bukrs = ws_bsid-bukrs

  • saknr = ws_konts. "UNCOMMENT THESE LINE

  • BINARY SEARCH.

----


READ TABLE it_skb1 WITH KEY

bukrs = it_bseg-bukrs

saknr = ws_konts.

  • BINARY SEARCH.

IF sy-subrc = 0.

MOVE it_skb1-fstag TO ws_fstag.

ENDIF.

IF ws_fstag = 'FS12'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLKACB'.

PERFORM bdc_field USING 'BDC_OKCODE' '=COBL_XERGO'.

IF ws_bsid-rstgr = 'Z99'.

IF sy-host = 'r1p10'.

PERFORM bdc_dynpro USING 'SAPLKEAK' '0300'.

PERFORM bdc_field USING 'RKEAK-FIELD(02)' 'X400'.

PERFORM bdc_field USING 'RKEAK-FIELD(15)' '0199'.

PERFORM bdc_field USING 'BDC_OKCODE' '=WEIT'.

ELSE.

PERFORM bdc_dynpro USING 'SAPLKEAK' '0300'.

PERFORM bdc_field USING 'RKEAK-FIELD(01)' 'X400'.

PERFORM bdc_field USING 'RKEAK-FIELD(04)' '0199'.

PERFORM bdc_field USING 'BDC_OKCODE' '=WEIT'.

ENDIF.

ELSE.

PERFORM bdc_dynpro USING 'SAPLKEAK' '0300'.

PERFORM bdc_field USING 'RKEAK-FIELD(01)' 'X400'.

PERFORM bdc_field USING 'RKEAK-FIELD(04)' '3000'.

PERFORM bdc_field USING 'BDC_OKCODE' '=WEIT'.

ENDIF.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

  • PERFORM bdc_field USING 'DKACB-XERGO' 'X'.

PERFORM bdc_field USING 'BDC_OKCODE' '=ENTE'.

PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLKACB'.

ELSE.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

CLEAR ws_kostl.

*002

IF ws_bsid-bukrs = '3000'.

ws_kostl = '8002900'.

PERFORM bdc_field USING 'COBL-KOSTL' ws_kostl.

ELSE.

**B_ST002--Logic added to get CostCenter for SS and SR

IF ws_bsid-blart NOT IN p_blart.

  • PERFORM get_cost_center.

READ TABLE it_bseg WITH KEY

bukrs = ws_bsid-bukrs

belnr = ws_bsid-belnr

gjahr = ws_bsid-gjahr

BINARY SEARCH.

IF sy-subrc = 0.

MOVE it_bseg-kostl TO ws_kostl.

ENDIF.

IF ws_kostl = space.

endloop.

-


plz give a look at this bdc,

here i have started with loop at ws_bsid.

i have given some conditions with it_bsig table also.

my requirement is i want to run this below statement for 4 times bcz wrbtr is amount and there is 4 amounts for me.

----


PERFORM bdc_field USING 'BSEG-WRBTR' ws_wrbtr.

----


this field is there in both bseg and bsid table.

if i am looping this through bseg table than i am getting some prob, as you can seen in the top.

so give me a appropritate solution which can help me to run this particular bdc for 4 times.

thanks

mrutyun