Attach files to GOS with Save, Retrieve, Delete functionality in SAP Web Dynpro ABAP – Part 2
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 . wdevent->get_data( CASE lv_id. lo_view_ctrl ?= wd_this->wd_get_api( ). |
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 . CASE wd_comp_controller->gv_user_action. WHEN 3 OR 4. “Display or Delete lo_tc ?= view->get_element( id = ‘TC_MIDDLE’ ). “get transparent container 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 . 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. “get transparent container WHEN OTHERS. |
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
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
Hi Xavier,
Thanks for your feedback .. yup.. missed the implementation part of CREATE_ATT 😛
I have added the implementation of those methods.
Regards,
Rama
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
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
Hi Rama,
Good Efforts and thanks for sharing.
Regards,
Murali (B&B)
Thanks Murali....hmm.... B&B 🙂 .. Nice to see your comments here.. I appreciate your time.
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!!!!
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
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
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.