Application Development 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: 

CRAETE OPERATION USING BAPI_ALM_ORDER_MAINTAIN

hady_ibrahim
Participant

HI ABAP EXPERTS,

I am trying to create components and operations for an existing  order(IW32) .

i can create component correctly,but i face a problem creating new operation

this is my bapi

could you provide me solving the error?


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_up TYPE bapi_alm_order_operation_up.
DATA it_operation_up TYPE TABLE OF bapi_alm_order_operation_up.


data:
        IT_PLANT TYPE STANDARD TABLE OF  BAPI_ALM_ORDER_HEADERS_I-PLANPLANT, "HADY PLANT
        WA_PLANT LIKE LINE OF IT_PLANT,


it_methods type standard table of bapi_alm_order_method,
wa_methods like line of it_methods,
it_header type standard table of bapi_alm_order_headers_i,
wa_header like line of it_header,
it_header_up type standard table of bapi_alm_order_headers_up,
it_header_srv type standard table of bapi_alm_order_srvdat_e,
it_header_srv_up type standard table of bapi_alm_order_srvdat_up,
it_userstatus type standard table of bapi_alm_order_usrstat,
it_partner type standard table of bapi_alm_order_partn_mul,
wa_partner like line of it_partner,
it_partner_up type standard table of bapi_alm_order_partn_mul_up,
it_operation type standard table of bapi_alm_order_operation,
wa_operation like line of it_operation,
*it_operation_up type standard table of bapi_alm_order_operation_up,
it_relation type standard table of bapi_alm_order_relation ,
it_relation_up type standard table of bapi_alm_order_relation_up ,
it_component type standard table of bapi_alm_order_component,
wa_component like LINE OF it_component,
it_component_up type standard table of bapi_alm_order_component_up,
it_text type standard table of bapi_alm_text,
it_text_lines type standard table of bapi_alm_text_lines,
extension_in type standard table of bapiparex,
return type standard table of bapiret2,
wa_return like line of return,
et_numbers type standard table of bapi_alm_numbers,
wa_numbers like line of et_numbers.




  wa_methods-refnumber = 1.
  wa_methods-objecttype = 'OPERATION'.
  wa_methods-method = 'CREATE'.
  wa_methods-objectkey = '%00000000001'.
  APPEND wa_methods TO it_methods.


  wa_methods-refnumber = 1.
  wa_methods-objecttype = ' '.
  wa_methods-method = 'SAVE'.
  wa_methods-objectkey = ORDERNO.
  APPEND wa_methods TO IT_methods.


  wa_header-orderid = ORDERNO.
  wa_header-order_type = 'ZSM2'.
  wa_header-mn_wk_ctr = 'HAHV'.
  WA_HEADER-EQUIPMENT = '000000000010008442'.
  wa_header-start_date = '20150217'.
  wa_header-FINISH_DATE = '20150217'.
  wa_header-short_text = 'HEADER'.
  wa_header-NOTIF_NO = '300002927'.
  APPEND wa_header TO IT_header.

  wa_header_up-mn_wk_ctr = 'X'.
  WA_HEADER_up-EQUIPMENT = 'X'.

  wa_header_up-start_date = 'X'.
  wa_header_up-short_text = 'X'.
  APPEND wa_header_up TO itab_header_up.

  wa_operation-activity = '0010'.
  WA_OPERATION-WORK_CNTR = 'HAHV'.
  wa_operation-control_key = 'SM01'.
  wa_operation-plant = 'BC20'.
  WA_OPERATION-DESCRIPTION = 'OPERATION DESCRIPTION'.
  APPEND wa_operation TO IT_operation.

  wa_operation_UP-activity = 'X'.
  WA_OPERATION_UP-WORK_CNTR = 'X'.
  wa_operation_UP-control_key = 'X'.
  wa_operation_UP-plant = 'X'.
  wa_operation_UP-description = 'X'.

  APPEND wa_operation_up TO IT_operation_up.











     wa_methods-refnumber = '000001'.
     wa_methods-objecttype = ''.
     wa_methods-method = 'SAVE'.
     wa_methods-objectkey ORDERNO.
     append wa_methods to it_methods.
     clear wa_methods.

     wa_methods-refnumber  = '000001'.                    " Component
     wa_methods-objecttype = 'COMPONENT'.
     wa_methods-method     = 'CREATE'.
     wa_methods-objectkey  = ORDERNO.
     append wa_methods to it_methods.
     clear wa_methods.

     wa_component-ACTIVITY                      = '0010'.
     wa_component-material                      = 'TY-120'.
     Wa_component-item_cat                      = 'L'.
     wa_component-unload_pt                     = 'XXX'.
     wa_component-requirement_quantity          = '4'.
     wa_component-planT          = 'BC20'.
     append wa_component to it_component.
     clear wa_component.

     refresh return.








BREAK ABAPTEAM.

     refresh return.
     call function 'BAPI_ALM_ORDER_MAINTAIN'
       TABLES
         it_methods       = it_methods
         it_header        = it_header
         it_header_up     = it_header_up
         it_header_srv    = it_header_srv
         it_header_srv_up = it_header_srv_up
         it_userstatus    = it_userstatus
         it_partner       = it_partner
         it_partner_up    = it_partner_up
         it_operation     = it_operation
         it_operation_up  = it_operation_up
         it_relation      = it_relation
         it_relation_up   = it_relation_up
         it_component     = it_component
         it_component_up  = it_component_up
         it_text          = it_text
         it_text_lines    = it_text_lines
         extension_in     = extension_in
         return           = return
         et_numbers       = et_numbers.

  DATA : XX TYPE I VALUE 0.
     loop at return into wa_return.
       IF WA_RETURN-TYPE = 'S'.
         FLAG = 1.


         ELSE.
         FLAG = ''.
         write:/   WA_RETURN-MESSAGE.

       ENDIF.

     endloop.



     call function 'BAPI_TRANSACTION_COMMIT'
       EXPORTING
         wait = 'X'.

     CALL FUNCTION 'DEQUEUE_ALL'
       EXPORTING
         _SYNCHRON = 'X'.
     commit work and wait.




7 REPLIES 7

Former Member
0 Kudos

Hi,

Could you help us to try and help you by at least explaining what error or problem you are experiencing?  That way, others don't have to waste their own time trying to replicate your code in their own systems to understand what your actual problem is.

Cheers,

G.

0 Kudos

hi 

The problem which i experiencing is i cant create operation for existing order.

code below can create component correctly for existing order.

could you help me to create operation and long text for order?


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_up TYPE bapi_alm_order_operation_up.
DATA it_operation_up TYPE TABLE OF bapi_alm_order_operation_up.


data:
        IT_PLANT TYPE STANDARD TABLE OF  BAPI_ALM_ORDER_HEADERS_I-PLANPLANT, "HADY PLANT
        WA_PLANT LIKE LINE OF IT_PLANT,


it_methods type standard table of bapi_alm_order_method,
wa_methods like line of it_methods,
it_header type standard table of bapi_alm_order_headers_i,
wa_header like line of it_header,
it_header_up type standard table of bapi_alm_order_headers_up,
it_header_srv type standard table of bapi_alm_order_srvdat_e,
it_header_srv_up type standard table of bapi_alm_order_srvdat_up,
it_userstatus type standard table of bapi_alm_order_usrstat,
it_partner type standard table of bapi_alm_order_partn_mul,
wa_partner like line of it_partner,
it_partner_up type standard table of bapi_alm_order_partn_mul_up,
it_operation type standard table of bapi_alm_order_operation,
wa_operation like line of it_operation,
*it_operation_up type standard table of bapi_alm_order_operation_up,
it_relation type standard table of bapi_alm_order_relation ,
it_relation_up type standard table of bapi_alm_order_relation_up ,
it_component type standard table of bapi_alm_order_component,
wa_component like LINE OF it_component,
it_component_up type standard table of bapi_alm_order_component_up,
it_text type standard table of bapi_alm_text,
it_text_lines type standard table of bapi_alm_text_lines,
extension_in type standard table of bapiparex,
return type standard table of bapiret2,
wa_return like line of return,
et_numbers type standard table of bapi_alm_numbers,
wa_numbers like line of et_numbers.

     wa_methods-refnumber = '000001'.
     wa_methods-objecttype = ''.
     wa_methods-method = 'SAVE'.
     wa_methods-objectkey ORDERNO. '"order number
     append wa_methods to it_methods.
     clear wa_methods.
     wa_methods-refnumber  = '000001'.                    " Component - 1
     wa_methods-objecttype = 'COMPONENT'.
     wa_methods-method     = 'CREATE'.
     wa_methods-objectkey  = ORDERNO.
     append wa_methods to it_methods.
     clear wa_methods.


     wa_component-ACTIVITY                      = '0010'.
     wa_component-material                      = 'TY-120'.
     Wa_component-item_cat                      = 'L'.
     wa_component-unload_pt                     = 'XXX'.
     wa_component-requirement_quantity          = '4'.
     wa_component-planT          = 'BC20'.
     append wa_component to it_component.
     clear wa_component.

     refresh return.



BREAK ABAPTEAM.

     refresh return.
     call function 'BAPI_ALM_ORDER_MAINTAIN'
       TABLES
         it_methods       = it_methods
         it_header        = it_header
         it_header_up     = it_header_up
         it_header_srv    = it_header_srv
         it_header_srv_up = it_header_srv_up
         it_userstatus    = it_userstatus
         it_partner       = it_partner
         it_partner_up    = it_partner_up
         it_operation     = it_operation
         it_operation_up  = it_operation_up
         it_relation      = it_relation
         it_relation_up   = it_relation_up
         it_component     = it_component
         it_component_up  = it_component_up
         it_text          = it_text
         it_text_lines    = it_text_lines
         extension_in     = extension_in
         return           = return
         et_numbers       = et_numbers.

  DATA : XX TYPE I VALUE 0.
     loop at return into wa_return.
       IF WA_RETURN-TYPE = 'S'.
         FLAG = 1.


         ELSE.
         FLAG = ''.
         write:/   WA_RETURN-MESSAGE.

       ENDIF.

     endloop.



     call function 'BAPI_TRANSACTION_COMMIT'
       EXPORTING
         wait = 'X'.

     CALL FUNCTION 'DEQUEUE_ALL'
       EXPORTING
         _SYNCHRON = 'X'.
     commit work and wait.




thanks in advance

0 Kudos

You still haven't said what error or problem you are facing - please do this so that people have a chance to try and help you.

0 Kudos

i cant create an operation for the order.

thanks

0 Kudos

Yes, you have said a few times now but you haven't explained WHY you can't.  Do you get an error message, do you not know what data to use, etc.?

0 Kudos

Yes, i am not professional  using standard BAPI and how they work.

any way this is error message  for my code.

1    E    CP    404    Enter another operation number

2    E    IWO_BAPI2    113    Error  during processing of BAPI methods


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_up TYPE bapi_alm_order_operation_up.
DATA it_operation_up TYPE TABLE OF bapi_alm_order_operation_up.


data:
        IT_PLANT TYPE STANDARD TABLE OF  BAPI_ALM_ORDER_HEADERS_I-PLANPLANT, "HADY PLANT
        WA_PLANT LIKE LINE OF IT_PLANT,


it_methods type standard table of bapi_alm_order_method,
wa_methods like line of it_methods,
it_header type standard table of bapi_alm_order_headers_i,
wa_header like line of it_header,
it_header_up type standard table of bapi_alm_order_headers_up,
it_header_srv type standard table of bapi_alm_order_srvdat_e,
it_header_srv_up type standard table of bapi_alm_order_srvdat_up,
it_userstatus type standard table of bapi_alm_order_usrstat,
it_partner type standard table of bapi_alm_order_partn_mul,
wa_partner like line of it_partner,
it_partner_up type standard table of bapi_alm_order_partn_mul_up,
it_operation type standard table of bapi_alm_order_operation,
wa_operation like line of it_operation,
*it_operation_up type standard table of bapi_alm_order_operation_up,
it_relation type standard table of bapi_alm_order_relation ,
it_relation_up type standard table of bapi_alm_order_relation_up ,
it_component type standard table of bapi_alm_order_component,
wa_component like LINE OF it_component,
it_component_up type standard table of bapi_alm_order_component_up,
it_text type standard table of bapi_alm_text,
it_text_lines type standard table of bapi_alm_text_lines,
extension_in type standard table of bapiparex,
return type standard table of bapiret2,
wa_return like line of return,
et_numbers type standard table of bapi_alm_numbers,
wa_numbers like line of et_numbers.




wa_methods-refnumber = 1.
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = ORDERNO..
APPEND wa_methods TO it_methods.

  wa_methods-refnumber = 1.
  wa_methods-objecttype = ' '.
  wa_methods-method = 'SAVE'.
  wa_methods-objectkey = ORDERNO.
  APPEND wa_methods TO IT_methods.


  wa_header-orderid = ORDERNO.
  wa_header-order_type = 'ZSM2'.
  wa_header-mn_wk_ctr = 'HAHV'.
* WA_HEADER-EQUIPMENT = '000000000010008442'.
  WA_HEADER-EQUIPMENT = '000000000010007275'.
  wa_header-start_date = '20150218'.
  wa_header-FINISH_DATE = '20150218'.
  wa_header-short_text = 'HEADER'.
  wa_header-NOTIF_NO = '300002927'.
  APPEND wa_header TO IT_header.

  wa_header_up-mn_wk_ctr = 'X'.
  WA_HEADER_up-EQUIPMENT = 'X'.

  wa_header_up-start_date = 'X'.
  wa_header_up-short_text = 'X'.
  APPEND wa_header_up TO itab_header_up.

  wa_operation-activity = '0010'.
  WA_OPERATION-WORK_CNTR = 'HAHV'.
  wa_operation-control_key = 'SM01'.
  wa_operation-plant = 'BC20'.
  WA_OPERATION-DESCRIPTION = 'OPERATION DESCRIPTION'.
  APPEND wa_operation TO IT_operation.

  wa_operation_UP-activity = 'X'.
  WA_OPERATION_UP-WORK_CNTR = 'X'.
  wa_operation_UP-control_key = 'X'.
  wa_operation_UP-plant = 'X'.
  wa_operation_UP-description = 'X'.

  APPEND wa_operation_up TO IT_operation_up.











     wa_methods-refnumber = '000001'.
     wa_methods-objecttype = ''.
     wa_methods-method = 'SAVE'.
     wa_methods-objectkey ORDERNO.
     append wa_methods to it_methods.
     clear wa_methods.

*-- Header Mapping
*    clear wa_header.




     wa_methods-refnumber  = '000001'.                    " Component - 1
     wa_methods-objecttype = 'COMPONENT'.
     wa_methods-method     = 'CREATE'.
     wa_methods-objectkey  = ORDERNO.
     append wa_methods to it_methods.
     clear wa_methods.


     wa_component-ACTIVITY                      = '0010'.
     wa_component-material                      = 'TY-120'.
     Wa_component-item_cat                      = 'L'.
     wa_component-unload_pt                     = 'XXX'.
     wa_component-requirement_quantity          = '4'.
     wa_component-planT          = 'BC20'.
     append wa_component to it_component.
     clear wa_component.

     refresh return.








BREAK ABAPTEAM.

     refresh return.
     call function 'BAPI_ALM_ORDER_MAINTAIN'
       TABLES
         it_methods       = it_methods
         it_header        = it_header
         it_header_up     = it_header_up
         it_header_srv    = it_header_srv
         it_header_srv_up = it_header_srv_up
         it_userstatus    = it_userstatus
         it_partner       = it_partner
         it_partner_up    = it_partner_up
         it_operation     = it_operation
         it_operation_up  = it_operation_up
         it_relation      = it_relation
         it_relation_up   = it_relation_up
         it_component     = it_component
         it_component_up  = it_component_up
         it_text          = it_text
         it_text_lines    = it_text_lines
         extension_in     = extension_in
         return           = return
         et_numbers       = et_numbers.

  DATA : XX TYPE I VALUE 0.
     loop at return into wa_return.
       IF WA_RETURN-TYPE = 'S'.
         FLAG = 1.


         ELSE.
         FLAG = ''.
         write:/   WA_RETURN-MESSAGE.

       ENDIF.

     endloop.



     call function 'BAPI_TRANSACTION_COMMIT'
       EXPORTING
         wait = 'X'.

     CALL FUNCTION 'DEQUEUE_ALL'
       EXPORTING
         _SYNCHRON = 'X'.
     commit work and wait.

0 Kudos

Hi,

As you entered a notification number (NOTIF_NO), I think the BAPI is automatically generating an operation from the notification details with activity number '0010'.

Either specify no operation OR change your operation details to '0020'.

Would gladly learn how to change this behaviour..