SAP BLOG How to add customer-specific fields into MB52

SAP Blog

Kayıtlı Üye
Katılım
22 Ara 2017
Mesajlar
1,925
Tepki puanı
7
Puanları
6
It is the common requirement to extend standard reporting programs with additional information.

Here is the example of extending Transaction MB52 List of Warehouse Stocks on Hand ( Program RM07MLBS; Component MM-IM Inventory Management ) by a new field Supplier batch. The field is used as a unique identification number for tracking purposes and is usually received from a supplier before the Goods receipt step).

Important note: Based on the customizing the batch number can be unique at Client, Plant or Material level. Dependent on it, the source table to retrieve batch master attributes will be different.

To fulfill the requirement we can use the predefined enhancements spots inside the program RM07MLBS:

  • Extend the field structure ( type structure bestand, RM07MLBS) with the new columns: ENHANCEMENT–POINT ehp604_rm07mlbs_03 SPOTS es_rm07mlbs STATIC .

Extend-structure-1.png


  • Extend the routing by adding a field into the field catalog and filling the newly added fields. Progam RM07MLBS, routine list_output. Use the ENHANCEMENT-SECTION rm07mlbs_09 SPOTS es_rm07mlbs.

Kod:
  TRY.
* Adding a field into the Field catalog
    INSERT VALUE #( fieldname = 'LICHA' 
                    tabname   = 'BESTAND'
                    ref_fieldname = 'LICHA'  
                    ref_tabname = 'MCH1'
                    col_pos = fieldcat[ 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_query
      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 a 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 MB52:

Field.png


The new column is added and filled with a value ( Supplier batch for an internal batch number ).

Okumaya devam et...
 
Üst