1. Introduction
Enhancements are the means by which we add our own/ modify existing functionality to SAP's standard business applications.
Screen Enhancement means enhancing the Standard SAP Screen with the custom defined fields according to the customer Requirements.
In Audit Management, the BADI used for enhancing the standard screen with the custom defined fields is BADI_PLM_COR_CUSTOM_FIELDS.
Methods Implemented: SET_SCREEN_DATA
2. Steps to find the Business Add-Ins in Audit Management
There are two ways to find the Business Add-Ins
We can find the BADI by keeping the breakpoint inside the method CL_EXITHANDLER -> GET_INSTANCE and execute the transaction PLMD_AUDIT.
Alternate Method:
Go to Transaction Code: PLMC_AUDIT
Expand the Tree Structure “System Adjustment” in which all the Business Add-Ins will be shown.
We can see the functionality of the BADI by Clicking the button .
3. Methods to create Corrective Action.
Transaction Code for Audit: PLMD_AUDIT
3.1 Creating an Audit
Go to Create --> Audit.
3.2 Creating a Question List
The Audit should be assigned to the Question List. Go to Audit--> Right click-->Create -->Audit Question.
Hierarchy Profile should be filled with values.
4. Creating a Corrective Action
Two ways of Creating a Corrective Action.
a) Creating from Questions List
b) Creating directly from node
4.1 Creating Corrective Action from Question List
We can create the Corrective Action from the Question List page.
We have two options in the View Selection
a) Details
b) Valuation
Click on the Valuation Button, we have an option of creating the Corrective Action.
4.2 Creating Corrective Action directly from node
After Creating the Question List, We can right click on the Question list and create a Corrective Action from here.
5. Process Overview
Corrective Action will have the Screen as shown below.
When the user creates a Corrective Action in the Transaction PLMD_AUDIT, the Additional Fields highlighted below should be added to the BASIC DATA Tab.
When the user creates a Corrective Action in the Transaction PLMD_AUDIT, the Additional Text Types highlighted below should be added to the TEXTS Tab.
6. Additional Fields in BASIC DATA TAB
Create a Module Pool Program and design a screen with all the additional fields.
Create a BADI Implementation for Enhancement Spot BADI_PLM_COR_CUSTOM_FIELDS
We can see two nodes created under our Implementation.
Ø Implementing Class
Ø Screen Enhancements
Implementing Class
Inside implementing class we can have all the methods of the class in which coding can be done.
We have to pass the data from module pool to the methods of class. While passing the data from Module Pool Program to the BADI Implementation, the values disappeared. The reason behind that is there is no data visibility between the screen and the Methods of the class. So, we created two function modules for importing and exporting the data. While creating a Corrective Action, a unique key will be created. A custom table is created with the unique key for saving all the values of the Corrective Actions. The values of the Additional fields are moved to the global variables of the function Group.
Screen Enhancements
Under Screen Enhancements our module pool program name and the Subscreen number should be assigned to the standard program.
Pseudo code
While creating a Corrective Action, a unique key will be created. A Custom table is created for saving all the values of the Corrective Actions. From Module pool program the values of the Additional fields are moved to the global variables of the function Group. Then we can export the data from Global variables based on the unique key.
SELECT SINGLE yycorno FROM yplm_refnumber INTO w_cor WHERE yycorno = plmt_audit_act_ui-external_id.
IF sy-subrc NE 0.
MOVE plmt_audit_act_ui-external_id TO w_cor-yycorno.
INSERT INTO yplm_refnumber VALUES w_cor.
ENDIF.
IF plmt_audit_act_ui-yytype IS NOT INITIAL.
w_flag = wc_x.
CALL FUNCTION 'Y_PLM_FIELDS_SET'
EXPORTING
i_corno = plmt_audit_act_ui-external_id
i_type = plmt_audit_act_ui-yytype
i_desc = plmt_audit_act_ui-yydescription
i_category = plmt_audit_act_ui-yycategory
i_catdesc = plmt_audit_act_ui-yycat_desc
i_error = plmt_audit_act_ui-yyerrorcode
i_ecode = plmt_audit_act_ui-yyecode
i_err_desc = plmt_audit_act_ui-yyerr_desc
i_cause = plmt_audit_act_ui-yycausecode
i_ccode = plmt_audit_act_ui-yyccode
i_cau_desc = plmt_audit_act_ui-yycau_desc
i_reftype = plmt_audit_act_ui-yyref_type
i_refdesc = plmt_audit_act_ui-yyref_desc
i_refnumber = plmt_audit_act_ui-yyref_number
i_flag = w_flag.
ENDIF.
Inside the method SET_SCREEN_DATA of the BADI Implementation we export the global variables from the module pool program.
Pseudo code
METHOD if_ex_plm_cor_custom_fields~set_screen_data.
CALL FUNCTION 'Y_PLM_FIELDS_GET'
EXPORTING
i_corno = is_plmt_audit_act_ui-external_id
IMPORTING
e_type = is_plmt_audit_act_ui-yytype
e_desc = is_plmt_audit_act_ui-yydescription
e_category = is_plmt_audit_act_ui-yycategory
e_catdesc = is_plmt_audit_act_ui-yycat_desc
e_error = is_plmt_audit_act_ui-yyerrorcode
e_ecode = is_plmt_audit_act_ui-yyecode
e_err_desc = is_plmt_audit_act_ui-yyerr_desc
e_cause = is_plmt_audit_act_ui-yycausecode
e_ccode = is_plmt_audit_act_ui-yyccode
e_cau_desc = is_plmt_audit_act_ui-yycau_desc
e_reftype = is_plmt_audit_act_ui-yyref_type
e_refdesc = is_plmt_audit_act_ui-yyref_desc
e_refnumber = is_plmt_audit_act_ui-yyref_number.
MOVE is_plmt_audit_act_ui TO w_plmt_audit_act_ui.
ENDMETHOD.
OUTCOME:
Additional Fields are added to the BASIC DATA Tab.
7. Additional Fields in TEXTS TAB
When the user creates a Corrective Action in the Transaction PLMD_AUDIT, the Additional Text Types should be added to the TEXTS Tab.
Additional Text Types:
CAUSE:
Whenever a Corrective Action is created, the user has to mention the cause for creating it, which makes the End User to understand the reason for Creating the Corrective Action.
PLAN:
Whenever a Corrective Action is created, the user has to mention the plan for correcting it ,so that End User understands that some planning activities has been done for correcting it.
Create a BADI Implementation for PLM_AUDIT_TEXT_ID
We can have the implementing class to incorporate our code.
Method CHECK_TDID is used to display the Text ID’s in the TEXTS Tab.Passing the newly added text types in the method CHECK_TDID.
Pseudo code
Corrective Action: ‘COR’.
WHEN ’COR’.
MOVE ‘CAUSE’ TO ls_tdid-tdid.
CALL METHOD check_tdid
EXPORTING
i_tdid = ls_tdid-tdid
RECEIVING
r_tdid_ok = l_tdid_ok.
IF l_tdid_ok = co_true.
MOVE ‘X’ TO ls_tdid-changeable.
APPEND ls_tdid TO et_tdid.
ENDIF.
MOVE ‘PLAN’ TO ls_tdid-tdid.
CALL METHOD check_tdid
EXPORTING
i_tdid = ls_tdid-tdid
RECEIVING
r_tdid_ok = l_tdid_ok.
IF l_tdid_ok = co_true.
MOVE ‘X’ TO ls_tdid-changeable.
APPEND ls_tdid TO et_tdid.
ENDIF.
OUTCOME:
Additional Text Types ‘CAUSE’ and ‘PLAN’ are added to the TEXTS Tab.
8. Challenges
· When the data is passed from the module pool program to the BADI Implementation there is no data visibility. So, a function group assigned with two function modules is created and the data is stored in a global variable in the function group.