01-25-2011 9:55 AM
Hi All,
I am facing problem to fill BAPI: BAPI_GOODSMVT_CREATE_OIL with additional quantities,
if any body has sample code please send it across.
Regards,
Prasanth
02-01-2011 3:04 PM
Hi,
Sample code for BAPI_GOODSMVT_CREATE_OIL:
This code is to post the documents using MB1C transaction with manual additional quantities.
1. Get material default temperatures and densities
Get default Material temperatures & densities
CALL FUNCTION 'OIB_QCI_DEFAULTS'
EXPORTING
i_matnr = ws_socdip1-matnr
i_werks = ws_socdip1-station
i_lgort = '0001'
TABLES
et_param = wt_qci_dflts
EXCEPTIONS
pdtyp_not_found = 1
rdggrp_not_found = 2
move_field_to_itab_failed = 3
marc_single_read_failed = 4
param_error = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CLEAR ws_mat_params.
ws_mat_params-matnr = ws_socdip1-matnr.
ws_mat_params-station = ws_socdip1-station.
Test temperature
CLEAR ws_qci_dflts.
READ TABLE wt_qci_dflts INTO ws_qci_dflts
WITH KEY fieldname = 'TSTMP'.
IF sy-subrc = 0.
ws_mat_params-test_temp = ws_qci_dflts-par_fltp.
ENDIF.
Test density
CLEAR ws_qci_dflts.
READ TABLE wt_qci_dflts INTO ws_qci_dflts
WITH KEY fieldname = 'TDICH'.
IF sy-subrc = 0.
ws_mat_params-test_dens = ws_qci_dflts-par_fltp.
ENDIF.
APPEND ws_mat_params TO wt_mat_params.
CLEAR: ws_mat_params, ws_qci_dflts.
ENDIF.
2. Fill the BAPI parameter as per the requirement
Note: 'ws_param-testtemp_density_uom' must be 'CEL', because it is temperature UOM not density UOM.
wv_gm_code = '05'. "for MB1C
wlv_line_id = wlv_line_id + 1.
Setup BAPI header data.
ws_header-pstng_date = sy-datum.
ws_header-doc_date = sy-datum.
ws_header-pstng_time = sy-uzeit.
Main item details
ws_item-line_id = wlv_line_id.
ws_item-move_type = wls_tmp_dip_vals-mnt_type.
ws_item-material = wls_tmp_dip_vals-matnr.
ws_item-plant = wls_tmp_dip_vals-station.
ws_item-stge_loc = '0001'.
ws_item-batch = 'TAX'.
COMPUTE ws_item-entry_qnt = wls_tmp_dip_vals-sdiff_l20.
ws_item-entry_uom = 'L20'.
APPEND ws_item TO wt_item.
Oil Specific details
ws_oil_item-line_id = wlv_line_id.
ws_oil_item-handling_type = '01'.
APPEND ws_oil_item TO wt_oil_item.
READ TABLE wt_mat_params INTO ws_mat_params
WITH KEY matnr = wls_tmp_dip_vals-matnr
station = wls_tmp_dip_vals-station
BINARY SEARCH.
IF sy-subrc = 0.
ws_param-line_id = wlv_line_id.
ws_param-calculatemissing = 'X'.
ws_param-materialtemperature = wls_tmp_dip_vals-ambtem.
ws_param-materialtemperature_uom = 'CEL'.
ws_param-testdensity = ws_mat_params-test_dens.
ws_param-testdensity_uom = 'KGV'.
ws_param-testtemperature_density = ws_mat_params-test_temp.
ws_param-testtemp_density_uom = 'CEL'.
APPEND ws_param TO wt_param.
ENDIF.
CLEAR ws_quan.
ws_quan-line_id = wlv_line_id.
ws_quan-quantitypacked = wls_tmp_dip_vals-sdiff_l20.
ws_quan-quantityfloat = wls_tmp_dip_vals-sdiff_l20.
ws_quan-quantityuom = 'L20'.
ws_quan-quantitycheck = 'U'.
APPEND ws_quan TO wt_quan.
CLEAR ws_quan.
ws_quan-line_id = wlv_line_id.
ws_quan-quantitypacked = wls_tmp_dip_vals-sdiff_kg.
ws_quan-quantityfloat = wls_tmp_dip_vals-sdiff_kg.
ws_quan-quantityuom = 'KG'.
ws_quan-quantitycheck = 'U'.
APPEND ws_quan TO wt_quan.
CLEAR ws_quan.
ws_quan-line_id = wlv_line_id.
ws_quan-quantitypacked = wls_tmp_dip_vals-sdiff_l.
ws_quan-quantityfloat = wls_tmp_dip_vals-sdiff_l.
ws_quan-quantityuom = 'L'.
ws_quan-quantitycheck = 'U'.
APPEND ws_quan TO wt_quan.
Calling BAPI
CLEAR ws_goodsmvt_header.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE_OIL'
EXPORTING
goodsmvt_header = ws_header
goodsmvt_code = wv_gm_code
testrun = wc_valx
IMPORTING
goodsmvt_headret = ws_goodsmvt_header
TABLES
goodsmvt_item_01 = wt_item
goodsmvt_item_02 = wt_oil_item
goodsmvt_item_param = wt_param
goodsmvt_item_quan = wt_quan
return = wt_return.
02-01-2011 3:06 PM