Currently Being Moderated

Attaching files to GOS via Web Dynpro ABAP

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).

New Picture (24).jpg

 

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

New Picture (25).jpg

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.

img2.JPG

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.

img3.JPG

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.

img4.JPG

img5.JPG

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.

img6.JPG


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

New Picture (26).jpg

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.

img7.JPG

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

New Picture (27).jpg

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

 

 

 

View DISPLAY_VIEW

New Picture (28).jpg

FPM based Web Dynpro Application

New Picture (29).jpg

Application Configuration for FPM Application ZWD_A_UIBB_BUPA

New Picture.jpg

New Picture (1).jpg

OIF Component Configuration for FPM Application Configuration ZWD_AC_UIBB_BUPA

New Picture (2).jpg

Adding Component ZWD_UIBB_BUPA as a UIBB

New Picture (3).jpg

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

New Picture (5).jpg

After successfully executing above steps, Test the configuration.

New Picture (6).jpg

New Picture (7).png

2. ZWD_UIBB_ATTACH_GOS  - WD Component

Component Structure

New Picture (9).png

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

New Picture (10).png

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.

New Picture (11).png

 

Methods in Component Controller               

New Picture (30).png

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

New Picture (20).png

INITIALIZATION( ) method in Component Controller

New Picture (21).png

ATTACH_DOCUMENT( ) method in Component Controller

New Picture (22).png

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

New Picture (23).png

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

New Picture (13).png

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

New Picture (14).png

View V_UPLOAD_FILES

New Picture (15).png

Actions in V_UPLOAD_FILES View

START_UPLOAD action calls ATTACH_DOCUMENT( ) method of component controller

CANCEL_UPLOAD action closes the Popup Window.

New Picture (16).png

Context of V_UPLOAD_FILES View

New Picture (17).png

View V_ATTACH_LIST – Used to display existing list of attachments

New Picture (18).png

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)

image001.png

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.


Best Regards

Tushar Shinde

Comments

Delete Document

Are you sure you want to delete this document?