Attach files with save, retrieve and delete functionality in Web Dynpro ABAP – Part 1
Application for attaching files with save, retrieve & delete functionality in Webdynpro ABAP
I would like to explain the functionality of how to save,retrieve & delete files during attachments in Webdynpro ABAP application. It stores attached files in custom data base table.
Step by step Process
The process is divided as below
- Create a custom table YTR_ATTACH_FILES to store files
- Create a WDA component with save, retrieve & delete function
In this document, just for demo purpose the business logic of saving & retrieving data from data base table has written in WDA component.
Strictly the business logic should be separated from WDA component by using a model i.e. class, function module, etc.
(Refer MVC architecture in Architecture of Webdynpro for ABAP)
Create a transparent table YTR_ATTACH_FILES
Go to transaction code SE11 and enter database table name YTR_ATTACH_FILES as below
Set the delivery & maintenance settings as below
Go to technical settings and maintain the entries as below
Create the fields in table as below
Create a Webdynpro ABAP component
Go to transaction code SE80 and create the Webdynpro ABAP component as below with a view V_MAIN as below
Go to the view context of view V_MAIN and create a node INPUT by using table name YTR_ATTACH_FILES as below
Create a node ATTACHMENT_LIST by using table name YTR_ATTACH_FILES as below
Create the layout by using context nodes INPUT & OUTPUT as below
Choose the editors for table columns as suggested below
Create a ui element FILE_UPLOAD and bind the properties as shown below
Create a button BTN_ATTACH and attach an action ATTACH as below
Add the below code into event handler method ONACTIONATTACH (to attach a file into table)
METHOD onactionattach .
* get element via lead selection
* get all declared attributes
” return if nothing to do
ls_attachment_list-file_data = ls_input-file_data.
” get file name from path
ls_attachment_list-file_type = ls_input-file_type.
APPEND ls_attachment_list TO lt_attachment_list.