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

3_6.PNG

Step 19:

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

3_6_1.PNG

Step 20:

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

3_6_2.PNG

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

4_1.PNG

Step 22:

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

4_2.PNG

Step 23:

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

4_3.PNG

Step 24:

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

4_4.PNG

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

5.PNG

Step 26:

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

5_2.PNG

Step 27:

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

5_3.PNG

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

6.PNG

Step 29:

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

6_1.PNG

Now, save and activate the whole component YDEMO_ATTACH_FILES_GOS

Step 30:

Create an application as below

7.PNG

Now, test the application:

Output:

The initial out put screen looks as below

o1.PNG

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

o2.PNG

Click on menu “New Attachments” to attach a note or a file

Choose the Create Note option from menu as below .

/wp-content/uploads/2014/03/o3_408392.png

Now, a popup window opens up as below

o3_1.PNG

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

o3_2.PNG

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

o3_3.PNG

Similarly, we can create an attachment of files

Choose, CreateAttachment option from menu as below

/wp-content/uploads/2014/03/o7_408399.png

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

o7_1.PNG

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

o7_2.PNG

We can see the attachments created as below

o7_3.PNG

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

o8.PNG

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

o8_1.PNG

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

o8_2.PNG

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

o9_3.PNG

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

o9.PNG

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

o9_1.PNG

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

o9_2.PNG

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

o9_3.PNG

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

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

To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

  1. Xavier Thibert

    Hello

    Very interesting subject and well done tutorial, but can you add the implementation for actions methods CREATE_ATT and DO_ACTION.

    Those one are missing, so even if there is no error at runtime, test are not correct ..

    Cheers

    Xavier

    (0) 
      1. Xavier Thibert

        Hi Rama,

        Thanks for the methods.

        Finally it works !

        Thanks for sharing this point.

        Just two others information, in my current system I do not have /MSG/H_POL_ID, I used SIBFBORIID instead. Same for /MSG/HRISK, I used SIBFTYPEID.

        And in V_NAME view, I created a SAVE action and implement ONACTIONSAVE method with simply   wd_comp_controller->do_save( ). Otherwise there is a dump.

        And one more question, if I want to get the list of attach document for an FI document for example, do you know how to build the policy number ?

        Regards

        Xavier

        (0) 
        1. Ramakrishnappa Gangappa Post author

          Hi Xavier,

          Find the entries in table SRGBTBREL where the gos documents are saved and you can find out the keys and same can be used to get the instance of GOS for the business object.

          Also, SAVE action, logic added 🙂

          Regards,

          Rama

          (0) 
  2. loli elmoulaoui

    Hi Rama,

    thanks for the methods.

    in creation of : View V_ATTACH_FILES, i create an ui element “FileUpload” in property data i cant effect V_ATTACH_FILES.ATTACHMENT_CONTENTS.CONTENT_X

    just type V_ATTACH_FILES.ATTACHMENT_CONTENTS.CONTENT is compatible with this property.

    cant you help please!!!!

    (0) 
    1. Ramakrishnappa Gangappa Post author

      Hi Loli,

      I think your system is on lower version like NW7.0,

      The field CONTENT_X is of type RAWSTRING in structure GOS_S_ATTCONT and it is not supported in WD context by your system version.

      I suggest you to create a context attribute NEW_CONTENT_X of type XSTRING in context directly.

      So, you need to have extra attribute in context of type XSTRING and when you save contents, move the data of NEW_CONTENT_X to CONTENT_X of structure in DO_SAVE method ( Refer the  step 5A in PART 1 link )

      Hope this helps you.

      Regards,

      Rama

      (0) 
  3. Ross Goodman

    Hi,

       In my system I have none of the GOS structures or elements you use in the instructions. Also the API  CL_GOS_API does not exist .Why would this be the case and what do I do now?

    Cheers,

    Ross G

    (0) 
  4. Arjun gupta

    Hi

    I am trying to do the same, But i am getting the Error:

    500 SAP Internal Server Error

    ERROR: Could not find attribute ATTACHMENTS (termination: RABAX_STATE)

    please help me, I am new for WD.

    (0) 

Leave a Reply