Find how to add customer specific fields into MB52

 Find how to add customer specific fields into MB52(List of Warehouse Stocks on Hand):

The most common requirement to extend standard reporting programs with additional information.

For example of extending Transaction code tcode MB52 List of Warehouse Stocks on Hand ( Program RM07MLBS, Component MM-IM Inventory Management) by a new field Supplier batch. This field is used as a unique identification number (ID) for tracking purposes & are usually received from a supplier before the Goods receipt step).

Note: Based on the customizing batch number can be unique at Client/ Plant or Material level. Dependent on them, the source table to retrieve batch master attribute will be different.

For fulfilling  requirement, we can use predefined enhancements spots inside the program RM07MLBS -

  • Extend  field structure ( type structure bestand, RM07MLBS) with  new columns - ENHANCEMENTPOINT ehp604_rm07mlbs_03 SPOTS es_rm07mlbs STATIC .

  • Extend routing by adding a field into the field catalog & filling the newly added fields. Program RM07MLBS, routine list_output. We will use the ENHANCEMENT-SECTION rm07mlbs_09 SPOTS es_rm07mlbs.
  TRY.
*** Adding a field into the Field catalog
    INSERT VALUE #( fieldname = 'LICHA' 
                    tabname   = 'BESTAND'
                    ref_fieldname = 'LICHA'  
                    ref_tabname = 'MCH1'
                    col_pos = fieldct [ fieldname = 'CHARG' ]-col_pos ) INTO TABLE fieldcat.

*** Selecting materials with batches
    DATA(lt_batches_query) = CORRESPONDING tt_mcha( bestand[] ).

*** Getting batch attributes
    SELECT matnr, charg, licha
      INTO TABLE @DATA(lt_batch_master)
      FROM mch1 FOR ALL ENTRIES IN @lt_batches_quer
      WHERE  matnr = @lt_batches_query-matnr AND 
             charg = @lt_batches_query-charg and 
             lvorm = ''.
    IF sy-subrc EQ 0.
      LOOP AT bestand[] ASSIGNING FIELD-SYMBOL(<lfs_output>) WHERE charg IS NOT INITIAL.
        TRY.
*** Assign the value to an output line
            <lfs_output>-licha = lt_batch_master[ matnr = <lfs_output>-matnr 
                                                  charg = <lfs_output>-charg ]-licha.
          CATCH cx_sy_itab_line_not_found.
            CONTINUE.
        ENDTRY.
      ENDLOOP.
    ENDIF.
   CATCH cx_sy_itab_line_not_found.
    " No exception handling 
  ENDTRY.
  • Check the result by running the transaction code Tcode MB52 - 

New column added & filled with a value ( Supplier batch for an internal batch number ).

Hope this Helps. Thank you everyone.

Comments

Popular posts from this blog

EVENTS IN INTERACTIVE REPORTS OF SAP ABAP

SAP ABAP Fresher Resume/ CV Writing Format..

CONCEPTS OF INNER JOIN AND OUTER JOIN in SAP ABAP