Using .properties file in web dynpro
Hi,
I am having a requirement. I have to create a .properties file and I have to use it in my web dynpro application. How can I do that? Any help...
Thanks & Regards,
Raj
Hi,
Go to the navigator view...select src\Components\<ComponentName> and create create a .properties file.
You can read the configuration file in your webdynpro app as follows
IWDConfiguration configuration =
WDConfiguration.getConfigurationByName(
wdComponentAPI.getDeployableObjectPart(),
"<<>>");
http://help.sap.com/saphelp_nw04/helpdata/en/b8/aa343e32ff1033e10000000a114084/frameset.htm
Regards, Anilkumar
Message was edited by:
Anilkumar Vippagunta
Similar Messages
-
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 do I read a properties file in WEB-INF without hard-coding a path?
Hello,
How do I read a properties file in WEB-INF without hard-coding a path?
I tried:
Properties properties = new Properties();
properties.load(new FileInputStream("db.properties"));
driver = properties.getProperty("driver");
but it cannot find the db.properties file.
Thanks for the help.
FrankDon't use a File to read those properties.
Better to use the servlet context and
getResourceAsStream() method to get the InputStream.
It'll look for any file in the CLASSPATH. If you put
that properties file in the WEB-INF/classes directory
you'll have no problems, even if you deploy with a
WAR file.Completely agree with this approach. Just have to mention the following for completeness
according to the API,
"This method is different from java.lang.Class.getResourceAsStream, which uses a class loader. This method allows servlet containers to make a resource available to a servlet from any location, without using a class loader. "
So using this method, the resource can be anywhere under your web context, not just in the classpath.
Cheers,
evnafets -
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 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 -
Hi,
I want to use properties file in my application. I have kept properties file inside a directory called properties which is inside myProject(which is the parent directory of my project) i.e "myProject/properties".
My java file where i want to call this properties file is inside the myProject/WEB-INF/src/java.
How can i call the properties file from myProject/WEB-INF/src/java/PropertyReader.java
I wrote java program in myProject/WEB-INF/src/java/PropertyReader.java like:::::
ResourceBundle resBun = ResourceBundle.getBundle("Test", Locale.getDefault()); // Test.properties is inside myProject/properties
resBun..getString("name");
After running the program i am getting the following errors:::::
Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name Test, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
at PropertiesReader.main(PropertiesReader.java:4)
What is the issue? How to use properties file?
Waiting for reply.
ThanksStill getting same exception. As you explained i tried like the below:::
1. I am using ant as build tool.
2. My properties file is for database configuration
My properties file is::
database.properties (inside myProject/properties)
JDBCDriver=org.gjt.mm.mysql.Driver
JDBCConnectionURL=jdbc:mysql://pmdbmysql:3306/bandwidthshaper?user=admin&password=admin
My java package structure is
WEB-INF/src/java
WEB-INF/src/classes
For build WEB-INF is the base directory and build.xml is inside the src directory
In my build.xml i wrote the following lines for compilation::
<target name="compile" >
<javac srcdir="src" destdir="src/classes" debug="true" debuglevel="lines,vars,source">
<classpath refid="class.path"/>
</javac>
<copy todir = "src/classes" >
<fileset dir = "../properties" />
</copy>
<jar jarfile="lib/${project.jar.file}" basedir="src/classes"/>
</target>
I am copying properties file to the classes directory.
Now in java file which is inside /WEB-INF/src/java, I wrote::
try {
Properties programProps = new Properties();
InputStream is = getClass().getResourceAsStream("/database.properties");
if(is == null)
throw new IllegalStateException("Properties file missing ");
programProps.load(is);
System.out.println("driver name::::::: "+programProps.getProperty("JDBCDriver"));
is.close();
} catch(Exception e) {
e.printStackTrace();
After compilation in my classes directory i am getting database.properties file and my java file with package.
At the time of running i am getting "java.lang.IllegalStateException: Properties file missing"
Now tell me where is the fault. Why again i am getting exception.
Thanks -
Can anyone expalin to me the following properties in the Web Dynpro Iview P
Hi all,
Can anyone expalin to me the following properties in the Web Dynpro Iview Properties Editor--
Authentication Scheme
Can be Merged
Default Entry for Folder
Entry Point
Show Debug Screen
Tray Type
Points assured for helpHi shobhendra srivastava,
1) An authentication scheme is a definition of what is required for an authentication process. In the iView you can set what authentication process (UserName/Password, X.509 certificate, etc.) the iView requires. Find more information <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/90/52c43dac1bcf51e10000000a114084/frameset.htm">here</a>.
2) The attribute "Can be Merged" allows you to merge certain objects (worksets, pages, iviews) under the same point in the portal navigation structure. All objects with the same value for attribute "Merge ID" are merged together. The object with the highest value for attribute "Merge Priority" provides the name displayed in the navigation elements (tabs in TLN and links in Detailed Navigation)
3) Find a good explanation of the attribute Entry Point <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/4e/3e703e632c7937e10000000a114084/frameset.htm">here</a>.
4) If this parameter is "true" a debugging screen is displayed before starting the WebDynpro application. Make sure that the parameter DebugMode in the service configuration (=>Applications=>com.sap.portal.appintegrator => Service => Common_Configuration) is not 'false' if you want to use this feature.
5) The attribute Tray Type defines the design of the iView's frame. The attribute can take the following values:
fill: The content area appears with a background color
plain: The content area appears with a white background and a frame
transparent: The background is transparent and the content area appears without a frame
Hope I could help!
Best regards,
Martin -
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 -
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 -
How to use a CAS in web dynpro with NWDS 7.0
Hi, all.
I implemented a cas project (some entity services and application services). Now I want to use it in a web dynpro project.
I know how to do that with NWDS 7.1, but it seems something differernt with NWDS 7.0.
Can anyone give me a hand? Thanks.hi
CAF Core project comes with a sub-project WebDynpro.
You can implement business logic using CAF Core Service ,integrate it in WebDynpro UI.
1)Select your CAF project root , right click on it and select u201CCreate Web Dynpro Modelu201D from the context menu.
2) Switch to the Web Dynpro Perspective
3)You can find the CAF Core services have been generated and are available to the WebDynpro component.
you can find caf services under modelclasses of webdypro project .
4)Then you proceed with creating component etc..
Regards
sowmya. -
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 -
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? -
Uploading excel file in Web Dynpro for ABAP
Hello Gurus,
I need to upload a excel file in my Web Dynpro (ABAP) program. Can anyone please tell me how do i do this. Kindly help.
Regards,
Aditya.Hi Aditya,
Please search the forum...
Please check this link
Uploading Data from Excel File To Dynpro
Excel Upload via Web dynpro ABAP
Upload and Reading Excel File in Web Dynpro
Best regards,
raam -
Using FREE-SELECTIONS_DIALOG in Web Dynpro
Hi Experts,
I want to transfer a report whicht uses the FREE_SELECTION_DIALOG Function into Web Dynpro.
Is it possible to use this function with Web Dynpro?
The aim is to generate a list on the left side of the screen with different attributes from a dictionary table.
By clicking on an attribute it should open the select-options for this field. The inputs should be saved.
In the End I want to select data from a list that fit to all of the inputs.
Thanks for any ideas!
Martinany help..
-
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
Maybe you are looking for
-
Unable to provide input value to InfoObject in SEM-BCS
Hello BI Experts, I have created an infoobject 'ABC' in BI and have flagged 'With Master Data' and 'With Text'. This infoobject has an navigational attribute 'XYZ'(XYZ also has 'With Master Data' and 'With Text'). When I go to T.Code UCWB(BCS Workbe
-
Having trouble sending photo through messages
I Can send a message but not photos, they are undeliverable?
-
DB Version:11.1.0.6.0 OS : AIX This is related to threadi had started earlier. Create a second database from an existing ORACLE_HOME I'll just give you a background: We have a database running for an OLTP test environment. We needed to create another
-
Mouse right click throttled/not detected after burst of right clicks
I have a problem with the right click of my mouse after sending a "burst" of clicks (I cant really count but its at least 1/sec). I noticed this problem first when trying to play Dota2, I have not yet tested if I can reproduce the problem from any ot
-
Why are the buttons not reading my fingers now? Terrible upgrade
This upgrade is frustrating, wish I could undo it. The buttons don't respond to touch and I'm doing things more than one time now.