Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
          View Sundeep Sethi's profile on LinkedIn    

We undertook a project to migrate the ESS solution implemented in Web Dynpro Java to Business Package for Web Dynpro ABAP (1.5).

I have shared my experience in working on Travel & Expense Implementation in the below blogs:

Demystifying FPM for Travel & Expense (FITV_FPM)

Demystifying POWL and Feeder Class in Travel Management

In this blog I would share my project learning's on Adding custom field in Record Working Time and Applying dynamic filtering to links appearing in Launchpad.

1) Adding custom field in Record Working Time application:

The Record Working Time application can be found in the package "PAOC_CATS_ESS_WDA".

Web Dynpro Component "HRESS_C_CATS" and Web Dynpro Application "HRESS_A_CATS_1".

Challenge was to introduce a new column "Task Short Text" (Data Element LTXA1) in the Record Working Time application ALV table.

First approach would be to utilize the fields "DISPTEXT1" or "DISPTEXT1" in structure "CATSFIELDS".SAP recommends in order to introduce custom fields on the Record Working Time Web Dynpro ABAP screen or CAT2 transaction we should make use of these two fields. By maintaining proper mapping in this structure your custom field can be displayed and it can be populated by using User-Exit "CATS0009-CATS: Customer-Specific Text Fields in Data Entry Section". You can read the documentation of this exit in transaction SMOD.

However the main challenge arises if we have to introduce a third custom field. In my project we have already used the fields "CATSFIELDS-DISPTEXT1" and "CATSFIELDS-DISPTEXT2" to display Engagement Name and Client Name. Now we wanted to introduce a new column which would display Task Description.

I wondered why should SAP restrict the customers to allow populating only two custom fields using the user exit "CATS0009". That is a million dollar question which only SAP can answer.

Anyhow in order to add a third custom field follow the steps below:

i- Add your custom field to the structure "CI_CATSDB". The fields can only be of TYPE CHAR or NUMC. Let's say we maintained ZZTASK_DSC in the structure "CI_CATSDB"

ii.- Next go to txn SPRO and navigate to Create Customer fields and then select "Make field Assignment" in the pop up

iii.-SAP allows to add upto 10 custom fields using this approach. Select field No. 1 and the corresponding CI_CATSDB field here

iv.- Go Back and select option "Add customer fields to field selection" => "Data Entry Section" and set field "Additional field 1 i.e. CATS_ADDFI-FIELD1" to DISPLAY.

v.-As a result the Task Short Text Column will be visible on the Record Working Time WD application.

vi.-Now the tricky part, how to populate data in this column. If the requirement was to populate this field only in CAT2 transaction we could have done this using EXIT "CATS0002". But in order to populate this field on WD ABAP screen we have to implement an Enhancement to the WD ABAP component "HRESS_C_CATS". In my scenario I implemented a Overwrite Exit to the Method "BUILD_TSDATA" in the Component Controller. Append the following code after pasting the SAP code in the Overwrite Exit-


**prior to this line paste the SAP code of BUILD_TSDATA method****


******Custom Code Starts here******


DATA lv_vornr TYPE VORNR.


DATA lv_engm TYPE AUFNR.


DATA lv_task_desc TYPE LTXA1.


DATA lt_f_et_return TYPE bapirettab.


FIELD-SYMBOLS <ls_f_et_return> LIKE LINE OF lt_f_et_return.


DATA lt_f_et_value_list_npact TYPE ptrv_web_activity_npact_t.


FIELD-SYMBOLS <ls_f_et_value_list_npact> LIKE LINE OF lt_f_et_value_list_npact.


FIELD-SYMBOLS <lv_desc> TYPE any.


LOOP AT <dyn_table> ASSIGNING <dyn_wa>.


ASSIGN COMPONENT 'VORNR' OF STRUCTURE <dyn_wa> TO <dyn_fs>.


lv_vornr = <dyn_fs>.


ASSIGN COMPONENT 'RAUFNR' OF STRUCTURE <dyn_wa> TO <dyn_fs>.


lv_engm = <dyn_fs>.




IF lv_engm IS NOT INITIAL AND lv_vornr IS NOT INITIAL.


    CALL FUNCTION 'PTRM_WEB_ACTIVITY_NPACT'


     EXPORTING


       I_ORDERID                 = lv_engm


       I_ACTIVITY                = lv_vornr


*      I_DESCRIPTION             =


*      I_MAXROW                  = 150


     IMPORTING


       et_value_list_npact =             lt_f_et_value_list_npact


        et_return =                       lt_f_et_return


              .


    LOOP AT lt_f_et_value_list_npact[] ASSIGNING <ls_f_et_value_list_npact>.


     ASSIGN COMPONENT 'DESCRIPTION' OF STRUCTURE <ls_f_et_value_list_npact> TO <lv_desc>.


     lv_task_desc = <lv_desc>.




   ENDLOOP.


   ASSIGN COMPONENT 'ZZTASK_DSC' OF STRUCTURE <dyn_wa> TO <dyn_fs>.


   <dyn_fs> = lv_task_desc.


   MODIFY <dyn_table>  FROM <dyn_wa> .


ENDIF.


   ENDLOOP.










Crux of the Code: In this method the FIELD-SYMBOLS <dyn_table>, has the run time data which is displayed in the Working Time ALV table. We fetch the Task Description using FM " PTRM_WEB_ACTIVITY_NPACT" and set its value in the <dyn_table> structure for the custom column ZZTASK_DSC which we have added in step iii above.

2) Applying dynamic filtering to links appearing in Launchpad

Earlier in the Home Page Framework links were filtered by using Proxy Classes which were specified at the Service Level in SPRO Configuration.

With the Launchpad the dynamic filtering is done by setting up Alias in the Launchpad Application and then putting the filtering logic for this alias in the HRESS_MENU BADI.


I will try to explain the scenario by using example of Travel and Expense. In the home page framework the links for Travel and Expense were controlled through the Proxy Class "CL_TRAVEL_AREAPAGE". This class in turn called a standard FM " PTRM_WEB_TRIPS_WELCOME_SCREEN" which determined based on authorization of the logged in user, which links would be visible for the user.


The implementation "PTRM_NEW_HRESS_MENU" of BADI "HRESS_MENU" takes care of filtering the Travel Plan links and does not apply filter on the links Create Travel Request, Create Expense Report etc. We had to apply custom filter on these links and other custom links based on authorization the user had.


To implement this in the Launchpad follow the steps below:

i- Create a custom implementation of BADI "HRESS_MENU" say "Z_PTRM_NEW_HRESS_MENU" in transaction SE19.

ii.-Provide the Alias of the applications as Filter Values for this Badi Implementation e.g. if in Launchpad you have maintained alias "CreateExpenseReport" for the Create Expense link, provide that as a filter value.



iii.Create implementation class say "ZCL_PTRM_NEW_HRESS_MENU" for this BADI implementation and ensure that the class implements the interfaces "IF_EX_HRESS_MENU" and "IF_BADI_INTERFACE" . In the method "IF_EX_HRESS_MENU~MODIFY_APPLICATION_ATTRIBUTES" write your custom code which will call the standard FM "PTRM_WEB_TRIPS_WELCOME_SCREEN" and hide or show the Create Request or Expense links.


METHOD if_ex_hress_menu~modify_application_attributes.


   DATA: lv_trvof              TYPE office_find,


         ls_nwbc_context       TYPE cl_nwbc=>t_context,


         lv_client_environment TYPE i.



   DATA: l_employeenumber TYPE bapiempl-pernr,


         lt_www_links_ext TYPE ptrv_web_links_ext_t,


         lt_return        TYPE bapirettab.



   CLEAR lt_return.        REFRESH lt_return.


   CLEAR lt_www_links_ext. REFRESH lt_www_links_ext.




   DATA lv_pernr TYPE pernr_d.


   DATA i_name TYPE emnam.


   DATA lv_ccc_active TYPE xfeld.


   DATA lv_ccc_number_receipts TYPE i.


   DATA lv_request_active TYPE xfeld.


   DATA lv_plan_active TYPE xfeld.


   DATA lv_expense_active TYPE xfeld.


   DATA lv_own_trips_only TYPE xfeld VALUE 'X'.



* Get employee number



   DATA: lr_emp_service TYPE REF TO cl_hress_employee_services.


   TRY.


       lr_emp_service = cl_hress_employee_services=>get_instance( ).


       lv_pernr = lr_emp_service->get_pernr( ).


     CATCH cx_hress.


       "DO NOTHING


   ENDTRY.



   CALL FUNCTION 'PTRM_WEB_TRIPS_WELCOME_SCREEN'


     EXPORTING


       i_employeenumber      = lv_pernr


     IMPORTING


       e_ccc_active          = lv_ccc_active


       e_ccc_number_receipts = lv_ccc_number_receipts


       e_request_active      = lv_request_active


       e_plan_active         = lv_plan_active


       e_expense_active      = lv_expense_active


       e_own_trips_only      = lv_own_trips_only


       e_name                = i_name


     TABLES


       et_www_links_ext      = lt_www_links_ext


       et_return             = lt_return.


   CASE iv_application_alias.


     WHEN 'CallTravelRequest'.


       IF lv_request_active = 'X'.


         cv_isvisible = abap_true.


       ELSE.


         cv_isvisible = abap_false.


       ENDIF.




     WHEN 'CallExpenseReport'.



       IF lv_expense_active = 'X'.


         cv_isvisible = abap_true.


       ELSE.


         cv_isvisible = abap_false.


       ENDIF.



     WHEN 'CallTravelPlan'.



       IF lv_plan_active = 'X'.


         cv_isvisible = abap_true.


       ELSE.


         cv_isvisible = abap_false.


       ENDIF.



     WHEN 'FindRouting'.


       cv_isvisible = abap_false.



     WHEN 'MaintainProfile'.


       cv_isvisible = abap_false.



     WHEN 'CallAssistantPOWL'.


       cv_isvisible = abap_false.



     WHEN 'CallExpressExpenses'.


       cv_isvisible = abap_false.



   ENDCASE.


ENDMETHOD.










In a similar way you can control visibility of any of the links in launchpad by maintaining its Alias in lpd_cust transaction, and including that alias as a filter value in a custom implementation of the BADI HRESS_MENU and making sure you handle the case of that alias in your custom code in the implementing class of the BADI implementation.

1 Comment
Labels in this area