Posted: Tue Oct 09, 2007 10:19 am Post subject: Creating / Changing an order for the notification
Creation of an Order
Use
Process an order by creating an order in the system.
Integration
In order that you can create orders for notifications, the application component Maintenance Notifications (PM-WOC-MN) must be used in your company.
Prerequisites
The different options are only available if the necessary settings have been made in your system in the Customizing of Plant Maintenance.
Code:
DATA wa_methods TYPE bapi_alm_order_method.
DATA itab_methods TYPE TABLE OF bapi_alm_order_method.
DATA wa_header TYPE bapi_alm_order_headers_i.
DATA itab_header TYPE TABLE OF bapi_alm_order_headers_i.
DATA wa_header_up TYPE bapi_alm_order_headers_up.
DATA itab_header_up TYPE TABLE OF bapi_alm_order_headers_up.
DATA wa_operation TYPE bapi_alm_order_operation.
DATA itab_operation TYPE TABLE OF bapi_alm_order_operation.
DATA wa_operation_up TYPE bapi_alm_order_operation_up.
DATA itab_operation_up TYPE TABLE OF bapi_alm_order_operation_up.
DATA wa_text TYPE bapi_alm_text.
DATA itab_text TYPE TABLE OF bapi_alm_text.
DATA wa_text_lines TYPE bapi_alm_text_lines.
DATA itab_text_lines TYPE TABLE OF bapi_alm_text_lines.
DATA itab_return TYPE TABLE OF bapiret2.
DATA itab_numbers TYPE TABLE OF bapi_alm_numbers.
* IT_HEADER
wa_header-orderid = '%00000000001'.
wa_header-order_type = 'PM01'. <-- according to customizing
wa_header-planplant = 1000. <-- according to customizing
wa_header-mn_wk_ctr = 'MINMC'. <-- according to customizing
wa_header-plant = 1000.
wa_header-pmacttype = '001'.
wa_header-start_date = '20041019'. "se colocan al reves de como son
wa_header-finish_date = '20041020'.
wa_header-short_text = 'HEADER'.
APPEND wa_header TO itab_header.
DATA: it_methods LIKE STANDARD TABLE OF bapi_alm_order_method,
wa_methods LIKE LINE OF it_methods.
DATA: it_header LIKE STANDARD TABLE OF bapi_alm_order_headers_i,
wa_header LIKE LINE OF it_header.
DATA: it_operation LIKE STANDARD TABLE OF bapi_alm_order_operation,
wa_operation LIKE LINE OF it_operation.
DATA: it_text LIKE STANDARD TABLE OF bapi_alm_text,
wa_text LIKE LINE OF it_text.
DATA: et_numbers LIKE STANDARD TABLE OF bapi_alm_numbers,
wa_numbers LIKE LINE OF et_numbers.
data: it_return LIKE STANDARD TABLE OF BAPIRET2.
START-OF-SELECTION.
* METHODS SECTION
MOVE '1' TO wa_methods-REFNUMBER.
MOVE 'HEADER' TO wa_methods-objecttype.
*MOVE 'CREATE' TO wa_methods-method.
MOVE 'CHANGE' TO wa_methods-method.
*MOVE '%00000000001' TO wa_methods-objectkey.
MOVE '000006000065' TO wa_methods-objectkey.
*INSERT wa_methods INTO TABLE it_methods.
APPEND wa_methods TO it_methods.
MOVE '1' TO wa_methods-REFNUMBER.
MOVE 'OPERATION' TO wa_methods-objecttype.
*MOVE 'CREATE' TO wa_methods-method.
MOVE 'CHANGE' TO wa_methods-method.
*MOVE '%000000000010010' TO wa_methods-objectkey.
MOVE '000006000065' TO wa_methods-objectkey.
*INSERT wa_methods INTO TABLE it_methods.
APPEND wa_methods TO it_methods.
MOVE '1' TO wa_methods-REFNUMBER.
MOVE '' TO wa_methods-objecttype.
MOVE 'SAVE' TO wa_methods-method.
*MOVE '%00000000001' TO wa_methods-objectkey.
MOVE '000006000065' TO wa_methods-objectkey.
*INSERT wa_methods INTO TABLE it_methods.
APPEND wa_methods TO it_methods.
* HEADER SECTION
*MOVE '%00000000001' TO wa_header-orderid.
MOVE '000006000065' TO wa_header-orderid.
MOVE 'ZDIS' TO wa_header-order_type.
MOVE '1001' TO wa_header-planplant.
*MOVE '1001' TO wa_header-mn_wk_ctr.
MOVE '1001' TO wa_header-plant.
*MOVE 'CUV-SZV-CSUR-ATEM-I...' TO wa_header-funct_loc.
MOVE '' TO wa_header-equipment.
MOVE '' TO wa_header-material.
MOVE '8000001022' TO wa_header-funct_loc.
MOVE '20071212' TO wa_header-finish_date.
MOVE SYST-UZEIT TO WA_HEADER-BASIC_FIN.
MOVE 'Changed by manohar from BAPI' TO wa_header-short_text.
*INSERT wa_header INTO TABLE it_header.
APPEND wa_header TO it_header.
* OPERATION SECTION
MOVE '10' TO wa_operation-activity.
MOVE '' TO wa_operation-sub_activity.
MOVE '' TO wa_operation-standard_text_key.
MOVE 'This is what i need ' TO wa_operation-description.
MOVE '' TO wa_operation-vendor_no.
MOVE 3 TO wa_operation-quantity.
MOVE 'KG' TO wa_operation-base_uom.
MOVE '00000015' TO wa_operation-pers_no.
*INSERT wa_operation INTO TABLE it_operation.
APPEND wa_operation TO it_operation.
REFRESH et_numbers.
data: it_text_line type table of BAPI_ALM_TEXT_LINES,
I_TEXTLINE TYPE STANDARD TABLE OF TLINE,
w_text_line type BAPI_ALM_TEXT_LINES.
*Use function module 'READ TEXT'
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = 'KOPF'
language = SYST-LANGU
name = '120000006000065'
object = 'AUFK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
tables
lines = IT_TEXT_LINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
break mdubbaka.
w_text_line-TDFORMAT = '*'.
w_text_line-TDLINE = 'Manohar has changed this from program'.
append w_text_line to it_text_line.
data: it_header_serv TYPE TABLE OF BAPI_ALM_ORDER_SRVDAT_E,
WA_HEADER_SERV TYPE BAPI_ALM_ORDER_SRVDAT_E,
IT_HEADER_SERVX TYPE TABLE OF BAPI_ALM_ORDER_SRVDAT_UP,
IT_USERSTATUS type table of BAPI_ALM_ORDER_USRSTAT,
wa_userstatus TYPE BAPI_ALM_ORDER_USRSTAT,
WA_HEADER_SERVX TYPE BAPI_ALM_ORDER_SRVDAT_UP.
* wa_USERSTATUS-USER_ST_TEXT = 'TECO'.
* append wa_userstatus TO it_userstatus.
*The following BAPIs can be made used to get the details of operation,
*Use the function module ALM_ME_ORDER_GETDETAIL as in the program ZORDERLIST_FM
*and pass the corresponding values to th structures and internal tables of the
*BAPI Used below 'BAPI_ALM_ORDER_MAINTAIN' to update PERNR, COMPLETION DATE AND TIME
*The text as of now we will only use the one given in header structure by INSERTING
*The text we want to enter in the internal table IT_TEXT_LINE(NEED TO TEST THIS).
*Other related function modules in include LIBAPI_ALM_ORDERUXX (Don't need them anyways).
*Commit BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*Display order status
FORMAT COLOR 6 INVERSE ON.
READ TABLE RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
WRITE: /,'Order not maintained'.
LOOP AT RETURN.
WRITE: /,RETURN-MESSAGE.
ENDLOOP.
ELSE.
WRITE:/,RETURN-MESSAGE,/,'Order maintained with number',ODR_NO.
ENDIF.
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 cannot 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.