cancel
Showing results for 
Search instead for 
Did you mean: 

file upload and view in web dynpro abap

Former Member
0 Kudos

Hi experts,

I m developing an application in web dynpro abap. There is one tab for attachments. When i attached the attachments and press upload button, immediately it should be appear in the below table(filename, file type, file size, file content). And when i click on file content link file should be open. How can i achieve this? What is the data element for file content.. why because i need to save it in a z-table...

thanks in advance   ramana

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ramana,

Create context node as follow

CONTEXT

|

|-----FILE_UPLOAD

|      |----NAME

|      |----CONTENT - XSTRING

|      |----TYPE

|----FILE_LIST

       |---NAME

       |---CONTENT -XSTRING

       |---TYPE

FILE_UPLOAD's cardinality should be 1. And bind the corresponding attributes of FILE_UPLOAD to FileUploadUIElement's properties.

FILE_LIST cardinality should be 0 to n. Now create a table with data binding to FILE_LIST node and show two fields, NAME and TYPE.

NAME filed should be FileDownload UI Element. Now bind the CONTENT of FILE_LIST to data property of the FileDownload UI Element.

Have a button named upload.

In upload button write code, for adding the data from FILE_UPLOAD to the internal table of FILE_LIST.

RAWSTRING is the data type to store file in the database.

Hope this helps you.

Regards,

Fareez

Former Member
0 Kudos

Hi Fareez,

Thanks for ur reply,

I m doing the same what u specified....  but not  getting..

When i created table with 4 fields.. file content type rawstring.. it is saying that need to create domain.. is dat not predefined?...

after clicking file upload button i m getting dump...

because of select query..

here is my code....

DATA LS_FILE_UPLOAD TYPE ZITER_MED_FILES.

   DATA LT_FILE_DOWNLOAD TYPE TABLE OF ZITER_MED_FILES.

   DATA LO_ND_UPLOAD TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LO_EL_UPLOAD TYPE REF TO IF_WD_CONTEXT_ELEMENT.

   DATA LS_UPLOAD TYPE WD_THIS->ELEMENT_UPLOAD.

   DATA LO_ND_DOWNLOAD TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LT_DOWNLOAD TYPE WD_THIS->ELEMENTS_DOWNLOAD.

   LO_ND_UPLOAD = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_UPLOAD ).

   LO_EL_UPLOAD = LO_ND_UPLOAD->GET_ELEMENT( ).

   LO_ND_DOWNLOAD = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_DOWNLOAD ).

   LO_EL_UPLOAD->GET_STATIC_ATTRIBUTES(

     IMPORTING

       STATIC_ATTRIBUTES = LS_UPLOAD ).

   LS_UPLOAD-FILE_SIZE = XSTRLEN( LS_UPLOAD-FILE_CONTENT ).

   LS_FILE_UPLOAD-FILE_NAME     = LS_UPLOAD-FILE_NAME.

   LS_FILE_UPLOAD-FILE_TYPE     = LS_UPLOAD-FILE_TYPE.

   LS_FILE_UPLOAD-FILE_SIZE     = LS_UPLOAD-FILE_SIZE.

   LS_FILE_UPLOAD-FILE_CONTENT  = LS_UPLOAD-FILE_CONTENT.

   INSERT ZITER_MED_FILES FROM LS_FILE_UPLOAD.

   IF SY-SUBRC EQ 0.

     SELECT FILE_NAME

         FILE_TYPE

         FILE_SIZE

         FILE_CONTENT

         FROM ZITER_MED_FILES

         INTO TABLE LT_DOWNLOAD.

     LO_ND_DOWNLOAD->BIND_TABLE( NEW_ITEMS = LT_DOWNLOAD SET_INITIAL_ELEMENTS = ABAP_TRUE ).

   ELSE.

   ENDIF.

and the document which i followed is .......

http://wiki.sdn.sap.com/wiki/display/WDABAP/Upload+and+Download+files+in+Webdynpro+ABAP

regards

ramana

Former Member
0 Kudos

Hi Ramana,

  Kindly refer this link which has given detailed explanation about the file upload and viewing the same using a table UI element.

    http://an-sap-consultant.blogspot.co.uk/2012/03/web-dynpro-abap-file-upload-excel.html

Regards,

Navith

Former Member
0 Kudos

Hi Ramana,

Create a domain with data type as RAWSTRING and then try. Probably that should be the reason for the error in Select query. From your message, it seems that insert query worked alright. Go to se16 and check whether data is uploaded successfully to database.

You did not show what datatypes you have used for your context nodes. Check whether it is compatible with the datatypes of the database.

Regards,

Fareez

Former Member
0 Kudos

Thank u fareez,

Its working...

Former Member
0 Kudos

Hi fareezz,

the same application i have a table(not alv---jst normal table), with input field columns...

so in out put i m entering data in the 1st row of the table... and pressing enter..

when i going to enter data in 2nd row , it remains noneditable.... i need to enter 10-20 records. but i m unable to do it because of this.. can u suggest me how to make this editable after filling the previous row data?

thanks and regards

ramana

Former Member
0 Kudos

Hi Ramana,

This is because, each row in a table is enabled only if it is having corresponding data bound in the internal table bound to the context node. Now create an internal table of 30 records with empty string and bind it with the table. You would be able to enter then.

Otherwise on the OnEnter of the input field write code to add one more empty record to the context node using bind_element. This will make the next row editable.

Hope this will help you

An obligation. Hereafter when you have a different question start a new thread. This will help everyone to have look on that and you will also get a variety of answers.

Thanks & Regards ,

Fareez

Answers (0)