form get_cost_element
using
pi_plant type werks_d
pi_matnr type matnr
pi_date type sydatum
changing
po_cost type total_amt.
data:
lt_cvar type standard table of bapicstgva with header line,
lt_matnr type standard table of bapimateri with header line,
lt_plant type standard table of bapiplant with header line,
lt_costs type standard table of bapisplitt with header line.
data: begin of it_list occurs 0.
include structure bapicolist.
data: end of it_list.
data:
ls_cost_header like bapiheader.
data:
ls_ret type bapireturn,
lf_found type char1 value ' '.
* ABCD is the costing variant. It should be your company specifics.
add_selection_value 'ABDC' lt_cvar.
add_selection_value pi_matnr lt_matnr.
add_selection_value pi_plant lt_plant.
clear: po_cost.
call function 'BAPI_COSTESTIMATE_GETLIST'
importing
return = ls_ret
tables
costing_variant = lt_cvar
material = lt_matnr
plant = lt_plant
cost_estimate_list = it_list
exceptions
others = 1.
check sy-subrc = 0.
* sort to get result of the last costing run
sort it_list by valid_from descending.
* XX and YYY should be specific to your task.
* Check with debugger after calling the first BAPI
loop at it_list where cstg_type = 'XX' and
vltn_vrnt = 'YYY'.
if lf_found = 'X'.
exit.
endif.
* Get first costing suitable by date
if pi_date >= it_list-valid_from and
pi_date 0.
po_cost = lt_costs-total_amt.
lf_found = 'X'.
exit.
endloop.
endif.
endif.
endloop.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.