extension using interface i_reservationdocumenttp
implementation in class zbp_e_reservationdocumentheade unique;
extend behavior for ReservationDocument
{
extend draft determine action Prepare {
validation ReservationDocumentItem~validateStockItem;
}
}
extend behavior for ReservationDocumentItem
{
validation validateStockItem on save { field Reservation; create; update; }
}
*"* use this source file for the definition and implementation of
*"* local helper classes, interface definitions and type
*"* declarations
CLASS lhc_reservationdocumentheader DEFINITION INHERITING FROM cl_abap_behavior_handler.
PUBLIC SECTION.
CONSTANTS:
validate_stock_item TYPE string VALUE 'VALIDATE_STOCK_ITEM',
serial_num TYPE zser_num VALUE '001'.
PRIVATE SECTION.
METHODS validatestockitem FOR VALIDATE ON SAVE
IMPORTING keys FOR reservationdocumentitem~validatestockitem.
ENDCLASS.
CLASS lhc_reservationdocumentheader IMPLEMENTATION.
METHOD validatestockitem.
*Get the reservation document items
READ ENTITIES OF i_reservationdocumenttp IN LOCAL MODE
ENTITY reservationdocumentitem
FIELDS ( product plant storagelocation )
WITH CORRESPONDING #( keys )
RESULT DATA(lt_items).
LOOP AT lt_items ASSIGNING FIELD-SYMBOL(<ls_res_item>)
WHERE reservationitmismarkedfordeltn EQ abap_false
AND reservationitemisfinallyissued EQ abap_false
AND product IS NOT INITIAL
AND plant IS NOT INITIAL. "#EC CI_STDSEQ
*If stock is zero for the material and plant combination,
*issue a warning message
SELECT SUM( labst ) FROM nsdm_e_mard
INTO @DATA(quantity_in_stock)
WHERE matnr EQ @<ls_res_item>-product
AND werks EQ @<ls_res_item>-plant.
IF sy-subrc EQ 0.
IF quantity_in_stock EQ 0.
APPEND VALUE #( %tky = <ls_res_item>-%tky
%state_area = validate_stock_item
%path-reservationdocument-%is_draft = <ls_res_item>-%is_draft
%path-reservationdocument-reservation = <ls_res_item>-reservation
)
TO reported-reservationdocumentitem.
APPEND VALUE #( %tky = <ls_res_item>-%tky
%state_area = validate_stock_item
%msg = NEW zcm_reservation_message(
textid = zcm_reservation_message=>stock_unavailable
severity = if_abap_behv_message=>severity-warning
product = <ls_res_item>-product
plant = <ls_res_item>-plant
)
%element-resvnitmrequiredqtyinentryunit = if_abap_behv=>mk-on
%path-reservationdocument-%is_draft = <ls_res_item>-%is_draft
%path-reservationdocument-reservation = <ls_res_item>-reservation
)
TO reported-reservationdocumentitem.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
8 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |