Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_ALM_ORDER_MAINTAIN

Former Member
0 Likes
2,241

Hi all,

Can anyone know how to use BAPI_ALM_ORDER_MAINTAIN to delete a component item under the component overview? I do not know the actual way to construct the method table used in this BAPI. Appreciate any help provided

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,488

Hi ,

you can try using the bapi with this example

data: w_orderid type objidext value '%00000000001',

w_operid type objidext value '%000000000010010'.

lt_return1 like BAPIRET2,

refresh: t_order_methods,

t_order_header,

t_order_partner,

t_order_oper,

t_order_text,

t_order_text_lines,

t_return.

  • methods

clear w_order_methods.

w_order_methods-refnumber = 1.

  • Create Order

w_order_methods-objecttype = 'HEADER'.

w_order_methods-objectkey = w_orderid.

w_order_methods-method = 'CREATE'.

append w_order_methods to t_order_methods.

  • Create Operation

w_order_methods-objecttype = 'OPERATION'.

w_order_methods-objectkey = w_operid.

w_order_methods-method = 'CREATE'.

append w_order_methods to t_order_methods.

  • Create Text

perform read_text.

if not tlines[] is initial.

w_order_methods-objecttype = 'TEXT'.

w_order_methods-objectkey = w_orderid.

w_order_methods-method = 'CREATE'.

append w_order_methods to t_order_methods.

w_order_text-orderid = w_orderid.

  • w_order_text-activity = '0010'.

w_order_text-textstart = 1.

describe table tlines lines w_order_text-textend.

if not it_single_tab-ltxa1 is initial.

w_order_text_lines-tdformat = '*'.

w_order_text_lines-tdline = it_single_tab-ltxa1.

add 1 to w_order_text-textend.

append w_order_text_lines to t_order_text_lines.

endif.

append w_order_text to t_order_text.

loop at tlines.

move-corresponding tlines to w_order_text_lines.

append w_order_text_lines to t_order_text_lines.

endloop.

endif.

  • header

perform build_order_header using w_orderid changing w_order_header.

append w_order_header to t_order_header.

  • operations

perform build_order_operation changing w_order_oper.

append w_order_oper to t_order_oper.

call function 'BAPI_ALM_ORDER_MAINTAIN'

tables

it_methods = t_order_methods

it_header = t_order_header

it_operation = t_order_oper

it_text = t_order_text

it_text_lines = t_order_text_lines

return = t_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

IMPORTING

RETURN = lt_return1.

reward pts if found usefull

Regards,

Sathish

Hi all,

Can anyone know how to use BAPI_ALM_ORDER_MAINTAIN to delete a component item under the component overview? I do not know the actual way to construct the method table used in this BAPI. Appreciate any help provided

2 REPLIES 2
Read only

Former Member
0 Likes
1,489

Hi ,

you can try using the bapi with this example

data: w_orderid type objidext value '%00000000001',

w_operid type objidext value '%000000000010010'.

lt_return1 like BAPIRET2,

refresh: t_order_methods,

t_order_header,

t_order_partner,

t_order_oper,

t_order_text,

t_order_text_lines,

t_return.

  • methods

clear w_order_methods.

w_order_methods-refnumber = 1.

  • Create Order

w_order_methods-objecttype = 'HEADER'.

w_order_methods-objectkey = w_orderid.

w_order_methods-method = 'CREATE'.

append w_order_methods to t_order_methods.

  • Create Operation

w_order_methods-objecttype = 'OPERATION'.

w_order_methods-objectkey = w_operid.

w_order_methods-method = 'CREATE'.

append w_order_methods to t_order_methods.

  • Create Text

perform read_text.

if not tlines[] is initial.

w_order_methods-objecttype = 'TEXT'.

w_order_methods-objectkey = w_orderid.

w_order_methods-method = 'CREATE'.

append w_order_methods to t_order_methods.

w_order_text-orderid = w_orderid.

  • w_order_text-activity = '0010'.

w_order_text-textstart = 1.

describe table tlines lines w_order_text-textend.

if not it_single_tab-ltxa1 is initial.

w_order_text_lines-tdformat = '*'.

w_order_text_lines-tdline = it_single_tab-ltxa1.

add 1 to w_order_text-textend.

append w_order_text_lines to t_order_text_lines.

endif.

append w_order_text to t_order_text.

loop at tlines.

move-corresponding tlines to w_order_text_lines.

append w_order_text_lines to t_order_text_lines.

endloop.

endif.

  • header

perform build_order_header using w_orderid changing w_order_header.

append w_order_header to t_order_header.

  • operations

perform build_order_operation changing w_order_oper.

append w_order_oper to t_order_oper.

call function 'BAPI_ALM_ORDER_MAINTAIN'

tables

it_methods = t_order_methods

it_header = t_order_header

it_operation = t_order_oper

it_text = t_order_text

it_text_lines = t_order_text_lines

return = t_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

IMPORTING

RETURN = lt_return1.

reward pts if found usefull

Regards,

Sathish

Read only

Former Member
0 Likes
1,488

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.

***********************************************************************************

***Convert into external format

**CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

    • EXPORTING

    • INPUT = ODR_NO

    • IMPORTING

    • OUTPUT = OD.

if helpful reward points