MM02 BDC – Select Specific Material Master View

By | September 24, 2008 | Classical | 9,274 | 2

Creating a BDC of the MM02 will not be an easy task. As soon as we enter the material and hit enter it will ask us to choose the required Material master views. This popup contains the available material master views and they are not constant. Sometimes MRP1 comes at the 12th line and sometimes it comes to 6th line. This dynamic of the views are solely depended on the Status (MARA-VPSTA).

To overcome of this dynamics we need to get to know where exactly our required view will appear e.g. line 6 or line 10 or line 15. We will use the FM SELECTION_VIEWS_FIND to find out which view will come at which position.

In our BDC, we will follow these steps:
1. Always select the Basic Data 1
2. Get the respective user command for the tab by Executing the FM SELECTION_VIEWS_FIND.

Status (MARA-VPSTA) contains the combination of the View indicator. You can find the relation of the status indicator and view name in the documentation of the data element PSTAT_D or follow this table:

User department Maintenance status
Work scheduling A
Accounting B
Classification C
Purchasing E
Production resources/tools F
Costing G
Basic data K
Storage L
Forecasting P
Quality management Q
Warehouse management S
Sales V
Plant stocks X
Storage location stocks Z

In this my test BDC, I want to update the MRP type. MRP type comes under the “MRP 1″ view of the material master. So, I will first select the Basic Data and than move to MRP 1 view and update the MRP type.
Code Snippet to Select View in MM02

REPORT ztest_np_mm02
* Local data
DATA:   messtab LIKE bdcmsgcoll OCCURS WITH HEADER LINE.
DATA:   bdcdata LIKE bdcdata    OCCURS WITH HEADER LINE.
* Selection Screen
            p_werks TYPE marc-werks OBLIGATORY,
            p_lgort TYPE rmmg1-lgort OBLIGATORY,
            p_dismm TYPE marc-dismm OBLIGATORY.
* Material views ....................................................
  DATA:  l_vpsta LIKE t130m-pstat.
         INTO   l_vpsta
         FROM   mara
         WHERE  matnr p_matnr.
* Get View sequence .................................................
  DATAl_bild  LIKE t133a-bilds,
        lt_bild LIKE mbildtab OCCURS WITH HEADER LINE.
* Screen Sequence for Standard Industry tab pages in material master
  l_bild '21'.
* Get screen sequence
      bildsequenz     l_bild
      pflegestatus    l_vpsta
      bildtab         lt_bild
      call_wrong      1
      empty_selection 2
      OTHERS          3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* Get the Tab page for MRP1 .........................................
  DATAl_tab_mrp1 TYPE sy-ucomm.
* reading table with MRP view
  READ TABLE lt_bild WITH KEY pstat 'D'.
  IF sy-subrc 0.
    l_tab_mrp1 lt_bild-guifu.
* make ok code for the MRP1
  CONCATENATE '=' l_tab_mrp1 INTO l_tab_mrp1.
* BDC ...............................................................
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '0060'.
  PERFORM bdc_field       USING 'RMMG1-MATNR'
  PERFORM bdc_field       USING 'BDC_OKCODE'
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '0070'.
  PERFORM bdc_field       USING 'MSICHTAUSW-KZSEL(01)'
  PERFORM bdc_field       USING 'BDC_OKCODE'
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '4004'.
  PERFORM bdc_field       USING 'BDC_OKCODE'
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '0081'.
  PERFORM bdc_field       USING 'RMMG1-WERKS'
  PERFORM bdc_field       USING 'RMMG1-LGORT'
  PERFORM bdc_field       USING 'BDC_OKCODE'
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '4000'.
  PERFORM bdc_field       USING 'MARC-DISMM'
  PERFORM bdc_field       USING 'BDC_OKCODE'
  PERFORM bdc_transaction USING 'MM02'.
*&      Form  BDC_DYNPRO
FORM bdc_dynpro USING p_program
  MOVEp_program TO bdcdata-program,
        p_screen  TO bdcdata-dynpro,
        'X'       TO bdcdata-dynbegin.
  APPEND bdcdata.
  CLEAR  bdcdata.
ENDFORM.                    " BDC_DYNPRO
*&      Form  BDC_FIELD
FORM bdc_field USING p_field_name
  MOVEp_field_name  TO bdcdata-fnam,
        p_field_value TO bdcdata-fval.
  APPEND bdcdata.
  CLEAR  bdcdata.
ENDFORM.                    " BDC_FIELD
FORM bdc_transaction USING tcode.
  DATAl_subrc LIKE sy-subrc.
* batch input session
  REFRESH messtab.
                   MODE   'A'
                   "A: show all dynpros
                   "E: show dynpro on error only
                   "N: do not display dynpro
                   UPDATE 'L'
                   MESSAGES INTO messtab.
  REFRESH bdcdata.
ENDFORM.                    "BDC_TRANSACTION

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{271 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 271 articles.

Load comments


  • Anonymous

    This artical helped me a lot to resolve the same issue.

  • Anonymous

    Too good !!! source
    thank you !!
    AAbhar tamaro !!

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.