The reuqirement is this:
A user attaches doucments ( using the Generic Object Services to attach document ) while creating/changing Purchase Requisition (ME51N / ME52N).
Now when any user goes to see the docuemnts attached to the PR, he selects the 'Attachement List' from the context menu, he should only be able to read it and should not be allowed to change or delete the document. For this we need to disable the 'change' and 'delete' buttons from the toolbar.
Awaiting your response.......
Have a look at the following link from SAP Help - it seems you can use transaction SGOS for your needs or if you're feeling more adventurous BADI GOS_SRV_SELECT.
I have solved the issue Alhamdulillah by the foll. method:
1. Copied CL_GOS_SRV_ATTACHMENT_LIST to ZCL_GOS_SRV_ATTACHMENT_LIST
2. In ZCL_GOS_SRV_ATTACHMENT_LIST there is a method called: CHECK_STATUS. I overwrote with my check;
on_mode_changed( 'D' ). --- For display
on_mode_changed( 'E' ). --- For edit mode.
3. In SGOS tcode, added VIEW_ATTA to point to ZCL_GOS_SRV_ATTACHMENT_LIST
That solution I also found in note 491271.
I try to disable the "CREATE ATTACHMENT" Service... ..but end up with that both my method AND the SAP method CHECK_STATUS is executed....
I follow the instruction from SAP:
If you want to provide a service for certain authorizations only, check the SGOSATTR table to see which ABAP OO class implements the service. Create a new subclass, and overwrite the CHECK_STATUS method. Store a separate authorization check here. If this fails, set the service status to inactive. Then enter your new class in SGOSATTR.
I did this...
New subclass of CL_GOS_SRV_ATTACHMENT_CREATE >> ZCL_GOS_SRV_ATTACHMENT_CREATE.
In this Z-class I Redefined the CHECK_STATUS method with my coding.
I changed the table entry in table SGOSATTR to point at ZCL_GOS_SRV_ATTACHMENT_CREATE.
Then when I select an invoice via FB03 and press the Attachment List button...
I do dive into my CHECK_STATUS method
....BUT....AFTER my CHECK_STATUS was executed SAP also execute the standard CHECK_STATUS method belonging to CL_GOS_SRV_ATTACHMENT_CREATE (the class that I created a new subclass)
What did I do wrong??
Probably you have uncommented the call to super class when you reimplement the method on child class (z class)
I just implement the same thing now and it worked for me. Take a look:
1 - Modify the SGOSATTR table by SM30, just write a Z class (in my case CL_GOS_SRV_ATTACHMENT_CREATE) .
2 - Create/inheridt a subclass (not a copy) in SE24 of the standard class.
3 - Implement the method CHECK_STATUS in the z class. Note that the call to method on super class came commented. You only uncomment if you want to also execute a standard code in the super class.
Here is my code:
NOTE - In my real implementation I have uncommented the code below because I want do standard code be executed before my own check.
*CALL METHOD SUPER->CHECK_STATUS
IS_LPORB = IS_LPORB
IS_OBJECT = IS_OBJECT
EP_STATUS = EP_STATUS
EP_ICON = EP_ICON
Check for BUS2012 = Bussinnes Object for Purchase Order
IF IS_LPORB.TYPEID = BUS2012
Check authorization and disable create attachment item if the user does not have authority...
IF IS_LPORB-TYPEID = 'BUS2012'.
AUTHORITY-CHECK OBJECT 'Z_MM001' ID 'ACTVT' FIELD '01'.
IF sy-subrc <> 0.
ep_status = mp_status_inactive.
I have tried, it is working..
But it is possible to enable or disable the complete service.
My requirement is, the user should be able to open the attachment, he can view the document but shouln't change or delete it.
it means in 'VIEW_ATTA' service, DISPLAY should work and CHANGE , DELETE should be disabled.