There are some raw materials which belongs to the group
of CELL which is solar cell. Hence these raw materials must contain WATTPEAK at
the time of creating Batch. From MSC1N & MSC2N we can create & edit
batch classification. The system must check if there is a valid WATTPEAK
against a material of CELL group with that particular created batch.
There is no any standard configuration by which system
will abort the SAVE option while creating a batch without WATTPEAK. Hence we
need to go by Enhancement of MSC2N. There is a BADI named BATCH_MASTER which
can conclude this requirement.
From SE18 we can see the Interfaces of that particular
BADI. There is a method named CHECK_CLASSIF_BEFORE_SAVE which triggers at the
time of SAVE. We will implement that method with our custom logic over there.
Now we need to create our custom implementation at SE19 –
create implementation (ZBATCH_CLASS). We can display & edit after creation
from the edit implementation field from SE19. Now go to interface and double
click the method CHECK_CLASSIF_BEFORE_SAVE.
Now we can write our custom code there to meet the
required logic as follows. It will not allow us to save a batch data if we try
to enter without WATTPEAK of a CELL material.
METHOD if_ex_batch_master~check_classif_before_save.
IF it_values_buffer IS NOT INITIAL AND
sy-ucomm = 'SAVE' AND
( sy-tcode = 'MSC1N' OR sy-tcode = 'MSC2N' ).
SELECT SINGLE atinn, spras, adzhl, atbez
FROM cabnt INTO @DATA(wa_cabnt)
WHERE atinn = 811
AND spras = @sy-langu.
SORT it_values_buffer BY atinn.
READ TABLE it_values_buffer ASSIGNING FIELD-SYMBOL(<wa_val>)
WITH KEY atinn = wa_cabnt-atinn BINARY SEARCH.
IF sy-subrc = 0.
IF <wa_val>-atflv IS INITIAL.
MESSAGE 'Cell Material must contains Wattpeak'
TYPE 'I' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDIF.
ELSE.
MESSAGE 'Cell Material must contains Wattpeak'
TYPE 'I' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDIF.
ENDIF.
ENDMETHOD.
IF it_values_buffer IS NOT INITIAL AND
sy-ucomm = 'SAVE' AND
( sy-tcode = 'MSC1N' OR sy-tcode = 'MSC2N' ).
SELECT SINGLE atinn, spras, adzhl, atbez
FROM cabnt INTO @DATA(wa_cabnt)
WHERE atinn = 811
AND spras = @sy-langu.
SORT it_values_buffer BY atinn.
READ TABLE it_values_buffer ASSIGNING FIELD-SYMBOL(<wa_val>)
WITH KEY atinn = wa_cabnt-atinn BINARY SEARCH.
IF sy-subrc = 0.
IF <wa_val>-atflv IS INITIAL.
MESSAGE 'Cell Material must contains Wattpeak'
TYPE 'I' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDIF.
ELSE.
MESSAGE 'Cell Material must contains Wattpeak'
TYPE 'I' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDIF.
ENDIF.
ENDMETHOD.
No comments:
Post a Comment