Skip to Content
Technical Articles
Author's profile photo Kevin Dass

Automatically Generated External-ID Portfolio Item and Initiatives

I thought to write this blog as I couldn’t find a solve with complete information. However there are very few questions asked by many on but users comments didn’t assist much. So this blog would walk you through on how to automatically generated external-ID Portfolio Item and Initiatives.


As we know post SPRO configuration Automatically Generated External-ID of Portfolio Objects Set to Read-Only there could be addiotnal ask by customer on it’s behavior

In Portfolio Management the number range object RPM_EXTID is used to determine the next external ID of an object.

The BAdI RPM_OBJECT_SERVICES with method GET_NEXT_NUMBER_FOR_EXTID can be used to make further changes to the external-ID and to determine the external-ID based on customer-logic(KBA note 2183855 for List of BAdIs Portfolio Management). The switch must be activated that the External-ID can be further changed with BAdI RPM_OBJECT_SERVICES with method GET_NEXT_NUMBER_FOR_EXTID. Information can you find in KBA Note 2179188.

BAdI RPM_OBJECT_SERVICES with method GET_NEXT_NUMBER_FOR_EXTID suits perfectly, however the external number would be generated during Create event which is same a SAP behavior.


So what if one would like to generate during Save event which would help not to lose number range in case user plans not to save Portfolio Item and Initiatives?

In order to archive this BAdI RPM_PROJ_CUST_FIELDS method CUST_PROJ_PREPARE_TO_SAVE could assist. However thing to note here is that method CUST_PROJ_PREPARE_TO_SAVE has only importing parameters.

In order to deal with this, we would need to use Master Project Definition class “CL_RPM_PROJECT” along with Project Management Controller “CL_RPM_OBJ_MANAGER”.

METHOD if_ex_rpm_proj_cust_fields~cust_proj_prepare_to_save.
DATA: lv_nr     TYPE nrnr,
      lv_obj    TYPE nrobj,
      lv_prefix TYPE char3.

DATA lt_projects     TYPE rpm_tt_guid_project_defs.
DATA lv_ui_change_mode TYPE boole_d.
DATA or_item           TYPE REF TO cl_rpm_project.
DATA ls_attributes     TYPE rpm_ts_project_int.

*  During SAVE when PPM object is being created
IF is_attributes-external_id NE is_attributes_old-external_id AND
   is_attributes_old-external_id IS INITIAL.
  DATA(lr_manager) = cl_rpm_obj_manager=>get_instance( iv_langu = sy-langu ).
  CALL METHOD lr_manager->load_projects
      iv_guid             = is_attributes-guid
      et_projects         = lt_projects
      ev_load_change_mode = lv_ui_change_mode.

      DATA(ls_project) = lt_projects[ 1 ].
      or_item = ls_project-reference.

    CATCH cx_sy_itab_line_not_found.

  IF or_item IS BOUND.
* Check your Item and Initiatives Item_Type as per system configuration 
    CASE ls_attributes-rpm_project-item_type.
      WHEN ''. "Initiatives
*              lv_nr   = .
*              lv_obj  = .
*              lv_prefix =   .
      WHEN ''.  "Portfolio Item
*              lv_nr   = .
*              lv_obj  = .
*              lv_prefix =   .

    IF NOT lv_prefix IS INITIAL.
          nr_range_nr             = lv_nr
          object                  = lv_obj
          ignore_buffer           = 'X'
          number                  = lv_extid
          interval_not_found      = 1
          number_range_not_intern = 2
          object_not_found        = 3
          quantity_is_0           = 4
          quantity_is_not_1       = 5
          interval_overflow       = 6
          buffer_overflow         = 7
          OTHERS                  = 8.
      IF sy-subrc <> 0.
*               Implement suitable error handling here
      ls_attributes-external_id = |{ lv_prefix }| && |{ '.' }| && |{ lv_extid }|.
          CALL METHOD or_item->set_attributes
              is_attributes = ls_attributes.
        CATCH cx_rpm_object_update_error .
        CATCH cx_rpm_configuration_error .

PPM Item:

BAdI Definition Name: RPM_PROJ_CUST_FIELDS, method CUST_PROJ_PREPARE_TO_SAVE to overwrite External ID

PPM Initiative:

BAdI Definition Name: INM_INITIATIVE_O_BADI, method ON_SAVE_REQUESTED to overwrite External ID


With above custom code at the right place one could achieve PPM external ID generation on Save event rather than SAP provided on Create event


Thank you for reading and would like to hear from you and/or clarifying questions in the comment section.







Assigned Tags

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