‎2006 Oct 24 1:21 PM
Hi all!!
Im trying to use this BAPI, but it don´t update the ISEG... This is my code.
FORM grabartabla .
DAta: begin of tabapi occurs 0.
include structure BAPI_PHYSINV_COUNT_ITEMS.
DATA end of tabapi.
DATA taberror like BAPIRET2 occurs 0.
LOOP AT itabaux3.
Meto en una wa para poder insertar correctamente en ZMM002
wa_aux-docinv = itabaux3-ndoc.
wa_aux-nref = itabaux3-nref.
Sin UNPACK no tira bien la SLECT
UNPACK itabaux3-matnr TO itabaux3-matnr.
UNPACK itabaux3-ndoc TO itabaux3-ndoc.
BSTAR igual a 1 es stock EN ALMACEN!! Tiene que ser = A 1
SELECT SINGLE menge zeili INTO v_menge v_zeili FROM iseg
SELECT SINGLE * FROM iseg
WHERE iblnr = itabaux3-ndoc
AND matnr = itabaux3-matnr
AND bstar = '1'.
v_menge = iseg-menge.
v_zeili = iseg-zeili.
Sumo el stock de la DBtab y de la Itab
v_menge = v_menge + itabaux3-cantidad.
Lo inserto en la tabla sobreescribiendo el anterior
*BAPI!!
UPDATE iseg
SET menge = v_menge
WHERE iblnr = itabaux3-ndoc
AND matnr = itabaux3-matnr
AND bstar = '1'.
*Si hemos llegado hasta aqui es porque el doc y la ref no están en la
*ZMM002, solo lo meto una vez
SELECT SINGLE * FROM zmm002 WHERE docinv = itabaux3-ndoc
AND nref = itabaux3-nref.
IF sy-subrc = 4.
INSERT INTO zmm002 VALUES wa_aux.
values docinv nref.
ENDIF.
tabapi-ITEM = v_zeili.
tabapi-MATERIAL = itabaux3-matnr.
tabapi-ENTRY_UOM = 'UN'."esto hay que cambiarlo
tabapi-ENTRY_QNT = itabaux3-cantidad.
APPEND tabapi.
CLEAR v_menge.
CLEAR wa_aux.
ENDLOOP.
CALL FUNCTION 'BAPI_MATPHYSINV_COUNT'
EXPORTING
physinventory = itabaux3-ndoc
fiscalyear = '2006' "Esto hay k cambiarlo
PERCENTAGE_VARIANCE =
COUNT_DATE =
tables
items = tabapi
return = taberror
SERIALNUMBERS =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
Thanks a lot
‎2006 Oct 24 1:23 PM
Check your taberrors table and see if the call was indeed succesful.
Regards,
Ravi
‎2006 Oct 24 1:48 PM
Hi,
try to check like this after calling FM 'BAPI_MATPHYSINV_COUNT'.....
data : v_wait like bapita-wait value 'X'.
if sy-subrc <> 0.
*-- Execute external Commit when using BAPIs
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = v_wait
importing
return = t_return2.
endif.
‎2006 Oct 24 2:29 PM
Hi,
the bapi returns 0, and the error table returns that all is ok...