Generic Object Services (GOS) Toolbar Part 2 : Handle added Service in the Toolbar

By | November 18, 2008 | Generic Object Services (GOS) | 32,043 | 41

Describes the way to handle the added service in the Generic Object service Toolbar

You can find all of these discussions at Tutorials > Generic Object Services (GOS).
Today we will see how to call our custom business logic in the added new Service in GOS Toolbar. To be able to process custom logic in the GOS toolbar service, we need to inherit out service class from the GOS generic service class CL_GOS_SERVICE and put our logic in the inherited class.

Steps to follow:
1. Inherit a class from the CL_GOS_SERVICE:

2. Maintain the Entry in the Table SGOSATTR as discussed in the Generic Object Services (GOS) Toolbar Part 1 : Add New Option in the Toolbar:

3. Redefine the Method EXECUTE to process our custom business logic. Redefine the Method and activate it. For demo purpose, we will not implement any logic in this but you can create a ALV or kind of list as we get in the Attachement List.

Now, when we access the GOS toolbar, you will see the option “Sales Order List”.

By accessing this option, you will get the empty screen like this:

You may have noticed that this Option is coming in all the GOS toolbars i.e. Toolbar in XD02 and XK02 and so on. To restrict the GOS toolbar service to only particular transaction, we need to redefine the method CHECK_STATUS.

Code snippet for the CHECK_STATUS method:

*&---------------------------------------------------------------------*
*& Redefinition of the Method CHECK_STATUS
*&---------------------------------------------------------------------*
METHOD CHECK_STATUS.
* Service active for customer   IF IS_LPORB-TYPEID = 'KNA1'.
    EP_STATUS MP_STATUS_ACTIVE.
  ELSE.
    EP_STATUS MP_STATUS_INVISIBLE.
  ENDIF.
*
ENDMETHOD.

Now, we will only get the service only in the XD02 and XD03 transactions.

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{272 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 272 articles.

Load comments

41 Comments

  • Anonymous

    Thanks Naimesh.
    This particular options useful while custom enhancements to standard transactions with GOS.

  • Kati Laszlo

    Dear Naimesh,

    I can see you are an expert of GOS, so I am wondering if you could please answer my questions: I wanted to create just a simple GOS test program using dialog programming. In the selection screen I select a functional location number, that is all.

    In the PBO init I create a container and later call CREATE OBJECT lo_gos_manager
    EXPORTING
    is_object = ls_object
    ip_no_commit = 'X'
    ip_mode = 'E'
    EXCEPTIONS
    object_invalid = 1
    callback_invalid = 2
    OTHERS = 3.

    And after this:
    CALL METHOD lo_gos_manager->start_service_direct
    EXPORTING
    ip_service = 'VIEW_ATTA'
    is_object = ls_object
    io_container = lo_container
    EXCEPTIONS
    no_object = 1
    object_invalid = 2
    execution_failed = 3
    OTHERS = 4.

    It displays the toolbas and everything fine, I select create new attachment from the menu, I get the message "Attachment was successfully created".

    What method should I call in the PAI to make the attachment stay? I just want to press Exit, return to selection screen so I can press F8 again and see my newly uploaded stuff there. I already tried

    COMMIT WORK AND WAIT.
    LEAVE TO SCREEN 1000.

    but it did not work either. Could you please help me? Kind regards,

    Kati

  • Hello Kati,

    When you call your Service using the method ‘start_service_direct’ your object must be there.

    For example, if you are working with the object for the Sales Order. You must pass the sales order number and the Sales order object to the method ‘start_service_direct’.

    I guess, when you run you don’t pass anything to the object. If you don’t pass any object in LS_OBJECT variable, system will not understand for which object it has to get back the attachement list.

    Regards,
    Naimesh Patel

  • Anonymous

    Hi Namesh,
    I was hoping you could answer a question for me. Why is the “Store business document” option greyed out on certain transactions but available on others. Thanks in advance.

  • "Store Business Document" option depends of the setting of the Archieve option for that perticular Business Object. Like for Sales Order, if you have properly configured the archieve settings than you will have Store business document option selectable.
    Check this thread: https://forums.sdn.sap.com/thread.jspa?threadID=1083975&tstart;=0

    Regards,
    Naimesh Patel

  • Hello Naimesh,
    Its very nice blog and I hope you will definitely help me:
    I have to create a custom pgm: for “Create Note” in the Services For Object for IW32 transaction. So can you please help me with the steps.

    Thanks in advance.
    Param.

  • Anonymous

    Naimesh,
    How do I have the “creator name” field populated on the “Attachment List”?

  • Anonymous

    Naimesh,

    It’s really a nice blog and very helpful for me. Thanks for such a great information.
    I wanted to know how can I allow my option under GOS toolbar to be available under different transactions like MM03, IE03, CC03 etc. and not under all transactions.
    In your example you used typeID to make your option available just under XD01, XD02, Xd03 and all these transaction uses same typeid ‘KNA1′. But in my case all transactions uses different typeid.
    Also, can I make use of CATID (BO) instead of typeid?.

    Thanks once again

  • Hello,

    “I wanted to know how can I allow my option under GOS toolbar to be available under different transactions like MM03, IE03, CC03 etc. and not under all transactions.
    In your example you used typeID to make your option available just under XD01, XD02, Xd03 and all these transaction uses same typeid ‘KNA1′. But in my case all transactions uses different typeid.
    Also, can I make use of CATID (BO) instead of typeid?.”

    You can put as many TYPEID’s in this condition.
    IF IS_LPORB-TYPEID = ‘KNA1′ ” Customer
    OR IS_LPORB-TYPEID = ‘BUS1001′. ” Material

    ENDIF.

    Regards,
    Naimesh Patel

  • Anonymous

    Hi Naimesh.
    I’m struggling… and saw your answers abow, I guess you know the answer to my ‘issue’ as well :-)

    I have a report with several sales documents and I need to find out if the sales order has any attachments. If there are attachments I ONLY want to add an icon in my report.
    ( -There will be another icon opening the attachmentlist, I have solved this by using function module GOS_EXECUTE_SERVICE -no problem)

    I’m trying to find the link between the Sales order number and the attached documents.
    Do you know which table / function module or method I can use to find out if there is attachments?

    kind regards
    ah

  • Hello,

    I’m trying to find the link between the Sales order number and the attached documents.
    Do you know which table / function module or method I can use to find out if there is attachments?

    Use method CL_BINARY_RELATION=>READ_LINKS to read the attachments.

    I will post the entire solution to the blog.

    Regards,
    Naimesh Patel

  • Anonymous

    Thanks for your reply Naimesh.

    Is there any way I can find out the TYPEID for a particular transaction?.
    I am very much new to ABAP and trying to learn as much as I can through forums and blogs.

    Thanks once again
    Karry

  • Hello,

    Is there any way I can find out the TYPEID for a particular transaction?.

    For GOS related TYPEID, you can set the break point in the CONSTRUCTOR method of the class CL_GOS_MANAGER and check the parameter IS_OBJECT for the TYPEID.

    Alternativly you can use SWO1 transaction code to find out the Business Object.

  • Anonymous

    Naimesh,

    setting a break point worked for me.
    Thanks a lot for such a valuable information.

    Regards,
    Karry

  • Anonymous

    Thanks Naimesh, CL_BINARY_RELATION=>READ_LINKS worked just fine :-)

    I also found a report (ztest_np_gos_note) that you had posted at SAP Community Network which was simple and helpful.

    Thanks again, regards ah

  • Anonymous

    We have added GOS service to a Z program and it is active(I can see: Create, Private Note, send, Workflow). But if I expand CREATE, create attachment, create note is INACTIVE.
    How can I make it active.

    Thanks in advance.

  • Anonymous

    In VA03 the option ‘Store business document’ is active but in ME23N the same option is in-active. How do I activate this option pleae.
    Thanks.
    Soyab

  • Anonymous

    Please ignore my earlier post.
    The question had already been asked.
    Soyab

  • Hi Naimesh,

    You have been posting wonderful and very useful information about GOS.
    I need help on the below.
    I would like to know the type of document attached wheather PDF, JPG, text file etc. how could i find out for the attachments!
    Ideally i could see these as an icons on the Attachment List window.
    Here my requirement is i need to create a report program which lists title of the attachement and
    type of the attachment.

  • What is the difference between "create attachment" and "store business document" in GOS on SAP?

  • Hello Nelus,

    You asked:
    What is the difference between "create attachment" and "store business document" in GOS?

    Create Attachment stores the data on the object where as the Store Business document will store the file on the object and Archive it.

    For Create Attachment
    http://help.sap.com/saphelp_nw04/helpdata/EN/87/a5ee07dd4511d289840000e8216438/content.htm

    For Store Business document
    http://help.sap.com/saphelp_nw04/helpdata/EN/87/a5edf8dd4511d289840000e8216438/content.htm

    Regards,
    Naimesh Patel

  • Hi Naimesh,

    thankyou for this very useful blog.

    Can you please tell me if it is possible to restrict the activation of GOS icon/button based on the user's authorization?
    Further explanation in the example below:
    Userid: User1
    Transaction: PA20 / PA30
    Authorization object in user's profile:P_ORGINCON
    Now if user is authorized to view a personnel number based on the levels defined in P_ORGINCON then GOS button should be activated. If user is not authorized to the personnel number, then it should not be activated.

    Apprecaite you guidance on this.

    Many thanks

    Zubair

  • Anonymous

    Hi,

    How can we hide the option of Delete in the GOS toolbar?

  • Hello,

    Anonymous wrote:
    "How can we hide the option of Delete in the GOS toolbar?"

    Check this discussion on the same subject.
    https://forums.sdn.sap.com/message.jspa?messageID=6747549

    Regards,
    Naimesh Patel

  • Anonymous

    Hellow Naimesh,
    I found that the Generic Object Service is not available for Batch master (transaction codes MSC1N, MSC2N, MSC3N). Is there anyway to activate Generic Object Service for batch master?

  • Anonymous

    Hello Naimesh:

    I was hoping you could help with respect to the start workflow option. I do not see my custom workflows as a choice on the start workflow. Do you know how I include them.

  • Anonymous

    Hi Namesh,

    Thank you for posting this blog, it has been very helpful. I am hoping you can help me figure out how to disable the delete icon from the Display attchments toolbar. I am using the GOS_SRV_SELECT BAdI for the services but cannot figure out how to disable any icon from the View attachements tool bar. I need to do it based on the status of the QN from which it is called, so user authorizations don't matter. I have checked the SDN and can't find a solution.

    Thanks,
    Nicole

  • Anonymous

    Hi Naimesh,

    You are mentioning that the GOS toolbar can be accessed in i.e. transaction XK01 or XD01.
    I thought the GOS services are not available in any create transaction (i.e. VA01, ME21N etc.).

    Could you please explain how I can make the GOS toolbar available in a create transaction like VA01.

    Kind Regards,
    Johan

  • Hello Johan,

    You are mentioning that the GOS toolbar can be accessed in i.e. transaction XK01 or XD01. I thought the GOS services are not available in any create transaction (i.e. VA01, ME21N etc.).

    Yes, you are right. We can't have the GOS toolbar available in the Create transaction as we don't have the suitable key generated for the business object.

    This SDN discussion talks about this: https://forums.sdn.sap.com/thread.jspa?threadID=1196617&tstart;=0

    Regards,
    Naimesh Patel

  • Hi Nimesh

    I am using one transaction. In that transaction when i call services for object, it says "no services available". I have object type /IRM/GMATX..how do i activate services for objects for the transaction..i found somewhere that i have to publish my object type but where and how i do that..

    Thanks
    Nehal

  • Hi Naimesh,

    Thank you for the wonderful blog. When I use the store business document option, I do not get the file name as the title and neither the creator name? Do you know if ti is possible to populate?

    Thanks
    Ganesh.S

  • Anonymous

    Hi!

    Could anybody help modifying the CHECK_STATUS in order to give access to this GOS to users with a certain ROLE?

    Thanks!

    PS: I do not know much about ABAP,…sorry…

  • Anonymous

    Hi Naimesh,
    how would we add the name, create time, and file name to the list of fields displayed on the attachment list? Would it be better to capture this information in a 'Z' table or to create and append for the TOA01-03 tables?

    Thanks – excellent blog.

  • Anonymous

    Hi Naimesh

    I do not have experience in GOS at all and I need to when going to transaction CV04n, create a attachment from my local PC and then build in code to delete the file of my local PC after attaching it. How do I do this?
    Thanks

  • Anonymous

    Hi Naimesh, Nice blog. In my scenario i want to make several options visible for create/change transactions for attachment(like create/delete attachment) whereas in display transactions some options should be invisible.

  • Hi Naimesh,

    I have one issue.
    How would you display the office 2007 file attached as a attachment in GOS and stored on the external file server(IXOS).if the user who want to open the file has office 2002 installed on his workstation?

  • Anonymous

    Hi Naimesh,

    I was going through the blogs to find an answer to my query but in vain. I have a task to add attachments to tcode CL03. The scenario is that i need to take a dump of all the attachments for classes from 1 system and i need to upload the same in another system for the relevant class.In most of the blogs i checked it was a specific case like fb03 or xd03 where a unique entry exist, but in this case i am really clueless.This is a new topic to me and was hoping if you could help me with this.

    Thanks in advance for your help

  • Sami from KSA

    Hi there,
    this old thing for you but still I think you are a head of us in years for us in this .
    I need to disable/control the delete icon/function at the attachment list alv ?

    can this be done . Thanks.

  • mohan

    A user exists in quality and sandbox systems with the same profiles, However, when I try to execute Tcode IW22 and enter notifications, A screen appears where I can view Services for Object Icon. When I click in the Create Attachment in the Services for Object in the Quality system, A dialog box appears to upload the documents from my desktop. However the same does not happen in my sandbox system…dialogbox not appeaing

    Kindly help me,

  • NEWBABY

    How can I check to make sure that the service object has data( note for example)?

  • NEWBABY

    I meant “attachments “

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.