Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
Xiaolong
Associate
Associate

Introduction: 

As my colleague has outlined in this blog, there are 2 different possibilities for managing projects, Enterprise projects and Professional Services Projects, within S/4HANA Cloud public edition.  Until now, a key user would use this approach Automatic Generation of Project IDs using BAdI in SAP S/4HANA Cloud to influence the generation of project IDs based on some key combinations, as mentioned  in the blog Automatic Generation of Project IDs using BAdI in SAP S/4HANA Cloud. However, the above approach has a couple of shortcomings, 

  1. Project ID generation via (/CPD/ENGMTPROJECTID_GEN was only possible via SAP Standard UI (such as Plan Customer Projects). For example, projects created via Solution Order or API (Enterprise Project API)  couldn’t make use of the above approach. 
  2. Project ID generation couldn’t be influenced by a custom field defined for Enterprise Project API. 

We now have a unified approach that can be applied to both types of project control activities using enterprise project APIs (yes, enterprise project APIs now can be used to create both professional services projects and enterprise projects! Yes, we have some areas to catch up.) 

In this blog, I detail out project ID generation using the new approach and overcoming those challenges mentioned above. 

Here you will learn:  

How to generate Custom Project IDs based on customer name and project year. Typically, customers generate Project IDs based on the customer's short name and project year and then sequence numbers. For example, CUSTOMERNAME2023001. 

How to debug Cloud BADI via ABAP Development Tools. (Only available in CE2402) 

Generate Customer Project Id via new BADI 

Default Functionality: 

With the Customer Project functionality in SAP S/4HANA Cloud, customers can manually enter alphanumeric values for their internal and customer projects. But a unique number must be entered each time the Customer creates a new project. 

For customer projects generated by solution order, the project ID is combination of solution order number and item number. 

In this document, only covers  Plan Customer Projects. 

Customization: 

The creation of a new implementation of the BadI will be carried out in SAP S/4HANA Cloud under the Business User using Custom Logic without access to the Classic SAP GUI. The new implementation of BadI will generate a Project ID for Customer Project based on the short name of the client and the year of the project, and then serial numbers. 

Preconditions: 

In order to achieve this task, you need the following Roles or copied roles assigned to your business user.  

Business Role 

Business Role ID 

Extensibility Specialist 

SAP_BR_EXTENSIBILITY_SPEC 

Project Manager - Professional Services 

SAP_BR_PROJECT_MANAGER_PROF 

 If you don’t have the above roles, you need ask your administrator to request roles. Or follow the guide Maintain Business Users if you are the administrator. 

Development: 

To achieve our goal, we will need to create a new implementation of BadI based on the extension point /S4PPM/PROJECT_DETERMINATION_2 using the Custom Logic functionality and write code that will generate a new Project ID according to our requirements. 

Go to the Application Custom Logic -> Click on the “Create” button. 

Xiaolong_0-1706597013835.png

Or use App Finder 

 

Xiaolong_1-1706597079662.png

 

Xiaolong_2-1706597079664.png

 Set Extension Point.

Set Extension point as /S4PPM/PROJECT_DETERMINATION_2. 

Xiaolong_3-1706597159754.png

 

Set Implementation Attributes.

 Set Filter as PROJECTCATEGORY = 7. 

  1. Set Implementation description and Implementation Id.  

For example,  

  • Description: GENERATEPROJECTID. 
  • Implementation ID: YY1_GENERATEPROJECTID.  

Click on the button “Review”. 

 Xiaolong_4-1706597159757.png

To create a New Implementation, click on the button “Create”. 

Xiaolong_5-1706597159759.png

Wait until BadI Implementation will be available and click on the button “Publish”. 

Xiaolong_6-1706597159760.png

Click on the button “Open Code Editor”. 

Xiaolong_7-1706597670819.png

Insert the Code below and click on the button “Save and Publish”. 

 

********************************************************************** 
*Generate Project ID with Specific Format: <Customer Name><Current Year><Next Sequence Number> 
********************************************************************** 

    CONSTANTS: 

     cn_startcustproj(5) TYPE n VALUE '00001',     "StartValue Counter CUSTOMER Projects 

     cs_cntmask(5)       TYPE c VALUE '_____'.     "Mask for select 

 

    DATA: ls_project      TYPE /s4ppm/ts_ent_proj, 

          lv_projectid    TYPE /cpd/mproj_id, 

          lv_sequence_num TYPE n LENGTH 5. 

 

    FIELD-SYMBOLS: <fs_number>  TYPE c. 

 

    MOVE-CORRESPONDING enterpriseproject TO changedenterpriseproject . 

    MOVE-CORRESPONDING enterpriseproject TO ls_project. 

 

    CHECK ls_project-customer IS NOT INITIAL AND ls_project-customer <> '0000000000' 

    AND   enterpriseproject-projectuuid IS INITIAL. 

 

    SELECT SINGLE customername 

    FROM i_customer 

    INTO @DATA(lv_customername) 

    WHERE customer = @ls_project-customer. 

 

    "Construct New Project ID Format 

 

    DATA(lv_curr_date) = cl_abap_context_info=>get_system_date( ). 

 

    changedenterpriseproject-project = lv_customername(6) && "Customer Name 

                                       lv_curr_date(4).      "Current Year 

 

* Select highest project ID created so far for this Numbering Scheme 

      ASSIGN changedenterpriseproject-project+10(5) TO <fs_number>."fs_number is the second part of the ID 

      <fs_number> = cs_cntmask. 

      DATA(lv_project_format) = changedenterpriseproject-project(10) && '%'. 

 

      CONDENSE lv_project_format NO-GAPS. 

      TRANSLATE lv_project_format TO UPPER CASE. 

 

      SELECT MAX( project ) 

      FROM i_enterpriseproject 

      INTO @lv_projectid 

      WHERE project LIKE @lv_project_format. 

      IF lv_projectid IS INITIAL. 

* Nothing found. Must be first such project. 

        <fs_number> = cn_startcustproj ."Second Part of ID 

      ELSE. 

* Get next number 

 

        changedenterpriseproject-project = lv_projectid. 

 

        lv_sequence_num = <fs_number> + cn_startcustproj. 

 

        <fs_number> = lv_sequence_num. 

 

     ENDIF. 

 

     CONDENSE changedenterpriseproject-project NO-GAPS. 

 

Xiaolong_8-1706597993857.png

Test: 

Now we are completely ready to test our new functionality that we have implemented. To do this, go to the Create Customer Projects application, create a Project, and save. 

 

Xiaolong_9-1706597993859.png

 

Xiaolong_10-1706597993861.pngAs you can see, Project ID contains: Short Name of the Customer + Current Year + sequence number. 

Xiaolong_11-1706597993862.png

How to debug Cloud BADI

As a programmer, it would be very convenient if debug is supported. With developer extensibility enabled, you are able to debug Cloud BADI 

Preconditions: 

ABAP Development Tools (ADT) is installed. 

Developer Extensibility is supported. 

In order to achieve this task, you need the following Roles or copied roles assigned to your business user.  

Business Role 

Business Role ID 

Application Support Engineer - Development Support 

SAP_BR_APPL_SUP_ENG_DEV_SUP 

Application Support Engineer 

SAP_BR_APPL_SUPPORT_ENGINEER 

Create ABAP Service Instance Connection in the ADT client to the SAP S/4HANA Cloud system we need

Open ADT-> Click on the select wizard (top left button under File tab) -> Choose ABAP Cloud Project and press “Next”. 

Xiaolong_0-1706615089559.png

Xiaolong_1-1706615089560.png

Choose SAP S4/HANA Cloud ABAP Environment -> Enter URL of your system and click “Next” -> Click on the button “Open Logon Page in Browser” -> Log In to the system under your Business User in the Web Page. 

Xiaolong_2-1706615089561.png

Xiaolong_3-1706615089561.png

Xiaolong_4-1706615089562.png

The result of it must be successfully logged on to the System. 

Xiaolong_5-1706615089562.png

To continue creating the ABAP Service Instance Connection, click on the button “Next” -> Click on the button “Finish”. 

Xiaolong_6-1706615089563.png

Xiaolong_7-1706615089564.png

Once all steps have been completed successfully. You should be able to log into your system using ADT. 

Xiaolong_8-1706615089564.png

Review your BADI implementation code and debug in ABAP development tool

ADT contains more advanced functionality for interaction with the SAP system. To find the new extension class YY1_GENERATEPROJECTID which was generated based on the new BadI Implementation we need to Open ABAP Development Object manually or use combination of the Cntrl+Shift+A. In this class you can see the code you wrote in Custom Logic.  

 

Xiaolong_9-1706615089565.png

Here you can set a breakpoint and debug the code. 

To set a breakpoint, you need to double-click on the blue area to the left of the line numbering. 

Xiaolong_0-1706615726270.png

Conclusion: 

In this blog, we looked at an example of how you can create an extension from scratch using Custom Logic for a Customer Projects, write code, access the code through ADT and test it.