Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Is there any BAPI or Function module to update Standard field 'EPC1' of table VEKP

There is requirement like, in VL02N when the Material is packed into any handling unit it should display pop-up asking to enter a number ,and that number should get saved in the field EPC1 according to handling unit.Secondly when the user clicks on empty button,the material is unpacked and the number which got saved while packing should get deleted from the field EPC1.

Former Member
Former Member replied

Hi Bhavika,

Hu header VEKP table cannot be updated directly.

There are 4 FM's to be called together(one after other) to achieve it. viz.

HU_PACKING_REFRSH

V51P_FILL_GT

HU_HEADER_UPDATE

HU_PACKING_UPDATE

Please find below my code where i tried to update VEGR1 and VEGR2 field

/* Populate the tables required to pass to the FM.

READ TABLE gt_huheader INTO gw_huheader WITH KEY hu_exid = gw_alvhu-exidv.

      IF sy-subrc = 0.

        lw_hu-exidv = gw_alvhu-exidv.

        APPEND lw_hu TO lt_hus.

        lw_flags-no_db_select = ' '.

        lw_flags-lock_hu      = 'X'.

        lw_flags-add_and_exp  = 'X'.

        APPEND lw_object TO lt_objects.

        lw_new_values-hdl_unit_itid = gw_huheader-hu_id. " Internal Handling Unit Number

        lw_new_values-hdl_unit_exid = gw_huheader-hu_exid. " External Handling Unit Identification

        lw_new_values-field_name = 'VEGR1'.         " Field name of changed field

        lw_new_values-field_value =  gw_alvhu-pci .  " Value of field to be changed

        APPEND lw_new_values TO lt_new_values.

        lw_new_values-hdl_unit_itid = gw_huheader-hu_id. " Internal Handling Unit Number

        lw_new_values-hdl_unit_exid = gw_huheader-hu_exid. " External Handling Unit Identification

        lw_new_values-field_name = 'VEGR2'.         " Field name of changed field

        lw_new_values-field_value =  gw_alvhu-load .  " Value of field to be changed

        APPEND lw_new_values TO lt_new_values.

   

/*Call the FM in sequence

CALL FUNCTION 'HU_PACKING_REFRESH'.

  IF lt_hus[] IS NOT INITIAL.

    CALL FUNCTION 'V51P_FILL_GT'

      EXPORTING

        is_flags         = lw_flags

        it_hus           = lt_hus

      IMPORTING

        ef_rcode         = lv_rcode

        et_vekp          = lt_header

        et_vepo          = lt_items

        et_vevw          = lt_history

        et_highest_level = lt_high

        et_messages      = lt_messages_hu

      EXCEPTIONS

        hu_locked        = 01

        no_hu_found      = 02

        OTHERS           = 99.

  ENDIF.

  IF lt_new_values IS NOT INITIAL.

    CALL FUNCTION 'HU_HEADER_UPDATE'

      EXPORTING

        it_new_values = lt_new_values

      IMPORTING

        et_messages   = lt_messages

      EXCEPTIONS

        not_possible  = 1

        OTHERS        = 2.

    IF sy-subrc <> 0.

      MESSAGE e018 WITH gw_huheader-hu_exid.

   else.

      CALL FUNCTION 'HU_PACKING_UPDATE'

        EXPORTING

          if_synchron = 'X'.

ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question