当前位置: 首页 > 工具软件 > MasterView > 使用案例 >

MM02 BDC - Select Specific Material Master View

茹航
2023-12-01
 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
MRP D
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
NO STANDARD PAGE HEADING LINE-SIZE 255.
*
* Local data
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
*
* Selection Screen
PARAMETERS: p_matnr TYPE mara-matnr OBLIGATORY,
p_werks TYPE marc-werks OBLIGATORY,
p_lgort TYPE rmmg1-lgort OBLIGATORY,
p_dismm TYPE marc-dismm OBLIGATORY.
*
*
START-OF-SELECTION.
*
* Material views ....................................................
DATA: l_vpsta LIKE t130m-pstat.
*
SELECT SINGLE vpsta
INTO l_vpsta
FROM mara
WHERE matnr = p_matnr.
*
* Get View sequence .................................................
DATA: l_bild LIKE t133a-bilds,
lt_bild LIKE mbildtab OCCURS 0 WITH HEADER LINE.
*
* Screen Sequence for Standard Industry tab pages in material master
l_bild = '21'.
*
* Get screen sequence
CALL FUNCTION 'SELECTION_VIEWS_FIND'
EXPORTING
bildsequenz = l_bild
pflegestatus = l_vpsta
TABLES
bildtab = lt_bild
EXCEPTIONS
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.
ENDIF.
*
* Get the Tab page for MRP1 .........................................
DATA: l_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.
ENDIF.
*
* 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'
p_matnr.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
*
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
*
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
l_tab_mrp1.
*
PERFORM bdc_dynpro USING 'SAPLMGMM' '0081'.
PERFORM bdc_field USING 'RMMG1-WERKS'
p_werks.
PERFORM bdc_field USING 'RMMG1-LGORT'
p_lgort.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
*
PERFORM bdc_dynpro USING 'SAPLMGMM' '4000'.
PERFORM bdc_field USING 'MARC-DISMM'
p_dismm.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
*
PERFORM bdc_transaction USING 'MM02'.
*
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
FORM bdc_dynpro USING p_program
p_screen.
*
MOVE: p_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
p_field_value.
*
MOVE: p_field_name TO bdcdata-fnam,
p_field_value TO bdcdata-fval.
*
APPEND bdcdata.
CLEAR bdcdata.
*
ENDFORM. " BDC_FIELD
*
*
*&---------------------------------------------------------------------*
*& Form BDC_TRANSACTION
*&---------------------------------------------------------------------*
FORM bdc_transaction USING tcode.
DATA: l_mstring(480).
DATA: l_subrc LIKE sy-subrc.
* batch input session
REFRESH messtab.
CALL TRANSACTION tcode USING bdcdata
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

 类似资料:

相关阅读

相关文章

相关问答