• February 12, 2026
  • Kishore Thutaram
  • 0

Control Access Sequence Priority in SAP Pricing Using RV61AFZB User Exit

Business Scenario:

“Pcontrol the access sequence condition record determination priority in sales order pricing. – this is needed for the discount condition types where there are multiple condition records are maintained without exclusion check in the config.”

Steps:

Open user exit Include – RV61AFZB

Form routine : FORM USEREXIT_XKOMV_FUELLEN USING RETURNCODE.


IF line_exists( xkomv[ kposn = xkomv-kposn kschl = xkomv-kschl ] ).
*--*IF Previous access greater than the current - give priority to the previous Else give priority to current record
      
            IF gv_kolnr GE komt2-kolnr.
              DELETE xkomv WHERE kposn = xkomv-kposn
                                         AND kschl = xkomv-kschl.
            ELSE.
              CLEAR cs_xkomv.
            ENDIF.
        ENDIF.
*--* Keep the Previous Access sequence in global variable to compare with current Access Sequence
          gv_kolnr = komt2-kolnr. "Set global variable  
 
*--* clean up balnk records
      IF xkomv[] IS NOT INITIAL.
        DELETE xkomv WHERE mandt IS INITIAL.
      ENDIF.
*--*for every new item clear the global variable
      IF xkomv[] IS INITIAL.
        CLEAR : gv_kolnr.
      ENDIF.
*--* return code should be zero always to make pricing consistent
    return = 0.
   
    

Kishore Thutaram

"SAP solution architect with a strong problem-solving mindset, sharing practical SAP S/4HANA and ABAP insights from real-world projects."

https://fiowelt.com