Hello Smart,
See this code:
IF caufvd_imp-auart = 'ZM01'.
TYPES: BEGIN OF ty_dates,
aufnr TYPE aufnr,
gstrp TYPE dats,
gltrp TYPE dats,
END OF ty_dates.
DATA: it_dates TYPE TABLE OF ty_dates,
wa_dates TYPE ty_dates.
DATA: msg1 TYPE string.
SELECT aufnr gstrp gltrp FROM viaufks INTO TABLE it_dates
WHERE auart = 'ZM01' AND ( iphas = '0' OR iphas = '2' ).
DELETE it_dates WHERE aufnr = caufvd_imp-aufnr.
LOOP AT it_dates INTO wa_dates.
SHIFT wa_dates-aufnr LEFT DELETING LEADING '0'.
IF caufvd_imp-gstrp LE wa_dates-gltrp
AND caufvd_imp-gltrp GE wa_dates-gstrp.
CONCATENATE 'Basic Dates overlap with those of Order' wa_dates-aufnr
'seen. Order can not be saved.' INTO msg1 SEPARATED BY space.
MESSAGE msg1 TYPE 'E' DISPLAY LIKE 'I'.
ENDIF.
ENDLOOP.
ENDIF.
User-exit: IWO10009 . When you put the above code in the include ZXWOCU07 of this exit, then Order Basic Dates overlaps are prevented. If any such are there you will get this error pop-up which prevents the Order from Saving.
Note these point
- 4200158 is the Order with which the code detected Dates overlap with the current Order.
- I have made this code limited to one Order type namely 'ZM01'. You can modify accordingly.
- You can also incorporate additional IFs to limit this Overlap prevention.
- With these inputs your ABAPer would be able to fine tune this code according to your requirement.
Good luck
KJogeswaraRao