black_adept hat geschrieben:Hallo autohandel7,
warum löst ihr das nicht im SAP-Standard mit Transaktion MM17.
Hi black_adept ,
ich habe schon fast geshaft, etwas stimt nicht bei aufruf BApi und zwar hier:
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
*
EXPORTING
headdata = BAPI_HEAD
* SALESDATA = BAPI_MVKEx
* SALESDATAX = BAPI_MVKEX
Schreibt feldlangen stimtnicht.
Hier ist mein code:
Danke im Vorraus
*-------------------------------------------------*
CONSTANTS vkorg_tab TYPE p VALUE '8100'.
CONSTANTS vtweg_tab TYPE p VALUE '81'.
CONSTANTS mtart_tab TYPE string VALUE 'ZPRS'.
TYPES:
BEGIN OF t_tab,
matnr TYPE matnr,
mtart TYPE mtart,
*MAKTX TYPE MAKTX,
meins TYPE meins,
zzmatnr TYPE zzmatnr,
*ZZIDTNR TYPE ZZIDTNR,
*ZZKOVOT TYPE ZZKOVOT,
*ZZSETA TYPE ZZSETA,
*ZZANTO TYPE ZZANTO,
*ZZVPEI TYPE ZZVPEI,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
sktof TYPE sktof,
*VKORG_BEZ TYPE VKORG_BEZ,
*SPRAS TYPE SPRAS,
lvorm TYPE lvorm,
END OF t_tab.
DATA:
it_join TYPE t_tab,
* p_matnr TYPE matnr,
wa_tab TYPE t_tab,
it_tab TYPE TABLE OF t_tab WITH KEY matnr.
PARAMETERS: p_matnr LIKE mseg-matnr.
*--------------------------------------------------------
START-OF-SELECTION.
*----------it_tab----------------------------------------
SELECT
mara~matnr
mara~mtart
*MAKT~MAKTX
mara~meins
mara~zzmatnr
*mara~ZZIDTNR
*mara~ZZKOVOT
*mara~ZZSETA
*mara~ZZANTO
*mara~ZZVPEI
mvke~vkorg
mvke~vtweg
mvke~sktof
*makt~SPRAS
mara~lvorm
*RMMG1_BEZ~VKORG_BEZ
FROM mara
JOIN mvke ON mara~matnr = mvke~matnr
INTO CORRESPONDING FIELDS OF TABLE it_tab
WHERE
mara~mtart = mtart_tab
and mara~matnr = p_matnr "
AND mvke~vkorg = vkorg_tab
AND mvke~vtweg = vtweg_tab.
* AND mara~lvorm = 'X'.
SORT it_tab BY matnr.
DELETE ADJACENT DUPLICATES FROM it_tab.
*&---------------------------------------------------------------------*
*& Form UPDATE_MM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*FORM UPDATE_MM.
Data: BAPI_HEAD TYPE bapimathead,
BAPI_MARA1 TYPE BAPI_MARA,
BAPI_Vertrieb TYPE BAPI_MVKE,
BAPI_MVKEX TYPE BAPI_MVKE,
SALESDATA TYPE BAPI_MVKE,
SALESDATAx TYPE BAPI_MVKE,
tabvkorg TYPE c LENGTH 4 VALUE '8200',
tabvtweg TYPE c LENGTH 2 VALUE '82'.
LOOP AT it_tab into wa_tab.
* Header
BAPI_HEAD-MATERIAL = wa_tab-MATNR.
BAPI_HEAD-MATL_TYPE = wa_tab-mtart.
*CLIENTDATA
BAPI_MARA1-BASE_UOM = wa_tab-meins.
* zzmatnr
* SALESDATA
BAPI_Vertrieb-SALES_ORG = tabvkorg.
BAPI_Vertrieb-DISTR_CHAN = tabvtweg. "wa_tab-vtweg.
BAPI_Vertrieb-CASH_DISC = wa_tab-sktof.
SALESDATAx = 'X'.
ENDLOOP.
WRITE:/ BAPI_HEAD, / BAPI_Vertrieb-SALES_ORG, / BAPI_Vertrieb-DISTR_CHAN.
*ENDFORM.
**
**--------------------------------
DATA:
** Fehlertabelle
gw_return TYPE bapiret2,
** Fehlertext
g_message TYPE bapiret2-message.
****-------------------------- ***
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
*
EXPORTING
headdata = BAPI_HEAD
* SALESDATA = BAPI_MVKEx
SALESDATAX = BAPI_MVKEX
IMPORTING
return = gw_return
TABLES
*
MATERIALDESCRIPTION = it_tab.
COMMIT WORK.
* Langtext besorgen
CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
EXPORTING
id = gw_return-id
number = gw_return-number
textformat = 'ASC'
message_v1 = gw_return-message_v1
message_v2 = gw_return-message_v2
message_v3 = gw_return-message_v3
message_v4 = gw_return-message_v4
IMPORTING
message = g_message.
CASE gw_return-type.
WHEN 'S' OR 'I'.
FORMAT COLOR 5.
WRITE / g_message.
WHEN 'E' OR 'A'.
FORMAT COLOR 6.
WRITE / g_message.
WHEN 'W'.
FORMAT COLOR 3.
WRITE / g_message.
WHEN OTHERS.
FORMAT COLOR OFF.
WRITE / g_message.
ENDCASE.