Purpose:
Application for attaching files with save, retrieve & delete functionality in Webdynpro ABAP
Scenario:
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.
Pre-requisite:
Basic knowledge of Webdynpro ABAP,& OO ABAP
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
Note:
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
Step 1.
Go to transaction code SE11 and enter database table name YTR_ATTACH_FILES as below
Step 2:
Set the delivery & maintenance settings as below
Step 3:
Go to technical settings and maintain the entries as below
Step 4:
Create the fields in table as below
Create a Webdynpro ABAP component
Step1:
Go to transaction code SE80 and create the Webdynpro ABAP component as below with a view V_MAIN as below
Step 2:
Go to the view context of view V_MAIN and create a node INPUT by using table name YTR_ATTACH_FILES as below
Step3:
Create a node ATTACHMENT_LIST by using table name YTR_ATTACH_FILES as below
Step 4:
Create the layout by using context nodes INPUT & OUTPUT as below
Choose the editors for table columns as suggested below
Step 5:
Create a ui element FILE_UPLOAD and bind the properties as shown below
Step 6:
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)
ONACTIONATTACH |
---|
METHOD onactionattach . “========================================================== * get element via lead selection * get all declared attributes ” return if nothing to do “========================================================== lo_nd_attachment_list->get_static_attributes_table( “========================================================== 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. “========================================================== ENDMETHOD. |
——————————————–
Continued………..
Attach files with save, retrieve and delete functionality in Web Dynpro ABAP – Part 2
When we are binding property “Data” to FILE_DATA of Input node on Upload UI. We get error that “Property Data is not type Compatible with context element FILE_DATA”. The data type in table for this is RAWSTRING.Is that is the reason ?
Hi Vimal,
It should not given any error if its of type RAWSTRING / XSTRING.
Could you share the snap shot of error and your binding ?
Regards,
Rama
Following are the screenshots :
1)Error while binding
2)Table to from which attribute derived
3)Table in which field is declared as Rawstring.
Oh, there is an issue.
It works fine in NW 7.31. I think you are not meeting this system requirement.
Please change data type of your FILE_DATA to XSTRING in context node( don’t use table field reference ).
While saving data pass this data to your table field of type RAWSTRING.
Hope this resolves your issue.
Regards,
Rama
Hi Ramakrishna,
Thanks for the Post,It helped me to solve one of my major requirement.
If I want to view the file again in the same format(means preview) how can i achieve this?
Hi Rohith,
Good to hear that this document helped you.
In the table there is file download ui element ( i.e. file name as hyper link ) click on that, so that you would be able to open it its original format.
Regards,
Rama
Hi Ramakrishna,
Thanks for your replies so far.the issue had resolved.
I had a requirement to call a Custom Report in Webdynpro and show the output in Webdynpro by passing some values as input to the report(eg: vendor).
Can u please help me on this.
Thanks
nice document sir
Thank you 🙂
Hello Ramakrishna,
Can you please advise what is the type of element you used for TC_INPUT. I am trying with LayoutContainer and it is giving different ICON and also tried with other types which could not help me.
Thanking you in Anticipation