Application Development and Automation 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: 
Read only

problem in bdc for table control for line items

Former Member
0 Likes
860

Hi experts,

I am runnig a bdc for ME52.

i am just entering PR number, in the second screen i have got all the line items. I need to select these line item 10 and double click or hit enter, it takes me to screen 3, there im just checking a checkbox and saving.

Again i need to select the line item 20 and double click or hit enter. again the same process.

Again repeat for all the line items.

But my problem is it is updating everytime for only line item 10. for line item 20 and others it say "no chnge in the data".

I am pasting my code here. please check and revert me back .plz.

DATA: w_output LIKE LINE OF i_output.

REFRESH I_ITAB[].

SELECT * FROM EBAN

INTO TABLE i_itab

WHERE banfn in s_banfn AND

bsart in s_bsart AND

bstyp in s_bstyp AND

matnr in s_matnr AND

werks in s_werks AND

lfdat in s_lfdat AND

pstyp in s_pstyp AND

knttp in s_knttp AND

estkz in s_estkz AND

loekz eq ' '.

IF sy-subrc = 0.

CLEAR: w_itab,

i_poitab[].

SORT i_itab by banfn.

LOOP AT i_itab INTO w_itab where menge GT eban-bsmng.

IF p_close = 'X' AND p_rep = 'X'.

IF w_itab-ebakz = 'X'.

w_itab-ebakz = ' '.

APPEND w_itab to i_poitab.

ENDIF.

ELSEIF p_open = 'X' AND p_rep = 'X'.

IF w_itab-ebakz = ' '.

w_itab-ebakz = 'X'.

APPEND w_itab to i_poitab.

ENDIF.

ELSEIF p_close = 'X' AND p_repw = 'X'.

IF w_itab-ebakz = ' '.

APPEND w_itab to i_poitab.

ENDIF.

ELSEIF p_open = 'X' AND p_repw = 'X'.

IF w_itab-ebakz = 'X'.

APPEND w_itab to i_poitab.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

LOOP AT i_poitab into w_output.

APPEND w_output to i_output.

  • PERFORM CALL_BDC.

endloop.

IF p_rep = 'X'.

PERFORM CALL_BDC.

ENDIF.

ENDFORM. " GET_DATA

&----


*& Form CALL_BDC

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CALL_BDC.

DATA: seltab(5) TYPE N,

seltab1(2) TYPE N,

tempvar(30) TYPE N,

cnt TYPE N.

LOOP AT i_output.

clear: seltab,

seltab1.

seltab = i_output-bnfpo.

seltab1 = seltab+2(2).

perform bdc_dynpro using 'SAPMM06B' '0105'.

perform bdc_field using 'BDC_CURSOR'

'EBAN-BANFN'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'EBAN-BANFN'

i_output-banfn.

perform bdc_dynpro using 'SAPMM06B' '0106'.

clear tempvar.

*cnt = 1.

concatenate 'EBAN-BNFPO(' seltab1 ')' into tempvar.

perform bdc_field using 'BDC_CURSOR'

  • 'EBAN-BNFPO(seltab1)'.

tempvar.

perform bdc_field using 'BDC_OKCODE'

'=DETA'.

perform bdc_field using 'RM06B-BNFPO'

i_output-bnfpo.

  • perform bdc_field using 'RM06B-TCSELFLAG(seltab1)'

  • 'X'.

perform bdc_dynpro using 'SAPMM06B' '0102'.

perform bdc_field using 'BDC_CURSOR'

'EBAN-EBAKZ'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'EBAN-EBAKZ'

i_output-ebakz.

CALL TRANSACTION 'ME52' USING bdc_data MODE 'A'

MESSAGES INTO i_bdcmsg.

COMMIT WORK AND WAIT.

ENDLOOP.

ENDFORM. " CALL_BDC

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0686 text

  • -->P_0687 text

----


FORM bdc_dynpro USING program dynpro.

CLEAR bdc_data.

bdc_data-program = program.

bdc_data-dynpro = dynpro.

bdc_data-dynbegin = 'X'.

APPEND bdc_data.

CLEAR bdc_data.

ENDFORM.

thanks,

N

Hi experts,

I am runnig a bdc for ME52.

i am just entering PR number, in the second screen i have got all the line items. I need to select these line item 10 and double click or hit enter, it takes me to screen 3, there im just checking a checkbox and saving.

Again i need to select the line item 20 and double click or hit enter. again the same process.

Again repeat for all the line items.

But my problem is it is updating everytime for only line item 10. for line item 20 and others it say "no chnge in the data".

I am pasting my code here. please check and revert me back .plz.

DATA: w_output LIKE LINE OF i_output.

REFRESH I_ITAB[].

SELECT * FROM EBAN

INTO TABLE i_itab

WHERE banfn in s_banfn AND

bsart in s_bsart AND

bstyp in s_bstyp AND

matnr in s_matnr AND

werks in s_werks AND

lfdat in s_lfdat AND

pstyp in s_pstyp AND

knttp in s_knttp AND

estkz in s_estkz AND

loekz eq ' '.

IF sy-subrc = 0.

CLEAR: w_itab,

i_poitab[].

SORT i_itab by banfn.

LOOP AT i_itab INTO w_itab where menge GT eban-bsmng.

IF p_close = 'X' AND p_rep = 'X'.

IF w_itab-ebakz = 'X'.

w_itab-ebakz = ' '.

APPEND w_itab to i_poitab.

ENDIF.

ELSEIF p_open = 'X' AND p_rep = 'X'.

IF w_itab-ebakz = ' '.

w_itab-ebakz = 'X'.

APPEND w_itab to i_poitab.

ENDIF.

ELSEIF p_close = 'X' AND p_repw = 'X'.

IF w_itab-ebakz = ' '.

APPEND w_itab to i_poitab.

ENDIF.

ELSEIF p_open = 'X' AND p_repw = 'X'.

IF w_itab-ebakz = 'X'.

APPEND w_itab to i_poitab.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

LOOP AT i_poitab into w_output.

APPEND w_output to i_output.

  • PERFORM CALL_BDC.

endloop.

IF p_rep = 'X'.

PERFORM CALL_BDC.

ENDIF.

ENDFORM. " GET_DATA

&----


*& Form CALL_BDC

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CALL_BDC.

DATA: seltab(5) TYPE N,

seltab1(2) TYPE N,

tempvar(30) TYPE N,

cnt TYPE N.

LOOP AT i_output.

clear: seltab,

seltab1.

seltab = i_output-bnfpo.

seltab1 = seltab+2(2).

perform bdc_dynpro using 'SAPMM06B' '0105'.

perform bdc_field using 'BDC_CURSOR'

'EBAN-BANFN'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'EBAN-BANFN'

i_output-banfn.

perform bdc_dynpro using 'SAPMM06B' '0106'.

clear tempvar.

*cnt = 1.

concatenate 'EBAN-BNFPO(' seltab1 ')' into tempvar.

perform bdc_field using 'BDC_CURSOR'

  • 'EBAN-BNFPO(seltab1)'.

tempvar.

perform bdc_field using 'BDC_OKCODE'

'=DETA'.

perform bdc_field using 'RM06B-BNFPO'

i_output-bnfpo.

  • perform bdc_field using 'RM06B-TCSELFLAG(seltab1)'

  • 'X'.

perform bdc_dynpro using 'SAPMM06B' '0102'.

perform bdc_field using 'BDC_CURSOR'

'EBAN-EBAKZ'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'EBAN-EBAKZ'

i_output-ebakz.

CALL TRANSACTION 'ME52' USING bdc_data MODE 'A'

MESSAGES INTO i_bdcmsg.

COMMIT WORK AND WAIT.

ENDLOOP.

ENDFORM. " CALL_BDC

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0686 text

  • -->P_0687 text

----


FORM bdc_dynpro USING program dynpro.

CLEAR bdc_data.

bdc_data-program = program.

bdc_data-dynpro = dynpro.

bdc_data-dynbegin = 'X'.

APPEND bdc_data.

CLEAR bdc_data.

ENDFORM.

thanks,

N

6 REPLIES 6
Read only

Former Member
0 Likes
807

Looks like table control logic is wrong -- do compare with below program...

only table contril area

REPORT ZPadmam

NO STANDARD PAGE HEADING LINE-SIZE 255.

DATA : BEGIN OF itab OCCURS 0,

i1 TYPE i,

lifnr LIKE rf02k-lifnr,

bukrs LIKE rf02k-bukrs,

ekorg LIKE rf02k-ekorg,

ktokk LIKE rf02k-ktokk,

anred LIKE lfa1-anred,

name1 LIKE lfa1-name1,

sortl LIKE lfa1-sortl,

land1 LIKE lfa1-land1,

akont LIKE lfb1-akont,

fdgrv LIKE lfb1-fdgrv,

waers LIKE lfm1-waers,

END OF itab.

DATA : BEGIN OF jtab OCCURS 0,

j1 TYPE i,

banks LIKE lfbk-banks,

bankl LIKE lfbk-bankl,

bankn LIKE lfbk-bankn,

END OF jtab.

DATA : cnt(4) TYPE n.

DATA : fdt(20) TYPE c.

DATA : c TYPE i.

INCLUDE bdcrecx1.

START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'C:\first1.txt'

filetype = 'DAT'

TABLES

data_tab = itab.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = 'C:\second.txt'

filetype = 'DAT'

TABLES

data_tab = jtab.

LOOP AT itab.

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'

itab-lifnr.

PERFORM bdc_field USING 'RF02K-BUKRS'

itab-bukrs.

PERFORM bdc_field USING 'RF02K-EKORG'

itab-ekorg.

PERFORM bdc_field USING 'RF02K-KTOKK'

itab-ktokk.

PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-LAND1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'LFA1-ANRED'

itab-anred.

PERFORM bdc_field USING 'LFA1-NAME1'

itab-name1.

PERFORM bdc_field USING 'LFA1-SORTL'

itab-sortl.

PERFORM bdc_field USING 'LFA1-LAND1'

itab-land1.

PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFA1-KUNNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKN(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

cnt = 0.

LOOP AT jtab WHERE j1 = itab-i1.

cnt = cnt + 1.

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

PERFORM bdc_field USING fdt jtab-banks.

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

PERFORM bdc_field USING fdt jtab-bankl.

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

PERFORM bdc_field USING fdt jtab-bankn.

IF cnt = 5.

cnt = 0.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=P+'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'LFBK-BANKN(02)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTR'.

ENDIF.

ENDLOOP.

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'

itab-akont.

PERFORM bdc_field USING 'LFB1-FDGRV'

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'

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.

Thanks

Seshu

Read only

0 Likes
807

i have seen this code in sdn.

But i didnt uderstand the jtab loop..

instead i have taken the offset, which will be 01 02 03 etc for each line itm. then BDC_CURSOR it should go to the corresponding line item.

But it still taking the first line item everytime.

because every time the second screen is called by default the curson is on the first line item.

My code for 02 is there, but it still goes iwth first line item..

kindly help.

N

Read only

0 Likes
807

Try Always Modifying Item 1. Just send 'Next Item' or 'Go to position Previous + 1' command and modify the position 1 of the table every time until you're finish. I hope I was clear, I'm in ECC 6.0 and I can't access ME52, only ME52N.

Regards.

Read only

0 Likes
807

Other option: BAPI_REQUISITION_CHANGE, instead of the BDC.

Read only

0 Likes
807

i solved it on my own

Read only

0 Likes
807

Would you mind to tell us how did you solve it?

Regards.