Application Development and Automation 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: 
Read only

About BAPI_MATPHYSINV_COUNT

Former Member
0 Likes
761

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

3 REPLIES 3
Read only

Former Member
0 Likes
526

Check your taberrors table and see if the call was indeed succesful.

Regards,

Ravi

Read only

Former Member
0 Likes
526

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.

Read only

0 Likes
526

Hi,

the bapi returns 0, and the error table returns that all is ok...