Skip to Content
Technical Articles

PPM: Automate the process of creation and assignment of elements for Initiatives

This is a beginner level article intended for consultants to gain technical insight on the process of automatic creation and assignment of elements for initiatives in the PPM space.

 

Problem Statement:

In the PPM workspace, whenever a new initiative is created, we want to automate the process of creating and assigning elements to the created initiative.

 

Required background Knowledge:

Portfolio Item:

A portfolio item is a generic object representing for example proposals, projects, concepts (anything that should be analyzed within a portfolio).

Each portfolio item consists of a set of attributes and can have services (for example, icons, questionnaires, scoring models) assigned to it.

Initiatives:

An object used in the process of discovering, designing, and developing new products within a company, and introducing these products to the market. This innovation process follows predefined innovation process templates where decision gates and phases are defined. This includes the post-launch phase.

We use the initiative to track the Decision Flow Management process. From the initiative overview, we can monitor the status of the decision points and phases.

Object Links for Items and Initiatives

Portfolio items and initiatives can be related in various ways to business objects in other applications, such as projects in Project Management, Project System projects in SAP ERP, or facilities in SAP Environmental Compliance. These business objects can be located in the same system or in a different system, for example, a separate ERP system. By creating object links, you can connect portfolio items and initiatives to business objects of predefined object types in order to achieve the following:

  • Provide an overview of all objects relevant for an item or initiative
  • Enable the display of detailed header data for these objects within Portfolio Management
  • Provide access to predefined applications related to these objects, allowing you to, for example, display master data, or analyze and edit transactional data

Solution:

In order to achieve the above requirement, the below BADI needs to be implemented:

BADI    INM_INITIATIVE_O_BADI
Method of implementing class        IF_INM_EX_INITIATIVE_O~ON_CHANGES_COMMITTED

 

Part 1: Creation of elements:

To create the elements below FM is used. This can be used to create single/multiple elements in a go.

Function Module /RPM/ITEM_MODIFY

Pre-requisites:

In order to create the elements, the item type should already be configured. To do this, go to the below path in SPRO:

SAP Portfolio and Project Management   Portfolio Management  Global Customizing  Portfolio-Independent Settings  Define Portfolio Item Types.

 

Part 2: Assign the element to the initiative:

To assign the element to the initiative, the below FM is used.

FM       /RPM/OBJECT_LINK_MODIFY

 

Prerequisites

The object type of the object to which you want to link has been configured for usage in portfolio items or initiatives.

 

Sample Code:

FUNCTION ZPPM_CREATE_INI_ELEMENTS.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IS_ATTRIBUTES) TYPE  INM_TS_INITIATIVE_EXT
*"----------------------------------------------------------------------
  TYPES: BEGIN OF mty_element,
           item_type TYPE /rpm/item_d-item_type,
           text      TYPE char40,
         END OF mty_element,
         mtt_element TYPE STANDARD TABLE OF mty_element.

  DATA: lt_elements TYPE mtt_element.

  APPEND VALUE #( item_type = 'ZECO_P&M' text = 'Prefactibilidad y Maduración')              TO lt_elements ##NO_TEXT .
  APPEND VALUE #( item_type = 'ZECO_IIS' text = 'Infraestructura Industrial de Superficie')  TO lt_elements ##NO_TEXT .
  APPEND VALUE #( item_type = 'ZECO_P&C' text = 'Perforación y Completamiento')              TO lt_elements ##NO_TEXT .
  APPEND VALUE #( item_type = 'ZECO_INI' text = 'Infraestructura no Industrial')             TO lt_elements ##NO_TEXT .
  APPEND VALUE #( item_type = 'ZECO_AMB' text = 'Ambiental')                                 TO lt_elements ##NO_TEXT .
  APPEND VALUE #( item_type = 'ZECO_VSO' text = 'Viabilidad social')                         TO lt_elements ##NO_TEXT .
  APPEND VALUE #( item_type = 'ZECO_CON' text = 'Contingencias')                             TO lt_elements ##NO_TEXT .

  DATA:
    ls_attributes        TYPE /rpm/ts_item_d_api,
    ls_attr_intf         TYPE /rpm/ts_item_d_api_intf,
    lt_attr_intf         TYPE /rpm/tt_item_d_api_intf,
    lt_msg               TYPE /rpm/tt_messages,
    lv_rc                TYPE i,
    lt_guids             TYPE /rpm/tt_guid,
    ls_guid              TYPE /rpm/ts_guid,
    ls_rpm_obj_link      TYPE /rpm/ts_obj_link_api,
    lt_created_obj_links TYPE /rpm/tt_object_link_api,
    ls_item_context      TYPE /rpm/ts_item_context.

  SELECT
  SINGLE guid,
         location,
         geography
    FROM /rpm/item_d
    INTO @DATA(ls_item_details)
   WHERE guid = @is_attributes-item_guid.
  IF sy-subrc <> 0.
    RETURN.
  ENDIF.

  LOOP AT lt_elements ASSIGNING FIELD-SYMBOL(<ls_element>).
    CLEAR: ls_attributes, lv_rc, lt_created_obj_links, lt_guids, lt_attr_intf, lt_msg.

    ls_attributes-proj_description = <ls_element>-text.
    ls_attributes-item_type        = <ls_element>-item_type.

    ls_attributes-category         = is_attributes-category.
    ls_attributes-subcategory      = is_attributes-subcategory.
    ls_attributes-location         = ls_item_details-location.
    ls_attributes-geography        = ls_item_details-geography.
    ls_attributes-master_item_guid = is_attributes-item_guid.

    MOVE-CORRESPONDING ls_attributes TO ls_attr_intf.
    ls_attr_intf-portfolio_guid = is_attributes-portfolio_guid.
    ls_attr_intf-parent_guid = is_attributes-parent_guid.
    ls_attr_intf-initiative_guid = is_attributes-guid.
    APPEND ls_attr_intf TO lt_attr_intf.

    CALL FUNCTION '/RPM/ITEM_MODIFY'
      EXPORTING
        iv_change_mode    = 'C'
        is_modify_context = ls_item_context
      IMPORTING
        ev_rc             = lv_rc
      TABLES
        et_guid           = lt_guids
        it_attributes     = lt_attr_intf
        et_msg            = lt_msg.

* Add object link item to initiative (if not done already by item_modify)
    IF lv_rc IS INITIAL AND lt_guids IS NOT INITIAL.

      CALL FUNCTION '/RPM/SAVE_CHANGES'
        IMPORTING
          et_msg = lt_msg.

      READ TABLE lt_msg TRANSPORTING NO FIELDS WITH KEY msgtype = 'E'.
      IF sy-subrc <> 0.
        READ TABLE lt_guids INTO ls_guid INDEX 1.
        ls_rpm_obj_link-project_guid     = is_attributes-guid.
        ls_rpm_obj_link-object_link_type = '0INMITEM'.
        ls_rpm_obj_link-object_key       = ls_guid-guid.

        APPEND ls_rpm_obj_link TO lt_created_obj_links.
        CALL FUNCTION '/RPM/OBJECT_LINK_MODIFY'
          EXPORTING
            it_attributes  = lt_created_obj_links
            iv_change_mode = 'C'
          IMPORTING
            ev_rc          = lv_rc
            et_msg         = lt_msg.
        IF lv_rc IS INITIAL.
          CALL FUNCTION '/RPM/SAVE_CHANGES'
            IMPORTING
              et_msg = lt_msg.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDFUNCTION.

 

Hope you had a good read. Please feel free to reach me for any questions. 🙂

Be the first to leave a comment
You must be Logged on to comment or reply to a post.