Skip to Content
0
Former Member
Dec 11, 2007 at 10:44 AM

Problem with MATERIAL_MAINTAIN_DARK

23 Views

Hi,

I want to create a material master with MATERIAL_MAINTAIN_DARK.

But I always get error MG - 159 (type Error):

"The material cannot be created since no maintainable data exists"

Here's the coding:

CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'

EXPORTING

material_type = wa_matyp

industry_sector = wa_branch

TABLES

material_number = it_bapimatinr.

READ TABLE it_bapimatinr INDEX 1 INTO wa_bapimatinr.

wa_mara-mandt = sy-mandt. wa_mara-matnr = wa_bapimatinr-material.

wa_mara-mtart = wa_matyp. wa_mara-mbrsh = wa_branch.

wa_mara-matkl = wa_wagru. wa_mara-prdha = wa_hierar.

wa_mara-vpsta = 'KVDPBEALGQ'.

wa_mara-pstat = 'KVDPBELGQ'.

wa_mara-tcode = 'MM01'.

wa_mara-tranc = 1. wa_mara-d_ind = 1.

wa_mara-kz_mat_res = 'X'.

APPEND wa_mara TO it_mara.

wa_makt-mandt = sy-mandt. wa_makt-matnr = wa_bapimatinr-material.

wa_makt-spras = 'D'. wa_makt-maktx = wa_txtde.

wa_makt-tranc = 1. wa_makt-d_ind = 2.

APPEND wa_makt TO it_makt.

wa_marc-mandt = sy-mandt. wa_marc-matnr = wa_bapimatinr-material.

wa_marc-werks = wa_werk.

wa_marc-tranc = 1. wa_marc-d_ind = 3.

APPEND wa_marc TO it_marc.

wa_mard-mandt = sy-mandt. wa_mard-matnr = wa_bapimatinr-material.

wa_mard-werks = wa_werk. wa_mard-lgort = wa_lgort.

wa_mard-tranc = 1. wa_mard-d_ind = 4.

APPEND wa_mard TO it_mard.

wa_mvke-mandt = sy-mandt. wa_mvke-matnr = wa_bapimatinr-material.

wa_mvke-vkorg = wa_vkorg. wa_mvke-vtweg = wa_vtweg.

wa_mvke-prodh = wa_hierar.

wa_mvke-tranc = 1. wa_mvke-d_ind = 5.

APPEND wa_mvke TO it_mvke.

CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'

EXPORTING

flag_muss_pruefen = ' '

sperrmodus = ' '

p_kz_no_warn = 'N'

kz_prf = 'I'

user = sy-uname

TABLES

amara_ueb = it_mara

amakt_ueb = it_makt

amarc_ueb = it_marc

amard_ueb = it_mard

amvke_ueb = it_mvke

amerrdat = it_error "Fehlerliste

EXCEPTIONS

kstatus_empty = 1

tkstatus_empty = 2

t130m_error = 3

internal_error = 4

too_many_errors = 5

update_error = 6

error_propagate_header = 7

OTHERS = 8.

IF sy-subrc = 0. COMMIT WORK. ENDIF.

Best regards,

Werner.