FileUpload in Web dynpro
Hi
Iam creating an application in web dynpro.In that
Label Name -
FileName
UI Element -
FileUpload
I created One Node "FileUpload" under that "FileResource" one attribute, i had taken.I mapped that attribute to the "Resource" Element.
In the Java Dictionary i created Parameter.
Finally i Map that to the FileUpload Element under properities "Data" and "Resource".Like "FileUpload.FileResource".
I created SupplyFunction to the Node named as"Supply FileUpload"
While i was Writing the Code its giving errors.
Will any one please provide the Code for for File Upload.
Regards
Sushma
Hi Sushma,
Check out the beolw link:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f
Regards,
Suhash.
Similar Messages
-
Attach to Mail using FileUpload UI in Web dynpro Java
Hi,
I need to send a file from my system as attachment with a mail in a web dynpro java application.
I am trying to implement it by uploading the file to server using FileUpload UI and then sending the file as attachment
using java mail api which is not working at the moment.
Can anyone please suggest possible solution for this. Is there anyother approach to implement this?
-- ArnabI am using the following code to upload the file. Its not showing any error only the mail is sent without the attachment.
IPrivateFormView.IFileUploadElement element = wdContext.currentFileUploadElement();
InputStream text = null;
int temp=0;
try{
File file = new File(element.getFilename().getResourceName());
FileOutputStream out = new FileOutputStream(file);
if(element.getFilename()!= null){
text = element.getFilename().read(false);
while((temp = text.read()) != -1){
out.write(temp);
out.flush();
out.close();
String filePath = file.getAbsolutePath();
wdContext.currentContextElement().setAttachFileExtension(filePath);
msg.reportSuccess("File:" + filePath);
}catch(Exception e){
And the following code to attach the file to mail
MimeBodyPart bodyPart = null;
Multipart mp = new MimeMultipart();
try {
bodyPart = new MimeBodyPart();
bodyPart.setContent("Attached Mail","text/plain");
mp.addBodyPart(bodyPart);
//FileDataSource fds = new FileDataSource("http://dcwwdvsaprt02:50000/irj/go/km/docs");
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
//attachmentBodyPart.setDataHandler(new DataHandler(fds));
URL URLattachedFileName = new URL(wdContext.currentContextElement().getAttachFileExtension());
attachmentBodyPart.setDataHandler(new DataHandler(URLattachedFileName));
attachmentBodyPart.setFileName("Attachment");
mp.addBodyPart(attachmentBodyPart);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace(); -
Web Dynpro FileUpload: How to store an image in a MaxDB ?
Hi all,
does anybody knows a good way to store an uploaded image with Web Dynpro in a MaxDB.
My problem is, that the type java.sql.Blob is not Serializable. Further I find no way to import a Model Attribute of type byte[].
Regards,
SilviaHi, I have the same problem whith pfd-files.
Best regards
Oliver -
Unable to download file from FileDownload UI Element - Java Web Dynpro
Hello Experts,
I am facing a strange issue.Scenario is:
I created an java web Dynpro application (Please note that it is just a standalone WD app, not integrated in portal) with just one FileUpload UI Element ,one FileDownload UI element and one button (for triggering an action).
I browse a file (e.g. text,pdf,doc etc.) and click on button. It uploads the file and when I click on download, there are two cases:
1) Simply click on download does not downloads the file and shows error: "Unable to download <file name> from <server name>. Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later." Though it is opening the file,showing the content.
2) I opened that portal URL in a new tab in same session and logged in with a portal user. Now if I click on download link of same WD app opened in different tab of same session, it downloads the file without any error.
I am using portal 7.0
Can somebody point what's going wrong with case 1?
Helpful pointers will be appreciated.
Thanks,
KirtimanHi Sid,
I did not gave any authentication of WD app as it is anonymous app. There is no parameter set in application properties.
As I run the app, it is showing the initial screen with UI elemtns and till upload works fine,.It has to be an anonymous app, so cannot ask for credential from user.
Thanks
Kirtiman -
Import Data from Office Control (Web Dynpro for ABAP) into internal-Table
Hello,
I have a question concerning the Office Control UI-Eelement in Web Dynpro for ABAP:
How can I import spreadsheet data from the Office Control into a internal-table?
I have an Excel-sheet (without any data) which is shown initially in the Office Control. First the empty Excel-Sheet will be loaded and in the second step data from an alvxml-transformation will be loaded into the Excel-sheet with the method 'activatexmlsource'. This works so far. When I change the loaded data in the Office Control and save it it will be stored as XLS-File. The problem is that I'm not able to use existing Upload-FM because every function module I tried uses GUI-functions and WebDynpro has no GUI-functionality. I always get the error that data from clipboard cannot be imported.
So now the question is:
How can I import changed data from the Office control into a internal-table staying in Web Dynpro application?
Please give some advice, if you have some useful code or ideas.
Thanks
ram
Edited by: Ramakullay Challa on Sep 24, 2009 9:05 AM
Edited by: Ramakullay Challa on Sep 24, 2009 9:07 AMHi,
Once you save to desktop again you have made some changes to that file, this file you want to upload it right.
Then in that case you need to use the FILEUPLOAD UI element right.
Regards,
Lekha. -
Import data from excel/csv file in web dynpro
Hi All,
I need to populate a WD table by first importing a excel/CSV file thru web dynpro screen and then reading thru the file.Am using FileUpload element from NW04s.
How can I read/import data from excel / csv file in web dynpro table context?
Any help is appreciated.
Thanks a lot
AakashHi,
Here are the basic steps needed to read data from excel spreadsheet using the Java Excel API(jExcel API).
jExcel API can read a spreadsheet from a file stored on the local file system or from some input stream, ideally the following should be the steps while reading:
Create a workbook from a file on the local file system, as illustrated in the following code fragment:
import java.io.File;
import java.util.Date;
import jxl.*;
Workbook workbook = Workbook.getWorkbook(new File("test.xls"));
On getting access to the worksheet, once can use the following code piece to access individual sheets. These are zero indexed - the first sheet being 0, the second sheet being 1, and so on. (You can also use the API to retrieve a sheet by name).
Sheet sheet = workbook.getSheet(0);
After getting the sheet, you can retrieve the cell's contents as a string by using the convenience method getContents(). In the example code below, A1 is a text cell, B2 is numerical value and C2 is a date. The contents of these cells may be accessed as follows
Cell a1 = sheet.getCell(0,0);
Cell b2 = sheet.getCell(1,1);
Cell c2 = sheet.getCell(2,1);
String a1 = a1.getContents();
String b2 = b2.getContents();
String c2 = c2.getContents();
// perform operations on strings
However in case we need to access the cell's contents as the exact data type ie. as a numerical value or as a date, then the retrieved Cell must be cast to the correct type and the appropriate methods called. The code piece given below illustrates how JExcelApi may be used to retrieve a genuine java double and java.util.Date object from an Excel spreadsheet. For completeness the label is also cast to it's correct type. The code snippet also illustrates how to verify that cell is of the expected type - this can be useful when performing validations on the spreadsheet for presence of correct datatypes in the spreadsheet.
String a1 = null;
Double b2 = 0;
Date c2 = null;
Cell a1 = sheet.getCell(0,0);
Cell b2 = sheet.getCell(1,1);
Cell c2 = sheet.getCell(2,1);
if (a1.getType() == CellType.LABEL)
LabelCell lc = (LabelCell) a1;
stringa1 = lc.getString();
if (b2.getType() == CellType.NUMBER)
NumberCell nc = (NumberCell) b2;
numberb2 = nc.getValue();
if (c2.getType() == CellType.DATE)
DateCell dc = (DateCell) c2;
datec2 = dc.getDate();
// operate on dates and doubles
It is recommended to, use the close() method (as in the code piece below) when you are done with processing all the cells.This frees up any allocated memory used when reading spreadsheets and is particularly important when reading large spreadsheets.
// Finished - close the workbook and free up memory
workbook.close();
The API class files are availble in the 'jxl.jar', which is available for download.
Regards
Raghu -
HI:
Now come across a problem.
In Web Dynpro, there are several UI: inputfield and fileupload. when click submit, create an microsoft word with the content of inputfield and fileupload. then save in server.
My question is : how to create microsoft word in web dynpro.You need to use OfficeControl UI element.
check this link
http://help.sap.com/saphelp_dm40/helpdata/en/4c/9980415dc6050de10000000a1550b0/frameset.htm
Thanks
Bala Duvvuri -
Upload a .xls file in web dynpro abap
Hello,
I want to upload a .xls file into a internal table in web dynpro abap (Netweaver 7.31).
The file is not delimited, is not an csv file.
In my view I have an fileUpload UI Element with the attribute data is un attribute type XSTRING and the following function module are not in my system:
HR_KR_XSTRING_TO_STRING
ALSM_EXCEL_TO_INTERNAL_TABLE
How can I upload the file with this format?.
Thanks in advance.
XaviUnless the files are zipped together into one archive file, you have to do them one at a time. Furthermore with the normal browser based fileUpload UI element, you must do them one at a time and the user must manually select each one (browser security limitation).
If you are on 7.01 you can use ACFUpDown to perform multiple file uploads, but there is no file dialog or directory scan so file selection is difficult.
If you are on 7.02 you can use ACFUpdown and it has a multiple file open/save dialog.
If you are on 7.01 you could use FlashIslands to perform the multiple file upload. I have a tutorial and source code sample for this on SCN.
If you are on 7.01 you could also use ACFExecute to run a batch script on the client side that zips all the files and then upload the zip archive. -
Reading contents of uploaded excel file in web dynpro java
Hi All.
I am aware how to provide facility to upload files in web dynpro java. But my requirement is that on uploading a particular file (for eg. an excel file having 10 columns), I need to read the contents of that file and store it in a table in R/3.Can anyone suggest a way how I can read the contents of the uploaded file?
Thanks and Regards,
Saurabh.Hi.
I am having the following requirement : I have a FileUpload UI element where user clicks Browse button, selects a file from the local system and presses a Upload button. Upon pressing Upload, the name of the selected file and the contents of the file should be shown.
In the View context, I have two value attributes: FileName of type String and FileResource of type binary.
This is the code that I have in the Upload button action handler :
public void onActionUpload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionUpload(ServerEvent)
IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(
IPrivateReadExcelView.IContextElement.FILE_RESOURCE);
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)attributeInfo.
getModifiableSimpleType();
IPrivateReadExcelView.IContextElement element = wdContext.createContextElement();
String fname = binaryType.getFileName();
wdComponentAPI.getMessageManager().reportSuccess("File selected - "+fname); //Statement 1
try {
wdComponentAPI.getMessageManager().reportSuccess("Successful"); // Statement 2
InputStream in = new FileInputStream(fname);
HSSFWorkbook wb = new HSSFWorkbook(in);
wdComponentAPI.getMessageManager().reportSuccess("Successful"); //Statement 3
int sheetsNo = wb.getNumberOfSheets();
for (int i=0;i<sheetsNo;i++) {
HSSFSheet sheet = wb.getSheetAt(i);
Iterator rowsNo = sheet.rowIterator();
while(rowsNo.hasNext()) {
HSSFRow rows = (HSSFRow)rowsNo.next();
Iterator colsNo = rows.cellIterator();
while(colsNo.hasNext()) {
HSSFCell cell = (HSSFCell)colsNo.next();
wdComponentAPI.getMessageManager().reportSuccess("File uploaded" +
"successfully");
if(cell.getCellType()==1) {
wdComponentAPI.getMessageManager().reportSuccess("00000"+
cell.getStringCellValue());
else if(cell.getCellType()==0) {
String str=""+cell.getNumericCellValue();
wdComponentAPI.getMessageManager().reportSuccess("11111"+str);
catch(Exception e) { wdComponentAPI.getMessageManager().raisePendingException();
//@@end
On pressing Upload button, name of selected file is being shown(Statement 1). I am also getting Statement 2 in the output. However I am not getting Statement 3 onwards.
Where am I going wrong? Can anyone shed some light on this? -
File Upload in Web Dynpro ABAP not using File Upload UI element
Hi all ,
I have searching for a way to upload a file using the file open dialog ( or even by manually specifying the path/file name) without using the file upload UI Element in ABAP web Dynpro . The File Upload UI element works for smaller files however with large file sizes 64 MB , the system seems to be running of memory (SYSTEM_NO_ROLL) . This is due to a known fact that the UI element makes a duplicate copy of the whole copy while it does the upload.
I have been looking at the ACFUPDOWNLOAD as a way to solve this problem but cannot seem to figure out how it works , even the sample program provided by SAP does not work. I am working with a regular abap server and not kpro( knowledge mananagement provider) or portal .
Any help would be greatly appreciated.
thanks,
Ali.If you are on NetWeaver 7.01, you can try both the ACFUpDownload UI element or try creating your own FileUpload in Adobe Flex with Flash Islands. ACFUpDownload requires the KPRO by default (which is why the same application isn't working for you), but you can write your own handler class to act as the KPRO receiver. Here is an eLearning on the topic:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/109b9b52-bc00-2c10-8786-e4c5e96d7e04
and source code:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70645070-bb00-2c10-f086-f126721acdb4
If you want an eLearning on the FlashIslands approach, you can find it here as well:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50d42644-91ef-2b10-228c-9e0ae75b274e
and Source Code:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f044b62c-90ef-2b10-64a6-9ec25294d133
However in both of these approaches you still have to be careful with how you handle large files. The problem is that they are processed often a single binary string. This makes the processing easy, but requires total amount of session memory at least as large as the file being uploaded. In NetWeaver 7.02 ABAP adds the concept of Streams and Locators to help with the partial processing of large files. This feature doesn't come until later this year, but if you are interested you can learn about it here:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80f983df-213e-2c10-ba89-b5a12ef178e8 -
HI Masters , I need information for file upload program in web dynpro java
Hi masters,
i need some inforamtion and documentation on file upload program in web dynpro javaHi surya,
You can follow this procedure to upload the file
i) Take One Context Attribute named as "D1" of Type "binary".
ii) Take one FileUpload UI Element in the Layout Tab.
iii) Bind FileUpload UI Element's data Property to the taken Context Attribute. Here it is "D1".
iv) Take one Button UI Element in the Layout Tab named "Upload" and in the Action of that Button write the following Code.
v) The following code Generates one Folder in the Server & inside that Folder given file is Uploaded.
File ff=new File("FolderXYZ"); // Creates One Folder with the given Name ( Here Folder name is "FolderXYZ")
ff.mkdir();
try
byte b[]=null;
IWDAttributeInfo objAttinfo=null;
IWDModifiableBinaryType binType=null;
File f=null;
FileOutputStream fos=null;
if(wdContext.currentContextElement().getD1()!=null)
b=wdContext.currentContextElement().getD1();
objAttinfo=wdContext.getNodeInfo().getAttribute(IPrivateAttachView.IContextElement.D1);
binType=(IWDModifiableBinaryType)objAttinfo.getModifiableSimpleType();
f=new File(ff.getName()+"
"+binType.getFileName());
fos=new FileOutputStream(f);
fos.write(b);
fos.flush();
fos.close();
objMessageManager.reportSuccess("File uploaded to server");
} catch (Exception e)
objMessageManager.reportException("Unable to upload file to server, error is:"+e,false);
return;
The Uploaded file is stored in the folder & that folder is stored in the Server's following Path.
<Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0
You can access your Uploaded file from the following Path
<Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0\FolderXYZ
Regards
Sagar Ingalwar -
Replicate ME52N create attachment and attachment list in Web dynpro
Dear Experts,
Please can someone provide sample code and 'How to' steps to replicate ME52N create attachment and attachment list in Web dynpro?
I've looked at FILEUPLOAD and FILEDOWNLOAD in Web dynpro and this seems suitable for only 1 file attachment.
Many thanks, Jas.Hi ,
If your are having a UI like ME52N and you want an attachment feature in each row, I have below suggestions:
Suggestion 1: If you use ALV
Add a column in list of type Xstring or which ever suits your document specificatio
Add a Button on the ALV for attachment,
On click of the button you can Popup a browse window and user can select the file.
The content of the file can be stored as Xstring for that Line item.
Suggestion 2: IF you use Table UI element
Add an attreibute to context node of type Xstring
In the Table set, you can set FIleUpload as the editor for this column.
I hope it helps.
Regards,
Sumit -
Problems using ALSM_EXCEL_TO_INTERNAL_TABLE in Web Dynpro ABAP
Hello experts, im using the fm ALSM_EXCEL_TO_INTERNAL_TABLE.
When i call this fm from a web dynpro i have a dump that says that cannot import the clipboard.
Any ideas why this is happening?
(The parameter of the function are Ok, becouse if I call the function from SAP/R3 everything work fine)
ThankS!>
Mariano Gallicchio wrote:
> Thanks for the answer!
>
> I will continue searching for other fm!
I didn't mean to imply that there is a Function Module that should work from Web Dynpro. In fact I would be highly suprised if there was one. As already posted in this forum, the only way to get data from the client desktop is with the fileUpload UI element. No function module is going to be able to work with the Web Dynpro UI element. -
Interactive Forms by Adobe in Web Dynpro for ABAP: offline scenario
Hi colleagues,
I have the following problem:
So I created a web-Dynpro with an interactive from. In this application there are two scenarios:
- An Online scenario: it works!
- An Offline scenario: unfortunately doesnt work (The problem persists in this scenario).
As I understood correct, I should be able to upload the PDF-file from my documents. But the up-load option doesnt work.
Please see the steps I follow:
1. I created a FileUpload-application and then I browsed a PDF- File by using browse-button. And I got a standard open-window and I was able to choose a PDF-file, which I want to open.
2. I click on the button upload and it doesnt work. But the current page is only refreshed. In case it works, I should see the information I have uploaded onto my PDF-form.
I already discussed this issue with my colleague, but couldnt find the solution yet.
Does anybody have the idea, why the Upload option doesnt work?
Thank you in advance!
Kind Regards,
MohamedHi Mahamed,
I got your problem. You have not done anything wrong.
It is WebAS version which is not supported for this functionality.
But there is solution to this problem
Please refer to the SAP Note number - 1055738.
I think you will get the answer and the scenario described there will match your requirement.
This is a know issues with WebDypro ABAP but this works fine for Java Web Dynpro.
I have also tried for 2 months but finally came to know about it.
Regards
Satya -
Hi experts,
I have a requirement to upload the document of any type (jpg,doc,tff,ppt,pps,xls,pdf etc) to a Z table (may be in a binary format) in a web dynpro application.
I think this can be achieved through Fileupload view element.
In another window, I need to display the document based on what is selected in the table row. Which control or method can display any type of document? As far as I know, the office control view element can only display documents of type (.doc and .xls).
Please provide pointers on this or any example will help me.
Thanks,
AmitJainAbhimanyu,
Thanks for the reply. Wonderful it worked like a miracle.
Awarded full points.
Thanks
Code I used in the action: onactionclick
METHOD onactionclick .
DATA: content TYPE xstring.
DATA: lr_context_view_node TYPE REF TO if_wd_context_node.
wd_context->get_attribute(
EXPORTING
name = `PDF`
IMPORTING
value = content ).
CALL METHOD cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = 'Default_pdf.pdf'
i_content = content
i_mime_type = 'pdf'
i_in_new_window = ABAP_FALSE
i_inplace = ABAP_FALSE
ENDMETHOD.
Edited by: Amit Jain on Apr 2, 2009 5:46 PM
Maybe you are looking for
-
Static NAT inbound correct - Outbound using Interface IP
Here is the scenario that i have: I have a router (2921) that has 2 interfaces: G0/0 - WAN - 10.254.1.10 G0/1 - LAN - 192.168.1.230 I have a few static NATs for servers that are behind g0/1, this is the only nat config i have except for an
-
Where is the file that creates the mozilla firefox start page found?
I like the Firefox start page but want to tweak it a bit. Where can I gain access to the file? I am using Firefox 29.0.1 Thanks
-
Usb superdrive just ejects disks on retina yosemite
Would appreciate some advice and help PLEASE Just purchased a USB SUPERDRIVE to go into my Macbook 15" retina with Yosemite, it just clunks a few times and ejects the disk, the disk is an installation disk for the OED Version 3.1 CD ROM. Over 25 mile
-
Operation changes in production
Hello All, How to capture the operation changes in detail(operation number, time, old new values workcenter, standard text) for prodution orders.Is there any standard report. Example: user XYZ add an operation 85 in ProdOrd 1234567 We would like to
-
I've been working on this document saved in my Dropbox all day long. Could really really really use some recovery tips. I've tried placing it into another doc, opening it with with CS5, but all that I've been able to salvage is the minimal amount of