‎2005 Nov 25 1:15 AM
Hi,
I have created BDC program for MM02 and the t_mat(itab) having 2 records.This program working fine.But while looping second record is not gettng into the screen(means screen is not getting empty to get second record),but it showing in debugging correctly.How to refresh the screen?
Pls see the code.
<b>Actually i have two distribution channels FM & TD.
In the first loop it is gettng FM from itab.Second loop also getting FM instead of TD.</b>
REPORT YMATERIAL_CHANGE no standard page heading
line-size 100
line-count 65
message-id Z1.
tables: mvke,makt,mara.
data: begin of t_mat occurs 0,
MATNR like mvke-matnr,
MAKTX like makt-maktx,
VERSG like mvke-VERSG,
MTPOS_MARA like mara-MTPOS_MARA,
MTPOS like mvke-MTPOS,
KTGRM like mvke-KTGRM,
PRODH like mvke-PRODH,
VTWEG like mvke-VTWEG,
end of t_mat.
data: begin of t_ch occurs 0,
vtweg(2),
end of t_ch.
<b>data: messtab like bdcmsgcoll occurs 0 with header line,
bdcdata like bdcdata occurs 0 with header line.</b>
data: begin of bdctab occurs 10. "BDC table
include structure bdcdata.
data: end of bdctab.
data: g_maktx like makt-maktx.
data: g_MTPOS_MARA like mara-MTPOS_MARA.
data: v_prodh like mvke-prodh.
data: v_ktgrm like mvke-ktgrm.
Parameter: p_matnr like mara-matnr.
start-of-selection.
select MATNR VERSG MTPOS KTGRM PRODH VTWEG
from MVKE into corresponding fields of table t_mat
where matnr = p_matnr and
ktgrm = '12'.
loop at t_mat.
select single * from makt where matnr = t_mat-matnr.
t_mat-maktx = makt-maktx.
if sy-subrc = 0.
modify t_mat.
clear t_mat.
endif.
endloop.
loop at t_mat.
select single * from mara where matnr = t_mat-matnr.
t_mat-MTPOS_MARA = mara-MTPOS_MARA.
if sy-subrc = 0.
modify t_mat.
clear t_mat.
endif.
endloop.
&----
*& Form fill_bdcdata
&----
text
----
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
p_matnr.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(04)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-VTWEG'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-WERKS'
'3000'.
perform bdc_field using 'RMMG1-VKORG'
'3000'.
<b>loop at t_mat.</b>
perform bdc_field using 'RMMG1-VTWEG'
t_mat-vtweg.<----- <b>here iam getting the problem..not getting second record</b>
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'BU'.
perform bdc_field using 'MAKT-MAKTX'
t_mat-MAKTX.
perform bdc_field using 'MVKE-VERSG'
t_mat-VERSG.
v_prodh = t_mat-prodh+0(2).
if v_prodh = 'LM'.
t_mat-KTGRM = '21'.
elseif v_prodh = 'LA'.
t_mat-KTGRM = '22'.
elseif v_prodh = 'LX'.
t_mat-KTGRM = '23'.
elseif v_prodh = 'LC'.
t_mat-KTGRM = '24'.
endif.
perform bdc_field using 'MVKE-KTGRM'
t_mat-KTGRM.
perform bdc_field using 'BDC_CURSOR'
'MVKE-PRODH'.
perform bdc_field using 'MARA-MTPOS_MARA'
t_mat-MTPOS_MARA.
perform bdc_field using 'MVKE-MTPOS'
t_mat-MTPOS.
perform bdc_field using 'MVKE-PRODH'
t_mat-PRODH.
<b>call transaction 'MM02' using bdcdata
mode 'A' update 'S' messages into messtab.</b>
<b>endloop.</b>
"bdc_va02
----
Form BDC_DYNPRO
----
form bdc_dynpro using program dynpro.
clear bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
append bdcdata.
endform. " BDC_DYNPRO
----
Form BDC_FIELD
----
form bdc_field using fnam fval.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
append bdcdata.
endform. "bdc_field
----
FORM NAME : BDC_TAB
FORM DESCRIPTION : This routine fills the BDC table.
----
form bdc_tab using dynbegin program dynpro.
clear bdctab.
if dynbegin = 'X'.
bdctab-dynbegin = dynbegin.
bdctab-program = program.
bdctab-dynpro = dynpro.
append bdctab.
else.
bdctab-fnam = program.
bdctab-fval = dynpro.
append bdctab.
endif.
endform. "bdc_tab
points guaranteed
cheers
kaki
‎2005 Nov 25 1:25 AM
Basically your logic should be like this.
LOOP AT T_MAT.
*-- REFRESH BDCDATA INTERNAL TABLE
*-- PREPARE BDC DATA
*-- CALL TRANSACTION
ENDLOOP.
‎2005 Nov 25 1:21 AM
Either after your call transaction or at the start of your loop at itab statement, <b><u>refresh</u></b> your bdcdata internal table.
Srinivas
‎2005 Nov 25 1:25 AM
Basically your logic should be like this.
LOOP AT T_MAT.
*-- REFRESH BDCDATA INTERNAL TABLE
*-- PREPARE BDC DATA
*-- CALL TRANSACTION
ENDLOOP.
‎2005 Nov 25 1:36 AM
Hi Srinivas,
If i write the "refresh bdctab" with in the loop it is throwing the error.Can u check the code pls.
kaki.
‎2005 Nov 25 1:45 AM
Did you rewrite your logic as I mentioned in my second response?
In your original code, you are trying to update multiple sales views of a material at one go, but that is not possible. You have to do them seperately.
Srinivas
‎2005 Nov 25 1:56 AM
o ic,but if i have 10 records to update in sales view then how to write separately? can u explain me clearly srinivas if u dont mind.
thanks
kaki
‎2005 Nov 25 2:25 AM
‎2005 Nov 25 4:58 AM
Glad to see that the problem is resolved. I was away from the computer for some time, so I could not respond immediately. But looks like you understood and found a way to achieve it.
Materials, Customers, Vendors, even though are identified by a unique identifier, they have different attributes for different views. So for a sales view they will have certain attributes and for a general view they will have certain attributes. There will be only one general view, but multiple instances of other views.
So a material can be just one, but will have 3 different values for attributes in sales view, if it is extended to 3 different sales areas. You can only view/change a specific sales area data at any point of time.
What you initially attempted was to do the updates to all sales views at one go.
Regards,
Srinivas