cancel
Showing results for 
Search instead for 
Did you mean: 

Query to find number of SyncBOs

0 Kudos

Hello All,

I have a requirement to find the number of SyncBOs (of a particular SyncBODescriptor type) present in the db. I need two numbers - one for number of SyncBOs with status GLOBAL and another with status LOCAL.

I understand that there's an API SmartSyncQueryFactory which I could use to perform queries. But now, I am slightly confused as to how do I use this API for my requirement because most of the methods in this Interface accept Field / Row descriptors as parameters while I need to base my query on the SyncBO status. Also, the SyncBO must be of the particular SyncBODescriptor type.

Any ideas to tackle this?

I hope that the problem explanation above is clear enough.

Best Regards,

- Sandeep.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Thanks for your replies Rahul & Prashanth.

However, there is still more to the problem. As I had mentioned, I need to find the number of SyncBOs with status GLOBAL & LOCAL.

Now I guess this can be achieved with the solution proposed by Rahul simply by including a check in the iteration. But its needless to say the loss in performance that would ensure.

Considering the solution proposed by Prashanth, I still have a problem in creating a condition for my query because I need a condition that checks the status of the SyncBO as GLOBAL or LOCAL. But in SmartSyncQueryFactory API, the methods for creating condition accept only row / field descriptors as I had mentioned in my earlier post. Is there any other API which I could use to form a query using the SyncBO status as a parameter ?

Thanks in advance.

Best Regards,

- Sandeep.

prashantha_hj
Employee
Employee
0 Kudos

Hi Sandeep,

The status of the SyncBOs can be obtained only by SyncBo instances by calling getStatus() method on each SyncBO. This is because, the status information is stored by MI in a system field. And this information is not exposed to the application with any api from persistence layer directly. So you have to create an instance of SyncBO to obtain this information. You can implement it and may check for the perfomance, it may be in acceptable range also.

I think, you have to use Rahul's method (with if condition in the loop) to solve your problem.

Regards,

Prashanth

Former Member
0 Kudos

hi sandeep,

currently there's no API that can satisfy your requirements at the moment. as a

workaround you can either:

1) retrieve all the SyncBo instances first, iterate on them checking on their

StatusType via getStatus if it is LOCAL or GLOBAL (as what had been suggested).

the only trade off is that all your SyncBo instances will be created and this

consumes memory and processing time.

2) other way is to use the SyncBoDataFacade.size method.

all downloaded GLOBAL SyncBo instances count can be queried with a condition

(SyncKey>=100000) via the size(Query) method. then you can then use

getSyncBos(Query) to get all SyncBos having SyncKey<100000 and iterate on

the collection to check on their status. this way, we're only iterating in a smaller

set of data i.e. only those SyncBos having smaller synckey values.

3) another way is to use a symantec key field of your SyncBo's top row if you have

such field e.g. the PERSNUMBER in the contact address sample (MEREP_PERSON).

since a symantec field will only be assigned once a SyncBo is inserted into the

backend, GLOBAL syncbos' symantec field will have a non-empty value. thus you

can query their count via the size method using condition SemanticField !="" or

SemanticField>0 depending the field type. for LOCAL i.e. those not uploaded to

the MI server yet, condition will may be SemanticField ="" or SemanticField = 0 or <-1...

4) is to use the implementation classes for calling the persistence layer directly.

however this requires deep understanding of the framework and is not recommended

since implementation classes might change in the future.

#3 is the fastest and the most accurate I guess. since statusType has a type of

IN_SYNC, you which is this case, it is still local...

just let me know if something's not clear.

regards

jo

Answers (3)

Answers (3)

0 Kudos

Thanks for your replies Prashanth & Jo.

I also think that option # 3 would be a good solution to my requirement - thanks for suggesting that Jo. I will definately try it out.

Best Regards,

- Sandeep.

prashantha_hj
Employee
Employee
0 Kudos

Hi Sandeep,

SyncBoDataFacade has a method called size(Query query) which returns the number of business objects returned by the query.

You can use SmartSyncQueryFactory for creating the query required for it.

there is an API createQuery(SyncBoDescriptor syncBoDescriptor, Condition condition) which returns a Query object.

I think this is more performant than the one explained by Rahul,

You can still use the method described by the Rahul also. If so, do not use the loop, rather there is a method called size() on the SyncBoCollection.

Regards,

Prashanth

Former Member
0 Kudos

Hi,

Try this:

1. private static SyncBoDataFacade dataFacade;

2.

dataFacade.getSyncBos(SyncBoDescriptor syncBoDescriptor)

Returns a static collection (SyncBoCollection) of all SyncBo objects for the specified SyncBoDescriptor from the repository.

3.

SyncBoCollection.iterator()

Returns the iterator of the SyncBo entities in this SyncBoCollection.

4. Use

while(iterator.hasNext())

i++;

return i -->No. of syncBos.

Hope this helps.

Rgds,

Rahul

Disclaimer: I am ABAP developer exploring the MI client only from past few days.