2007 Jul 23 4:39 PM
Hi everyone,
I'm using BAPI_ALM_ORDER_MAINTAIN, to create a Order, but i keep getting the following error : "Please enter valid control key". ID - IW message number 104.
"Error during processing of BAPI methods".
My IT_METHODS Table, has the following info:
CLEAR: IT_METHODS,
IT_METHODS[],
IT_METHODS-REFNUMBER = '000001'.
IT_METHODS-OBJECTTYPE = 'HEADER'.
IT_METHODS-METHOD = 'CREATE'.
IT_METHODS-OBJECTKEY = '%00000000001'.
APPEND IT_METHODS.
IT_METHODS-REFNUMBER = '000001'.
IT_METHODS-OBJECTTYPE = 'OPERATION '.
IT_METHODS-METHOD = 'CREATE'.
IT_METHODS-OBJECTKEY = '%00000000001010'.
APPEND IT_METHODS.
IT_METHODS-REFNUMBER = '000001'.
IT_METHODS-OBJECTTYPE = ''.
IT_METHODS-METHOD = 'SAVE'.
IT_METHODS-OBJECTKEY = '%00000000001'.
APPEND IT_METHODS.
Can anyone help overcome this error ? Beste regards.
PC
2007 Jul 23 4:46 PM
Hello,
use this code,,,,
*&---------------------------------------------------------------------*
*& Report ZSAN_BAPI_ORDER_MAINTAIN *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZSAN_BAPI_ORDER_MAINTAIN .
PARAMETER: ODR_NO LIKE BAPI_ALM_ORDER_HEADERS_I-ORDERID. " Order Number
DATA: IT_METHODS LIKE BAPI_ALM_ORDER_METHOD OCCURS 0 WITH HEADER LINE,
" Processing methods
IT_HEADER LIKE BAPI_ALM_ORDER_HEADERS_I OCCURS 0 WITH HEADER LINE,
" Import Structure for ALM Order Headers
IT_HEADER_UP LIKE BAPI_ALM_ORDER_HEADERS_UP OCCURS 0 WITH HEADER LINE,
" Update Structure for ALM Order Headers
IT_OPERATION LIKE BAPI_ALM_ORDER_OPERATION OCCURS 0 WITH HEADER LINE,
" Input Structure for PM/CS BAPIs Operations
IT_OPERATION_UP LIKE BAPI_ALM_ORDER_OPERATION_UP OCCURS 0 WITH HEADER LINE,
" Update Structure for PM/CS BAPI Operations
IT_HEADER_SRV LIKE BAPI_ALM_ORDER_SRVDAT_E OCCURS 0 WITH HEADER LINE,
" Service-Specific Data, External Structure
IT_HEADER_SRV_UP LIKE BAPI_ALM_ORDER_SRVDAT_UP OCCURS 0 WITH HEADER LINE,
" Service-Specific Data, External Structure
IT_PARTNERS LIKE BAPI_ALM_ORDER_PARTN_MUL OCCURS 0 WITH HEADER LINE,
" Partner Data
IT_PARTNERS_UP LIKE BAPI_ALM_ORDER_PARTN_MUL_UP OCCURS 0 WITH HEADER LINE,
" Partner Data for Several Orders, Update
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
" Table for return messages
*Tables to get deatils for Order
ES_HEADER LIKE BAPI_ALM_ORDER_HEADER_E OCCURS 0 WITH HEADER LINE,
" Export Structure for ALM Order Header
ES_SRVDATA LIKE BAPI_ALM_ORDER_SRVDAT_E OCCURS 0 WITH HEADER LINE,
" ALM Order BAPIs: Service-Specific Data, External Structure
ET_PARTNER LIKE BAPI_ALM_ORDER_PARTNER OCCURS 0 WITH HEADER LINE,
" Partner Data for Several Orders
ET_OPERATIONS LIKE BAPI_ALM_ORDER_OPERATION_E OCCURS 0 WITH HEADER LINE,
" Export Structure for PM/CS BAPIs Operations
ET_COMP LIKE BAPI_ALM_ORDER_COMPONENT_E OCCURS 0 WITH HEADER LINE,
ET_RELATIONS LIKE BAPI_ALM_ORDER_RELATION_EXPORT OCCURS 0 WITH HEADER LINE,
" BAPI Structure for ALM Order Relationships
ET_TEXTS LIKE BAPI_ALM_TEXT OCCURS 0 WITH HEADER LINE,
" Text Header for ALM Order BAPIs
ET_TEXT_LINES LIKE BAPI_ALM_TEXT_LINES OCCURS 0 WITH HEADER LINE,
" Text Lines for ALM BAPIs
ET_PRTS LIKE BAPI_ALM_ORDER_PRT_E OCCURS 0 WITH HEADER LINE,
" Structure for Production Resources/Tools
ET_COSTS_SUM LIKE BAPI_ALM_ORDER_COSTS_SUM_E OCCURS 0 WITH HEADER LINE,
" Structure for Order Costs Sum
ET_COST_DET LIKE BAPI_ALM_ORDER_COSTS_DETAIL_E OCCURS 0 WITH HEADER LINE,
" Structure for Order Costs Detail
RETURN1 LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE
" Table for return messages
.
*Get deatils for Order
CALL FUNCTION 'BAPI_ALM_ORDER_GET_DETAIL'
EXPORTING
NUMBER = ODR_NO
IMPORTING
ES_HEADER = ES_HEADER
ES_SRVDATA = ES_SRVDATA
TABLES
ET_PARTNER = ET_PARTNER
ET_OPERATIONS = ET_OPERATIONS
ET_COMPONENTS = ET_COMP
ET_RELATIONS = ET_RELATIONS
ET_TEXTS = ET_TEXTS
ET_TEXT_LINES = ET_TEXT_LINES
ET_PRTS = ET_PRTS
ET_COSTS_SUM = ET_COSTS_SUM
ET_COSTS_DETAILS = ET_COST_DET
RETURN = RETURN1.
*Fill values in IT_METHODS
IT_METHODS-METHOD = 'SAVE'.
IT_METHODS-OBJECTKEY = ODR_NO.
APPEND IT_METHODS.
*Fill values in IT_METHODS
IT_METHODS-METHOD = 'CHANGE'.
IT_METHODS-REFNUMBER = 1.
IT_METHODS-OBJECTTYPE = 'HEADER'.
IT_METHODS-OBJECTKEY = ODR_NO.
APPEND IT_METHODS.
*Fill values in IT_HEADER
IT_HEADER-ORDERID = ODR_NO.
IT_HEADER-MN_WK_CTR = '1114'.
*IT_HEADER-PLANT = ES_HEADER-PLANT.
*IT_HEADER-ORDER_TYPE = ES_HEADER-ORDER_TYPE.
*IT_HEADER-PLANPLANT = ES_HEADER-PLANPLANT.
*IT_HEADER-BUS_AREA = ES_HEADER-BUS_AREA.
IT_HEADER-MATERIAL = 'Y-352'.
APPEND IT_HEADER.
*Fill values in IT_HEADER_UP
IT_HEADER_UP-ORDERID = ODR_NO.
IT_HEADER_UP-MN_WK_CTR = 'X'.
IT_HEADER_UP-MATERIAL = 'X'.
APPEND IT_HEADER_UP.
*Maintain Order
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
IT_METHODS = IT_METHODS
IT_HEADER = IT_HEADER
IT_HEADER_UP = IT_HEADER_UP
IT_PARTNER = IT_PARTNERS
IT_PARTNER_UP = IT_PARTNERS_UP
IT_OPERATION = IT_OPERATION
IT_OPERATION_UP = IT_OPERATION_UP
IT_HEADER_SRV = IT_HEADER_SRV
IT_HEADER_SRV_UP = IT_HEADER_SRV_UP
RETURN = RETURN.
*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.
FORMAT COLOR OFF INVERSE OFF.
Regards,
Deepu.K
2016 May 04 12:52 PM