Hi Experts,
I have a small issue,
Program to update u201C Safety time/act.covu201D (MARC-SHZET) -MRP 2 view
Program will have a selection screen with the following parameters:
1) Plant (WERKS) Default (blank = ALL plants)
2) Date (SPMON) Default = Current Month + 1
Program will need to update u201CSafety time/act.covu201D (MARC-SHZET) from S976
Target Daysu2019 supply (REICZ).
The program will join records from S976 version = u201CA00u201D and SPMON = current month +1 (default from selection screen) with MARC. The join will be on plant (WERKS) and material (MATNR).
Update the MARC-SHZET field with the value in S976-REICZ.
If REICZ > 99 make the value in MARC-SHZET = 99.
For the Above issue i wrote the program as below , but it is not updating the safety time please check it adn if any one got the solution or coding please revert me.
&----
*& Report ZR_SFTYTIMEUPD *
*& *
&----
REPORT ZR_SFTYTIMEUPD .
tables: s976,
marc.
data : begin of it_s976 occurs 0,
vrsio type s976-vrsio, "Version number in the information
"structure
spmon type s976-spmon, "Period to analyze - month
werks type s976-werks, "Plant
matnr type s976-matnr, "Material Number
reicz type s976-reicz, "Target range of coverage (target
"days'supply)
end of it_s976.
DATA: BEGIN OF it_marc OCCURS 0.
INCLUDE STRUCTURE marc.
DATA: END OF it_marc.
data: lv_date1 type sy-datum,
lv_date2 type sy-datum,
lv_month(2) type n,
lv_year(4) type n.
data:it_bdcdata like bdcdata occurs 0 with header line.
data:it_messtab like bdcmsgcoll occurs 0 with header line.
data: v_mode.
selection-screen: begin of block b1 with frame title text-000.
select-options: s_spmon for s976-spmon,
s_werks for s976-werks,
s_matnr for s976-matnr.
selection-screen: end of block b1.
initialization.
concatenate sy-datum0(4) sy-datum4(2) into lv_date1.
lv_month = sy-datum+4(2).
lv_year = sy-datum+0(4).
do 1 times.
lv_month = lv_month + 1.
if lv_month gt 12.
lv_month = 1.
lv_year = lv_year + 1.
endif.
enddo.
concatenate lv_year lv_month into lv_date2.
s_spmon-low = lv_date1.
s_spmon-high = lv_date2.
s_spmon-option = 'BT'.
s_spmon-sign = 'I'.
append s_spmon.
clear s_spmon.
start-of-selection.
select vrsio
spmon
werks
matnr
reicz
into table it_s976 from s976
where vrsio = 'A00'
and spmon in s_spmon
and werks in s_werks.
if sy-subrc = 0.
SORT it_s976 by spmon werks matnr.
endif.
if it_s976[] is not initial.
select *
into table it_marc from marc
for all entries in it_s976
where matnr = it_s976-matnr
and werks = it_s976-werks.
endif.
if sy-subrc = 0.
SORT it_marc BY werks matnr.
endif.
loop at it_s976.
read table it_marc with key werks = it_s976-werks
matnr = it_s976-matnr.
if sy-subrc = 0.
if it_s976-reicz > 99.
it_marc-shzet = 99.
else.
it_marc-shzet = it_s976-reicz .
endif.
**-- Initial Screen
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'
it_marc-matnr.
**-- Pop up materials view
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(13)'.
perform bdc_field using 'MSICHTAUSW-KZSEL(13)'
'X'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
**-- Pop Plant entry screen
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-WERKS'.
perform bdc_field using 'RMMG1-WERKS'
it_marc-WERKS.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
**-- Second screen
perform bdc_dynpro using 'SAPLMGMM' '3000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'MAKT-MAKTX'
it_marc-MAKTX.
*perform bdc_field using 'MARC-BESKZ'
it_marc-BESKZ.
*perform bdc_field using 'MARC-LGPRO'
it_marc-LGPRO.
*perform bdc_field using 'MARC-LGFSB'
it_marc-LGFSB.
*perform bdc_field using 'MARC-FHORI'
it_marc-FHORI.
perform bdc_field using 'MARC-SHZET'
it_marc-shzet.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=yes'.
*perform bdc_transaction using 'MM02'.
endif.
call transaction 'MM02' using it_bdcdata
mode 'A'
messages into it_messtab.
clear it_marc.
endloop.
&----
*& Form BDC_DYNPRO
&----
BDC screens information
----
form bdc_dynpro using program dynpro.
clear it_bdcdata.
it_bdcdata-program = program.
it_bdcdata-dynpro = dynpro.
it_bdcdata-dynbegin = 'X'.
append it_bdcdata.
clear it_bdcdata.
endform. " BDC_DYNPRO
&----
*& Form BDC_FIELD
&----
BDC fields information
----
form bdc_field using fnam fval.
clear it_bdcdata.
it_bdcdata-fnam = fnam.
it_bdcdata-fval = fval.
append it_bdcdata.
clear it_bdcdata.
endform. " BDC_FIELD
Thanks & Regards,
Prasad.T