You may not realize it, but you have used the GOS toolbar on SAP's standard documents already. GOS or Generic Object Services is a suite of functionality that allows the end user to add / maintain attachments. It's the button that can be found just to the left of the application title. A personal note can be added to the document, as can attachments. It is even possible to have the system add an attachment document, when .e.g. the shopping cart was created for a web site through which the attachment was uploaded.
The GOS or Generic Object Services functionality is supported by quite a few classes, which are briefly explained here. Topic by topic, tackling day-to-day issues you may need to resolve:
Add an attachment to the GOS toolbar
Say you want to add an attachment to a certain shopping cart, because it contains items that needs a warning notice as is it dangerous. The company sells old-style gunpowder and we want to make sure a notice document is attached to the shopping cart automatically.
To set this functionality up for your own application, table
SGOSATTR plays an important role. This table contains the settings through which functionality is enabled. It controls which functions will be available and it even allows adding your own functionality - which should of course be destined for other applications too. In effect the settings on this table can be regarded as a linkage table linking GOS functions (codes and Icons are mentioned) to available functionality. This is the same for all GOS usage, thus alter something here to control the Shopping cart process and the Purchase order will also be altered.
Note that the naming convention
CL_GOS_ for classes yields 43 classes. Class
CL_GOS_SERVICE_TOOLS has methods
MOVE_LINKED_OBJECTS to delete, move or copy objects that were created through GOS.
SAP explains how this all works nicely on SDN: sap-generic-object-services-components-and-usage.
Add the GOS toolbar to your own application
The toolbar can be added to any application, including you own. A business object instance (read: Purchase order = the business object, nr 12345431 is the instance) is required to enable the toolbar. So if you use it with e.g. the business object of an employee (
BUS1065) and your application is about an actual employee, the GOS toolbar that is embedded in your application is shared with the one that may show on transaction
PA30. The attachment that is added in your application, is also visible in the SAP transaction code for "change employee" - and vice versa.
Would you like to try ? Just create a test report and run it:
REPORT Z_GOS_TESTER. data : go_gos_manager type ref to cl_gos_manager, gw_borident type borident. START-OF-SELECTION. gw_borident-objtype = 'BUS1065'. "- Employee (check SWO1) gw_borident-objkey = '00000001'. "- Employee 1 create object go_gos_manager exporting is_object = gw_borident ip_no_commit = ' ' exceptions object_invalid = 1. write: / 'Hello world - of GOS'.
You will find a new button in the report output screen, just left of the titlebar. It's GOS!
A GOS toolbar, specific to your report selection screen
The object in GOS is a very important matter, it identifies which purchase order or which employee the attachments are for. But what if you want to use GOS for a more general setup - e.g. an interface report. Is there a business object for reports with a key "report name" ? Yes there is. Check the example below:
REPORT Z_GOS_TESTER2. data : go_gos_manager type ref to cl_gos_manager, gw_borident type borident. parameter pa_par type c length 1. AT SELECTION-SCREEN OUTPUT. * Involve GOS on the selection screen of your report, * and make it specific to the report: gw_borident-objtype = 'REPORT'. "a valid business object ! gw_borident-objkey = sy-repid. create object go_gos_manager exporting is_object = gw_borident ip_no_commit = ' ' exceptions object_invalid = 1. START-OF-SELECTION. * The main output of the report write: / 'Hello world - of GOS'.
So now you can run an outbound interface and add the report that is produced at the recieving system to the interface report. Add the instruction document for the interface as a Word document attachment or update an actionlist in XLS and let the report selection screen hold on to it. The setup can be applied to multiple reports without changing code content.