Malzeme Yaratırken ZZ`li Alanların Doldurulması
`BAPI_MATERIAL_SAVEDATA` fonksiyonu ile malzeme yaratırken, daha önceden mara,marc,mvke vs. gibi tablolara eklenmiş ZZ`li alanlar doldurulabilir. Yada güncellenebilir.
Fonksiyon hatasız çalışmasına rağmen ve malzeme MM02/MM03`de gözükmesine rağmen ilgili alanlar boş gözüküyorsa T130F tablosu kontrol edilmelidir. FNAME alanı ilgilendiğimiz ZZ`li alana ait olan satırın PSTAT alanı `V` değerini içermelidir.
DATA: lt_extensionin TYPE TABLE OF bapiparex,
ls_extensionin LIKE LINE OF lt_extensionin,
lt_extensioninx TYPE TABLE OF bapiparexx,
ls_extensioninx LIKE LINE OF lt_extensioninx,
ls_bapi_te_mara LIKE bapi_te_mara,
ls_bapi_te_marax LIKE bapi_te_marax.
"ZZ`li ek alanlar
CLEAR ls_bapi_te_mara.
ls_bapi_te_mara-material = ls_head-material.
IF ls_mara-zzithal IS NOT INITIAL.
SHIFT ls_mara-zzithal LEFT DELETING LEADING `0`.
CONCATENATE `0` ls_mara-zzithal INTO ls_mara-zzithal.
ls_bapi_te_mara-zzithal = ls_mara-zzithal.
ENDIF.
ls_bapi_te_mara-zzprodh = ls_mara-prdha.
CLEAR ls_bapi_te_marax.
ls_bapi_te_marax-material = ls_head-material.
ls_bapi_te_marax-zzithal = `X`.
ls_bapi_te_marax-zzprodh = `X`.
CLEAR ls_extensionin.
ls_extensionin-structure = `BAPI_TE_MARA`.
ls_extensionin-valuepart1 = ls_bapi_te_mara.
APPEND ls_extensionin TO lt_extensionin.
CLEAR ls_extensioninx.
ls_extensioninx-structure = `BAPI_TE_MARAX`.
ls_extensioninx-valuepart1 = ls_bapi_te_marax.
APPEND ls_extensioninx TO lt_extensioninx.
CALL FUNCTION `BAPI_MATERIAL_SAVEDATA`
EXPORTING
headdata = ls_head
clientdata = ls_clientdata
clientdatax = ls_clientdatax
plantdata = ls_marc
plantdatax = ls_marc_x
storagelocationdata = ls_mard
storagelocationdatax = ls_mard_x
salesdata = ls_salesdata
salesdatax = ls_salesdatax
IMPORTING
return = ls_return1
TABLES
materialdescription = lt_materialdescription
unitsofmeasure = lt_unitsofmeasure
unitsofmeasurex = lt_unitsofmeasurex
taxclassifications = lt_taxclassifications
extensionin = lt_extensionin
extensioninx = lt_extensioninx
returnmessages = lt_return.
LOOP AT lt_return INTO ls_return WHERE type CA `EAX`.
MOVE-CORRESPONDING ls_return TO ls_ret2.
APPEND ls_ret2 TO lt_ret2.
ENDLOOP.
IF sy-subrc = 0 OR ls_return1-type CA `EAX`.
CALL FUNCTION `BAPI_TRANSACTION_ROLLBACK`.
ELSE.
CALL FUNCTION `BAPI_TRANSACTION_COMMIT`
EXPORTING
wait = `X`.
ENDIF.