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

function module for maintenance order creation

Former Member
0 Likes
7,350

Hi all,

I have a problem in maintenance order creation.

I am using the BAPI_ALM_ORDER_MAINTAIN function module to create the maintenance  order.But continuously it gives error messages.

I need what are all the parameters needed to pass into BAPI or if any other way to get the maintenance order no please suggest me.


Thanks & Regards,

Mahesh

22 REPLIES 22
Read only

Shubham_Srivastava1
Product and Topic Expert
Product and Topic Expert
0 Likes
5,803

Hello Mahesh

Have you read the documentation of this BAPI in detail.

Please refer the link & kindly share what errors you are encountering.

Regards

Shubham

Read only

Former Member
0 Likes
5,803

Hi,

Please share the error details. Also for your reference you can check the below parameters passed to this BAPI.

IT_Header-ordered = '%00000000001'

IT_header-ordertype

IT_header-equipment

IT_header-short_text

IT_Partner-ordered = '%00000000001'

IT_Operation-activity

IT_Operation-control_key

IT_Operation-work_cntr

IT_operation-plant

IT_Operation-description

Method used:

Create 'HEADER'

Create 'PARTNER'

Create 'OPERATION'

SAVE

Read only

Former Member
0 Likes
5,803

HI

clear wa_methods.

*  wa_methods-refnumber = '000000825369'.

   wa_methods-refnumber = '1'.

   wa_methods-objecttype = 'HEADER'.

   wa_methods-method = 'CREATE'.

   wa_methods-objectkey = ORDERID.

*  wa_methods-objectkey = '%00000000001'.

   append wa_methods to it_methods. clear wa_methods.

  clear wa_methods.

*  wa_methods-refnumber = '000000825369'.

   wa_methods-refnumber = '1'.

   wa_methods-objecttype = ''.

   wa_methods-method = 'SAVE'.

   wa_methods-objectkey = ORDERID.

*  wa_methods-objectkey = '%00000000001'.

   append wa_methods to it_methods. clear wa_methods.

   clear wa_methods.

*-- Header Mapping

   clear wa_header.

*  loop at it_methods into wa_methods.

   wa_header-orderid = ORDERID.

   wa_header-order_type = 'PM01'." ordtype.   " order type

   wa_header-plant = '3000'."PPLANT.     " plant

   wa_header-planplant = '3000'.

   wa_header-mn_wk_ctr = 'MECHMNT'."mnwkctr.    " work center

   wa_header-START_DATE = sy-datum.

   wa_header-BASICSTART = sy-uzeit.

*  wa_header-BASICSTART = sy-timlo.

   wa_header-FINISH_DATE = sy-datum.

   wa_header-BASIC_FIN = sy-uzeit.

*  wa_header-FINISH_DATE = '20160420'.

   wa_header-short_text  ='maintance order'."shorttxt. "short text value

   wa_header-FUNCT_LOC  = 'C1-B01-1'."FUNC_LOC.  "functional location

   wa_header-EQUIPMENT  = 'P-3000-N001'."EQUIP.     "equipment

   wa_header-PMACTTYPE  = '103'.

   wa_header-PLANGROUP = 'UT7'.

*  wa_header-PRIORITY = '2'.

APPEND wa_header to IT_HEADER.

*endloop.

CLEAR wa_header_up.

wa_header_up-ORDERID = ORDERID.

wa_header_up-MN_WK_CTR = 'X'.

wa_header_up-PLANT = 'X'.

wa_header_up-PMACTTYPE = 'X'.

wa_header_up-PLANGROUP = 'X'.

wa_header_up-FUNCT_LOC = 'X'.

wa_header_up-EQUIPMENT = 'X'.

wa_header_up-START_DATE = 'X' .

wa_header_up-BASICSTART = 'X'.

wa_header_up-FINISH_DATE = 'X'.

wa_header_up-BASIC_FIN = 'X'.

append wa_header_up to it_header_up.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

* EXPORTING

*   IV_MMSRV_EXTERNAL_MAINTENACE       = 'E'

   TABLES

     IT_METHODS                         = it_methods

     IT_HEADER                          = it_HEADER

*   IT_HEADER_UP                       = it_header_up,

*   IT_HEADER_SRV                      =

*   IT_HEADER_SRV_UP                   =

*   IT_USERSTATUS                      =

*   IT_PARTNER                         =

*   IT_PARTNER_UP                      =

*   IT_OPERATION                       =

*   IT_OPERATION_UP                    =

*   IT_RELATION                        =

*   IT_RELATION_UP                     =

*   IT_COMPONENT                       =

*   IT_COMPONENT_UP                    =

*   IT_OBJECTLIST                      =

*   IT_OBJECTLIST_UP                   =

*   IT_OLIST_RELATION                  =

*   IT_TEXT                            =

*   IT_TEXT_LINES                      =

*   IT_SRULE                           =

*   IT_SRULE_UP                        =

*   IT_TASKLISTS                       =

*   EXTENSION_IN                       =

    RETURN                             = it_return

*   ET_NUMBERS                         =

*   IT_REFORDER_ITEM                   =

*   IT_REFORDER_ITEM_UP                =

*   IT_REFORDER_SERNO_OLIST_INS        =

*   IT_REFORDER_SERNO_OLIST_DEL        =

*   IT_PRT                             =

*   IT_PRT_UP                          =

*   IT_REFORDER_OPERATION              =

*   IT_SERVICEOUTLINE                  =

*   IT_SERVICEOUTLINE_UP               =

*   IT_SERVICELINES                    =

*   IT_SERVICELINES_UP                 =

*   IT_SERVICELIMIT                    =

*   IT_SERVICELIMIT_UP                 =

*   IT_SERVICECONTRACTLIMITS           =

*   IT_SERVICECONTRACTLIMITS_UP        =

*   ET_NOTIFICATION_NUMBERS            =

*   IT_PERMIT                          =

*   IT_PERMIT_UP                       =

*   IT_PERMIT_ISSUE                    =

*   IT_ESTIMATED_COSTS                 =

           .

read TABLE it_return INTO wa_return with key type = 'S'.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  EXPORTING

    WAIT          = 'X'.

READ TABLE it_return INTO wa_return with key type = 'E'.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

data: char type char300.

char = wa_return.


This is my coding, if i execute this it gives dump error.

  write:/ 'return' , char .

Read only

0 Likes
5,803

Hi,

If i change the reference number the error message comes like

'The reference number '2' is not in the method table'.

If i give refnumber as '000001' the error message is

'The reference number '0' is not in the method table'.

If you have fulling coding please share me.

Thanks & Regards,

Mahesh

Read only

0 Likes
5,803

Hi Mahesh,

I can't see any operation passed in it_operation, also try to pass  it_objectlist,  it_partner along with it_operation,  it_header and it_methods.

Not sure why you are passing it_header_up, this table is passed in case of updating work order.

Regards,

Tarun

Read only

0 Likes
5,803

ohhh I missed reply from Anamika Jain  she has already suggested you to pass Header, Operation and Partner. Please try that and see if Objectlist is required.

Well for me i had to pass objectlist also and it works.

Regards,

Tarun

Read only

0 Likes
5,803

Hi tarun,

I need to create pm order based on the it_header fields only.

I also tried without passing it_header_up.

that time also same error comes.

Regards,

Mahesh

Read only

0 Likes
5,803

Hi tarun & Anamika,

If you have successfully created the PM order using the BAPI,can you please share me your code.

Thanks & Regards,

Mahesh

Read only

0 Likes
5,803

Hi,

Please go through the attached file. There is a sample code for order creation.

Regards

Ashish

Read only

0 Likes
5,803

HI Ashish,

I am trying to execute your coding but its not working.

The errors occurred in the below lines.

p_method lv_ord_ref 'HEADER' 'CREATE' lv_objkey.


p_method '' '' 'SAVE' lv_objkey.

p_method lv_ord_ref 'HEADER' 'RELEASE' lv_objkey.


what is P_method and where it is declared.

and in loop at statement which internal table and work area need to loop.

Regards,

Mahesh

Read only

0 Likes
5,803

Hi,

If you look at bottom of file, i have declared about p_method. Its a macro I declared in top include of my program. In loop statement the table is my own internal table which contains the data records for header value, like you will also be having one.

You can use it as -

data: lt_methods  TYPE TABLE OF  bapi_alm_order_method,

        ls_method TYPE  bapi_alm_order_method.

  ls_method-refnumber  = '1'.

  ls_method-objecttype = 'HEADER'.

  ls_method-method     = 'CREATE'.

  ls_method-objectkey  = '%00000000001'.

append ls_method to lt_methods.

clear ls_method.

Regards

Ashish

Read only

0 Likes
5,803

Hi Ashish,

I tried as you told,but i cant able to create an order.

any way thanks.

temporarily i use BDC for creating maintenance order.

I you have any free time please send me the coding part fully from top to bottom.

Again Thanks,


Regards,

Mahesh.

Read only

0 Likes
5,803

Hi,

   What error are you getting.? The code which I have sent you is working. Can you please tell the error and paste your code?

Regards

Ashish

Read only

0 Likes
5,803

Hi Ashish,

I dont have good knowledge in Macros.so i cant able to re arrange your coding without macros.

Regards,

Mahesh

Read only

0 Likes
5,802

Hi,

  I have arranged the code for order creation without macros. If you get any error then please tell the error.

Have a look at the attached code.

Read only

0 Likes
5,802

Hi Ashish,

Now I get this error 'Error reading the order %00000000001 in the document tables'.

Regards,

Mahesh

Read only

0 Likes
5,802

Can you post your code please.?

Read only

0 Likes
5,802

Hi Ashish,

TYPES: BEGIN OF ORDER,

   ORDER_TY TYPE AUFART,

   SHT_TXT  TYPE EQFNR,

   PRIO_ID  TYPE PRIOK,

   FUNC_LOC TYPE TPLNR,

   EQUIP_ID TYPE EQUNR,

   ASSEMBLY TYPE BAUTL,

   PLANG_P  TYPE IWERK,

   PLAN_GRP TYPE INGRP,

   WK_CTRPT TYPE ARBPL,

   WORK_CNR TYPE GEWRK,

   SYS_CND  TYPE ANLZU,

   PM_ACTTP TYPE ILA,

   B_STRDAT TYPE CO_GSTRP,

   B_FINDAT TYPE CO_GLTRP,

   REVISN   TYPE REVNI,

   END OF ORDER.

PARAMETERS : ORDER_TY  TYPE AUFART,

SHT_TXT          TYPE EQFNR,

PRIO_ID          TYPE PRIOK,

FUNC_LOC         TYPE TPLNR,

EQUIP_ID         TYPE EQUNR,

ASSEMBLY         TYPE BAUTL,

PLANG_P          TYPE IWERK,

PLAN_GRP         TYPE INGRP,

WK_CTRPT         TYPE ARBPL,

WORK_CNR         TYPE GEWRK,

SYS_CND          TYPE ANLZU,

PM_ACTTP         TYPE ILA,

B_STRDAT         TYPE CO_GSTRP,

B_FINDAT         TYPE CO_GLTRP,

REVISN           TYPE REVNI.

DATA: ORDER TYPE TABLE OF ORDER,

       WA_ORDER TYPE ORDER.

DATA: LT_METHODS  TYPE TABLE OF  BAPI_ALM_ORDER_METHOD,

         LT_HEADER  TYPE TABLE OF  BAPI_ALM_ORDER_HEADERS_I,

         LT_PARTNER_UP TYPE TABLE OF BAPI_ALM_ORDER_PARTN_MUL_UP,

         LT_CONFRMITEM TYPE TABLE OF  BAPI_ALM_TIMECONFIRMATION,

         LS_TEXT TYPE  BAPI_ALM_TEXT,

         LV_AUFPL TYPE CO_AUFPL,

         LV_APLZL TYPE CO_APLZL,

         LT_RETURN TYPE TABLE OF BAPIRET2,

         LS_RETURN TYPE BAPIRET2.

DATA: LV_OBJKEY  TYPE OBJIDEXT VALUE '%00000000001',     " Temp key value , Imp

LV_ORD_REF TYPE IFREFNUM VALUE 1 .

DATA LS_METHOD TYPE BAPI_ALM_ORDER_METHOD.

FIELD-SYMBOLS<LT_METHODS>        TYPE BAPI_ALM_ORDER_METHOD,

                 <LT_HEADER>          TYPE BAPI_ALM_ORDER_HEADERS_I.

LOOP AT ORDER INTO WA_ORDER. " Order header "

   APPEND INITIAL LINE TO LT_HEADER ASSIGNING <LT_HEADER>.

   <LT_HEADER>-ORDERID = '%00000000001'.

   <LT_HEADER>-ORDER_TYPE = WA_ORDER-ORDER_TY.

   <LT_HEADER>-SHORT_TEXT = WA_ORDER-SHT_TXT.

   <LT_HEADER>-PRIORITY = WA_ORDER-PRIO_ID.

   <LT_HEADER>-FUNCT_LOC = WA_ORDER-FUNC_LOC.

   <LT_HEADER>-EQUIPMENT = WA_ORDER-EQUIP_ID.

   <LT_HEADER>-ASSEMBLY = WA_ORDER-ASSEMBLY.

   <LT_HEADER>-PLANPLANT = WA_ORDER-PLANG_P.

   <LT_HEADER>-PLANGROUP = WA_ORDER-PLAN_GRP.

   <LT_HEADER>-PLANT = WA_ORDER-WK_CTRPT.

   <LT_HEADER>-MN_WK_CTR = WA_ORDER-WORK_CNR.

   <LT_HEADER>-SYSTCOND = WA_ORDER-SYS_CND.

   <LT_HEADER>-PMACTTYPE = WA_ORDER-PM_ACTTP.

   <LT_HEADER>-START_DATE = WA_ORDER-B_STRDAT.

   <LT_HEADER>-FINISH_DATE = WA_ORDER-B_FINDAT.

   <LT_HEADER>-REVISION = WA_ORDER-REVISN.

   LS_METHOD-REFNUMBER  = '1'.

   LS_METHOD-OBJECTTYPE = 'HEADER'.

   LS_METHOD-METHOD     = 'CREATE'.

   LS_METHOD-OBJECTKEY  = '%00000000001'.

   APPEND LS_METHOD TO LT_METHODS.

   CLEAR LS_METHOD.

ENDLOOP.

LS_METHOD-REFNUMBER  = ''.

LS_METHOD-OBJECTTYPE = ''.

LS_METHOD-METHOD     = 'SAVE'.

LS_METHOD-OBJECTKEY  = '%00000000001'.

APPEND LS_METHOD TO LT_METHODS.

CLEAR LS_METHOD.

LS_METHOD-REFNUMBER  = '1'.

LS_METHOD-OBJECTTYPE = 'HEADER'.

LS_METHOD-METHOD     = 'RELEASE'.

LS_METHOD-OBJECTKEY  = '%00000000001'.

APPEND LS_METHOD TO LT_METHODS.

CLEAR LS_METHOD.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

   TABLES

     IT_METHODS = LT_METHODS

     IT_HEADER  = LT_HEADER

     RETURN     = LT_RETURN.

*  READ TABLE lt_return TRANSPORTING NO FIELDS WITH  KEY type = gc_error.

*  IF sy-subrc NE 0.

*

*    IF NOT lv_notif_check IS INITIAL.                           " Order created for notification

*

*      READ TABLE lt_return  INTO ls_return TRANSPORTING message_v2  WITH KEY type = 'S'  number = '126'.

*      lv_order_no = ls_return-message_v2.

*

*    ELSE.                                                       " Standalone order created

*

*      READ TABLE lt_return  INTO ls_return TRANSPORTING message_v2  WITH KEY type = 'S'  number = '112'.

*      lv_order_no = ls_return-message_v2.

*

*    ENDIF.

*

*    alpha_in lv_order_no.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

   EXPORTING

     WAIT = 'X'.


I execete above code in report.


Regards,

Mahesh

Read only

0 Likes
5,802

Hi Mahesh,

  Can you tell me one simple thing. When you are passing the value in the PARAMETER fields, why did you use loop for order.?

   In fact what is the need for loop when you have to take values from the fields which you have declared in PARAMETER.

That's why the main CREATE method is not getting filled and you are getting this error.

Remove the loop and directly pass the value from fields which you have declared in PARAMTETERS. 

     It's a simple thing. Just remove loop and directly pass the value. Don't remove anything else

And use proper conversion exits for functional equipment and equipment.

Regards

Ashish

Read only

0 Likes
5,802

Hi Ashish,

Now I send the coding to you can you please check in your system it is work or not.

while i try execute this coding it gives dump error,same coding like this i tried many times before, that time also it gives dump error only.

If it is working please send me the inputs you  gives.

PARAMETERS : ORDER_TY  TYPE AUFART,

SHT_TXT          TYPE EQFNR,

PRIO_ID          TYPE PRIOK,

FUNC_LOC         TYPE TPLNR,

EQUIP_ID         TYPE EQUNR,

ASSEMBLY         TYPE BAUTL,

PLANG_P          TYPE IWERK,

PLAN_GRP         TYPE INGRP,

WK_CTRPT         TYPE ARBPL,

WORK_CNR         TYPE GEWRK,

SYS_CND          TYPE ANLZU,

PM_ACTTP         TYPE ILA,

B_STRDAT         TYPE CO_GSTRP,

B_FINDAT         TYPE CO_GLTRP,

REVISN           TYPE REVNI.

DATA: ORDER TYPE TABLE OF ORDER,

       WA_ORDER TYPE ORDER.

DATA: LT_METHODS  TYPE TABLE OF  BAPI_ALM_ORDER_METHOD,

         LT_HEADER  TYPE TABLE OF  BAPI_ALM_ORDER_HEADERS_I,

         LT_PARTNER_UP TYPE TABLE OF BAPI_ALM_ORDER_PARTN_MUL_UP,

         LT_CONFRMITEM TYPE TABLE OF  BAPI_ALM_TIMECONFIRMATION,

         LS_TEXT TYPE  BAPI_ALM_TEXT,

         LV_AUFPL TYPE CO_AUFPL,

         LV_APLZL TYPE CO_APLZL,

         LT_RETURN TYPE TABLE OF BAPIRET2,

         LS_RETURN TYPE BAPIRET2.

DATA: LV_OBJKEY  TYPE OBJIDEXT VALUE '%00000000001',     " Temp key value , Imp

LV_ORD_REF TYPE IFREFNUM VALUE 1 .

DATA LS_METHOD TYPE BAPI_ALM_ORDER_METHOD.

FIELD-SYMBOLS<LT_METHODS>        TYPE BAPI_ALM_ORDER_METHOD,

                 <LT_HEADER>          TYPE BAPI_ALM_ORDER_HEADERS_I.

*LOOP AT ORDER INTO WA_ORDER. " Order header "

   APPEND INITIAL LINE TO LT_HEADER ASSIGNING <LT_HEADER>.

   <LT_HEADER>-ORDERID     = '%00000000001'.

   <LT_HEADER>-ORDER_TYPE  = ORDER_TY.

   <LT_HEADER>-SHORT_TEXT  = SHT_TXT.

   <LT_HEADER>-PRIORITY    = PRIO_ID.

   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

     EXPORTING

       INPUT         = FUNC_LOC

    IMPORTING

      OUTPUT         = FUNC_LOC.

   <LT_HEADER>-FUNCT_LOC   = FUNC_LOC.

       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

     EXPORTING

       INPUT         = EQUIP_ID

    IMPORTING

      OUTPUT         = EQUIP_ID.

   <LT_HEADER>-EQUIPMENT   = EQUIP_ID.

   <LT_HEADER>-ASSEMBLY    = ASSEMBLY.

   <LT_HEADER>-PLANPLANT   = PLANG_P.

   <LT_HEADER>-PLANGROUP   = PLAN_GRP.

   <LT_HEADER>-PLANT       = WK_CTRPT.

   <LT_HEADER>-MN_WK_CTR   = WORK_CNR.

   <LT_HEADER>-SYSTCOND    = SYS_CND.

   <LT_HEADER>-PMACTTYPE   = PM_ACTTP.

   <LT_HEADER>-START_DATE  = B_STRDAT.

   <LT_HEADER>-FINISH_DATE = B_FINDAT.

   <LT_HEADER>-REVISION    = REVISN.

   LS_METHOD-REFNUMBER  = '1'.

   LS_METHOD-OBJECTTYPE = 'HEADER'.

   LS_METHOD-METHOD     = 'CREATE'.

   LS_METHOD-OBJECTKEY  = '%00000000001'.

   APPEND LS_METHOD TO LT_METHODS.

   CLEAR LS_METHOD.

*ENDLOOP.

LS_METHOD-REFNUMBER  = ''.

LS_METHOD-OBJECTTYPE = ''.

LS_METHOD-METHOD     = 'SAVE'.

LS_METHOD-OBJECTKEY  = '%00000000001'.

APPEND LS_METHOD TO LT_METHODS.

CLEAR LS_METHOD.

LS_METHOD-REFNUMBER  = '1'.

LS_METHOD-OBJECTTYPE = 'HEADER'.

LS_METHOD-METHOD     = 'RELEASE'.

LS_METHOD-OBJECTKEY  = '%00000000001'.

APPEND LS_METHOD TO LT_METHODS.

CLEAR LS_METHOD.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

   TABLES

     IT_METHODS = LT_METHODS

     IT_HEADER  = LT_HEADER

     RETURN     = LT_RETURN.

*  READ TABLE lt_return TRANSPORTING NO FIELDS WITH  KEY type = gc_error.

*  IF sy-subrc NE 0.

*

*    IF NOT lv_notif_check IS INITIAL.                           " Order created for notification

*

*      READ TABLE lt_return  INTO ls_return TRANSPORTING message_v2  WITH KEY type = 'S'  number = '126'.

*      lv_order_no = ls_return-message_v2.

*

*    ELSE.                                                       " Standalone order created

*

*      READ TABLE lt_return  INTO ls_return TRANSPORTING message_v2  WITH KEY type = 'S'  number = '112'.

*      lv_order_no = ls_return-message_v2.

*

*    ENDIF.

*

*    alpha_in lv_order_no.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

   EXPORTING

     WAIT = 'X'.



Regards,

Mahesh

Read only

0 Likes
5,802

Hi,

For functional location , conversion exit is - CONVERSION_EXIT_TPLNR_INPUT.

This is the error message ' Order %00000000001 cannot be put in process, as no operation is maintained ', no dump.

I gave - order_ty = pm01

sht_txt - test order

func_loc = k1-b01

plang_p = 1000

work_cntr = mechanik

Read only

0 Likes
5,802

HI Ashish,

I am getting this dump error.

Regards,

Mahesh