gv_tmp_ord = '%00000000001'. (Refer to References in the BAPI documentation)
*Create Header
ls_method-refnumber = '000001'.
ls_method-objecttype = 'HEADER'.
ls_methods-method = 'CREATE' .
ls_method-objectkey = gv_tmp_ord.
APPEND ls_method to lt_methods.
CLEAR ls_method.
*Operations
LOOP AT lt_operations INTO ls_operation.
ls_method-refnumber = sy-tabix .
ls_method-objecttype = 'OPERATION'.
ls_method-method = 'CREATE' .
CONCATENATE gv_tmp_ord ls_operation-activity INTO
ls_method-objectkey .
APPEND ls_method to lt_methods.
CLEAR ls_method.
ENDLOOP.
Append all that you give as input like Components, User status & Texts in this manner and finally add 'SAVE'.
ls_method-method = 'SAVE' .
APPEND ls_method to lt_methods.
CLEAR ls_method.
Call the BAPI
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_methods
it_header = lt_header
it_operation = lt_operations
it_userstatus = lt_user_status
it_component = lt_components
it_text = lt_texts
it_text_lines = lt_text_lines
return = lt_return
et_numbers = lt_numbers.
*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
Go through the BAPI documentation to know how the object key is filled in the METHODS table.