Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
TusharShinde
Active Participant

This document will help you to add attachments to any Application Transaction and its associated Business Object which is configured to use GOS services for attachments, notes etc.

What is GOS?

GOS stands for Generic Object Services, available in various SAP Application Transactions, which helps to create personal or general note, attach files, trigger workflow, add URL etc. All these services are available by display of below icon in any standard SAP Transaction (You can even add it in your own Custom Applications as well).


On click of the Icon (or button), a toolbar is displayed as shown below.


Toolbar provides various facilities like, attaching documents, creating personal or general note, starting workflow etc.

Best explanation for

What is GOS? Where the documents attached in GOS are stored? Which tables are involved, when you attach any object to GOS for a particular Business Document?

All answers for above questions is available in SAP Notes ->


https://service.sap.com/sap/support/notes/530792


https://service.sap.com/sap/support/notes/927407


These notes explain very intricate details about GOS & and its technical aspects.

In SAP ESS – Travel Management Module, SAP had delivered a class CL_FITV_GOS, which was used within Travel Module for purpose of attachments to GOS. However, the class is nothing more specific to Travel Module, so I decided to copy the class into my own class, which will provide assistance to my Webdynpro for Uploading or Downloading files to & from GOS respectively.

In this blog, I have taken example of Application Transaction BP i.e. Business Partner, where we can create Business Partner & assign different Roles to it. The Business Object (BO) associated with this application transaction is BUS1006 (check transaction SWO1 to find Business Objects related to any application transactions).

Below is the screenshot of Class ZCL_GOS_SERVICES copied from standard class (CL_FITV_GOS) provided from SAP.


Method UPLOAD_DATA( ) helps in uploading file to GOS for a particular Business Partner. It takes below mentioned parameters as input.


methods UPLOAD_DATA


    importing


      value(FILE_DATA) type XSTRING


      value(OBJ_ID) type STRING "Business Partner Number


      value(FILE_NAME) type STRING


    returning


      value(RT_MESSAGES) type BAPIRETTAB .


Static Method GET_LINKS( ) gives the list of already attached Document ID for that Business Partner and


class-methods GET_LINKS


    importing


      !IS_LPORB type SIBFLPORB


    exporting


      !ET_ITEMS type ZWD_ATTA_TTY


      !ET_MESSAGES type BAPIRETTAB .


Static Method GET_CONTENT( ) is used to get the file data (XTSRING) for a particular Document ID.


  class-methods GET_CONTENT


    importing


      !IV_ATTA_ID type SO_ENTRYID


      !IV_OBJTP type SO_OBJ_TP


    exporting


      !EV_CONTENT type STRING


      !EV_CONTENT_HEX type XSTRING


      !ES_MESSAGE type BAPIRET2 .


SRGBTBREL – is a table where we can find the binary relationships between the GOS & Application Transaction is stored. Also there are many other tables as explained in above mentioned SAP notes.

Below is the Screenshot for Sample Web Dynpro Application, which demonstrates, how to attach files to GOS for a Business Partner (also check the video demo of Application at end of blog).

Below screen contains an Input Field, which accepts a Business Partner (BP) number, on enter displays details of Business Partner in form.

The Screen consists of 2- Buttons - Attach File & View Attachments. On click of Attach files, popup window is displayed, which provides option to select and upload a file for the mentioned BP.

After selecting file click on Start Upload button to upload file in GOS for specified Business Partner. Business Partner number will be the Key & the Object Type will be BUS1006, this entry will be visible in table SRGBTBREL which stores the relationship between attachments in GOS & Application Object.


Please check the screenshot which shows the entry maintained in table SRGBTBREL after uploading the file.

On click of View Attachment a Popup will display all list of Attachments as shown in below screenshot along with the recently attached document at last (highlighted in yellow for reference). Download link will provide the option to download & save file in a local system.

The following screenshots will display, technically all the developments done in Web Dynpro ABAP. Before going through the screen shots, just want to explain in short the components developed.

There are 2- Components

  1. ZWD_UIBB_BUPA – This component is front facing component which consist of Single View, which takes input a Business Partner number and displays the details of that Business Partner number. View consist of 2-buttons Attach File & View Attachments. On click of these buttons, a separate Pop-up window appears which actually come from another component, which is added in FPM configuration but visible only when the desired custom FPM Event is raised.
  2. ZWD_UIBB_ATTACH_GOS – This component is actually responsible for Attaching files to GOS or Displaying existing list of documents in a table. This component uses the Custom class ZCL_GOS_SERVICES created for assistance in Uploading or Downloading files to or from GOS respectively.

1. ZWD_UIBB_BUPA  - WD Component

Component Structure


This component is used to display details of Business Partner and provides buttons to Attach Files or View existing attachments.

View DISPLAY_VIEW


FPM based Web Dynpro Application


Application Configuration for FPM Application ZWD_A_UIBB_BUPA



OIF Component Configuration for FPM Application Configuration ZWD_AC_UIBB_BUPA


Adding Component ZWD_UIBB_BUPA as a UIBB


IDR Component Configuration for FPM Application Configuration ZWD_AC_UIBB_BUPANew Picture (4).png

After successfully executing above steps, Test the configuration.

2. ZWD_UIBB_ATTACH_GOS  - WD Component

Component Structure

Class ZCL_GOS_SERVICES is added in component attributes with attribute name MO_ASSIST.


2-Events are added in Component Controller, which are fired based on FPM event raised from Component-1 (i.e. ZWD_UIBB_BUPA). If Attach File button is clicked in Component-1, than SHOW_UPLOAD_SCREEN event is fired, which displays view V_UPLOAD_FILES of Component-2 (i.e. ZWD_UIBB_ATTACH_GOS) to upload a new file. If View Attachments button is clicked in Component-1, than SHOW_DOWNLOAD_SCREEN event is fired, which displays view V_ATTACH_LIST of Component-2 (i.e. ZWD_UIBB_ATTACH_GOS) to display existing attachments. For both events SHOW_UPLOAD_SCREEN & SHOW_DOWNLOAD_SCREEN, the Event Handler is added in V_BLANK View, which processes the event to display the desired View as Popup.


Methods in Component Controller               

In WDDOINIT( ) method INITIALIZATION( ) method is called.

INITIALIZATION( ) method in Component Controller

ATTACH_DOCUMENT( ) method in Component Controller


Here the custom class method UPLOAD_DATA( ) is called with necessary parameters to Upload the file for the Business Partner mentioned.

GET_ATTACTMENTS_LIST( ) method in Component Controller


Here the custom class methods GET_LINKS( ) & GET_CONTENT( ) is used to get List of attachments and also the File data of each attachment, so as to provide download functionality in Web Dynpro View.

PROCESS_EVENT( ) method in Component Controller – It is used to process events raised by any other UIBB’s in FPM instance.


METHOD process_event .

CONSTANTS lc_param_partner TYPE string VALUE 'PARTNER'.

DATA lo_wd_component TYPE REF TO if_wd_component.

DATA: lt_return TYPE TABLE OF bapiret2,
wa_return
LIKE LINE OF lt_return.

IF io_event->mv_event_id EQ 'ATTACH_POPUP'.

"Get Business Partner Number from Event Parameters
CALL METHOD io_event->mo_event_data->get_value
EXPORTING
iv_key  
= lc_param_partner
IMPORTING
ev_value
= wd_this->iv_obj_id. "Business Partner Number

IF wd_this->iv_obj_id IS NOT INITIAL.

DATA lo_nd_upload_data TYPE REF TO if_wd_context_node.
DATA lo_el_upload_data TYPE REF TO if_wd_context_element.
DATA ls_upload_data TYPE wd_this->element_upload_data.

*       navigate from <CONTEXT> to <UPLOAD_DATA> via lead selection
lo_nd_upload_data
= wd_context->get_child_node( name = wd_this->wdctx_upload_data ).

*       get element via lead selection
lo_el_upload_data
= lo_nd_upload_data->get_element( ).

*       @TODO fill static attributes
CLEAR : ls_upload_data.

*      reset all declared attributes
lo_el_upload_data
->set_static_attributes(
static_attributes
= ls_upload_data ).

"Fire SHOW_UPLOAD_SCREEN Event that will be handled by V_BLANK View
"to display Upload File Window W_UPLOAD_VIEW
wd_this
->fire_show_upload_screen_evt( ).

ENDIF.

ELSEIF io_event->mv_event_id EQ 'ATTACH_VIEW'.

"Display Attachment View to display list of Attachments
CALL METHOD io_event->mo_event_data->get_value
EXPORTING
iv_key  
= lc_param_partner
IMPORTING
ev_value
= wd_this->iv_obj_id. "Business Partner Number

IF wd_this->iv_obj_id IS NOT INITIAL.
"Get existing list of attachments for Business Partner
wd_this
->get_attachments_list( ).

"Fire SHOW_DOWNLOAD_SCREEN Event that will be handled by V_BLANK View
"to display Attachment List Window W_ATTACH_LIST_VIEW
wd_this
->fire_show_download_screen_evt( ).

ENDIF.

ENDIF.


ENDMETHOD.


View V_BLANK – No UI Element is added purposely in this view


Event Handlers in View V_BLANK – which are actually handling events raised by component controller so as to display the desired window as popup


View V_UPLOAD_FILES


Actions in V_UPLOAD_FILES View


START_UPLOAD action calls ATTACH_DOCUMENT( ) method of component controller


CANCEL_UPLOAD action closes the Popup Window.


Context of V_UPLOAD_FILES View


View V_ATTACH_LIST – Used to display existing list of attachments


Context of V_ATTACH_LIST View – the context structure is similar to the internal table the class returns but in addition a XSTRING attribute is added so as to get file content and store in it

Adding the Component in FPM OIF Config so as to enable communication between 2- Components (UIBB's)


Check the video demo to see how the sample application works.


References:-


Frequently asked questions about Generic Object Services (GOS)


https://service.sap.com/sap/support/notes/530792


https://service.sap.com/sap/support/notes/927407


To conclude, these article was prepared by me so as to enable attachments to GOS using Web Dynpro.


Caution -> This article is applicable only for folks trying to attach documents using GOS->Create -> Create Attachment option because the documents attached uses SAP Office config for storing documents, but for folks who are willing to attach documents thru GOS-> Create -> Store Business Document option, for this ArchiveLink specific FM/ Class can be used to attach and link document with SAP Business Transactions.


Best Regards

Tushar Shinde

9 Comments
Labels in this area