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: 
ramakrishnappa
Active Contributor

Continues......

Pre-requisite: ( Please go through the below link before you continue )

Attach files to GOS with Save, Retrieve, Delete functionality in SAP Web Dynpro ABAP - Part 1

Step 18 :

For new attachments, we need to create a menu with options - Create Note & Create Attachment

Create a toolbar and add the toolbar ui element "ToolBarLinkChoice" as below

Step 19:

Add menu action item "ATTACH_NOTE" and create an action "CREATE_ATT" and bind it as below

Step 20:

Similarly, add another menu action item "ATTACH_FILES" and bind the action "CREATE_ATT" as below


Step 20A:

Write the below code in event handler method of ONACTIONCREATE_ATT

ONACTIONCREATE_ATT

METHOD onactioncreate_att .
  DATA lv_window_name TYPE string.
  DATA lo_view_ctrl   TYPE REF TO if_wd_view_controller.
  DATA lv_id         TYPE string.

  wdevent->get_data(
    EXPORTING
      name  = 'ID'
    IMPORTING
      value = lv_id
  ).


  CASE lv_id.
    WHEN 'ATTACH_NOTE'.
      lv_window_name = 'W_ATTACH_NOTES'.
    WHEN 'ATTACH_FILES'.
      lv_window_name = 'W_ATTACH_FILES'.
    WHEN OTHERS.
  ENDCASE.

  lo_view_ctrl ?= wd_this->wd_get_api( ).
  "perform create action
  "=============================================
  wd_comp_controller->do_on_create(
    EXPORTING
      id_window_name = lv_window_name
      io_view_ctrl   = lo_view_ctrl
  ).
ENDMETHOD.

View V_ATTACH_FILES

Create a new view V_ATTACH_FILES to view/change the attachment of files

Step 21:

Go to the context tab and map the context node "ATTACHMENT_CONTENTS" from component controller to the view context as shown below

Step 22:

Go to the layout of view and create an ui element "InputField"  for the attachment title / name as below

Step 23:

Create an ui element "FileUpload" and bind the context attributes as below

Step 24:

Create an ui element "FileDownload: and bind the context attributes as below

Step 24A:

Write the below logic to hide/show, the ui elements based on user action as below

WDDOMODIFYVIEW

METHOD wddomodifyview .
  DATA lo_tc TYPE REF TO cl_wd_transparent_container.

  CASE wd_comp_controller->gv_user_action.
    WHEN 1. "Create
      "hide Download file
      lo_tc ?= view->get_element( id = 'TC_BOTTOM' ).
      lo_tc->set_visible(
          value = cl_wd_transparent_container=>e_visible-none ).


    WHEN 3  OR 4. "Display or Delete


      lo_tc ?= view->get_element( id = 'TC_MIDDLE' ).
      lo_tc->set_visible(
          value = cl_wd_transparent_container=>e_visible-none ).

      "get transparent container
      lo_tc ?= view->get_element( id = 'TC_TOP' ).
      DATA lo_inp TYPE REF TO cl_wd_input_field.
      lo_inp ?= lo_tc->get_child( id = 'ATTACHMENT_NAME' ).
      lo_inp->set_read_only( value = abap_true ).
    WHEN OTHERS.
  ENDCASE.


ENDMETHOD.

View V_ATTACH_NOTES

Create a new view V_ATTACH_NOTES to view/change the attachment of files

Step 25:

Go to the context tab and map the context node "ATTACHMENT_CONTENTS" from component controller to the view context as shown below

Step 26:

Create an ui element "InputField" and bind the context attributes as below

Step 27:

Insert an TextEdit ui element and bind the properties to context attributes as below

Step 27A:

Write the below logic to hide/show, the ui elements based on user action as below

WDDOMODIFYVIEW

METHOD wddomodifyview .
  DATA lo_tc TYPE REF TO cl_wd_transparent_container.

  CASE wd_comp_controller->gv_user_action.


    WHEN 3  OR 4. "Display or Delete


      lo_tc ?= view->get_element( id = 'TC_TOP' ).

      DATA lo_inp TYPE REF TO cl_wd_input_field.
      lo_inp ?= lo_tc->get_child( id = 'NOTES_TITLE' ).
      lo_inp->set_read_only( value = abap_true ).


      "get transparent container
      lo_tc ?= view->get_element( id = 'TC_CONTENT' ).
      DATA lo_text_edit TYPE REF TO cl_wd_text_edit.
      lo_text_edit ?= lo_tc->get_child( id = 'NOTES_CONTENT' ).
      lo_text_edit->set_read_only( value = abap_true ).


    WHEN OTHERS.
  ENDCASE.
ENDMETHOD.

Step 28:

Create a new window W_ATTACH_FILES and embed the view V_ATTACH_FILES as below

Step 29:

Create a new window W_ATTACH_NOTES and embed the view V_ATTACH_NOTES as below

Now, save and activate the whole component YDEMO_ATTACH_FILES_GOS

Step 30:

Create an application as below

Now, test the application:

Output:

The initial out put screen looks as below

Now, enter a policy number "6000031601" and click on button "Get Attachment List", and list of attachments shown as below

Click on menu "New Attachments" to attach a note or a file

Choose the Create Note option from menu as below .

Now, a popup window opens up as below

Provide the title of notes & enter some contents into notes text box and click on OK button as below

The attachment of Note to GOS is successful and it can be seen as below

Similarly, we can create an attachment of files

Choose, CreateAttachment option from menu as below

A popup window appears for create an attachment of a file as below

Now, enter the attachment name and browse a file from your system and click on OK button as below

We can see the attachments created as below

We can also, display or change or delete the attachments

To Display an attached file:

Click on display button of a particular record as below

a popup window opens up and shows the available contents in Display mode

To Change an attached file:

Click on change button of a particular record & a popup window opens up and can change the attachment as below

To Delete an attached file:

Click on delete button of a particular record & a popup window for deletion of attachment opens up and click on OK button to complete the deletion

Similarly we can perform the display or change or delete actions on Notes as well

To Display an attached Notes:

Click on display button of a particular record as below

a popup window opens up and shows the available contents in Display mode

To Change an attached Notes:

Click on change button of a particular record & a popup window opens up and can change the notes as below

To Delete an attached Notes:

Click on delete button of a particular record & a popup window for deletion of Notes opens up and click on OK button to complete the deletion


Hope this helps for those looking for attaching files / notes to GOS .

Your comments / Feedback / suggestions are highly appreciable & always welcome

10 Comments
Labels in this area