• February 13, 2026
  • Kishore Thutaram
  • 0

Update a Custom field value during Sales Billing document creation

Business Scenario:

“Update the custom fields during billing document creation using enhancement-user exit – In this case, we are updating the delivery count custom field value.”

Step : Open User Exit Include : RV60AFZC

Form Routine : FORM USEREXIT_FILL_VBRK_VBRP.

Implement the code as per the requirment.


    DATA(lv_lines) = lines( ct_xvbrp ).
      IF lv_lines GT 0.
*--*Read the latest processing Item from XVBRP - Note this gets filled item by Item
        READ TABLE ct_xvbrp ASSIGNING FIELD-SYMBOL() INDEX lv_lines.
        IF  IS ASSIGNED AND -aubel IS NOT INITIAL.
*--*Fetch Delivery Count from Delivery item Table
          SELECT deliverydocument,
                 deliverydocumentitem FROM i_deliverydocumentitem INTO TABLE @DATA(lt_delcount)
                                        WHERE referencesddocument = @-aubel
                                         AND referencesddocumentitem = @-aupos.
          IF sy-subrc EQ 0.
            SORT lt_delcount BY deliverydocument.
            DELETE ADJACENT DUPLICATES FROM lt_delcount COMPARING deliverydocument.
*--*Populate the delivery Count
            DATA(lv_del_count) = lines( lt_delcount ).
            IF lv_del_count IS NOT INITIAL.
              -zz1_delcount = lv_del_count.
              cs_vbrp-zz1_del_count = lv_del_count.
            ENDIF.
          ENDIF.

        ENDIF.
      ENDIF.
   
    

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