2
« en: 23 de Diciembre de 2008, 07:53:47 pm »
con esta BAPI se puede realizar el inventario fisico de materiales,
llena las estructuras de la BAPI
FORM obtener_datos .
LOOP AT tab_file.
SPLIT tab_file-registro
AT ','
INTO w_itab-iblnr
w_itab-zldat
w_itab-zeili
w_itab-matnr
w_itab-batch
w_itab-pmeng
w_itab-meins
w_itab-meins_iso.
APPEND w_itab.
CLEAR: w_itab, tab_file.
ENDLOOP.
SORT w_itab BY iblnr.
LOOP AT w_itab.
MOVE-CORRESPONDING w_itab TO w_itab2.
APPEND w_itab2.
ENDLOOP.
CLEAR w_itab.
REFRESH w_itab.
LOOP AT w_itab2.
MOVE-CORRESPONDING w_itab2 TO w_itab.
APPEND w_itab.
AT END OF iblnr.
physinventory = w_itab-iblnr.
count_date = w_itab-zldat.
LOOP AT w_itab.
CLEAR items.
items-item = w_itab-zeili.
items-material = w_itab-matnr.
items-batch = w_itab-batch.
IF w_itab-pmeng <> '0' OR w_itab-pmeng <> 0.
items-entry_qnt = w_itab-pmeng.
items-entry_uom = w_itab-meins.
items-entry_uom_iso = w_itab-meins.
ELSE.
items-zero_count = 'X'.
items-entry_uom = w_itab-meins.
items-entry_uom_iso = w_itab-meins.
ENDIF.
APPEND items.
ENDLOOP.
PERFORM procesa_bapi.
LOOP AT return.
MOVE-CORRESPONDING return TO message.
APPEND message.
ENDLOOP.
CLEAR: message, items, return, w_itab,
physinventory, count_date.
REFRESH: items, return, w_itab.
ENDAT.
ENDLOOP.
ENDFORM. " obtener_datos
FORM procesa_bapi .
CALL FUNCTION 'BAPI_MATPHYSINV_COUNT'
EXPORTING
physinventory = physinventory
fiscalyear = sy-datum+0(4)
count_date = count_date
TABLES
items = items
return = return.
* Confirma ejecución de BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = space.
ENDFORM. " procesa_bapi