Casting types
Hi!
Situation
class Point
class ColorPoint extends Point
Point pont = new Point();
ColorPoint = new ColorPoint();
colorPoint = (ColorPoint) point;
I get ClassCastException in run-time mode. Why?
And what I can do?
Thank you.
Point pont = new Point();
ColorPoint = new ColorPoint();you missed the variable here. Did you mean ColorPoint colorPoint = new ColorPoint();
colorPoint = (ColorPoint) point;This won't work (as you've seen ;-) ). colorPoint is of type ColorPoint but point is of type Point.
possible castings:
static:
Point point;
ColorPoint colorPoint = new ColorPoint();
point = colorPoint;
dynamic:
Point point = new ColorPoint(); // dynamic type is now ColorPoint but static Point
ColorPoint colorPoint = (ColorPoint) point; // works because the dynamic type of point is ColorPoint.
Greets
Puce
Similar Messages
-
Hello,
I create a new class object at runtime using:
Class dmClass = Class.forName(dmClassName);
I want to be able to use the Class object, dmClass, to cast new objects but I can't seem to get this to work. I've tried:
(dmClass) .......
(dmClass.getName()).....
But I get an Invalid Cast type expression error.
How can I use dmClass as the cast type in a statement?
Thanks
GlennOk,
I have:
class DataManager
class SasDMImp which implements DataManager
I do the following:
String dmClassName = "SasDMImp";
Class dmClass = Class.forName(dmClassName);
I now want to use the SasDMImp class to cast a new object and this is the part I'm having trouble with.
If I hard code the class name I use:
SasDMImp dm = (SasDMImp) Naming.lookup("rmi://" host registry);
I want to replace the hard coded SasDMImp with dmClass but I get the Invalid Cast type when I do this.
Hope this helps.
Glenn -
Problem doing ASSING.....CASTING TYPE (dbtype)
Hi everybody, i have a problem with a dinamic movement. I explain it below.
I want to copy HR Data with a Function Module with Destination parameter.
I build a table type PRELP with all the personal data with all the infotypes (PA)
In my Target System i do this:
**DECLARATIONS
field-symbols: <fs> type any.
LOOP at PRELP_T into PRELP_WA.
ASSING PRELP_WA to <fs> CASTING TYPE (PRELP_WA-infty)
"PRELP_WA-infty is like 'PA0001' For example.
MODIFY (PRELP_WA-infty) from <fs>
ENDLOOP.
If the <fs> contains fields like type DEC, when i move data with ASSING, this fields are fill like:
<0.0, or <0.3, or <3........rare characters.
In MODIFY sentences, programa return me a DUMP, I supose is becose this characters.
PS: if i modify in debug mode this DEC fields, and change <0.0 with 2 (For Example) it runs correctly.
I hope yo could help me
cheers
Edited by: Miguel Ortega on Jun 16, 2009 12:00 PMHi,
Did you create your destinations in your application server? It seems that the destinations such as topics and queues are not created. First you should create them and then start using them.
For example, in here, it says that jndi/Topic is not valid. To check if the destinations are valid or not; you can do it either through the graphical user interface or the command line console. -
Wht does it mean - "ASSIGN it_DB_TBL_name TO fs1 CASTING TYPE x"?
Hi Experts,
Just curious,
Pls. let me know that, Wht is the functionality of the following statement:
ASSIGN it_DB_TBL_name TO <fs1> CASTING TYPE x
thanqASSIGN feld TO <fs> CASTING TYPE type.
ASSIGN feld TO <fs> CASTING TYPE (typename).
ASSIGN feld TO <fs> CASTING LIKE fld.
ASSIGN feld TO <fs> CASTING DECIMALS dec.
You can use ASSIGN ... CASTING to treat the contents of a field as a value of another type using a field symbol. One application for this statement would be to provide different views on a structure with casts on different types.
One wide-spread ABAP technique is to use C fields or structures as containers for storing structures of different types that are frequently only known at runtime. The components of the structure are selected with offset/length accesses to the container. Since this technique no longer works with Unicode, you can also look upon an existing memory area as a container with the suitable type definition using a field symbol with the ASSIGN ... CASTING statement. In the next example, a certain field of database table X031L is read, whereby the field and table names are only defined at runtime.
Example:
* Read a field of table X031L
PARAMETERS:
TAB_NAME LIKE SY-TNAME, "Table name
TAB_COMP LIKE X031L-FIELDNAME, "Field name
ANZAHL TYPE I DEFAULT 10. "Number of lines
DATA:
BEGIN OF BUFFER,
ALIGNMENT TYPE F, "Alignment
C(8000) TYPE C, "Table contents
END OF BUFFER.
FIELD-SYMBOLS:
<WA> TYPE ANY,
TYPE ANY.
* Set field symbol with suitable to buffer area
ASSIGN BUFFER TO <WA> CASTING TYPE (TAB_NAME).
SELECT * FROM (TAB_NAME) INTO <WA>.
CHECK SY-DBCNT < ANZAHL.
ASSIGN COMPONENT TAB_COMP OF STRUCTURE <WA> TO .
WRITE: / TAB_COMP, .
ENDSELECT.
Until now, in the ASSIGN feld TO <f> CASTING ... statement, the system checked to ensure that the field was at least as long as the type that was assigned to the field symbol, <f>. (Field symbols can either be typed at declaration or the type specified in an ASSIGN statement using CASTING TYPE). The syntax check is now more thorough. Now, you can only assign the field field (in either a Unicode or non-Unicode program)
provided it is at least as long as the type assigned to the field symbol <f>. Otherwise, the system returns a syntax error. At runtime, the system only checks to see whether or not the lengths are compatible in the current system (as before).
If the field type or field symbol type is a deep structure, the system also checks that the offset and type of all the reference components match in the area of field that is covered by <f>. The syntax check is now more thorough. Now, the system checks that these components must be compatible with all systems, whether they have a one-byte, double-byte, or four-byte character length. At runtime, the system only checks to see whether or not the reference components are compatible in the current system
In Unicode systems, in the ASSIGN str TO <f> TYPE C/N and ASSIGN str TO <f> CASTING TYPE C/N statements, the length of str may not always be a multiple of the character length, in which case the program terminates at runtime. -
I encountered class cast type exception becos I set the attribute by passing in a class instance but when I get the attribute, I used a string to store it. So any idea how I can solve this error? Thanks.
request.setAttribute("message", cr); where cr is a class
but here i declare a string to store, so how do i do a conversion?
String messageString = request.getAttribute("message");
if (messageString == null){
messageString = "";All parameters of request objects are stored as type Object. So when you extract the objects from the request, you will need to explicitly cast to the type you are expecting e.g.
String myString = (String)request.getParameter("Hello"); -
Ora-1460 during select using table(cast(type))
Hi all!
I've got a problem with a query that fails with a ora-1460 at random time intervals. This is a 10.2.0.3 version database running on a sun os.
We've managed to reproduce this error controlled when running an analyze on the table in question at the same time this query runs.
The error looks like this:
Unexpected system error, see server log for details. Root message is: org.apache.ojb.broker.PersistenceBrokerSQLException: * SQLException during execution of sql-statement: * sql statement was 'SELECT A0.ID,A0.LOCK_VERSION,A0.CLASS_NAME,A0.DESCRIPTION,A0.NAME,A0.EXTERNAL_ID,A0.ORDER_NUMBER,A0.LEVEL_ID,A0.ROOT_AH_ID,A0.DIFF_END_DATE,A0.DIFF_START_DATE,A0.SUPPORTED_BY_ASS_CAL,A0.CATEGORY_ROLE_ID FROM CATEGORY A0 WHERE A0.ID IN (select /*+ cardinality(1) */ * from table(cast( ems_string_to_table(?) as ems_table_of_number_type ))union select /*+ cardinality(1) */ * from table(cast( ems_string_to_table('') as ems_table_of_number_type)))' * Exception message is [ORA-01460: unimplemented or unreasonable conversion requested ] * Vendor error code [1460] * SQL state code [72000]
ems_string_to_table is a function thats populates a type with a unknown number of values. Though, the length of the string never exceeds 4k.
ems_table_of_number_type is a type define as "table of numbers".
Has anybody seen this error before, or have any idea why this should be?
Best regards,
HeyersThere is an IN clause constaraint i.e max number of characters you can pass from Oracle .Please check your select inner query which might be resulting to cross more than the boundary IN clause ,
-
What cast type are used for?
In the example attached to this question is a simple VI application that cast, using type cast of LabVIEW, one value to different other type. My understanding of type cast, in C, C++ and to my best knowledge, was an implicit adaptation of a numerical value in a specific format to an other format. The value should remain the same. Unless the type in which the value is assigned is not enough large or adapted to contain such a number ex:
I8 = 500;
U32 = -1;
But in my example all the assigned indicator are large enough.
I have the same problem in LabVIEW 5.1.1 and 6.1
If someone could only tell me what it is used for?
Best regards,
Nitrof
Attachments:
Type_cast.vi 26 KBThe type cast function is really helpful for typecasting "unusual" data to a more convienient data format. It can also be used to coerce data, like in your example, but coercion is usually not always a good thing because it can cause bad values.
There are lots of good examples of typecasting.
For example, I use the typecast function to change refnums to unsigned 32 integers (U32), just so I can pass the refnums between VI's easier.
Another VERY common typecast is if you want to display the ASCII value of a character. Run the string character "A" into a typecast, and set the output type as a Unsigned 8 bit number (U8), and you will see 0x41. Take a look at my example VI's to see what I mean.
David
Attachments:
Type_cast_Example5.vi 16 KB
Type_cast_Example6.vi 18 KB -
Overloading & Cast &Type Save?
Here I use final bounds, therefore ignore cast warnings
and test overloading and inference(<- do not work)
My question: Is this considered type-save? public class DoW {
public static final String[] DAY_NAME=
{"Su","Mo","Tu","We","Th","Fr","Sa"};
private int wd;
public DoW(int day,int month, int year) {
// just for fun
if (month<3) { month= month+12; year--; }
wd= (day+ 2*month+ 3*(month+1)/5+ year+
year/4-year/100+year/400+1)%7;
public <T extends String> T getDoW() { return (T)DAY_NAME[wd]; }
public <T extends Integer> T getDoW() { return (T)new Integer(wd); }
public static void main(String[] args) {
DoW dow= new DoW(20,2,2005);
System.out.println(dow.<String>getDoW()+" #"+dow.<Integer>getDoW());
}I do not argue about sense, let me tinker please!
1. As String/Integer are final they can be used to fool
the compiler and get overloading on return types as a free lunch.
2. See reply Gafter to "Usafe casting with generics"
The compiler warns precisely when it cannot generate code to fully check the cast at runtime.Really? I doubt that, as Sun even ignores it's own compiler warning sometime.
If these two warnings are contrary to the fact that this is type save,
no one will care too much about warnings, as he might think
"my code is also Sun-type save".
This would be a (tiny?) disaster for Generics, as it depends on the fact
that only "warning-less" code can be used as generic building blocks.
3. If finals make a sense in bounds the compiler should not ignore that. -
Type Casting? When to use this concept?
There is one question bothering me very very much.
When should I use type casting?
For example
ClassNameQ c = (ClassNameQ) ......displayable
How do I know which 'cast type' to use? Is there a suitable pattern
we need to follow so that we can know 'Ah this is the cast
we need to use'
Please can any one point out which 'Cast type' points needs to be
followed?
RegardsYou can Cast an object from any subclass to its superclass,
or from a superclass to the sublass, if the object is already
an object of the subclass.
I have a class named Name:
public class Name {
I have a subclass named LastName:
public class LastName extends Name { [/b]
And another named FirstName:
[b]public class FirstName extends Name { [/b]
I create an object like this:
[b]LastName ln = new LastName("Johnson");
Then pass it to a method that can work on all names:
capitalFirstLetter(ln);
capitalFirstLetter(Name n) {
Now n in CapitalFirstLetter can be used only as a Name
object. Anything specific to the LastName object can't be used.
So if I need to use things specific to LastName I have to cast
the object to LastName. There is a problem, however, since this
method can work on all Names, so I don't know if the Name is
a LastName or not. The object itself DOES know, however, and
we can test, so we would cast to a subclass as follows:
if (n instanceof LastName) {
LastName ln = (LastName)n;
ln.addToGeneology();
} else of (n instanceof FirstName) {
FirstName fn = (FirstName)n;
fn.addOccurance();
Steve -
Hi
how can i change the data type of a field symbol at run time..(say Packed to char)
may be it can have a field data or structure data..
please help me ..........
Regards
alberthi
thank you for your reply
i am trying to do as follows but i am not getting the expected output
where do i go wrong.............
*"*"Local Interface:
*" TABLES
*" IT_OUT STRUCTURE THENV OPTIONAL
DATA: v_date type sy-datum,
mytype type C.
FIELD-SYMBOLS: <fs>,
<fs1>.
v_date = sy-datum.
ASSIGN v_date TO <fs>.
append <fs> to it_out.
WRITE / <fs>. " ---------------->20.09.2011
ASSIGN v_date TO <fs1> casting TYPE C.
append <fs1> to it_out.
WRITE / <fs1>. " --------------->20110920
LT_OUT is having the data as 20110920
20110920
but i expect in date format 20.09.2011
20.09.2011 -
VECTOR: Can't Locate Where to Specify Content Type
Hi all. I'm confused with warning from compiler. I'm specifying methods for swing TableModel using vector data and it always shows me unchecked call to set as a member of raw type (method setValueAt). I just have no idea how to cast type there. The code is below:
import java.util.Vector;
public class SSCCE {
public static void main(String[] args){
new dk_MF();
class dk_MF{
dk_MF(){ constructTable(); }
public void constructTable(){
Vector<Vector> bigvec = getTabData();
Vector smallvec = (Vector) bigvec.elementAt(0).clone();
bigvec.remove(0);
Model MM = new Model(bigvec,smallvec);
System.out.println(MM.getValueAt(0,0)); }
public Vector<Vector> getTabData(){
Vector<Vector> bv = new Vector<Vector>();
Vector<String> sv = new Vector<String>();
sv.add("one"); sv.add("two");
bv.add((Vector)sv.clone());
bv.add((Vector)sv.clone());
sv.clear();
return bv; }
class Model {
private Vector columnNames = null;
private Vector data = null;
public Object getValueAt(int row, int col){
return ((Vector) data.elementAt(row)).elementAt(col); }
public void setValueAt(Object value, int row, int col) {
((Vector) data.elementAt(row)).set(col, value); }
public void createNewTable(Vector b, Vector s) {
data = (Vector) b.clone();
columnNames = (Vector) s.clone(); }
Model(Vector big, Vector small) {
createNewTable(big,small);
}Thanks for the tip on casting problem! But now I'm back to the starting point. OK, I have a Vector of Vectors of Arbitrary Data: Vector<Vector<?>>. I've done all this description in the code (below). But this cursed "unchecked call to set" remains.
What, actually, this "unchecked call" means? Why casting ((Vector) data.elementAt(row)) at getValueAt does not get a warning?
P.S. I've tryed to put Vector<?> (caused error) and Vector<Object> (warning) in setValueAt, but this did not help!
import java.util.Vector;
public class SSCCE {
public static void main(String[] args){
new dk_MF();
class dk_MF{
dk_MF(){ constructTable(); }
public void constructTable(){
Vector<Vector<?>> bigvec = getTabData();
Vector smallvec = (Vector) bigvec.elementAt(0).clone();
bigvec.remove(0);
Model MM = new Model(bigvec,smallvec);
System.out.println(MM.getValueAt(0,0)); }
public Vector<Vector<?>> getTabData(){
Vector<Vector<?>> bv = new Vector<Vector<?>>();
Vector<String> sv = new Vector<String>();
sv.add("one"); sv.add("two");
bv.add(new Vector<String>(sv));
bv.add(new Vector<String>(sv));
sv.clear();
return bv; }
class Model {
private Vector columnNames = null;
private Vector data = null;
public Object getValueAt(int row, int col){
return ((Vector) data.elementAt(row)).elementAt(col); }
public void setValueAt(Object value, int row, int col) {
((Vector) data.elementAt(row)).set(col, value); }
public void createNewTable(Vector b, Vector s) {
data = (Vector) b.clone();
columnNames = (Vector) s.clone(); }
Model(Vector big, Vector small) {
createNewTable(big,small);
} -
The difference between FIELD-SYMBOL and normal DATA TYPE
Dear experts,
Please see the example below, both are output the same result.
DATA: EXTERNAL_RECORD(4000),
POSITION TYPE I,
LENGTH TYPE N,
ENTRY TYPE STRING.
EXTERNAL_RECORD = '0005Smith0007Edwards0005Young'.
DO.
LENGTH = EXTERNAL_RECORD+POSITION(4).
IF LENGTH = 0.
EXIT.
ENDIF.
ADD 4 TO POSITION.
MOVE EXTERNAL_RECORD+POSITION(LENGTH) TO ENTRY.
WRITE ENTRY.
ADD LENGTH TO POSITION.
IF POSITION >= 4000.
EXIT.
ENDIF.
ENDDO.
--OR It can be written as--
DATA: EXTERNAL_RECORD(4000),
POSITION TYPE I,
LENGTH TYPE N.
FIELD-SYMBOLS <ENTRY>.
EXTERNAL_RECORD = '0005Smith0007Edwards0005Young'.
DO.
LENGTH = EXTERNAL_RECORD+POSITION(4).
IF LENGTH = 0.
EXIT.
ENDIF.
ADD 4 TO POSITION.
ASSIGN EXTERNAL_RECORD+POSITION(LENGTH) TO <ENTRY>.
WRITE <ENTRY>.
ADD LENGTH TO POSITION.
IF POSITION >= 4000.
EXIT.
ENDIF.
ENDDO.
Is there any special circumstances we need to use FIELD-SYMBOL?
Why is FIELD-SYMBOL is introduce in the first place?
Kindly advice with example.
Thanks in advance for those who can help me on this.HI,
You can use field symbols to make the program more dynamic. In this example the name of a table control is substituted by a field symbol. Thus you cal call the form with any internal table, using the name of the table control as a parameter.
Example
form insert_row
using p_tc_name.
field-symbols <tc> type cxtab_control. "Table control
assign (p_tc_name) to <tc>.
insert 100 lines in table control
<tc>-lines = 100.
Field symbols allow you to:
** Assign an alias to a data object(for example, a shortened
name for data objects structured through several hierarchies
- <fs>-f instead of rec1-rec2-rec3-f)
** Set the offset and length for a string variably at runtime
** Set a pointer to a data object that you determine at runtime (dynamic ASSIGN)
** Adopt or change the type of a field dynamically at runtime
** Access components of a structure
** (from Release 4.5A) Point to lines of an internal table
(process internal tables without a separate work area)
Field symbols in ABAP are similar to pointers in other programming
languages. However, pointers (as used in PASCAL or C) differ from ABAP
field symbols in their reference syntax.
The statement ASSIGN f to <fs> assigns the field f to field
symbol <fs>. The field symbol <fs> then "points" to the
contents of field f at runtime. This means that all changes to the
contents of f are visible in <fs> and vice versa. You declare
the field symbol <fs> using the statement FIELD-SYMBOLS: <fs>.
Reference syntax
Programming languages such as PASCAL and C use a dereferencing symbol
to indicate the difference between a reference and the object to which
it refers; so PASCAL would use p^ for a pointer instead of p, C would
use *p instead of p. ABAP does not have any such dereferencing symbol.
** In PASCAL or C, if you assign a pointer p1 to a pointer p2,
you force p1 to point to the object to which p2 refers (reference semantics).
** In ABAP, if you assign a field symbol <fs1> to a field
symbol <fs2>, <fs1> takes the value of the data object to
which <fs2> refers (value semantics).
** Field symbols in ABAP are always dereferenced, that is,
they always access the referenced data object. If you want to
change the reference yourself in ABAP, you can use the ASSIGN statement
to assign field symbol <fs1> to field symbol <fs2>.
Using field symbols
You declare field symbols using the FIELD-SYMBOLS statement.
They may be declared either with or without a specific type.
At runtime you assign a field to the field symbol using the ASSIGN
statement. All of the operations on the field symbol act on the field
assigned to it.
When you assign a field to an untyped field symbol, the field symbol
adopts the type of the field. If, on the other hand, you want to assign
a field to a typed field symbol, the type of the field and that of the
field symbol must be compatible.
A field symbol can point to any data object and from Release 4.5A,
they can also point to lines of internal tables.
The brackets (<>) are part of the syntax.
Use the expression <fs> IS ASSIGNED to find out whether the field
symbol <fs> is assigned to a field.
The statement UNASSIGN <fs> sets the field symbol <fs> so
that it points to nothing. The logical expression <fs>
IS ASSIGNED is then false. The corresponding negative expression
is IF NOT <fs> IS ASSIGNED.
An unassigned field symbol <fs> behaves as a constant with
type C(1) and initial value SPACE.
MOVE <fs>
TO dest Transfers the initial value SPACE to the variable dest
MOVE 'A' to <fs>
Not possible, since <fs> is a constant
(runtime error).
To lift a type restriction, use the CASTING addition in the
ASSIGN statement. The data object is then interpreted as though
it had the data type of the field symbol. You can also do this
with untyped field symbols using the CASTING TYPE <type> addition.
The danger with pointers is that they may point to invalid areas.
This danger is not so acute in ABAP, because the language does not
use address arithmetic (for example, in other languages, pointer p
might point to address 1024. After the statement p = p + 10, it would
point to the address 1034). However, the danger does still exist, and
memory protection violations lead to runtime errors.
A pointer in ABAP may not point beyond a segment boundary. ABAP does
not have one large address space, but rather a set of segments.
Each of the following has its own segment:
* All global data
* All local data
* Each table work area (TABLES)
* Each COMMON PART
You should only let field symbols move within an elementary field or
structure where ABAP allows you to assign both within the global data
and beyond a field boundary.
Rgds
Umakanth -
Need a generic data type to hold any string
Hi,
I m trying to write a program which can log data from any table into a Trace Z table.
I have used
FIELD-SYMBOLS: <line>.
to get the line of that table. But now I want to dynamically know what are the field names of this line structure and the data in it. And then write it as a string to the trace Z table
form log_table_data tables rt_any_table
using rv_statement type string.
data: v_line type string,
v_char_line type char255.
FIELD-SYMBOLS: <line>.
loop at rt_table ASSIGNING <LINE>.
v_char_line = <LINE>. - Terminating at this statement
ASSIGN <LINE> to v_line casting type string.
endloop.
endform.
Thanks for readingHi,
if you are interested in generic programming in ABAP then this [presentation|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae] is full of information. There is a class CL_ABAP_STRUCTDESCR with method GET_COMPONENTS. This method returns a list of components of table or structure. So you will be able to loop over every field in the table and convert each field into string.
Cheers -
Plz help upgrade issue moving data from char type structure to non char typ
Hi Experts
plz help its very urgent
Data :workout(5000) .
FIELD-SYMBOLS : <FS_WORKOUT> TYPE ANY.
workout = ' u' .
ASSIGN WORKOUT TO <FS_WORKOUT> CASTING TYPE C .
BAPISDITM = <FS_WORKOUT>.
i am getting dump after BAPISDITM = <FS_WORKOUT>.
i think i am getting the dump bcoz i am moving character type structure to non character type structure but i think with field symbols we can remove this issue thats y i used it but its not working plz help me
its very urgent
*dump is :*
Short text
Data objects in Unicode programs cannot be converted.
What happened?
Error in the ABAP Application Program
The current ABAP program "ZSDR0009" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
How to correct the error
Use only convertible operands "dst" and "src" for the statement
"MOVE src TO dst"
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"UC_OBJECTS_NOT_CONVERTIBLE" " "
"ZSDR0009" or "ZSDR0009_I02"
"USER_COMMAND"
thanx in advancei got d solution in this thread
Hi all,
data: gv_line(6000) type c.
Bvbapkom = gv_line.
But i am getting the Error like : gv_line and Bvbapkom are not mutually convertable.
Note: Bvbapkom is a Structure
How do i solve this ?
Mahesh
KR
Posts: 210
Registered: 11/24/06
Forum Points: 0
Re: gv_line and Bvbapkom are not mutually convertable.
Posted: Nov 30, 2007 8:40 AM in response to: KR Reply
Hi ,
i got the solution
ANSWER:
Field-symbols: <X_Bvbapkom> type x,
<X_gv_line> type x.
Assign: Bvbapkom to <X_Bvbapkom> casting,
gv_line to <X_gv_line> casting.
<X_Bvbapkom> = <X_gv_line>.
Nasaka Ramakris...
Posts: 4
Registered: 1/19/08
Forum Points: 20
Re: gv_line and Bvbapkom are not mutually convertable.
Posted: Jan 19, 2008 7:42 AM in response to: KR Reply
Hi Check this answer.
ANSWER:
Field-symbols: <X_Bvbapkom> type x,
<X_gv_line> type x.
Assign: Bvbapkom to <X_Bvbapkom> casting,
gv_line to <X_gv_line> casting.
<X_Bvbapkom> = <X_gv_line>. -
Class Cast Exception for Date Format .
Hi Friends ,
I am getting a error for casting type from Object to Date type .
Could you please some one help me . I am using a prepared statement in OAF for inserting a data .
All fields are inserting except Date format .
My code in controller as follows :
try { String StartDate=row.getAttribute("StartDate").toString();
// String StartDate="30-Apr-2011";
DateFormat formatter ;
Date StartDate1;
formatter = new SimpleDateFormat("dd-MMM-yy");
StartDate1 = (Date)formatter.parse(StartDate);
//System.out.println("Today is " +date );
pstmt.setDate(12,StartDate1);
} catch (ParseException e)
{System.out.println("Exception :"+e); }
Thanks in Advance ,
KeerthiThanks so Much for the quick response .
Exception Details.
oracle.apps.fnd.framework.OAException: java.lang.ClassCastException at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:888) at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1145) at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(OAPageErrorHandler.java:1408) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2637) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534) ## Detail 0 ## java.lang.ClassCastException at SONY.oracle.apps.inv.xx_slapg.webui.ServiceRequestCO.processFormRequest(ServiceRequestCO.java:153) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534) java.lang.ClassCastException at SONY.oracle.apps.inv.xx_slapg.webui.ServiceRequestCO.processFormRequest(ServiceRequestCO.java:153) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534)
Here is my code .
java.util.Date StartDate=(java.util.Date)row.getAttribute("StartDate");
------------------------------------------------------------------------------------------------
Maybe you are looking for
-
Windows recognizes Ipod mini but itunes does not.
i have been having problems lately with windows recognizing my ipod but itunes will not. i have gone to the support page and have tried everything on their twice now and still nothing. i got the updater to recognize it at one point and hit restore bu
-
PP-PM Integration-capacity block due to maintenance order
Hi guys, I have an work center under which i have grouped 3 similar machines which has both machine & labour category Now with respect to notification(that one of the m/c in that wrok center got break down) from production if a maintenance order is p
-
Hello, Here is what I have: a dual 1.8 with a Granite Digital 1.6TB RAID 5 tower. This acts as the server. Connecting to it is a Dual 2.7 via giga-bit and a laptop wirelessly. All RAW files are on the RAID 5. We shoot primarily weddings with two phot
-
I receive e-mails from Quilted Paradise. People post pictures on this site, but, they will not display. Internet Explorer, they will display. Also, the reading area is way too small.
-
Is it possible to clear the buffers in 8i? I tired but getting this error: 16:25:00 SQL> alter system flush shared_pool; alter system flush shared_pool ERROR at line 1: ORA-02000: missing SHARED_POOL keyword