Generic Observer - Casting problems..
I'm trying to make a generic observer pattern, modeled after Wadler's book.
But I get type errors at the lines marked with ?? below, and although I fixed them, don't understand why the original code is wrong - any help please!
interface Observer<S extends Observable<S,O,A>,
O extends Observer <S,O,A>,
A > {
public void update ( S subject, A arg);
// public void update ( Observable<S,O,A> subject, A arg);
abstract class Observable<S extends Observable<S,O,A>,
O extends Observer <S,O,A>,
A > {
List<Observer<S,O,A>> obs = new ArrayList<Observer<S,O,A>>();
boolean changed = false;
public void notifyObservers(A a){
// for ( O o : obs ) // ??
// o.update(this,a); // ??
for ( Observer<S,O,A> o : obs )
o.update((S)this,a ); // Cast??
}
Stephan,
To illustrate the problem with your version and a client;
The type TestObsGen must implement the inherited abstract method Observer<Thing,TestObsGen,Integer>.update(Observable<Thing,TestObsGen,Integer>, Integer)
Any insights welcome!
public interface Observer<
S extends Observable<S, O, A>,
O extends Observer<S, O, A>,
A> {
public void update(Observable<S, O, A> subject, A arg);
abstract class Observable<
S extends Observable<S, O, A>,
O extends Observer<S, O, A>,
A> {
List<Observer<S, O, A>> obs = new ArrayList<Observer<S, O, A>>();
boolean changed = false;
public void notifyObservers(A a) {
for (Observer<S, O, A> o : obs)
o.update(this, a);
public class TestObsGen
implements Observer< Thing, TestObsGen, Integer >
Thing thing;
TestObsGen ( Thing t ) {
thing = t;
// t.addObserver(this);
void update(Thing t, Integer count) {
System.out.println("Count:" + count);
public static void main(String[] args) {
Thing t = new Thing();
TestObsGen test = new TestObsGen(t);
t.bump();
// Event received?!
class Thing
extends Observable< Thing, TestObsGen, Integer >
int count;
void bump() {
count++;
// setChanged();
// notifyObservers();
}
Similar Messages
-
The following code gives me runtime casting problems:
package edu.columbia.law.markup.test;
import java.util.*;
public class A {
protected static Hashtable hash = null;
static {
hash = new Hashtable ();
hash.put ("one", "value 1");
hash.put ("two", "value 2");
public static void main (String args []) {
A a = new A ();
String keys [] = a.keys ();
for (int i = 0; i < keys.length; i++) {
System.out.println (keys );
public String [] keys () {
return (String []) hash.keySet ().toArray ();
The output on my console is:
java.lang.ClassCastException: [Ljava.lang.Object;
at edu.columbia.law.markup.test.A.keys(A.java:37)
at edu.columbia.law.markup.test.A.main(A.java:29)I can not understand why is it a problem for JVM to cast?
Any ideas?
Thanks,
Alex.return (String []) hash.keySet ().toArray ();This form of toArray returns an Object[] reference to an Object[] object. You cannot cast a reference to an Object[] object to a String[] reference for the same reason that you cannot cast a reference to a Object object to a String reference.
You must use the alternate form of toArray instead:
return (String []) hash.keySet ().toArray (new String[0]);This will return an Object[] reference to a String[] object, and this reference can be cast to a String[] reference. -
Suggestions, Observations and problem with Time Capsule shares
*Some Observations*
The Time Capsule can take a long time to become active. This is especially true if using an extended or WDS network. I would suspect this is due to the negotiation between devices that it needs to do. I have on occasion believed it to be hung, only to find that after walking away for a bit it comes up. This also impacts devices showing up in the Airport utility.
Using a time capsule with one Airport Express B/G will work, but adding a second creates problems.
Extending a network with an Airport Express N seems to work well.
Best bet is to set up separate B/G and N networks and run your N network as N only at 5Ghz.
WEP provides no real security, so think of it as you would an open network.
*My Issue*
I am having an issue where the time capsule shares become unavailable. It is an intermittent issue, and I have been unable to identify a test case. This happens for devices connected over ethernet as well as wireless. The Time Capsule shows in the Finder list, but the volumes are not available. Connecting to them fails.
The device also appears in the Airport Utility list, but when clicking on Manual Setup, or guided set up, it causes a hang.
This results in Time Machine hanging when trying to initiate a backup.
I have also noticed that when this happens, the signal does start to get a bit flaky with "Roam (Beacons Lost)" messages. Wireless connectivity still seems to be very useable though. I can connect to other network shares through the Time Machine, but not to the shares on the Time Machine. The only way to recover from this is to power cycle the Time Capsule.
One thing I want to investigate more tonight is whether there are any issues with my keychain and old passwords in case there are multiple failed attempts in the mix that are doing something. Although I know of no lockout feature on the device.
Any suggestions would be appreciated. This is the second Time Machine, so I have seen this on two different devices. I am also seeing this issue across 4 different computers simultaneously, some via ethernet and some wirelessly. Time Capsule is 7.3.2Hi,
I have pretty much the same problem, 1TB Time Capsule that works fine most of the time as a wireless router. Up till recently Time Machine backups just worked (as one would expect them to) wired and wireless. I went away for a week came back and now every time Time Machine invokes a back up process all of a sudden my wireless network goes down, Time Machine can no longer see the Time Capsule and all other devices (iphone / apple TV other non apple devices) no longer have connections (they see wireless but no pass through to the internet or each other).
I have tried resetting all sorts of stuff, re-deployed my network, changed IP / LAN settings to make it less complex, Yasu'd my mac, connected only via wires, cleaned out my keychain etc etc and still get the same problems and as per Chris's point airport utility also hangs and the only solution is rebooting the time capsule.
I am fairly frustrated with this! any suggestions / help would be gratefully accepted.
thanks
alex -
Casting problems getting a home I/F of an EJB in another app when debuging a servlet
(Jdeveloper version = 9.0.2.798, OC4J Application Server version = Oracle9iAS (9.0.2.0.0))
I am trying to debug a multi-tier application using the embedded application server. Servlets and EJBs within that application need to call EJBs contained within a second application (Horus).
I have set up the embedded application server to run this second application automatically by adding the following entry into its server.xml
<application auto-start="true" name="Horus" path="M:\Studio\build\production\java\Server\Obfuscate\J2EE_HOME\Horus\Horus.xml"/>
I then start the embedded application server by debugging my servlet project, 'intermediateServlet'. I know the second application is running correctly in the embedded application server because I can access it from a separate client.
In the 'intermediateServlet', I want to obtain a reference to a Dispatcher EJB held in the Horus application. This EJB has the following properties
ejb-name = com.internal.server.Dispatcher
home interface = com.internal.server.DispatcherHome
bean class = com.internal.server.DispatcherEJB
remote interface= com.internal.server.Dispatcher
The following code is executed during the container's call to my servlet init( context ) method to try and get the appropriate home interface.
Context context = null;
Object tempRemoteIF1 = null;
Object tempRemoteIF2 = null;
Properties h = null;
h = new Properties();
h.put( Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory" );
h.put( Context.PROVIDER_URL, "ormi://127.0.0.1:23891/Horus");
h.put( Context.SECURITY_PRINCIPAL, "user0" );
h.put( Context.SECURITY_CREDENTIALS, "password" );
context = new InitialContext (h);
tempRemoteIF1 = context.lookup( "com.internal.server.Dispatcher" );
tempRemoteIF2 = javax.rmi.PortableRemoteObject.narrow
tempRemoteIF1,
Class.forName( "com.internal.server.DispatcherHome" )
The context.lookup call seems to work fine, returning an object of the class
DispatcherHome_StatelessSessionHomeWrapper5
Which I presume is a containter generated class implementing the home interface. To help confirm this,
the object has a property beanName that has the value "com.internal.server.Dispatcher".
The problem occurs on the next line, when I check whether I can cast the object to the home interface using ProtableRemoteObject.narrow(). This gives the following exception.
java.lang.ClassCastException
java.lang.Object com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
PortableRemoteObject.java:296
java.lang.Object javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
PortableRemoteObject.java:137
com.internal.server.Dispatcher com.Studio.servlet.intermediateServlet.getDispatcherRef(java.lang.String, java.lang.String, java.lang.String)
intermediateServlet.java:601
void com.Studio.servlet.intermediateServlet.init(javax.servlet.ServletConfig)
intermediateServlet.java:150
com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.loadServlet(com.evermind.util.ByteString)
HttpApplication.java:1669
com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.findServlet(com.evermind.util.ByteString)
HttpApplication.java:4001
javax.servlet.RequestDispatcher com.evermind.server.http.HttpApplication.getRequestDispatcher(com.evermind.util.ByteString, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse)
HttpApplication.java:2200
boolean com.evermind.server.http.HttpRequestHandler.processRequest(com.evermind.server.ApplicationServerThread, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
HttpRequestHandler.java:580
void com.evermind.server.http.HttpRequestHandler.run(java.lang.Thread)
HttpRequestHandler.java:243
void com.evermind.util.ThreadPoolThread.run()
ThreadPoolThread.java:62
Interestingly, if I use practically the same code, to obtain the home interface of an EJB that is defined in the application that I am debugging, the cast works perfectly. The returned object looks identical, apart from the name to the DispatcherHome_StatelessSessionHomeWrapper5 mentioned above.
Could the error possibly be because I need to declare 'Horus' as a parent application of the application I am debugging? If it is how do I do this?
Many thanks in advance for any help with this one.
Mark.(Jdeveloper version = 9.0.2.798, OC4J Application Server version = Oracle9iAS (9.0.2.0.0))
I am trying to debug a multi-tier application using the embedded application server. Servlets and EJBs within that application need to call EJBs contained within a second application (Horus).
I have set up the embedded application server to run this second application automatically by adding the following entry into its server.xml
<application auto-start="true" name="Horus" path="M:\Studio\build\production\java\Server\Obfuscate\J2EE_HOME\Horus\Horus.xml"/>
I then start the embedded application server by debugging my servlet project, 'intermediateServlet'. I know the second application is running correctly in the embedded application server because I can access it from a separate client.
In the 'intermediateServlet', I want to obtain a reference to a Dispatcher EJB held in the Horus application. This EJB has the following properties
ejb-name = com.internal.server.Dispatcher
home interface = com.internal.server.DispatcherHome
bean class = com.internal.server.DispatcherEJB
remote interface= com.internal.server.Dispatcher
The following code is executed during the container's call to my servlet init( context ) method to try and get the appropriate home interface.
Context context = null;
Object tempRemoteIF1 = null;
Object tempRemoteIF2 = null;
Properties h = null;
h = new Properties();
h.put( Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory" );
h.put( Context.PROVIDER_URL, "ormi://127.0.0.1:23891/Horus");
h.put( Context.SECURITY_PRINCIPAL, "user0" );
h.put( Context.SECURITY_CREDENTIALS, "password" );
context = new InitialContext (h);
tempRemoteIF1 = context.lookup( "com.internal.server.Dispatcher" );
tempRemoteIF2 = javax.rmi.PortableRemoteObject.narrow
tempRemoteIF1,
Class.forName( "com.internal.server.DispatcherHome" )
The context.lookup call seems to work fine, returning an object of the class
DispatcherHome_StatelessSessionHomeWrapper5
Which I presume is a containter generated class implementing the home interface. To help confirm this,
the object has a property beanName that has the value "com.internal.server.Dispatcher".
The problem occurs on the next line, when I check whether I can cast the object to the home interface using ProtableRemoteObject.narrow(). This gives the following exception.
java.lang.ClassCastException
java.lang.Object com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
PortableRemoteObject.java:296
java.lang.Object javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
PortableRemoteObject.java:137
com.internal.server.Dispatcher com.Studio.servlet.intermediateServlet.getDispatcherRef(java.lang.String, java.lang.String, java.lang.String)
intermediateServlet.java:601
void com.Studio.servlet.intermediateServlet.init(javax.servlet.ServletConfig)
intermediateServlet.java:150
com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.loadServlet(com.evermind.util.ByteString)
HttpApplication.java:1669
com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.findServlet(com.evermind.util.ByteString)
HttpApplication.java:4001
javax.servlet.RequestDispatcher com.evermind.server.http.HttpApplication.getRequestDispatcher(com.evermind.util.ByteString, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse)
HttpApplication.java:2200
boolean com.evermind.server.http.HttpRequestHandler.processRequest(com.evermind.server.ApplicationServerThread, com.evermind.server.http.EvermindHttpServletRequest, com.evermind.server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
HttpRequestHandler.java:580
void com.evermind.server.http.HttpRequestHandler.run(java.lang.Thread)
HttpRequestHandler.java:243
void com.evermind.util.ThreadPoolThread.run()
ThreadPoolThread.java:62
Interestingly, if I use practically the same code, to obtain the home interface of an EJB that is defined in the application that I am debugging, the cast works perfectly. The returned object looks identical, apart from the name to the DispatcherHome_StatelessSessionHomeWrapper5 mentioned above.
Could the error possibly be because I need to declare 'Horus' as a parent application of the application I am debugging? If it is how do I do this?
Many thanks in advance for any help with this one.
Mark. Try loading the home interface from the same classloader used to load the the returned home object.
tempRemoteIF2 = javax.rmi.PortableRemoteObject.narrow
( tempRemoteIF1,
tempRemoteIF1.getClass().getClassLoader().loadClass("com.internal.server.DispatcherHome" )
Dhiraj -
Class casting problems in JSP's
Folks,
Several people, including myself, have written about the problems they
ran into when trying to cast a class in JSP's. The following link might
provide the answer:
http://www.weblogic.com/docs51/classdocs/API_jsp.html#sessions
I believe this is a major limitation Weblogic put on web app
development, and hope BEA would eventually find a way to allow non-user
defined types being stored in servlet sessions.
Jeff
Folks,
Several people, including myself, have written about the problems they
ran into when trying to cast a class in JSP's. The following link might
provide the answer:
http://www.weblogic.com/docs51/classdocs/API_jsp.html#sessions
I believe this is a major limitation Weblogic put on web app
development, and hope BEA would eventually find a way to allow non-user
defined types being stored in servlet sessions.
Jeff
-
Describe non-generic array cast in JLS3 as being unchecked
This method :
static <T, U extends T> U[] cast(T[] a) { return (U[]) a; }will generate the warning: [unchecked] unchecked cast, found: T[], required: U[].
And it should. Wouldn't it be appropriate if
static Object[] cast(String[] a) { return (String[]) a; }would produce the same warning?
If you do that, you could translate the declaration
T[] at = new T[255]
String[] as = new String[255]into
Array<T> at = Array.<T>newInstance(255);
Array<String> as = Array.<String>newInstance(String.class, 255);where java.lang.reflect.Array would be something like
package java.lang.reflect.Array;
public final class Array<T> implements Iterable<T> {
public final int length;
private Type memberType;
private Array(Type memberType, int length) {
this.memberType = memberType;
this.length = length;
public native T getMember(int i);
public native void setMember(int i, T member);
public native java.util.Iterator<T> iterator();
public static <U> Array<U> newInstance(int length) {
return new Array<U>(null, length);
public static <U> Array<U> newInstance(Class<U> memberClass, int length) {
return new Array<U>(memberClass, length);Sorry, I created a bad example. It should have been:
static <T, U extends T> T[] cast(U[] a) { return (T[]) a; }and
static Object[] cast(String[] a) { return (Object[]) a; }The point is that an array of String is different from an array of Object and casts between them is unsafe. Throwing an ArrayStoreException if the wrong type is assigned is just a workaround for lack generic types in pre-Tiger Java. Now that we will have generics, I think it would be appropriate if Java arrays would be treated as proper generic types. For those that are afraid of breaking backwards compatiblility, the erasure mechanism should be able to take care of that. -
10gr2 TABLE(CAST( problem
We have an existing report that uses existing function to table cast back data in the from clause. A very simplified example:
FROM grant g, grantparticipant gt, table(cast(getSchedule(g.grant_pk, gt.grantparticipant_pk) as r_sched)) sched
where g.grant_pk = gt.grant_fk
and sched.grantparticipant_pk = gt.grantparticipant_pk
The grantparticipant_pk is NULL when captured in the function. There are no null values in the table (it's a primary key). When the where clause is changed to reference a specific pk it works fine and the value is filled in.
The works in our production db where the Oracle version is 10g. It works in development which is also 10g. The problem only appears to be with our 10gr2 DB.
Any ideas....The problem was solved with ANSI JOINs. Would still like to know why that problem occurred?
-
Generic delta has problem with delts pointer time stamp
Hi All,
We have generic delta data source with Delte pointer as Time stamp. We have not used any safety limits. We are loading the data to DSO and using Additive delta. But the problem is when delta flag is set, there might be a case where some records still being inserted to table with lower time stamp. These records are not being fetched in next delta.
We are planning to keep a safety upper limit of 5 min so that those records can not be missed. But we have a doubt as it is a Additive delta duplicate records will be loaded. If we make the delta to 'new status to changed records', it is going to work?? Any other things we have to check when we make this changes??
Thanks
HaarisHi
If you had selected additive delta then you can load data to DSo with addition mode only. No overwrite possible.
If you want to select new or changed status then you can load to DSO with overwrite mode only.
Additive or changed delta depends on your requirement because if you want to add data to the DSO then you can go ahead with additive otherwise you have to use DSO with overwrite mode only.
You can either give safety upper limit or lower limit but if you give safety lower limit then you can only load data to DSO with overwrite mode because there could be some duplicate records.
Hope it clarifies.
Regards
Sadeesh -
Shareable object interface cast problem
Hi,
I'm a student working on building a shareable object interface between two applets namely "EWallet" and "EPhone".
I currently use the javacard 2.2.X version and I mean to solve the shareable object interface in this version.
Thus not with servlets in 3.X.X.
The current problem I'm facing is the casting from the base type of shareable interface objects (Shareable) to the EWalletInterface which I need to do operations on the SIO of EWallet.
The code snippet of the EWallet applet (server)
public void verify(byte[] pincode) {
if ( pin.check(pincode, (short)0,(byte)(short)pincode.length) == false )
ISOException.throwIt(SW_VERIFICATION_FAILED);
public void debit(byte debitAmount) {
if (!pin.isValidated())
ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
// check debit amount
if ((debitAmount > MAX_TRANSACTION_AMOUNT) || (debitAmount < 0))
ISOException.throwIt(SW_INVALID_TRANSACTION_AMOUNT);
// check the new balance
if ((short)(balance - debitAmount) < (short)0)
ISOException.throwIt(SW_NEGATIVE_BALANCE);
balance = (short)(balance - debitAmount);
public Shareable getShareableInterfaceObject(AID client_aid, byte parameter){
byte[] ephone_aid_bytes = {(byte)0X15, (byte)0XEF, (byte)0X4D, (byte)0X55, (byte)0X86, (byte)0X60};
if(client_aid.equals(ephone_aid_bytes,(short)0,(byte)ephone_aid_bytes.length) == false)
return null;
if(parameter != (byte)0x01)
return null;
return this;
The code snippet of the EPhone applet (client)
//Helper method
private void makeBankcardDebit(short amount){
AID ewallet_aid = JCSystem.lookupAID(ewallet_aid_bytes,(short)0,(byte)ewallet_aid_bytes.length);
if(ewallet_aid == null)
ISOException.throwIt(SW_EWALLET_AID_NOT_EXIST);
//Error with casting from Shareable to EWalletInterface
EWalletInterface sio = (EWalletInterface)(JCSystem.getAppletShareableInterfaceObject(ewallet_aid, (byte)0x01));
if(sio == null)
ISOException.throwIt(SW_FAILED_TO_OBTAIN_SIO);
byte[] pin = new byte[4];
sio.verify(pin);
sio.debit((byte)amount);
this.balance = (short)(this.balance + amount);
The EWalletInterface code snippet
public interface EWalletInterface extends Shareable {
public void verify(byte[] pincode);
public void debit(byte amount);
The interface is currently both in the EWallet and EPhone packages.
The problem i'm facing is that in the code snippet of EPhone.
The "lookupAID"- and "getAppletShareableInterfaceObject"-methods work
The casting from Shareable to EWalletInterface gives me status word 0x6F00 which presents me with a google explanation of "No precise diagnosis".
Does anyone have an idea why the cast from Shareable to EWalletInterface doesn't work?
Thanks in advance,
JeroenHi,
What happens if you get the SOI reference and store in a Shareable and see if it is null? Just to confirm, the two applets are in different packages and the server applet has be installed and is selectable?
If you get 0x6F00, you should start adding try/catch blocks to find the root cause.
Cheers,
Shane
=================================
Reposting with {code} tags
=================================
Hi,
I'm a student working on building a shareable object interface between two applets namely "EWallet" and "EPhone".
I currently use the javacard 2.2.X version and I mean to solve the shareable object interface in this version.
Thus not with servlets in 3.X.X.
The current problem I'm facing is the casting from the base type of shareable interface objects (Shareable) to the EWalletInterface which I need to do operations on the SIO of EWallet.
The code snippet of the EWallet applet (server)
public void verify(byte[] pincode) {
if ( pin.check(pincode, (short)0,(byte)(short)pincode.length) == false )
ISOException.throwIt(SW_VERIFICATION_FAILED);
public void debit(byte debitAmount) {
if (!pin.isValidated())
ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
// check debit amount
if ((debitAmount > MAX_TRANSACTION_AMOUNT) || (debitAmount < 0))
ISOException.throwIt(SW_INVALID_TRANSACTION_AMOUNT);
// check the new balance
if ((short)(balance - debitAmount) < (short)0)
ISOException.throwIt(SW_NEGATIVE_BALANCE);
balance = (short)(balance - debitAmount);
public Shareable getShareableInterfaceObject(AID client_aid, byte parameter){
byte[] ephone_aid_bytes = {(byte)0X15, (byte)0XEF, (byte)0X4D, (byte)0X55, (byte)0X86, (byte)0X60};
if(client_aid.equals(ephone_aid_bytes,(short)0,(byte)ephone_aid_bytes.length) == false)
return null;
if(parameter != (byte)0x01)
return null;
return this;
The code snippet of the EPhone applet (client)
//Helper method
private void makeBankcardDebit(short amount){
AID ewallet_aid = JCSystem.lookupAID(ewallet_aid_bytes,(short)0,(byte)ewallet_aid_bytes.length);
if(ewallet_aid == null)
ISOException.throwIt(SW_EWALLET_AID_NOT_EXIST);
//Error with casting from Shareable to EWalletInterface
EWalletInterface sio = (EWalletInterface)(JCSystem.getAppletShareableInterfaceObject(ewallet_aid, (byte)0x01));
if(sio == null)
ISOException.throwIt(SW_FAILED_TO_OBTAIN_SIO);
byte[] pin = new byte[4];
sio.verify(pin);
sio.debit((byte)amount);
this.balance = (short)(this.balance + amount);
The EWalletInterface code snippet
public interface EWalletInterface extends Shareable {
public void verify(byte[] pincode);
public void debit(byte amount);
}The interface is currently both in the EWallet and EPhone packages.
The problem i'm facing is that in the code snippet of EPhone.
The "lookupAID"- and "getAppletShareableInterfaceObject"-methods work
The casting from Shareable to EWalletInterface gives me status word 0x6F00 which presents me with a google explanation of "No precise diagnosis".
Does anyone have an idea why the cast from Shareable to EWalletInterface doesn't work?
Thanks in advance,
Jeroen -
BW GENERIC EXTRACTION DELTA PROBLEM
I have a problem for extracting delta from R/3 to BW.
Init data is loaded from R/3 to BW system for ZST_ORDER datasource.
Repair full request and selection parameter is created on date August 1st 2007 to August15th 2007.
During the delta extraction - A lot of records around 500,000 records are getting extracting from R/3 to BW.
R/3 side - There is only 5 entries available in AUFK table.
It should extract delta only less than 35 entries.
ZST_ORDER is generic datasource . Delta captured field is DATUM -New status changed record value 2.
Advance Thx for your help. The code looks like
FUNCTION ZST_ORDER.
""Local Interface:
*" IMPORTING
*" REFERENCE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" REFERENCE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" REFERENCE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE DEFAULT 1000
*" REFERENCE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" REFERENCE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZST_ORDEROPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
TABLES: AUFK, "Order master data
TJ02T, "System status texts
TJ30T, "Texts for user status
JSTO. "Status object information
DATA DECLARATION
DATA: L_DATE TYPE DATS,
L_STATUS TYPE J_STATUS,
L_LINES TYPE SY-TABIX,
L_CHANGED(1) TYPE C.
Auxiliary Selection criteria structure
DATA: L_S_SELECT TYPE SRSC_S_SELECT.
Another data objects
Service Order Data
DATA: BEGIN OF LT_AUFK OCCURS 0,
AUFNR LIKE AUFK-AUFNR,
AUART LIKE AUFK-AUART,
ERDAT LIKE AUFK-ERDAT,
AEDAT LIKE AUFK-AEDAT,
STDAT LIKE AUFK-STDAT,
AEZEIT LIKE AUFK-AEZEIT,
ERFZEIT LIKE AUFK-ERFZEIT,
IDAT1 LIKE AUFK-IDAT1,
IDAT2 LIKE AUFK-IDAT2,
IDAT3 LIKE AUFK-IDAT3,
LOEKZ LIKE AUFK-LOEKZ,
OBJNR LIKE AUFK-OBJNR,
END OF LT_AUFK.
Individual Object Status
DATA: BEGIN OF LT_JEST OCCURS 0,
OBJNR LIKE JEST-OBJNR,
STAT LIKE JEST-STAT,
INACT LIKE JEST-INACT,
CHGNR LIKE JEST-CHGNR,
END OF LT_JEST.
***Change Documents for System/User Statuses (Table JEST)
DATA: BEGIN OF LT_JCDS OCCURS 0,
OBJNR LIKE JCDS-OBJNR,
STAT LIKE JCDS-STAT,
CHGNR LIKE JCDS-CHGNR,
USNAM LIKE JCDS-USNAM,
UDATE LIKE JCDS-UDATE,
UTIME LIKE JCDS-UTIME,
INACT LIKE JCDS-INACT,
CHIND LIKE JCDS-CHIND,
END OF LT_JCDS.
DATA: BEGIN OF LT_JSTO OCCURS 0,
OBJNR LIKE JSTO-OBJNR,
STSMA LIKE JSTO-STSMA,
END OF LT_JSTO.
STATIC FIELDS
STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
counter
S_COUNTER_DATAPAKID LIKE SY-TABIX,
cursor
S_CURSOR TYPE CURSOR.
User-defined Ranges
RANGES: L_R_AUFNR FOR AUFK-AUFNR ,
L_R_ERDAT FOR AUFK-ERDAT.
Initialization mode (first call by SAPI) or data transfer mode
(following calls) ?
IF I_INITFLAG = SBIWA_C_FLAG_ON.
Check DataSource validity
CASE I_DSOURCE.
WHEN 'ZST_ORDER '.
WHEN OTHERS.
RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDCASE.
Copy selection criteria for future extractor calls (fetch-calls)
APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT.
Fill parameter buffer for data extraction calls
S_S_IF-REQUNR = I_REQUNR.
S_S_IF-DSOURCE = I_DSOURCE.
S_S_IF-MAXSIZE = I_MAXSIZE.
S_S_IF-INITFLAG = I_INITFLAG.
APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.
ELSE.
First data package -> OPEN CURSOR
IF S_COUNTER_DATAPAKID = 0.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT
WHERE FIELDNM = 'AUFNR'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_AUFNR.
APPEND L_R_AUFNR.
ENDLOOP.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT
WHERE FIELDNM = 'ERDAT'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_ERDAT.
APPEND L_R_ERDAT.
ENDLOOP.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT
WHERE FIELDNM = 'DATUM'.
L_DATE = L_S_SELECT-LOW.
ENDLOOP.
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT AUFNR AUART ERDAT
AEDAT OBJNR AEZEIT
STDAT ERFZEIT IDAT1
IDAT2 IDAT3 LOEKZ
FROM AUFK
WHERE AUFNR IN L_R_AUFNR AND
ERDAT IN L_R_ERDAT.
ENDIF.
Fetch records into interface table LT_AUFK
FETCH NEXT CURSOR S_CURSOR
APPENDING CORRESPONDING FIELDS OF TABLE LT_AUFK
PACKAGE SIZE S_S_IF-MAXSIZE.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
Determining the number of lines of the table LT_AUFK .
L_LINES = LINES( LT_AUFK ).
IF L_LINES IS NOT INITIAL.
Sort the internal table LT_AUFK
SORT LT_AUFK BY OBJNR ASCENDING.
Selecting the records from JCDS depending upon the entries in LT_AUFK.
SELECT OBJNR STAT CHGNR USNAM
UDATE UTIME INACT CHIND
INTO TABLE LT_JCDS
FROM JCDS
FOR ALL ENTRIES IN LT_AUFK
WHERE OBJNR EQ LT_AUFK-OBJNR
AND ( CHGNR EQ '001'
OR UDATE >= L_DATE ).
Sort the internal table lt_jcds.
SORT LT_JCDS BY OBJNR STAT CHGNR ASCENDING.
Select records from table JEST depending upon the entries in LT_AUFK.
SELECT OBJNR STAT INACT CHGNR
INTO TABLE LT_JEST
FROM JEST
FOR ALL ENTRIES IN LT_AUFK
WHERE OBJNR = LT_AUFK-OBJNR.
SELECT OBJNR STSMA
INTO TABLE LT_JSTO
FROM JSTO
FOR ALL ENTRIES IN LT_AUFK
WHERE OBJNR = LT_AUFK-OBJNR.
SORT LT_JSTO BY OBJNR.
ENDIF.
LOOP AT LT_JEST.
CLEAR: LT_AUFK,
l_changed.
CLEAR L_CHANGED.
CLEAR LT_JSTO.
READ TABLE LT_JSTO WITH KEY OBJNR = LT_JEST-OBJNR BINARY SEARCH.
IF SY-SUBRC EQ 0.
E_T_DATA-STSMA = LT_JSTO-STSMA.
ENDIF.
*End**
Read the data from LT_AUFK.
READ TABLE LT_AUFK WITH KEY OBJNR = LT_JEST-OBJNR BINARY SEARCH.
E_T_DATA-AUFNR = LT_AUFK-AUFNR.
E_T_DATA-AUART = LT_AUFK-AUART.
E_T_DATA-ERDAT = LT_AUFK-ERDAT.
E_T_DATA-AEDAT = LT_AUFK-AEDAT.
E_T_DATA-AEZEIT = LT_AUFK-AEZEIT.
E_T_DATA-ERFZEIT = LT_AUFK-ERFZEIT.
E_T_DATA-IDAT1 = LT_AUFK-IDAT1.
E_T_DATA-IDAT2 = LT_AUFK-IDAT2.
E_T_DATA-IDAT3 = LT_AUFK-IDAT3.
E_T_DATA-LOEKZ = LT_AUFK-LOEKZ.
E_T_DATA-INACT = LT_JEST-INACT.
E_T_DATA-CHGNR = LT_JCDS-CHGNR.
e_t_data-datum = lt_aufk-erdat.
READ TABLE LT_JCDS WITH KEY OBJNR = LT_JEST-OBJNR
STAT = LT_JEST-STAT
CHGNR = '001'
BINARY SEARCH.
IF SY-SUBRC EQ 0.
E_T_DATA-UDATE = LT_JCDS-UDATE.
E_T_DATA-AEDAT = LT_JCDS-UDATE.
E_T_DATA-UTIME = LT_JCDS-UTIME.
E_T_DATA-AEZEIT = LT_JCDS-UTIME.
E_T_DATA-CHIND = LT_JCDS-CHIND.
E_T_DATA-USNAM = LT_JCDS-USNAM.
e_t_data-chgnr = lt_jcds-chgnr.
IF LT_JCDS-UDATE GE L_DATE
AND L_DATE IS NOT INITIAL.
L_CHANGED = 'X'.
ENDIF.
IF LT_JEST-CHGNR NE '001'.
CLEAR LT_JCDS.
READ TABLE LT_JCDS WITH KEY OBJNR = LT_JEST-OBJNR
STAT = LT_JEST-STAT
CHGNR = LT_JEST-CHGNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
L_CHANGED = 'X'.
E_T_DATA-AEDAT = LT_JCDS-UDATE.
E_T_DATA-AEZEIT = LT_JCDS-UTIME.
E_T_DATA-CHIND = LT_JCDS-CHIND.
E_T_DATA-USNAM = LT_JCDS-USNAM.
e_t_data-chgnr = lt_jcds-chgnr.
ENDIF.
ENDIF.
IF LT_JEST-STAT(1) EQ 'I'.
E_T_DATA-ISTAT = LT_JEST-STAT.
ELSEIF LT_JEST-STAT(1) EQ 'E'.
E_T_DATA-ESTAT = LT_JEST-STAT.
ENDIF.
IF L_CHANGED EQ 'X'
AND L_DATE IS NOT INITIAL.
APPEND E_T_DATA.
ELSEIF L_DATE IS INITIAL.
APPEND E_T_DATA.
ENDIF.
ENDIF.
CLEAR: LT_AUFK,
E_T_DATA.
ENDLOOP.
CLEAR LT_JEST.
REFRESH LT_JEST.
next data package
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
ENDIF. "Initialization mode or data extraction ?
ENDFUNCTION.hi,
for that quantity SALK3 is referring a different table in the reference field for your table fields. check that field and refer the correct table for that field in table view.
table join has a problem in that. i think your joined some other table with that field. replace the field assignment or create a new view.
hope this help you
regards
harikrishna N -
Magenta color cast problem on canon 7d raw files
when i import canon raw files (cr2) into lightroom 3, i get a magenta color cast over the whole image. the thumbnail image looks fine, but when lightroom opens up the image, it get's a magenta color cast over the whole thing. i shot raw+jpeg mode too, and there's a huge differnce in color between the two. the jpeg looks like how i shot it in camera but the raw image has the ugly magenta color. not only do i get this ugly color, but it seems like there's added noise compared to jpeg image.
i tried converting the cr2 into a dng. but when i open that in lightroom, i get the same problem.
i use aperture 2.1 (i only use the lr3 trial so far), but i have the same problem there.
i use cs3 but i downloaded cs5 trial.
acr i have is 6.1
help.
thanks.Go to develop and the callibration tab and change it in the pull down menu to a canon default like 'Neutral' and not the adobe one which is made by somebody totally colour blind or obviously a Nikon fan.
Although this is weird as the problem for me has always been canon JPG's with the cast and not the RAW.
Also check your white balance cause Lightroom seems to change it whatever.. 'AS SHOT' is a big fat Adobe lie so use a preset from your camera in the drop down box.. Why? I shoot with Canon's flash WB setting which i know to be 5500k with the tint at zero. On import, Lightroom changes it to 6150 and adds an amazing +7 on the magenta tint, if i chose 'FLASH' things suddenly turn to what i see on the camera LCD.. I'm sure that is where the big fat tint has come from since day one. -
Table
int id
string name
Tables extends table
Array<TableLinks> of children
TableLinks
Table rightTable
In flex, I get a list of Tables from my web service
Display a combobox with the list of Tables
Once someone selects from the list the list of TableLinks is populated in a datagrid
in the rightTable column it displays the rightTable.name in the label
When you edit the column a dropdownlist shows
<mx:DataGridColumn id="tableNameDC"
headerText="Table"
editable="true"
dataField="rightTable"
labelFunction="tableFormat"
editorDataField="value"
width="150">
Is there anyway to cast my Tables list to type Table here?
Currently, I keep the list as Tables
When you select and item the value is saved to a value object but casted from Tables to Table
When you exit the dropdownlist the get value function returns the Table value Object. But for some reason, it keeps telling me its null.
Its as if when I cast the Tables item to Table it fails.
public function get value():TableDto
return rightTableDto
protected function selectableDropDown_closeHandler(event:DropDownEvent):void
rightTableDto = selectableDropDown.selectedItem as TableDto;
So, if the first question is not doable, what do you think I am doing wrong?Hi,
You can use onClientSelect to trigger the javascript code.
Here is a sample code to trigger the javascript
<%String projectId="";%>
<hbj:dropdownListBox
id="projectIdDL"
width="110"
onClientSelect="getStages()">
<%projectId=myContext.getParamIdForComponent(projectIdDL);%>
</hbj:dropdownListBox>
<script>
var proid=document.getElementById('<%=projectId%>');
function getStages()
//code
</script>
Hope this will oslve your problem to trigger a javascript code when you select a value in DropdownListbox
Regards
Padmaja -
Output Parameter cast problems
Wondering if anyone has seen this ...
Migrating a data access layer (based on the MS DAAB) using the ODP.NET provider. I wrote my own parameter discovery code to dynamically configure parameters at runtime - just like the SqlCommandBuilder.DeriveParameters() method does for SQL Server sprocs.
(I query the "all_arguments" view to get this data, by the way, passing the package name and procedure name.)
Here's the problem: you cannot discover the Size property for a parameter via this query. Bummer. So for VarChar2 and Char types I tried setting the Size to somethng big, like 2000.
When I retrieve the parameters after an ExecuteNonQuery statement, I am getting Type cast errors:
"Cast from type 'OracleString' to type 'String' is not valid"
Here's the weird part:
- CType(params(5).Value, Integer) 'WORKS
- CType(params(2).Value, String) 'DOESN'T WORK
- params(2).Value.ToString 'WORKS
- CType(params(2).Value, Date) 'DOESN'T WORK
What the ...? Why can't I cast a VarChar2 or Char type back to a .NET String? Why does ToString work but Ctype() not work?
I hope somebody can offer guidance, I've got a lot invested in this DAL :-)
Thanks eh
Kurt Mang
Vancouver BCThere's not really an elegant way to provide these conversions in VB. In C# OracleString uses operator overloading to provide type conversions, but this version of VB doesn't support it.
They might have implemented IConvertible on the oracle types.
Then you could write
Dim osw as new OracleString("Hello")
Dim s as String = CType(osw, IConvertible).ToString
But that's not really better than
Dim osw as new OracleString("Hello")
Dim s as String = osw.Value
The long and short of it is, OracleTypes ( and other ADO.NET provider types), are special high-performance types (usually value types), and they convert using a different idiom. By convention they are converted to the corresponding framework type using a property called .Value, and constructed from framework types using a constructor.
String s = New OracleString("Hello").Value
Converts the Unicode string "Hello" to an OracleString structure, and then back to a unicode string.
David -
Object view multi-cast problem
We are using the following object to generate XML the output for multi=cast is prodicing an unwanted extra tag "*_ITEM"
Any ideias??
CREATE OR REPLACE VIEW sjs.arrest_obj_view
AS SELECT CAST(MULTISET(SELECT 'ERROR NEEDED ' FROM dual) AS errors_type) AS "Errors",
a.a_date AS "ArrestDate",
NVL(a.a_photo_num,'NULL') AS "PhotographNumber",
NVL(a.a_division,'NULL') AS "AgencyDivision",
'MODEL MAPPING PROBLEM' AS "ArrestType",
NVL(agcy.agcy_ori,'NULL') AS "ArrestingAgency",
a.a_id AS "ArrestNumber",
NVL(oa.o_number,'NULL') AS "ArrestingOfficerID",
NVL(o.o_number,'NULL') AS "AssistingOfficerID",
'MODEL MAPPING PROBLEM' AS "AssistingAgency",
'MODEL MAPPING PROBLEM' AS "CJTN",
CAST(MULTISET(SELECT l.lu_name AS "Weapon"
FROM sjs.arrestweapons awm,
sjs.lookuptable l
WHERE awm.a_id = a.a_id
AND awm.weapons_id = lu_id (+)) AS arrest_weapons_type) AS "ArrestWeapons"
FROM sjs.arrest a,
sjs.agency agcy,
sjs.officers o,
sjs.officers oa
WHERE a.agcy_id = agcy.agcy_id (+)
AND a.o_arrest_id = oa.o_id (+)
AND a.o_assist_id = o.o_id (+)
- <ROWSET>
- <ROW num="1">
<InterfaceTransaction>ADD</InterfaceTransaction>
<Resubmission>RESUBMISSION NEEDED</Resubmission>
<SubmittingAgency>NY1111111</SubmittingAgency>
<SubmittingEmployeeID>FFOTI</SubmittingEmployeeID>
<TOT>TOT NEEDED</TOT>
- <Errors>
- <Errors_ITEM>
<Error>ERROR NEEDED</Error>
</Errors_ITEM>
</Errors>
<ArrestDate>3/18/2002 9:40:0</ArrestDate>
<PhotographNumber>PPPPP</PhotographNumber>
<AgencyDivision>PPP</AgencyDivision>
<ArrestType>MODEL MAPPING PROBLEM</ArrestType>
<ArrestingAgency>NY1111111</ArrestingAgency>
<ArrestNumber>1</ArrestNumber>
<ArrestingOfficerID>NULL</ArrestingOfficerID>
<AssistingOfficerID>NULL</AssistingOfficerID>
<AssistingAgency>MODEL MAPPING PROBLEM</AssistingAgency>
<CJTN>MODEL MAPPING PROBLEM</CJTN>
- <ArrestWeapons>
- <ArrestWeapons_ITEM>
<Weapon>FULLY AUTOMATIC RIFLE OR MACHINE GUN</Weapon>
</ArrestWeapons_ITEM>
- <ArrestWeapons_ITEM>
<Weapon>FIRE/INCENDIARY DEVICE</Weapon>
</ArrestWeapons_ITEM>
</ArrestWeapons>
</ROW>
</ROWSET>How would you replace the multi-cast within the object with cursor?
Thanks -
Having some problems casting, or converting, and I'm not really sure why!
Here is a code snippit, with the problem line commented.
public void focusLost(FocusEvent focEvent) {
Field[] aField = this.getClass().getDeclaredFields();
Method[] aMethod = myEr.getClass().getDeclaredMethods();
for(int e = 0; e < aField.length; e++) {
if(aField.getClass().toString().equals("javax.swing.JTextField")) {
//This next line isn't quite working! :(
JTextField tempField = ((JTextField)aField[e]);
for(int q = 0; q < aMethod.length; q++) {
if(aMethod[q].toString().contains("set"+aField[e].toString())) {
aMethod[q].invoke(myEr, tempField.getText());
}I've also tried not using tempField and instead trying something like (JTextField)aField[e].getText();
Though I've been using java for a while now for school and just to write little apps casting has always been something I've never really studied enough to figure out why I'm having a problem. I've tried google but can't find very good information on this, and the java API docs really don't give much about object conversion, but instead talk more of primitive casting, etc (unless I'm looking in the wrong places)
Thanks in advance!Thanks Ron, I'll check out the API on that. The name's Monica.Oops, sorry!
Also, where would I want to use this instanceof
operator? If I try to use aField[e] instanceof
JTextField it won't work because aField is of type
field, and aField[e].getClass() or .getType() are
dynamically determined (and it the api said itwon't
work on those).instanceof is also dynamic.Heres what happens when I try that
/home/untwisted/sahtbidb/src/gui/sah/Er.java:455: inconvertible types
found : java.lang.reflect.Field
required: javax.swing.JTextField
if(aField[e] instanceof JTextField) {
Maybe you are looking for
-
CS5.5 InDesign is unresponsive when opened
I have Adobe CS5.5 Creative Suite, and all the programs work fine except for InDesign since the first time I tried opening the program. InDesign starts up and opens to a new page, but then suddenly freezes and is unresponsive and have to force quit.
-
Illustrator Running Slow on New Haswell CPU
Hi, I Have come across a very strange issue. After Upgrading a system for a client form an Ivy Bridge to Haswell Illustrator is running considerably slower. The rig is the same as before we only changed CPU and Motherboard. The Rig is Windows 7 Pro
-
songs in itunes wont play right ... its all fuzzy and you can hear every other word .. but it only happens in itunes ... windows media player sounds fine help? Windows XP
-
Updating consignment Purchase Order history.
Hi Gurus, I understand there's a constraint in SAP where a consignment PO history will not be updated at PO history during invoice settlements with the vendor. Is it possible to do update a consignment PO history with invoice update? ..Are there any
-
My imessage isnt working sending photos
My imessage is working fine sending text, but it wont send photos. It tells me that the photo is delivered and then minutes later it will say it's not delivered?