Hi all, i want to mass deletion for materials characteristic value. I use the following batch program to change or add characteristic value for materials. But I can't delete with the same method.
How can i delete characteristic value using SHDB session?
type-pools: slis.
data : begin of itab occurs 0 ,
bismt(18) , " Malzeme
maktx(40) , " Tanımı
karakteristik_degeri(70) ,
karakteristik_grubu(30) ,
end of itab .
data : bdctab like bdcdata occurs 0 with header line.
data : messtab like bdcmsgcoll occurs 0 with header line.
data : begin of returntab occurs 0 ,
matnr like mara-matnr ,
message like bapiret2-message ,
end of returntab .
data : gv_mode(1) .
selection-screen begin of block b1 with frame title text-001 .
parameters : p_backg radiobutton group bb ,
p_foreg radiobutton group bb default 'X' ,
p_error radiobutton group bb .
selection-screen end of block b1 .
selection-screen begin of block b2 with frame title text-002 .
parameters : p_fname like rlgrap-filename obligatory .
selection-screen end of block b2 .
at selection-screen on value-request for p_fname .
perform query_filename changing p_fname .
start-of-selection .
perform get_data .
if returntab[] is initial .
perform batch .
endif .
perform display_message .
*&---------------------------------------------------------------------*
*& Form QUERY_FILENAME
*&---------------------------------------------------------------------*
form query_filename changing def_path .
data: lt_file type filetable,
lv_rc like sy-subrc,
ls_file like line of lt_file.
call method cl_gui_frontend_services=>file_open_dialog
changing
file_table = lt_file
rc = lv_rc
exceptions
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
others = 4.
if sy-subrc eq 0.
read table lt_file into ls_file index 1.
def_path = ls_file-filename.
else.
message e002(z01) with 'Dosya bulunamadı.' .
endif.
endform. " QUERY_FILENAME
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
form get_data .
data : begin of lt_mtab occurs 0 ,
bismt like mara-bismt ,
index type int4 ,
end of lt_mtab .
data : rawdata(4096) type c occurs 0 ,
lv_atinn1 like cawn-atinn .
if p_backg = 'X' .
gv_mode = 'N' .
elseif p_foreg = 'X' .
gv_mode = 'A' .
elseif p_error = 'X' .
gv_mode = 'E' .
endif .
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Excel dosyası içeri okunuyor...'.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
i_tab_raw_data = rawdata
i_filename = p_fname
tables
i_tab_converted_data = itab
exceptions
conversion_failed = 1
others = 2.
if sy-subrc <> 0 .
message e002(z01) with 'Dosya hatalı, SAP içine alınamadı.' .
endif.
do 1 times .
delete itab index 1 .
enddo .
delete itab where bismt = space .
loop at itab .
** Kontroller
** 1. Eski malzeme no
select single bismt from mara
into itab-bismt
where bismt = itab-bismt
and lvorm = space .
if sy-subrc ne 0 .
returntab-matnr = itab-bismt .
returntab-message = text-004 .
append returntab .
clear returntab .
endif .
endloop .
endform. " GET_DATA
*&---------------------------------------------------------------------*
*& Form BATCH
*&---------------------------------------------------------------------*
form batch .
loop at itab .
perform fill_bdctab .
perform call_transaction.
perform move_messtab .
clear : bdctab, bdctab[].
endloop.
endform. " BATCH
*&---------------------------------------------------------------------*
*& Form CALL_TRANSACTION
*&---------------------------------------------------------------------*
form call_transaction .
call transaction 'MM02' using bdctab mode gv_mode update 'S'
messages into messtab .
endform. " CALL_TRANSACTION
*&---------------------------------------------------------------------*
*& Form MOVE_MESSAGE
*&---------------------------------------------------------------------*
form move_message .
data lv_text(480) .
loop at messtab .
if messtab-msgtyp = 'S' .
check not messtab-msgv1 is initial .
endif .
clear lv_text .
select single text from t100
into lv_text
where sprsl = messtab-msgspra
and arbgb = messtab-msgid
and msgnr = messtab-msgnr.
check not lv_text is initial .
if lv_text cs '&1'.
replace '&1' with messtab-msgv1 into lv_text .
replace '&2' with messtab-msgv2 into lv_text .
replace '&3' with messtab-msgv3 into lv_text .
replace '&4' with messtab-msgv4 into lv_text .
else.
replace '&' with messtab-msgv1 into lv_text .
replace '&' with messtab-msgv2 into lv_text .
replace '&' with messtab-msgv3 into lv_text .
replace '&' with messtab-msgv4 into lv_text .
endif.
condense lv_text .
returntab-message = lv_text .
collect returntab .
clear returntab .
endloop .
clear : messtab, messtab[].
endform. " MOVE_MESSAGE
*&---------------------------------------------------------------------*
*& Form DISPLAY_MESSAGE
*&---------------------------------------------------------------------*
form display_message .
** ALV için tanımlamalar
data : lv_repid like sy-repid ,
lt_fieldcat type slis_t_fieldcat_alv ,
ls_layout type slis_layout_alv ,
ls_fieldcat type slis_fieldcat_alv .
check not returntab[] is initial .
* Listelenecek alan katalogu olusturulur
lv_repid = sy-repid .
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = lv_repid
i_internal_tabname = 'RETURNTAB'
i_inclname = lv_repid
changing
ct_fieldcat = lt_fieldcat[].
loop at lt_fieldcat into ls_fieldcat .
case ls_fieldcat-fieldname.
when 'MESSAGE' .
ls_fieldcat-seltext_l = 'İletiler'(003).
endcase .
ls_fieldcat-seltext_s = ls_fieldcat-seltext_m
= ls_fieldcat-seltext_l .
ls_fieldcat-ddictxt = 'L'.
modify lt_fieldcat from ls_fieldcat index sy-tabix .
endloop .
ls_layout-zebra = 'X' . " Çizgili desen
ls_layout-cell_merge = 'X' . " Hücreleri birleştir
ls_layout-colwidth_optimize = 'X' . " Sütun optimizasyonu
ls_layout-detail_popup = 'X' .
** Display
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = lv_repid
is_layout = ls_layout
it_fieldcat = lt_fieldcat[]
tables
t_outtab = returntab[]
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_MESSAGE
*&---------------------------------------------------------------------*
*& Form FILL_BDCTAB
*&---------------------------------------------------------------------*
form fill_bdctab .
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'RMMG1-MATNR' itab-bismt.
perform bdc_field using 'BDC_OKCODE' '=ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(03)'.
perform bdc_field using 'MSICHTAUSW-KZSEL(03)' 'X'.
perform bdc_field using 'BDC_OKCODE' '=ENTR'.
*-> Sınıflandırma
perform bdc_dynpro using 'SAPLCLCA' '0602'.
perform bdc_field using 'BDC_CURSOR' 'RMCLF-KLART'.
perform bdc_field using 'RMCLF-KLART' '001'.
perform bdc_field using 'BDC_OKCODE' '=ENTE' .
perform bdc_dynpro using 'SAPLCLFM' '0500'.
perform bdc_field using 'BDC_CURSOR' 'RMCLF-CLASS(01)' .
perform bdc_field using 'BDC_OKCODE' '=AUSW' .
perform bdc_dynpro using 'SAPLCTMS' '0109'.
perform bdc_field using 'RCTMS-MNAME(01)' itab-karakteristik_grubu .
perform bdc_field using 'RCTMS-MWERT(01)' itab-karakteristik_degeri
.
perform bdc_field using 'BDC_OKCODE' '=BACK' .
perform bdc_dynpro using 'SAPLCLFM' '0500'.
perform bdc_field using 'BDC_OKCODE' '=SAVE' .
endform. " FILL_BDCTAB
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear bdctab.
bdctab-program = program.
bdctab-dynpro = dynpro.
bdctab-dynbegin = 'X'.
append bdctab.
endform. " BDC_DYNPRO
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
form bdc_field using fnam fval.
clear bdctab.
bdctab-fnam = fnam.
bdctab-fval = fval.
append bdctab.
endform. " BDC_FIELD
*&---------------------------------------------------------------------*
*& Form MOVE_MESSTAB
*&---------------------------------------------------------------------*
form move_messtab .
data : lv_text(480) ,
lv_matnr like mara-matnr .
loop at messtab where msgtyp = 'E' or msgtyp = 'S' .
if messtab-msgtyp = 'S' .
check not messtab-msgv1 is initial .
endif .
clear lv_text .
select single text from t100
into lv_text
where sprsl = messtab-msgspra
and arbgb = messtab-msgid
and msgnr = messtab-msgnr.
check not lv_text is initial .
if lv_text cs '&1'.
replace '&1' with messtab-msgv1 into lv_text .
replace '&2' with messtab-msgv2 into lv_text .
replace '&3' with messtab-msgv3 into lv_text .
replace '&4' with messtab-msgv4 into lv_text .
else.
replace '&' with messtab-msgv1 into lv_text .
replace '&' with messtab-msgv2 into lv_text .
replace '&' with messtab-msgv3 into lv_text .
replace '&' with messtab-msgv4 into lv_text .
endif.
condense lv_text .
if messtab-msgtyp = 'S' and
messtab-msgspra = 'T' and
messtab-msgid = 'M3' and
messtab-msgnr = '800' and
not messtab-msgv1 is initial .
call function 'CONVERSION_EXIT_MATN1_INPUT'
exporting
input = messtab-msgv1
importing
output = returntab-matnr
exceptions
length_error = 1
others = 2.
endif .
returntab-message = lv_text .
collect returntab .
clear returntab .
endloop .
clear : messtab, messtab[].
endform. " MOVE_MESSTAB