cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create Maintenance Plan (IP01) With Existing Maintenance Items Through Custom BAPI.

SATHEESHKUMAR_1
Explorer
0 Kudos
220

Hi,

I have developed custom BAPI using MPLAN_CREATE, but using this BAPI I am able to create Maintenance Plan with new Maintenance Items, but I want to create Maintenance Plan with Existing Maintenance Items. can anyone knows any other standard BAPI or any custom BAPI code for this requirement.

Regards,

Satheesh Kumar .

View Entire Topic
raga1234
Explorer
0 Kudos

Please Try MPLAN_CREATE_WITH_TEMPLATE

SATHEESHKUMAR_1
Explorer
0 Kudos

Hi,

Thanks for the reply, but Issue got Resolved with Action(C).

Now I am able to create Maintenance Item(IP04) with BDC, but I want to create Maintenance Item with object links, please find the below screen shots with existing code (Which I am creating Maintenance Item).

DATA  wa_msg TYPE bdcmsgcoll.
**  DATA messtab TYPE STANDARD TABLE OF bdcmsgcoll.
  DATA:       messtab    like bdcmsgcoll occurs 0 with header line.
  DATA : bapimsg  LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
         bapimsgq LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
  DATA : id   TYPE bapiret2-id,
         num  TYPE bapiret2-number,
         msg  TYPE bapiret2-message,
         msg1 TYPE bapiret2-message_v1,
         msg2 TYPE bapiret2-message_v2,
         msg3 TYPE bapiret2-message_v3,
         msg4 TYPE bapiret2-message_v4.
CLEAR:messtab[],bdcdata[].
  IF MAINTENANCEITEM-mptyp = 'PM'.

    PERFORM bdc_dynpro      USING 'SAPLIWP3' '0200'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RMIPM-WAPOS'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM bdc_field       USING 'RMIPM-MPTYP'
                                  'PM'.
    PERFORM bdc_dynpro      USING 'SAPLIWP3' '0201'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RMIPM-PSTXT'.
    PERFORM bdc_field       USING 'RMIPM-PSTXT'
                                  MAINTENANCEITEM-PStxt.


    PERFORM bdc_field       USING 'RIWO1-EQUNR'
                                  MAINTENANCEITEM-equnr.
    PERFORM bdc_field       USING 'RIWO1-TPLNR'
                                  MAINTENANCEITEM-tplnr.


    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RMIPM-GEWERK'.
    PERFORM bdc_field       USING 'RMIPM-IWERK'
                                  MAINTENANCEITEM-iwerk.
    PERFORM bdc_field       USING 'RMIPM-AUART'
                                  MAINTENANCEITEM-auart.
    PERFORM bdc_field       USING 'RMIPM-ILART'
                                  MAINTENANCEITEM-ilart.
    PERFORM bdc_field       USING 'RMIPM-GEWERK'
                                  MAINTENANCEITEM-gewerk.
    PERFORM bdc_field       USING 'RMIPM-GSBER'
                                  MAINTENANCEITEM-gsber.
    PERFORM bdc_field       USING 'RMIPM-wergw'
                                  MAINTENANCEITEM-wergw.
    PERFORM bdc_field       USING 'RMIPM-WPGRP'
                                  MAINTENANCEITEM-wpgrp.

    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RMIPM-PLNTY'.
    PERFORM bdc_field       USING 'RMIPM-PLNTY'
                                  MAINTENANCEITEM-plnty.
    PERFORM bdc_field       USING 'RMIPM-PLNAL'
                                  MAINTENANCEITEM-plnal.
    PERFORM bdc_field       USING 'RMIPM-PLNNR'
                                  MAINTENANCEITEM-plnnr.


    PERFORM bdc_dynpro      USING 'SAPLIWP3' '0201'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                '=BU'.


    PERFORM bdc_field       USING 'RMIPM-PSTXT'
                                  MAINTENANCEITEM-PStxt.
    PERFORM bdc_field       USING 'RIWO1-EQUNR'
                                  MAINTENANCEITEM-equnr.

    PERFORM bdc_field       USING 'RIWO1-EQUNR'
                                  MAINTENANCEITEM-tplnr.

    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RMIPM-PLNTY'.
    PERFORM bdc_field       USING 'RMIPM-IWERK'
                                  MAINTENANCEITEM-iwerk.
    PERFORM bdc_field       USING 'RMIPM-AUART'
                                  MAINTENANCEITEM-auart.
    PERFORM bdc_field       USING 'RMIPM-ILART'
                                  MAINTENANCEITEM-ilart.
    PERFORM bdc_field       USING 'RMIPM-GEWERK'
                                  MAINTENANCEITEM-gewerk.
    PERFORM bdc_field       USING 'RMIPM-wergw'
                                  MAINTENANCEITEM-wergw.

    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RMIPM-PLNTY'.
    PERFORM bdc_field       USING 'RMIPM-PLNTY'
                                  MAINTENANCEITEM-plnty.
    PERFORM bdc_field       USING 'RMIPM-PLNAL'
                                  MAINTENANCEITEM-plnal.
    PERFORM bdc_field       USING 'RMIPM-PLNNR'
                                  MAINTENANCEITEM-plnnr.

**    PERFORM bdc_transaction USING 'IP01'.
    PERFORM bdc_transaction TABLES messtab
    USING                         'IP04'
                                ctu
                                mode
                                update.
  ENDIF.


  READ TABLE messtab INTO wa_msg WITH KEY msgtyp = 'E'.
  IF sy-subrc = 0.
    id =   wa_msg-msgid.
    num =  wa_msg-msgnr.
    msg1 = wa_msg-msgv1.
    msg2 =  wa_msg-msgv2.
    msg3 =  wa_msg-msgv3.
    msg4 = wa_msg-msgv4.

    e_return = WA_MSG-MSGV1.
    e_retcd = '1'.
    CONCATENATE e_error wa_msg-MSGID wa_msg-MSGNR wa_msg-MSGV1 INTO e_error SEPARATED BY space.
    EXIT.
  ELSE.

    READ TABLE messtab INTO wa_msg WITH KEY msgtyp = 'S'.
    IF sy-subrc = 0.
    CONCATENATE 'Maintenance Item No'  WA_MSG-MSGV1 'created' INTO E_ERROR SEPARATED BY space.

      id =   wa_msg-msgid.
      num =  wa_msg-msgnr.
      msg1 = wa_msg-msgv1.
      msg2 =  wa_msg-msgv2.
      msg3 =  wa_msg-msgv3.
      msg4 = wa_msg-msgv4.

      e_return = WA_MSG-MSGV1.
      e_retcd = '0'.
    ENDIF.
  ENDIF.

 

SATHEESHKUMAR_1_0-1721367135316.png

Thanks

Satheesh Kumar