Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem using BAPI_ALM_ORDER_MAINTAIN

I am trying to create a new sevice message(transaction IW51) and an order for the service message(transaction IW31). I am trying to use the bapi BAPI_ALM_ORDER_MAINTAIN. As far as I can see the bapi only creates, changes orders and does not create both. If the bapi can do both then please someone send me a code example. Below is my code.

I am presently using batch input to create the message and the bapi BAPI_ALM_ORDER_MAINTAIN to create the order. After I have run the program I read the message table out of the bapi. There are some warnings and info but ne errors. The message table also tell's me that the order XXXX was succesfully created. When I go to transaction IW33 it tell's me the order does not exist? Where can I see the order

the bapi created?

Any help would be greatly appreciated, thanks

sven

loop at ximport into wximport.

zeile = zeile + 1.

REFRESH: it_methods, it_header, it_header_srv, it_partner,

it_operation, return, return1.

CLEAR: wit_methods, wit_header, wit_header_srv, wit_partner,

wit_operation, wreturn, wreturn1.

wit_methods-refnumber = '000001'.

wit_methods-objecttype = 'HEADER'.

wit_methods-method = 'CREATE'.

wit_methods-objectkey = wximport-aufnr.

APPEND wit_methods to it_methods.

wit_methods-objecttype = 'PARTNER'.

APPEND wit_methods to it_methods.

wit_methods-objecttype = 'OPERATION'.

APPEND wit_methods to it_methods.

CLEAR wit_methods.

wit_methods-method = 'SAVE'.

APPEND wit_methods to it_methods.

wit_header-orderid = wximport-aufnr.

wit_header-order_type = 'SM01'.

wit_header-planplant = wximport-werks.

wit_header-calc_motive = wximport-qmart.

wit_header-mn_wk_ctr = wximport-aplatz.

wit_header-plant = wximport-werks.

wit_header-pmacttype = 'GM'.

wit_header-equipment = wximport-equnr.

wit_header-loc_wk_ctr = wximport-aplatz.

wit_header-loc_comp_code = wximport-bukrs.

wit_header-salesorg = wximport-vkorg.

wit_header-distr_chan = wximport-vtweg.

wit_header-start_date = wximport-sdate.

wit_header-basicstart = wximport-stime.

wit_header-short_text = wximport-ltext.

wit_header-priority = wximport-priok.

wit_header-calc_motive = 'NO'.

APPEND wit_header to it_header.

wit_header_srv-salesorg = wximport-vkorg.

wit_header_srv-distr_chan = wximport-vtweg.

wit_header_srv-quantity = 1.

wit_header_srv-base_uom = 'LE'.

append wit_header_srv to it_header_srv.

wit_partner-orderid = wximport-aufnr.

wit_partner-partn_role = 'AG'.

wit_partner-partner = wximport-kunum.

APPEND wit_partner to it_partner.

wit_partner-orderid = wximport-aufnr.

wit_partner-partn_role = 'VW'.

wit_partner-partner = wximport-PERNR1.

APPEND wit_partner to it_partner.

wit_partner-orderid = wximport-aufnr.

wit_partner-partn_role = 'VW'.

wit_partner-partner = wximport-PERNR2.

APPEND wit_partner to it_partner.

wit_operation-activity = '0010'.

  • wit_operation-sub_activity = '0020'.

wit_operation-work_cntr = wximport-aplatz.

wit_operation-plant = wximport-werks.

wit_operation-description = wximport-ltext.

wit_operation-acttype = 'ARBEIT'.

wit_operation-work_activity = '1'.

wit_operation-un_work = 'STD'.

APPEND wit_operation to it_operation.

wit_operation-activity = '0020'.

  • wit_operation-sub_activity = '0030'.

wit_operation-work_cntr = wximport-aplatz.

wit_operation-plant = wximport-werks.

wit_operation-description = 'Fahrzeit'.

wit_operation-acttype = 'FAHRZ'.

wit_operation-work_activity = '1'.

wit_operation-un_work = 'STD'.

APPEND wit_operation to it_operation.

wit_operation-activity = '0030'.

wit_operation-work_cntr = wximport-aplatz.

wit_operation-plant = wximport-werks.

wit_operation-description = 'Kilometer'.

wit_operation-acttype = 'KM'.

wit_operation-work_activity = '1'.

wit_operation-un_work = 'STD'.

APPEND wit_operation to it_operation.

  • BAPI-Aufruf:

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

DESTINATION 'NONE'

TABLES

it_methods = it_methods

it_header = it_header

it_header_srv = it_header_srv

it_partner = it_partner

it_operation = it_operation

return = return.

clear ERROR.

loop at return into wreturn.

move zeile to wmessages-zeile.

move wximport-aufnr to wmessages-aufnr.

move wximport-qmart to wmessages-qmart.

move wximport-kunum to wmessages-kunum.

move wximport-equnr to wmessages-equnr.

move wreturn-type to wmessages-type.

move wreturn-message to wmessages-message.

append wmessages TO imessages.

if wreturn-type = 'E'.

error = 'E'.

endif.

endloop.

if ERROR = ' '.

WAIT = 'X'.

  • Verbuchung:

REFRESH return1.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = wait.

ENDIF.

endloop.

Tags:
Not what you were looking for? View more on this topic or Ask a question