Wednesday, 12 August 2015

Adding Custom Field In MB51 (Material Document List)

This is the topic to add custom field in MB51(Material Document List)

Requirement:Add material group and material description in MB51

Step:go to MSEG table add two fields like ZZMAT_GROUP & ZZMAT_DESC with structure

step2-then find out the program name for the transaction code MB51 which is RM07DOCS double click on that program name and on that click on spiral button to find the implicit enhancement position. when you find the position you have to add custom field to the LIST internal table.

step-3:then you search the perform name 'PERFORM output_list.' and double click on it and some logic on that part like this.

on this part write the code:

       wa_line TYPE TLINE,
       l_v_text TYPE char100,
       index TYPE sy-tabix.
****add by sujit on dt:10.08.2015
types:begin of ty_makt,
      matnr type matnr,
      matkl type matkl,
      end of ty_makt,
      BEGIN OF ty_desc,
      MATKL  type MATKL,
      WGBEZ  type WGBEZ,
      end of ty_desc.

data:lt_matkl TYPE TABLE OF ty_makt,
     lt_desc  type TABLE OF ty_desc.

FIELD-SYMBOLS<lfs_matkl> type ty_makt,
               <lfs_desc>  type ty_desc.
******end of addition mat group and description on dt:10.08.2015

**************add by sujit on dt:10.08.2015
******add mat group and description by sujit on dt 10.08.2015
data lt_itab1 LIKE list[].
FIELD-SYMBOLS <lfs_itab> like LINE OF lt_itab1.
lt_itab1[] list[].
if lt_itab1 is NOT INITIAL.
  select matnr
    from mara INTO TABLE lt_matkl
    FOR ALL ENTRIES IN lt_itab1
    WHERE matnr lt_itab1-matnr.
  if sy-subrc eq 0.
    sort lt_matkl by matnr.
      from T023T INTO table lt_desc
      FOR ALL ENTRIES IN lt_matkl
      where spras sy-langu and
            matkl lt_matkl-matkl.
      if sy-subrc eq 0.
        sort lt_desc by matkl.

  LOOP at lt_itab1 ASSIGNING <lfs_itab>.

    READ TABLE lt_matkl ASSIGNING <lfs_matkl> with key
                                      matnr <lfs_itab>-matnr BINARY SEARCH.
    if sy-subrc eq 0.
      <lfs_itab>-zzmat_group <lfs_matkl>-matkl.
     READ TABLE lt_desc ASSIGNING <lfs_desc> WITH key
                                      matkl <lfs_matkl>-matkl  BINARY SEARCH.
     if sy-subrc eq 0.
       <lfs_itab>-zzmat_desc <lfs_desc>-wgbez.


  list[] lt_itab1[].
*************end of addition mat group and description on dt:10.08.2015

step-4: then double click on Include structure ITAB and custom field on that declaration to show the fields in output list.

when double click on itab then you go to include RM07DOCS_GENERATED then you click on the spiral button append the fields to g_t_fields through enhanment.

this is the end of enhancement after that you run the tcode-MB51 and get the details on the out put.

if anyone face any problem post your comments the i will update you.


  1. Hello,
    thanks for your amazing sharing. I ve done everything what you tell but it doesn't show in ALV list. Do I need to add my Z field into some where else. When I checked ITAB table, everything is ok but when I checked filed catalog but Z field does not shown there. So do i miss some point? thanks again

  2. Lo unico que falta es modificar el LAYOUT para visualizar los campos que fueron agregados.

    Me resulto todo correctamente.


  3. In my version you have to add another ENHANCEMENT in RM07DOCS_GENERATED.
    After line
    501 rx'MKPF XBLNR 00 00'.

    rx'MSEG ZZMAT_GROUP 00 00'.
    rx'MSEG ZZMAT_DESC 00 00'.

    Otherwise it is not working - you don't get the extra fields in MB51.

  4. Allah senin belanı versin!!! Senin yüzünden yandı sistem...

  5. Hello,
    thanks for your amazing sharing.

  6. Hi, I want to add vendor name and old material no in output list of mb51 plz tell me how to add