Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

MASTERIDOC_CREATE_MATMAS

deepak_ghosh28
Explorer
0 Kudos
625

Hi Folks,

As per my requirement, The program name RBDMIDOC which was set as a background jobs and for message type 'MATMAS' I have to give certain condition inside the FM MASTERIDOC_CREATE_MATMAS to stop creating IDOC for condition (mara-mstav = 01,04,15,86 or mvke-mvgr2 = z1).
If the above condition satisfied our IDOC will not getting created. But the challenge which I'm facing that for same material we have different vkorg(Sales Organization).So we have multiple same material with different data.

My question is if changed some data like creation date or any other whose having mvke-mvgr2 = z1,So my segment is created for E1MARAM,so I can validate for mara-mstav, but as we don't do any changes for mvke-mvgr2,segment is not created for mvke.

How we can make system understand the value of that material with changes for particular vkorg,So that I can stop from processing.

Here is my code for validating. Please help me out.

METHOD if_ex_badi_matmas_ale_cr~change_matmas.

TYPES:BEGIN OF ty_itab,
matnr TYPE mara-matnr,
mstav TYPE mara-mstav,
mvgr2 TYPE mvke-mvgr2,
vkorg type mvke-vkorg,
END OF ty_itab.

DATA:lt_itab TYPE TABLE OF ty_itab,
ls_itab TYPE ty_itab.

DATA:ls_data TYPE edidd,
ls_e1maram TYPE e1maram,
lv_flag TYPE char1.

READ TABLE t_idoc_data INTO ls_data WITH KEY segnam = 'E1MARAM'.
IF sy-subrc = 0.
MOVE ls_data-sdata TO ls_e1maram.
SELECT mara~matnr
mara~mstav
mvke~mvgr2
mvke~vkorg
FROM mara INNER JOIN mvke ON
mara~matnr EQ mvke~matnr
INTO TABLE lt_itab
WHERE mara~matnr = ls_e1maram-matnr.
ENDIF.

CLEAR lv_flag.
LOOP AT t_idoc_data INTO ls_data.
IF ls_data-segnam EQ 'E1MARAM'.
MOVE ls_data-sdata TO ls_e1maram.
CLEAR ls_itab.
READ TABLE lt_itab INTO ls_itab WITH KEY matnr = ls_e1maram-matnr.
IF sy-subrc = 0.
IF ls_itab-mstav = '01' OR ls_itab-mstav = '04'
OR ls_itab-mstav = '15' OR ls_itab-mstav = '86' OR ls_itab-mvgr2 = 'Z1'.
lv_flag = 'X'.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
IF lv_flag = 'X'.
CLEAR t_idoc_data.
ENDIF.

ENDMETHOD.

1 REPLY 1

DominikTylczyn
Active Contributor
0 Kudos
379

Please use the to format your ABAP code!