cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Create follow-up work order(WO) using BAPI_ALM_ORDER_MAINTAIN

ricky_shaw
Contributor
0 Kudos
1,531

Hi Experts,

I need to create follow up Work Orders(WO). I am first trying to run Se37 followed by BAPI_commit.

I am trying to create a follow-up order for an existing WO using BAPI_ALM_ORDER_MAINTAIN.

The return RETURN & ET_NUMBERS table parameters showing nothing(empty) after executing in SE37.

I am filling the IT_METHODS tab in BAPI_ALM_ORDER_MAINTAIN as below:

objecttype = 'FOLLOWUPHDR'.

method = 'CREATE'.

objectkey = %00000000001

method = 'SAVE'.

In IT_HEADER:

ORDERID = %00000000001

ORDER_TYPE = ‘OTYPE1’.

Some fields..

REFERENCE_ORDER = ‘Exis Order#’.

IT_HEADER_UP:

All above fields as applicable with ‘X’ in IT_HEADER_UP[] table.

Am i missing something here. Pls help

Accepted Solutions (0)

Answers (3)

Answers (3)

RaymondGiuseppi
Active Contributor

Read this OSS note: 2074666 - Create subsequent order using BAPI improvement note

(Of course I suppose you already activated Business function LOG_EAM_CI_7)

ricky_shaw
Contributor
0 Kudos

Hi Raymond,

LOG_EAM_CI_7 is activated.

The OSS note 2074666 - says it cannot be implemented.

Any other suggestions please?

Sandra_Rossi
Active Contributor
0 Kudos

ricky.shaw Did you read the explanation in the note 2074666 - Create subsequent order using BAPI improvement note, with the example code how to call the BAPI?

RaymondGiuseppi
Active Contributor

Read the note, compare your code with the sample

ricky_shaw
Contributor
0 Kudos

Yes i did & also impl the code as i already pasted.

Can you pls suggest.

RaymondGiuseppi
Active Contributor
0 Kudos

Which value of OBJECTKEY did you pass in the FOLLOWUPHDR CREATE record of MEHODS, should be the previous order (so some doubt with %00000000001 which is useful when creating a new order not a following order.

ricky_shaw
Contributor
0 Kudos

Hi Raymond, Pls see below: The methods are updated with already existing order#(0002000000221). For this order # i need to create a follow-on order.

ls_methods-refnumber = 1.
ls_methods-objecttype = 'FOLLOWUPHDR'.
ls_methods-method = 'CREATE'.
ls_methods-objectkey(12) = '0002000000221'.
APPEND ls_methods TO lt_methods.

CLEAR: ls_header. 

CLEAR: ls_header_up.

RaymondGiuseppi
Active Contributor
0 Kudos

Remember this method will only create the link between orders, you have also to fill parameters as for another order creation.

  • 'In addition to the data for the creation of a normal order (header data, transaction data, and so on), the following must also be maintained to create a subsequent order
    Create follow-up link HEADER...'
ricky_shaw
Contributor
0 Kudos

Ok Raymond...Can you pls take a look and help me fix the code i pasted here?

JOSE-ODAR
Explorer

Hola ricky.shaw

El uso de esta bapi es un poco complejo, con respecto al número de la orden, previamente debes crear una logica en identificar cual es la última orden que existe en la tabla, y debes proponer el siguiente número de orden.

Despúes, toda orden de mantenimiento minimo debe tener una operación, porl o tanto debe llenar una linea de la tabla IT_OPERATIONS.

Tambien prueba ejecuntado de la siguiente forma:

ALM_ME_ORDER_CREATE

ALM_ME_ORD_BAPI_ORDER_POST

BAPI_ALM_ORDER_MAINTAIN

-------------------------------------------------------------------------------------

Hello Ricky

ShawThe use of this bapi is a bit complex, with respect to the order number, you must previously create a logic to identify which is the last order that exists in the table, and you must propose the next order number.Next, every minimum maintenance order must have an operation, therefore it must fill a line of the IT_OPERATIONS table.

Also try running it as follows:

ALM_ME_ORDER_CREATE

ALM_ME_ORD_BAPI_ORDER_POST

BAPI_ALM_ORDER_MAINTAIN

Sandra_Rossi
Active Contributor

Why answering 50% Spanish 50% English if the question is English? If you don't speak English, trust the translator and paste English only, Spanish is just polluting. My 2 cents.

ricky_shaw
Contributor
0 Kudos

Hi Jose,

Yes i am also filling IT_OPERATIONS.

But why should we determine last order that exists in the table, I need to create follow-up order for whatever order i need (maintenence order).

ricky_shaw
Contributor
0 Kudos

Hi Raymond & others

I implemented the code as per the oss note below:

DATA: lt_methods   TYPE TABLE OF bapi_alm_order_method,
      ls_methods   LIKE LINE OF lt_methods,
      lt_header    TYPE TABLE OF bapi_alm_order_headers_i,
      ls_header    LIKE LINE OF lt_header,
      lt_header_up TYPE TABLE OF bapi_alm_order_headers_up,
      ls_header_up LIKE LINE OF lt_header_up,
      lt_return    TYPE STANDARD TABLE OF bapiret2,
      ls_return    TYPE bapiret2.

* * INITIALIZATION

REFRESH: lt_methods, lt_header, lt_header_up.

* * CHANGE HEADER TEXT (to same value - test)

CLEAR: ls_methods.

ls_methods-refnumber = 1.
ls_methods-objecttype = 'FOLLOWUPHDR'.
ls_methods-method = 'CREATE'.
ls_methods-objectkey(12) = '%00000000001'.
APPEND ls_methods TO lt_methods.

CLEAR: ls_header.
CLEAR: ls_header_up.

ls_header_up-orderid = '%00000000001'.
ls_header_up-short_text = 'X'.
APPEND ls_header_up TO lt_header_up.

* * SAVE

CLEAR: ls_methods.
ls_methods-refnumber = 1.
ls_methods-method = 'SAVE'.
APPEND ls_methods TO lt_methods.


* Appended the IT_HEADER, IT_HEADER_UP tables
mainly LS_HEADE-REFERENCE_ORDER = 'Existing Parent Order#'  "2000000201
& other fields 
*Filling up the IT_OPERATIONS, IT_OPERATIONS_UP<br>
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
  TABLES
    it_methods   = lt_methods
    it_header    = lt_header
    it_header_up = lt_header_up
    return       = lt_return
   et_numbers = lt_numbers

READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.

IF sy-subrc NE 0.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.<br>***lt_return[] is always empty in above.
<br>
Sandra_Rossi
Active Contributor
0 Kudos

For information, your code appears in two posts in the forum.

ricky_shaw
Contributor
0 Kudos

Hi Sandra, I am sorry..I think i now deleted the duplicate post. Can you pls try to execute & let me know if i am wrong somewhere?

Sandra_Rossi
Active Contributor
0 Kudos

Unfortunately, I don't have LOG_EAM_CI_7 activated in my system. You can still contact SAP Support of course.

ricky_shaw
Contributor
0 Kudos

Sandra, i said its active in my system