Download files through web Dynpro
Hai All,
Now i am working in web Dynpro2.0.9. "IWDResource" property is used to download and upload files in web Dynpro. "IWDResource" is not supported by web Dynpro2.0.9.what is the alternative way for to download files other than using "IWDResource" property.If you have sample codings send it.
Thanks in Advance,
s.v.selva Bala.
Hallo Anilkumar,
read my tutorial on Uploading/Downloading Files in Web Dynpro NW04:
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d2201c20-0801-0010-49b3-94fca8f590d5">Uploading and Downloading Files (39)</a>
You are right, that the new on-demand-stream concept based on the IWDResource-API (Resource Simple Type) is not applicable in NW04.
Regards, Bertram
Similar Messages
-
Download Excel file through Web dynpro with no windows open?
Can we have a web dynpro application that just returns an Excel file in the response with no open windows? Similar to a java servlet that is used to download a Excel file?
This basically means that I cannot use wdComponentAPI.getWindowManager().createNonModalExternalWindow()
Java Servlet Code
HttpSession session = request.getSession(); // get a handle on the session id
response.setContentType("application/download");
response.setHeader("Content-Disposition", "filename=RTIS_Report.xls");
PrintWriter out = null;
out = response.getWriter();
String report = request.getParameter("REPORT");
JCO.Table lines = download(request, session, report);
for (int i = 0; i < lines.getNumRows(); i++) {
lines.setRow(i);
String content = lines.getString("LINES") + "\n";
out.write(content);
out.flush();
out.flush();
out.close();Hi,
I think you can use IWD Cached Web Resource to achieve this..
See the below code FYI..
public void downloadToExcel( )
String fileName = "Customer" + ".xls";
IWDCachedWebResource cachedExcelResource = null;
try
File f = new File("Customer.xls");
WritableWorkbook workbook = Workbook.createWorkbook(f);
WritableFont black = new WritableFont(WritableFont.createFont("Trebuchet MS"),WritableFont.DEFAULT_POINT_SIZE,WritableFont.BOLD,false,UnderlineStyle.SINGLE,Colour.BLACK);
WritableCellFormat blackFormat = new WritableCellFormat(black);
WritableFont blue = new WritableFont(WritableFont.createFont("Trebuchet MS"),WritableFont.DEFAULT_POINT_SIZE,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.BLUE);
WritableCellFormat blueFormat = new WritableCellFormat(blue);
WritableSheet sheet = workbook.createSheet("Customer", 0);
Label label;
String[] header={"Corporate Code","Batch ID"};
for (int i=0;i<2;i++)
label = new Label(i,0,header<i>.toString(),blackFormat);
sheet.addCell(label);
WritableCellFormat integerFormat = new WritableCellFormat(NumberFormats.INTEGER);
jxl.write.Number number;
// Reading the contents
for(int i=0;i<wdContext.nodeVn_DownloadToExcel().size();i++)
String strCorpName = wdContext.currentContextElement().getVa_CorpCode();
String strBatchID = wdContext.nodeVn_DownloadToExcel().getVn_DownloadToExcelElementAt(i).getVa_BatchID();
label = new Label(0,i+1,strCorpName,blueFormat);
sheet.addCell(label);
label = new Label(1,i+1,strBatchID,blueFormat);
sheet.addCell(label);
workbook.setColourRGB(Colour.LIME, 0xff, 0, 0);
workbook.write();
FileInputStream excelCSVFile = new FileInputStream(f);
IWDCachedWebResource cachedWebResource = null;
if (excelCSVFile!= null)
cachedWebResource = WDWebResource.getWebResource(excelCSVFile, WDWebResourceType.getWebResourceType("xls","application/ms-excel"));
cachedWebResource.setResourceName(fileName);
cachedExcelResource = cachedWebResource;
wdContext.currentContextElement().setVa_DownloadToExcel(cachedExcelResource.getURL());
workbook.close();
catch (Exception ex)
wdComponentAPI.getMessageManager().reportException("Error in Excel Download"+ex.getMessage(),false);
Regards,
Vijay -
Creating dynamic file through web Dynpro
Hai All,
Please tell information about my question.
HOW TO FETCH CLLIENT MACHINE ADDRESS IN WEB DYNPRO.
Best Regards,
S.V.Selva Bala.Hi Saravanan,
Go through Re: IP problem in UME this thread. It might help you.
Regards,
Satyajit.
Message was edited by: Satyajit Chakraborty
Message was edited by: Satyajit Chakraborty -
File DownLoad from R/3 to Local Disk through Web Dynpro
Hi,
I have a zebra print spool, to be saved in the local disk. For this, I have an RFC which will store the document in Portal Server KM folder and will give the file name for web dynpro app. The web dynpro app will search the KM Directory, and will enable the user to save the file on the local disk.
Is it right approach? Is there any other approaches which would be efficient. BTW, I have files from 4k to 12k size. Can I directly attach it to the context variable and store it directly onto the local disk.
I am running Netweaver2004 SP16. I cant use Input stream, does this affect the performance?.
Thanks, I appreciate your time.Hi Raj,
you have the name and the full path of the file you can access the file through FILE IO as the file is on portal server only and then you can use the File Download UI in web dynpro to download the file
Ninad -
Upload and Attach file to Service Notificacion through Web Dynpro
Hi,
I need to upload and attach a file (Word, PDF, TXT ...) to Service Notificacion (TX - IW53) through Web Dynpro.
I have used the integration component "File Upload" to obtain the "fileName" atribute. Also, I have used the functions SO_OBJECT_UPLOAD, SO_INSERT_OBJECT and BINARY_RELATION_CREATE_COMMIT.
But have a problem, because the function SO_OBJECT_UPLOAD use the class "cl _ gui _ frontend _ services" and that clash with Web Dynpro.
My question is: how could I resolve that problem?
I look forward to your response.
ThanksIV_NAME Importing Type STRING
IV_CONTENT Importing Type STRING
IV_CONTENT_HEX Importing Type XSTRING
IS_LPORB Importing Type SIBFLPORB
IV_OBJTP Importing Type SO_OBJ_TP
RT_MESSAGES Returning Type BAPIRETTAB
method save.
data ls_message type bapiret2.
data:
filename type string,
filefullname type string,
mime_type type string,
size type i,
offset type i,
offset_old type i,
temp_len type i,
objname type string,
l_obj_type type so_obj_tp,
hex_null type x length 1 value '20',
l_document_title type so_text255,
file_ext type string,
lt_objcont type standard table of solisti1 initial size 6,
objcont like line of lt_objcont,
lt_ls_doc_change type standard table of sodocchgi1,
ls_doc_change like line of lt_ls_doc_change,
lt_data type soli_tab,
ls_data type soli,
lt_xdata type solix_tab,
ls_xdata type solix,
l_folder_id type sofdk,
ls_object_id type soodk,
l_object_id_fol type so_obj_id,
l_object_id type so_obj_id,
l_doc_info TYPE sofolenti1,
l_object_hd_change type sood1,
l_tab_size type int4,
l_retype type breltyp-reltype,
lt_urltab type standard table of sood-objdes.
get foler
l_folder_id = 'FOL29000000000004'.
call function 'SO_FOLDER_ROOT_ID_GET'
exporting
owner = sy-uname
region = 'B'
importing
folder_id = l_folder_id
tables
path_table =
if iv_objtp = gc_type_file.
size = xstrlen( iv_content_hex ).
get file name and extension
call method split_path
exporting
iv_path = iv_name
importing
E_PATH =
ev_filename = filename
E_PSERVER =
call method split_file_extension
exporting
iv_filename_with_ext = filename
importing
ev_filename = objname
ev_extension = file_ext.
ls_doc_change-obj_name = objname.
ls_doc_change-obj_descr = objname.
ls_doc_change-obj_langu = sy-langu.
ls_doc_change-sensitivty = 'F'.
ls_doc_change-doc_size = size.
offset = 0.
while offset <= size.
offset_old = offset.
offset = offset + 255.
if offset > size.
temp_len = xstrlen( iv_content_hex+offset_old ).
clear ls_xdata-line with hex_null in byte mode.
ls_xdata-line = iv_content_hex+offset_old(temp_len).
else.
ls_xdata-line = iv_content_hex+offset_old(255).
endif.
append ls_xdata to lt_xdata.
endwhile.
set object type relation type and other header info
l_retype = 'ATTA'.
l_obj_type = 'EXT'.
l_object_hd_change-objnam = ls_doc_change-obj_name.
l_object_hd_change-objdes = ls_doc_change-obj_descr.
l_object_hd_change-objsns = ls_doc_change-sensitivty.
l_object_hd_change-objla = ls_doc_change-obj_langu.
l_object_hd_change-objlen = ls_doc_change-doc_size.
l_object_hd_change-file_ext = file_ext.
prepare header
data lt_obj_header type standard table of solisti1.
data ls_header type solisti1.
concatenate '&SO_FILENAME=' filename into ls_header.
append ls_header to lt_obj_header.
clear ls_header.
ls_header = '&SO_FORMAT=BIN'.
append ls_header to lt_obj_header.
change hex data to text data
call function 'SO_SOLIXTAB_TO_SOLITAB'
exporting
ip_solixtab = lt_xdata
importing
ep_solitab = lt_data.
else.
for note
size = strlen( iv_content ).
objname = iv_name.
ls_doc_change-obj_descr = objname.
ls_doc_change-sensitivty = 'O'.
ls_doc_change-obj_langu = sy-langu.
put content into table
offset = 0.
if iv_objtp = gc_type_note.
it's a note
l_retype = 'NOTE'.
l_obj_type = 'RAW'.
l_object_hd_change-file_ext = 'TXT'.
read note content into table
while offset <= size.
offset_old = offset.
offset = offset + 255.
if offset > size.
temp_len = strlen( iv_content+offset_old ).
clear ls_data-line.
ls_data-line = iv_content+offset_old(temp_len).
else.
ls_data-line = iv_content+offset_old(255).
endif.
append ls_data to lt_data.
endwhile.
get title from content , if it's initial
if objname is initial.
read table lt_data index 1 into l_document_title.
while l_document_title+49 <> ' '.
shift l_document_title right.
endwhile.
shift l_document_title left deleting leading ' '.
ls_doc_change-obj_descr = l_document_title.
endif.
else.
it's url (not note)
l_retype = 'URL'.
l_obj_type = 'URL'.
if objname is initial.
split iv_content at '/' into table lt_urltab.
describe table lt_urltab lines l_tab_size.
read table lt_urltab index l_tab_size into ls_doc_change-obj_descr.
endif.
while offset <= size.
offset_old = offset.
offset = offset + 250.
if offset > size.
temp_len = strlen( iv_content+offset_old ).
clear ls_data-line.
ls_data-line = iv_content+offset_old(temp_len).
else.
ls_data-line = iv_content+offset_old(250).
endif.
concatenate '&KEY&' ls_data-line into ls_data-line.
append ls_data to lt_data.
endwhile.
endif.
ls_doc_change-doc_size = size.
l_object_hd_change-objnam = ls_doc_change-obj_name.
l_object_hd_change-objdes = ls_doc_change-obj_descr.
l_object_hd_change-objsns = ls_doc_change-sensitivty.
l_object_hd_change-objla = ls_doc_change-obj_langu.
l_object_hd_change-objlen = ls_doc_change-doc_size.
endif.
save object
call function 'SO_OBJECT_INSERT'
exporting
folder_id = l_folder_id
OBJECT_FL_CHANGE = OBJECT_FL_CHANGE
object_hd_change = l_object_hd_change
object_type = l_obj_type
ORIGINATOR_ID = OWNER_ID
OWNER = USER-USRNAM
importing
OBJECT_FL_DISPLAY = OBJECT_FL_DISPLAY
OBJECT_HD_DISPLAY = OBJECT_HD_DISPLAY
object_id = ls_object_id "l_doc_info-object_id
tables
objcont = lt_data
objhead = lt_obj_header
OBJPARA = OBJECT_PARA
OBJPARB = OBJECT_PARB
exceptions
component_not_available = 01
folder_not_exist = 06
folder_no_authorization = 05
object_type_not_exist = 17
operation_no_authorization = 21
parameter_error = 23
others = 1000.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into ls_message-message.
ls_message-type = sy-msgty.
ls_message-id = sy-msgid.
ls_message-number = sy-msgno.
ls_message-message_v1 = sy-msgv1.
ls_message-message_v2 = sy-msgv2.
ls_message-message_v3 = sy-msgv3.
ls_message-message_v4 = sy-msgv4.
append ls_message to rt_messages.
return.
endif.
create relation
data l_obj_rolea type borident.
data l_obj_roleb type borident.
MOVE-CORRESPONDING wd_this->ms_lporb to l_obj_rolea.
l_obj_rolea-objkey = is_lporb-instid.
l_obj_rolea-objtype = is_lporb-typeid.
l_obj_rolea-logsys = is_lporb-catid.
l_object_id_fol = l_folder_id.
l_object_id = ls_object_id.
concatenate l_object_id_fol l_object_id into l_obj_roleb-objkey respecting blanks.
l_obj_roleb-objtype = 'MESSAGE'.
clear l_obj_roleb-logsys.
call function 'BINARY_RELATION_CREATE'
exporting
obj_rolea = l_obj_rolea
obj_roleb = l_obj_roleb
relationtype = l_retype
exceptions
others = 1.
if sy-subrc = 0.
commit work and wait.
wd_this->MV_UPDATE_FLAG = 'X'.
else.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into ls_message-message.
ls_message-type = sy-msgty.
ls_message-id = sy-msgid.
ls_message-number = sy-msgno.
ls_message-message_v1 = sy-msgv1.
ls_message-message_v2 = sy-msgv2.
ls_message-message_v3 = sy-msgv3.
ls_message-message_v4 = sy-msgv4.
append ls_message to rt_messages.
return.
endif.
endmethod.
Edited by: Reyleene Hunt on May 26, 2009 10:05 AM -
File Visibility in uploading the file using web DynPro java
hello,
i have gone through the tutorial " uploading & downloading the file using web DynPro java".
the upload functionalty is working fine. but i need to know thw path where these files are getting uploaded ??
Waiting for the reply..
Regards,
Viren GuptaHi Viren,
Are you are refering to the below tutorial for upload and download:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f?QuickLink=index&overridelayout=true
If yes, then answer is that the file is stored in the context of the application only as "com.sap.ide.webdynpro.uielement-definitions.Resource" object. Please read through the tutorial to understand the full process.
WD doesn't really upload to server automatically unless there is any explicit code written. All it does is to store the file in a temp context which you can access and write your own code to store it in a particular location.
Regards,
Mahesh -
Excel download feature in Web Dynpro Abap using OAOR document
Hi Friends,
I am facing an issue in implementing excel download feature in Web Dynpro.
Problem: I have stored an excel document in OAOR. I am displaying data on screen using ALV display in WDA.
I will provide a button to download excel in toolbar of ALV. When user clicks on this button i need to pick the document from OAOR and fill that with my screen values and download it to users desktop.
Please help me in this. Problem is when i am calling these classes c_oi_container_control_creator=>get_container_control and cl_gui_custom_container from my View's method they are returning error.
Thanks & Regards,
SaudHI,
You cannot use GUI classes and methods in web dynpro . That will dump.
Instead you can use file down load UI element or..
If you have the content in xstring format use ATTACH_FILE_TO_RESPONSE method of CL_WD_RUNTIME_SERVICES class.
Regards,
Madhu -
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 -
Upload and Reading Excel File in Web Dynpro
Hi all,
I have a requirement in my application( in 04s), where in, i need to upload an excel from a client through a web dynpro application(using fileupload UI) and read each and every the content of that excel file in web dynpro and process the data accordingly.
The format of the excel is fixed and pre-defined.
I went through a lot of blogs, but could not find a direct and exact solution to this requirement.
Please help me.
Looking forward to your contribution
Thank you,
Gita KC.Reading Excel Sheet from Java without using any Framework
Enhanced File Upload - Uploading and Processing Excel Sheets
Reading Multiple Sheets of Excel Sheet from Java
nikhil -
How do we scan for viruses of uploaded excel file in Web Dynpro for JAVA
Hi All,
Please let me know "How do we scan for viruses of uploaded excel file in Web Dynpro for JAVA"
Regards,
Ganga.Hi ,
pl go through this note "Integrating a virus scan into SAP applications 817623 "
SAP Virus Scan Interface
http://help.sap.com/saphelp_nw2004s/helpdata/en/30/42c13a38b44d5e8d1b140794e8e850/frameset.htm
Sample Application
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6e1c4221-0901-0010-63ba-b1f9459d6e74
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f2681486-0a01-0010-8497-c778eac80da5
Regards
Ayyappparaj -
CCMSETUP "failed to download files through BITS"
Hi
I'm strugling with my SCCM Clients.
We use:
ConfigMgr 2007 SP1. Client version 4.0.6221.1000. Mixed mode, one site. Server installed on Windows 2003 R2, database clustered. Client are Windows XP Pro with SP3. Site has been published in AD.
Push Client Deployment works fine.
First I tried to deploy the client with Group Policy. Stopped with "failed to download files through BITS"
Then I tried to deploy the client with a script, and finally manually. Got the same error message:"failed to download files through BITS".
End of log file looks like this:
Starting BITS download for client deployment files
Failed to download files through BITS
A Fallback Status Point has not been specified. Message with STATEID='309' will not be sent
Kind of stuck here. Please help!I solved the "BITS" problem. There was another web-application on the site-server that altered the permissions on the "Default Web Site". The CCM_CLIENT properties had "Script and Executables" selected for "Execute permissions". I Set this back to "None".
Now trying to deploy the client via GPO another error came: "Installation failed because another program is installing (1618)". This was during the wingapi.msi installation.
When a new Window XP Pro Computer is installed various applications are installed from GPO and also Office 2007 scripted. I guess this is a challenge for the ConfigManager Client Bootstrap installation.
So then I tried to deploy the client from startup script, setting the Policy "Maximum wait time for group policy script =0 (infinite)" and the policy "Run startup script asynchronously" = Disabled. This Works!!
The script will fire each time it boots until it is installed. The GPO installation will not retry to install. Therefore I think a script is a safer way to deploy the client.
I will test more on this.
Thanks for pointing me in the right direction!
-frode -
Hi,
I am getting an error while uploading an excel file in web Dynpro application. i am using the HR_KR_XSTRING_TO_STRING this function. I am getting the following error message 'Unable to interpret as a number'.First of all, are you sure you know what you are working with here. If this is standard Excel file in the Microsoft binary/propriatery format there is not function module or class in ABAP that can magically just transform this to a character string. You should search the forums as this has been discussed extensively. On that topic, please also do not post duplicate threads. I have already locked your other thread with the same basic question.
Instead of the binary/propriatery format of Excel, the file should be saved on the client as a text based format - like XML or Text Tab Delimited. You can then use several different options on the server to convert the XSTRING to STRING and process the content (becuase it was text based to begin with). You could use CL_BCS_CONVERT, the function modules in the function group SCMS_CONV, or the class CL_ABAP_CONV_IN_CE. -
How to call PDF file in Web Dynpro Appl?
How to call PDF file in Web Dynpro Appl?
Hi Gobinath,
1. Create a value attribute of type byte called pdfSource.
2. Insert an UI element called Interactive Form in your layout
3. Set the source property of this Interactive From UI element to the context pdfSource.
4. Insert a button which would open your pdf file.
public void onActionsubmit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionsubmit(ServerEvent)
IPrivate<viewname>.IContextElement contextElement = wdContext.currentContextElement();
byte[] bytes = contextElement.getPdfSource();
try
File file = new File("C:
temp
example.pdf");
FileOutputStream os = new FileOutputStream(file);
os.write(bytes);
os.close();
catch (IOException e)
// do something
e.printStackTrace();
//@@end
Warm Regards,
Murtuza -
Upload file in Web Dynpro and add to Workflow container as SOFM object
Hi!
I have a Web Dynpro for ABAP application that should send attachments of uploaded files to a workflow container. I have already managed to do this, and it works fine for TXT files, but when I try to attach a WORD (.DOC) file the file looks corrput when I open it from the SAP inbox.
When uploading files in Web Dynpro it is as an XSTRING. I have tried out the following alternatives regarding convertion of the XSTRING before it is inserted in the SOFM object:
1) Convert from XSTRING to STRING using codepage 4110.
Then it is split into a string table of 255 chars
2) Convert from XSTRING to STRING using codepage 4102
Then it is split into a string table of 255 chars
3) Convert from XSTRING to BINARY format
I use function module 'SWL_SOFM_CREATE_WITH_TABLE'
and then swf_create_object lr_sofm 'SOFM' ls_sofm_key.
before I call some macros to fill the container.
Anyone else who have tried to do this with success? I'm greatful for any help.
Regards, TineHi,
I had the same problem in the last days and finally I got a quite simple solution:
I had a look at the FM SWL_SOFM_CREATE_WITH_TABLE an noticed that it calls another FM (SO_DOCUMENT_INSERT_API1) which has a tables parameter for HEX data and is actually able to create a SOFM object from HEX data.
I simply copied SWL_SOFM_CREATE_WITH_TABLE as a customer FM and applied a few changes to make it accept HEX data:
First I added a new table parameter in the interface which gets the HEX data from the calling application (uploaded data using BIN format):
OBJECT_CONTENT_HEX LIKE SOLIX
Here is the code of the FM (I marked all additional and changed lines with a comment):
function z_test_sofm_create_with_table .
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(NOTE_TITLE) LIKE SODOCCHGI1-OBJ_DESCR OPTIONAL
*" VALUE(DOCUMENT_TYPE) LIKE SOODK-OBJTP DEFAULT SPACE
*" EXPORTING
*" VALUE(SOFM_KEY) LIKE SWOTOBJID-OBJKEY
*" TABLES
*" NOTE_TEXT STRUCTURE SOLISTI1 OPTIONAL
*" OBJECT_CONTENT_HEX STRUCTURE SOLIX OPTIONAL
*" EXCEPTIONS
*" ERROR_SOFM_CREATION
data: region like sofd-folrg.
data: folder_id like soodk.
data: l_folder_id like soobjinfi1-object_id.
data: document_data like sodocchgi1.
data: document_info like sofolenti1.
data: object_content like solisti1 occurs 0 with header line.
data: lines like sy-tabix.
*- set default
if document_type is initial.
document_type = 'RAW'.
endif.
*- create office object
*-- get dark folder
region = 'B'.
call function 'SO_FOLDER_ROOT_ID_GET'
exporting
region = region
importing
folder_id = folder_id
exceptions
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
others = 5.
if sy-subrc ne 0.
message e696(wl) "<== Add message class
raising error_sofm_creation.
endif.
*- get description
if note_title is initial.
read table note_text index 1.
note_title = note_text.
endif.
*-- create office document
document_data-obj_name = 'ATTACHMENT'.
document_data-obj_descr = note_title.
document_data-obj_langu = sy-langu.
object_content[] = note_text[].
describe table object_content lines lines.
document_data-doc_size = ( lines - 1 ) * 255 + strlen( object_content ).
if object_content[] is initial. "<== insert
describe table object_content_hex lines lines. "<== insert
document_data-doc_size = lines * 255. "<== insert
endif. "<== insert
l_folder_id = folder_id.
call function 'SO_DOCUMENT_INSERT_API1'
exporting
folder_id = l_folder_id
document_data = document_data
document_type = document_type
importing
document_info = document_info
tables
object_content = object_content
contents_hex = object_content_hex " <== Insert line
exceptions
folder_not_exist = 1
document_type_not_exist = 2
operation_no_authorization = 3
parameter_error = 4
x_error = 5
enqueue_error = 6
others = 7.
if sy-subrc ne 0.
message e696(wl) "<== Add message class
raising error_sofm_creation.
endif.
*- set export parameter
sofm_key = document_info-doc_id.
endfunction.
The returned SOFM key I added to a container element. The element refers to event parameter of type OBJ_RECORD in my ABAP OO Class
Using this function I was able to raise an event by using Method cl_swf_evt_event=>raise
that invoked a workitem containing an Excel-File i had uploaded as binary file and passed to the FM z_test_sofm_create_with_table as document type 'XLS'.
In the woritem preview when clicking on the attachment the file was opened directly in Excel.
Actually the new lines for calculation the file size is not yet quite correct. At first glance it does not seem to cause any trouble, but I will stll check that. In FM SO_OBJECT_INSERT the size is again checked and calculated if initial, so leaving size initial might also be an option.
I hope this helps anyone having a similar issue.
Greetings,
Michael Gulitz -
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?
Maybe you are looking for
-
How to use a transferfunction as a sub VI
Hello, Iam trying to make a pid controller.I succeed when I used a transferfunstion H(S) as the parameter to control.It is attached with the name controlsystemdesign.vi.But my aim is to use my own transfer function pidcontroltransfun.vi inst
-
there appears to be no communication between web pages and my printer. There is when using standard programs such as Microsoft Word or other installed programs. Is there a simple setting I've missed?
-
Unterstanding Integration Processes
Hello I got some problems understanding SERVICES. There are several Services: 1) service INTEGRATION PROCESS: - An integration process is an executable, cross-system process for processing messages 2) service BUSINESS SYSTEMS Business systems are log
-
4.7 Desktop SW Update does not let you choose what drive to install onto
I have my 4.7 Desktop SW installed on my D: Drive. Today I checked for updates and it came back & told me that there was an update available that came out yesterday 6/5/2009 consisting of 111 MB. I clicked on the update button and let it install. It
-
Acrobat 8 suddenly asks for serial number, won't launch
I have Acrobat Professional 8.1.3 as part of CS3 Design Premium, student license. Acrobat was not a separate disk. It was installed along with the rest of CS3 and always launched normally. Today, it requested the serial number and would not launch wi