This blog illustrates the method to post goods movement in IS-OIL.
Almost every one of us have used “BAPI_GOODSMVT_CREATE” to post a material goods movement in SAP. But when we are working in IS-Oil material this BAPI does not work and we end up trying different ways to do the same.
Well SAP has another BAPI for this and I will try to post a 311 movement with the same. I hope this helps in other postings as well.
The BAPI is BAPI_GOODSMVT_CREATE_OIL.
Data Declaration :
DATA : lw_item TYPE bapioil2017_gm_itm_crte_01,
lw_item_param TYPE bapioil2017_gm_itm_crte_param,
lw_header TYPE bapioil2017_gm_head_create,
lw_doc_no TYPE mkpf-mblnr,
lt_item TYPE TABLE OF bapioil2017_gm_itm_crte_01,
lt_item_param TYPE TABLE OF bapioil2017_gm_itm_crte_param,
lt_return TYPE TABLE OF bapiret2.
Passing the Data.
Now most data passing will be similar to our standard way.
Material Document Header.
lw_header-pstng_date = sy-datum.
lw_header-doc_date = sy-datum.
Material Document Item.
lw_item-material = lw_g_odet-matnr.
lw_item-move_mat = lw_g_odet-matnr.
lw_item-plant = lw_tankm-plant.
lw_item-stge_loc = lw_tankm-sloc.
lw_item-batch = lw_oijnomi-charg_o.
lw_item-val_type = lc_vatyp.
lw_item-move_plant = lw_tankm-plant.
lw_item-move_stloc = lc_vsloc.
lw_item-move_batch = lw_oijnomi-charg_o.
lw_item-move_val_type = lc_vatyp.
lw_item-move_type = '311'.
lw_item-entry_qnt = lw_tankm-tag_value.
lw_item-entry_uom = lw_tankm-tag_uom.
Posting the Additional Quantities
Now this is the major difference between normal goods movement and IS-Oil goods movement.
In the declared lt_item_param there are two control parameters for posting items with additional quantities:
§ CALCULATEMISSING
§ USEDEFAULTPARAMETERS
There are QCI [Quantity Conversion Interface] parameters which are default specified in configuration if you want to use them you put the USEDEFAULTPARAMETERS parameter value as ‘X’.
Extract from SAP FM Documentation for understanding.
If the value you enter for the CALCULATEMISSING parameter differs from the default value, the system determines all all necessary units of measure for this posting item and calculates the missing quantities. Otherwise you must ensure that the system can access all quantities in all required units of measure through the interface.
We are going to provide values.
For some materials the Air Buoyancy indicator is also a parameter for conversion that can be received from MARC.
SELECT SINGLE umrsl abfac FROM marc
INTO (lw_item_param-conversiongroup,
lw_item_param-airbuoyancyconstant )
WHERE matnr = lw_g_odet-matnr
AND werks = lw_tankm-werks.
IF sy-subrc IS INITIAL.
IF lw_item_param-airbuoyancyconstant IS NOT INITIAL.
lw_item_param-airbuoyancyindicator = 'X'.
ENDIF.
ENDIF.
lw_item_param-calculatemissing = 'X'.
lw_item_param-testtemperature_density = '15.00'.
lw_item_param-testtemp_density_uom = 'CEL'.
lw_item_param-basedensity = lw_tankm-tag_value.
lw_item_param-basedensityuom = lw_tankm-tag_uom.
lw_item_param-testdensity = lw_tankm-tag_value.
lw_item_param-testdensity_uom = lw_tankm-tag_uom.
lw_item_param-materialtemperature = lw_tankm-tag_value.
lw_item_param-materialtemperature_uom = lw_tankm-tag_uom.
Another important point
There is a mapping between the item and item_param that is line_id they should be same for the item for which the parameter is passed.
ADD 1 TO lw_item_count.
lw_item-line_id = lw_item_param-line_id = lw_item_count.
APPEND lw_item TO lt_item.
APPEND lw_item_param TO lt_item_param.
CLEAR : lw_item,
lw_item_param.
Calling the BAPI
Finally we will call the BAPI to post the Document.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE_OIL'
EXPORTING
goodsmvt_header = lw_header
goodsmvt_code = '04'
IMPORTING
materialdocument = lw_doc_no
TABLES
goodsmvt_item_01 = lt_item
goodsmvt_item_param = lt_item_param
return = lt_return.
IF lt_return IS INITIAL
AND lw_doc_no IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
MESSAGE s110 WITH lw_doc_no.
ELSE.
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY_OK'
EXPORTING
endpos_col = 150
endpos_row = 15
startpos_col = 5
startpos_row = 5
titletext = text-002
TABLES
valuetab = lt_return.
ENDIF.