Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

There are many documents and blog posts published in the forum explaining disabling of Create, Change and Delete buttons in the attachment list. Most of them have explained ways to disable these buttons considering them as a single entity. That is, we can either enable.disable all the buttons but not enable/disable selectively. This document is an attempt to explain a way in which the three buttons can be considered separetely and be enabled/disabled depending on a criteria. The document also includes the steps to be followed for disabling all three buttons considered together.

 

Step 1> Open the transaction for class builder (SE24) and provide the class name CL_GOS_SRV_ATTACHMENT_LIST in the object type input. The standard class has to be copied to a custom class for implementing required changes.

Copy the standard class to a custom Z class.

 

Step 2> Add Z class in the transaction SGOS for the service VIEW_ATTA (View attachment list)

 

Step 3> Open the method CHECK_STATUS of the Z class. The logic for disabling/enabling the buttons will be written in the method.

The above steps are common for any customization we can make for attachment list display. The process would change going further depending on the scenario (selectively disable or disable all buttons). We will consider the example of enable/disable according to the authorization for a user for both the scenarios.

 

Step 4.1> Disable Create, Edit and Delete buttons

The above code checks if the user has authorization for object OBJNAME. If the check fails, the buttons Create, Edit and Delete will be disabled. Value 'D' used as parameter value specifies that change is disabled for attachments. Value 'E' to be used for enabling change for attachments.

Below screen captures shows the appearance of the attachment list for users who don't have required authorization.

 

For users who have the required authorization, attachment list appears as shown below.

 

Step 4.2> Selectively disable Create, Edit and Delete buttons

Before going ahead with making the changes, we will try to understand how the three buttons are getting disabled when the value 'D' is passed to the method on_mode_changed. In the method value for global variable gp_mode is set to 'D' (value that is passed to the method). Further in the method CHECK_STATUS there is CREATE go_attachment_list which takes in value of variable gp_mode in the importing parameter ip_mode.

 

The reference variable go_attachment_list is of type CL_GOS_ATTACHMENT class. The class has method SET_TOOLBAR which is responsible for setting the toolbar of the attachment list. In this method, value of the variable gp_mode is used for disabling the buttons.

 

Value for local variable lp_disabled is set depending on value of gp_mode.

variable lp_disabled is used while creating New, Edit and Delete buttons. Since the same varaible is used for all the three variables, they will either be enabled/disabled.

 

If we want to change the behaviour code change is required in the method SET_TOOLBAR of the class CL_GOS_ATTACHMENTS. Being a standard object it is recommended not to make any changes. So, as the first step create a custom class that inherits the standard class CL_GOS_ATTACHMENTS.

 

 

In the class ZCL_GOS_ATTACHMENT_LIST the global variable go_attachment_list is defined as reference to the class CL_GOS_ATTACHMENTS.

 

Replace the associate type for go_attachment_list from CL_GOS_ATTACHMENTS to ZCL_GOS_ATTACHMENTS.

 

To ake any changes in the method SET_TOOLBAR method, it has to be redefined in the child class ZCL_GOS_ATTACHMENTS. Copy the implementation of the method from standard class CL_GOS_ATTACHMENT and then custom changes can be done. Below screen capture shows the logic written for Edit button.

 

Below picture shows a scenario where New and Delete buttons are enabled where as Edit button is disabled.

 

Note: The changes would be effective for all the documents in attachment list irrespective of document type or the transaction. Logic to handle specific document type/transaction will have to be written according to the requirement.

 

Regards,

~Athreya

  • No labels