07-17-2008 6:43 PM
Does anybody know how to use BAPI_ALM_ORDER_MAINTAIN to create a maintenance order? I did a where used and it isn't used by SAP. The documentation makes it look like I can use it for create but I am not sure how to do that.
Regards,
Davis
07-17-2008 6:47 PM
HI
Check out the links
https://forums.sdn.sap.com/click.jspa?searchID=12781394&messageID=4236927
Regards
Pavan
07-17-2008 6:50 PM
Thanks but it would have been nice if you wouldn't just recycle a post. I already looked at these links, the first time I saw them, and they do not help. Hell, the first one doesn't even do a create. It takes no effort to just post links.
Regards,
Davis
07-17-2008 6:52 PM
07-17-2008 6:53 PM
Hi,
I have one sample code piece. try to fit your requirement.
TYPES: t_alm_method type bapi_alm_order_method occurs 1.
TYPES: t_alm_component type bapi_alm_order_component occurs 1.
TYPES: t_alm_component_up type bapi_alm_order_component_up occurs 1.
TYPES: BEGIN of tp_sv_update,
aufnr type aufnr,
method type t_alm_method,
component type t_alm_component,
component_up type t_alm_component_up,
END of tp_sv_update.
DATA: ls_method type bapi_alm_order_method.
DATA: ls_component type bapi_alm_order_component.
DATA: ls_component_up type bapi_alm_order_component_up.
DATA: ls_sv_update type tp_sv_update.
DATA: lv_tabix like sy-tabix.
STATICS: sv_refno type i.
clear: lv_tabix, sv_refno.
ls_sv_update-aufnr = gt_alv1_data-aufnr.
endif.
sv_refno = sv_refno + 1.
ls_method-refnumber = sv_refno.
ls_method-objecttype = 'COMPONENT'.
ls_method-method = 'CHANGE'.
ls_method-objectkey = gt_alv1_data-aufnr.
APPEND ls_method to ls_sv_update-method.
if sv_refno eq 1.
ls_method-refnumber = sv_refno.
ls_method-objecttype = space.
ls_method-method = 'SAVE'.
ls_method-objectkey = gt_alv1_data-aufnr.
APPEND ls_method to ls_sv_update-method.
endif.
ls_component-reserv_no = gt_alv1_data-rsnum.
ls_component-res_item = gt_alv1_data-rspos.
ls_component-activity = gt_alv1_data-vornr.
ls_component-material = gt_alv1_data-matnr.
if gt_alv1_data-menge_up is not initial.
ls_component-requirement_quantity = gt_alv1_data-menge_up.
endif.
if gt_alv1_data-netpr_up is not initial.
ls_component-price = gt_alv1_data-netpr_up.
ls_component-currency = gt_alv1_data-waers.
* It appears the Price is not updated unless the quantity is
if gt_alv1_data-menge_up is initial.
ls_component-requirement_quantity = gt_alv1_data-bdmng.
endif.
endif.
APPEND ls_component to ls_sv_update-component.
if gt_alv1_data-menge_up is not initial.
ls_component_up-requirement_quantity = 'X'.
endif.
if gt_alv1_data-netpr_up is not initial.
ls_component_up-price = 'X'.
ls_component_up-currency = 'X'.
* It appears the Price is not updated unless the quantity is
ls_component_up-requirement_quantity = 'X'.
endif.
APPEND ls_component_up to ls_sv_update-component_up.
if lv_tabix is not initial.
SORT ls_sv_update-method by method.
MODIFY gt_sv_update from ls_sv_update
index lv_tabix transporting method component component_up.
else.
APPEND ls_sv_update to gt_sv_update.
endif.
if gt_alv1_data-menge_up is not initial.
move 'UPDATED' to gt_alv1_data-input_menge.
endif.
if gt_alv1_data-netpr_up is not initial.
move 'UPDATED' to gt_alv1_data-input_netpr.
endif.
modify gt_alv1_data transporting input_menge input_netpr.
LOOP at gt_sv_update.
CLEAR: lt_return[].
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = gt_sv_update-method
it_component = gt_sv_update-component
it_component_up = gt_sv_update-component_up
return = lt_return.
ENDLOOP.
07-17-2008 7:03 PM