‎2008 Oct 13 12:42 PM
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.
‎2008 Oct 13 1:00 PM
don't use Wait and see...
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
Try to Debug and see the return table , what are the values present inside the return table.
‎2008 Oct 13 1:04 PM
Hi
I am not sure, why BAPI_TRANSACTION_COMMIT is called with in loop.
instead you can try this
read table return into wreturn with key type = 'E'.
if sy-subrc ne 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
endif.
Regards
Madhan
‎2008 Oct 13 2:34 PM
thanks for your help. I want to add 1 order per time. Create - run bapi - commit - next record.
That is why the commit is in the loop.
‎2008 Oct 13 2:43 PM
Hi,
Try the logic below.
loop at ximport into wximport.
.
.
.
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.
endloop.
read table return into wreturn with key type = 'E'.
if sy-subrc ne 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
endif.
REFRESH return1.
ENDIF.
endloop.
‎2008 Oct 13 3:08 PM
Below are the messages. There are quite a few but none are errors and it does say the order was saved.
Cannot find order number AA117249 with transaction IW33.
Auftragsnum. Meldung Art Kunde Equipment Art Mess. Message
AA117249 M117249 S3 3254701 A000289 S Credit limit check not possible
AA117249 M117249 S3 3254701 A000289 I The organization data is determined again
AA117249 M117249 S3 3254701 A000289 S No batch input data for screen SAPLIPAR 0320
AA117249 M117249 S3 3254701 A000289 I Order AA117249 with external number changed during creation
AA117249 M117249 S3 3254701 A000289 W Start date is in the past
AA117249 M117249 S3 3254701 A000289 S Calculation executed
AA117249 M117249 S3 3254701 A000289 I Order AA117249 with external number changed during creation
AA117249 M117249 S3 3254701 A000289 W Start date is in the past
AA117249 M117249 S3 3254701 A000289 S Calculation executed
AA117249 M117249 S3 3254701 A000289 S Order saved with number AA117249
AA117249 M117249 S3 3254701 A000289 S BAPI control is ended
‎2008 Oct 14 3:28 PM
Thanks everyone for your help. I managed to sort it out. Does anyone have an example where
there is more than 1 position?
‎2011 Jun 07 7:11 AM
Hi Can you please tell me how you solved this issue ?
I have given few parameters for which the Return parameter says the Order xxxxxxx is saved but when i check in IW33 it says Order does not exist . Kindly advise.