- January 29, 2026
- Kishore Thutaram
-
- 0
Enable Item Category Field in SAP Sales Order Based on Condition
Business Scenario:
“Enable Item category field in sales order when there is no active Purchase order and Production order.”
Include- MV45AFZZ - > USEREXIT_FIELD_MODIFICATION
IF screen-name = 'VBAP-PSTYV' AND vbap-posnr IS NOT INITIAL.
*--* Active Purchase Order check
SELECT single n~ebeln
FROM ekkn AS n INNER JOIN ekpo AS i
ON n~ebeln = i~ebeln AND
n~ebelp = i~ebelp
WHERE n~vbeln = @vbap-vbeln AND
n~vbelp = @vbap-posnr AND
i~loekz IS INITIAL
INTO @DATA(lv_ebeln).
IF lv_ebeln IS INITIAL.
DATA(lv_no_purchOrd) = abap_true.
ENDIF.
*--*Production order check
SELECT aufnr FROM afpo INTO @DATA(lv_aufnr) UP TO 1 ROWS
WHERE kdauf = @ivbap-vbeln "#EC CI_NOORDER
AND kdpos = @vbap-posnr.
ENDSELECT.
IF sy-subrc EQ 0.
SELECT SINGLE objnr FROM aufk INTO @DATA(lv_objnr) WHERE aufnr = @lv_aufnr.
IF sy-subrc EQ 0.
SELECT stat FROM jest INTO TABLE @DATA(lt_jest) WHERE objnr = @lv_objnr
AND inact = @space .
IF sy-subrc EQ 0.
DATA(lv_no_prodord) = abap_true.
ENDIF.
ENDIF.
ENDIF.
ELSE.
lv_no_prodord = abap_true.
ENDIF.
*--*Update Screen - Set Item Category field Enable If there is no Purchase Order or Production Order
IF lv_no_purchord = abap_true AND " No Active Purchase order
lv_no_prodord = abap_true. " No Active Production Order
IF screen-input = 0.
screen-input = '1'.
ENDIF.
ENDIF.
ENDIF.





















