on 09-18-2006 8:23 AM
Hi All,
in my Web Dynpro Application I can create an entity in an existing entity service. I can do that with the following code:
AChangeDescriptionDB db = ChangeDescriptionDBServiceProxy.create();
db.setProcessID(processID);
db.setTitle(actualTitle);
db.setType(wdContext.currentContextElement().getType() );
...
db.getAspect().sendChanges();
But how can I update or delete an entity?
Should be possible, but I dont found out a way?
Thanks in advance
Steve
Hello Steve,
The update is performed like a create, except that you already have the Entity from a findBy() or through relationship navigation.
Example:
db.set..
db.set..
db.getAspect().sendChanges();
The delete is performed by calling removeAspectRow().
Example:
db.getAspect().removeAspectRow(db);
db.getAspect().sendChanges();
Regards,
Austin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Austin,
The code to get the aspect instance using findBy is as follows:
IAspect tempAspect = ChangeDescriptionDBServiceProxy.findBy(arg0, arg1,...);
If(tempAspect != null){
Iterator itr = tempAspect.iterator();
while(itr.hasNext())
AChangeDescriptionDB db = (AChangeDescriptionDB) itr.next();
.......
}
You can use any other method for looping if you want to retrieve the entire list.
If you want to retrieve a specific element from the available rows you can directly retrieve it as follows:
AChangeDescriptionDB db = (AChangeDescriptionDB)tempAspect.getAspectRow(0);
Hope this helps.
Regards,
Suparna
Hi Suparna,
I work with your second solution.
But the down-cast you mentioned is not working (or possible), it raised an errorevent.
AChangeDescriptionDB db = (AChangeDescriptionDB) itr.next();
AChangeDescriptionDB db = (AChangeDescriptionDB)tempAspect.getAspectRow(0);
In my mind I thought of an solution with a findby-method like findByUniqueKey(uniquekey) and then I got only one aspect row.
But its important cause my application is working now, its only for better code understanding.
Bye Steve
Hi Steve,
Which code are you using? As far as I can understand from your reply, its
code line 1: <i>IAspect tempAspect = ChangeDescriptionDBServiceProxy.findUniqueKey(uniqueKey);</i>
//This returns you only one record. So you do not use the iterator but directly get the first row as follows
code line 2:
<i>if(tempAspect!=null){
AChangeDescriptionDB db = (AChangeDescriptionDB) tempAspect.get(0);
....
}</i>
Can you please confirm if this code line 2 where you are typecasting is giving you the error? I am confused because you have mentioned 2 codes from 2 different scenarios, itr.next() for list and .getAspectRow(0) for single record. Or is it like both these cases throw error when you use them separately?
Here I have to mention that you must have added public part default of DC tc/col/api (compartment
SAP_JTECHS) in order to use the code for "IAspect".
Please let me know the error. Also, please mention the version of NW2004s that you are using.
Regards,
Suparna
Message was edited by: Suparna Deb
Hi Suparna,
sorry for the delay.
First i cannot find the method findByUniqueKey(uniqueKey).
Your question:
I used the two codelines seperatly for testing out.
AChangeDescriptionDB row = (AChangeDescriptionDB)aspitr.next();
is not working, raises an event.
AChangeDescriptionDB db = (AChangeDescriptionDB) asp.get(0);
works fine, sorry my fault.
Thanks STeve
Hi Steve,
Instead of the entity servce's create method I'm trying to call a custom create method of the CAF application service from Web Dynpro using the Web Dynpro model of the CAF project. In the custom create method of the App service I've an complex entity as input and a long as output. But the call
AEntity = (AEntity) AppServiceProxy.addData();
doesn't take any input parameter (the complex entity) and doesn't return the long also. And while executing this I'm getting an exception "Query with name addData() doesn't exists".
Ofcourse I've AEntity.sendChanges() and serviceFacade.save() after setting the attributes to the AEntity. But it seems the App service's create method call is not successful.
Please suggest if anyone have overcome this issue.
Thanks & Regards,
Dipankar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.