cancel
Showing results for 
Search instead for 
Did you mean: 

iPad - SUP connection questions

Former Member
0 Kudos

Hi there,

trying to undertand better the ways of using SUP Generated Code API in my on-going iPad dev.

The current situation is that I've got a button triggering the local db deletion and connection to SUP to retrieve new data.

this is done with code from SUP tutorial documents :



	SUPConnectionProfile* cp = [EHSIALMobile100_EHSIALMobile100DB  getSynchronizationProfile];
	[cp setDomainName:@"default"];
    	
    if([EHSIALMobile100_EHSIALMobile100DB databaseExists]) 
		[EHSIALMobile100_EHSIALMobile100DB deleteDatabase]; 
	[EHSIALMobile100_EHSIALMobile100DB createDatabase];	
    
    
	//Register a callback handler. 
	CallbackHandler *databaseCH = [CallbackHandler getInstance]; 
	[EHSIALMobile100_EHSIALMobile100DB registerCallbackHandler:databaseCH];
	
	//Start backgroundsynchronization.
	[EHSIALMobile100_EHSIALMobile100DB startBackgroundSynchronization]; 
	
    
	NSInteger stat = [SUPMessageClient start];

    BOOL shouldWait = YES;
    long sleepTime =1;
    long timeout = 80;
    
    while (shouldWait && (sleepTime < timeout)) {
        shouldWait = [SUPMessageClient status] != STATUS_START_CONNECTED;
        if (shouldWait) {
            [NSThread sleepForTimeInterval:0.2];
        }
        if (sleepTime < timeout) {
            timeout = timeout - sleepTime;
        }
    }if (shouldWait) {
        
        NSLog(@"SUPMessageClient start failed");
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SUP unreachable" 
                                                        message:@"SUPMessage Client is un reachable" delegate:self cancelButtonTitle:@"OK"
                                              otherButtonTitles: nil];
        [alert show];	
        [alert release];
        [SUPMessageClient stop];
        return;
        
    }
    
    [EHSIALMobile100_EHSIALMobile100DB beginOnlineLogin:@"supUser" password:@"s3pUser"];
    
	while([EHSIALMobile100_EHSIALMobile100DB getOnlineLoginStatus].status == SUPLoginPending)
        {
        [NSThread sleepForTimeInterval:1];
        }
    
    while ([EHSIALMobile100_EHSIALMobile100DB hasPendingOperations]) {
              [NSThread sleepForTimeInterval:1];
    }
    
	// After this, the status will be either SUPLoginSuccess or SUPLoginFailure
	if([EHSIALMobile100_EHSIALMobile100DB getOnlineLoginStatus].status == SUPLoginSuccess)
        { 
            [EHSIALMobile100_EHSIALMobile100DB subscribe];
        }
    
    // Wait for imports to come back from server
    while([databaseCH importSuccessCount] < 1)
        NSLog(@"Import unsuccessfull");
    [NSThread sleepForTimeInterval:1.0];    
}

The import works perfectly on device but I'd like to have more control on that. here are different questions I'm asking myself concerning that :

1) I'd like to check if the connectivity is ok before deleting the local DB ?

When using the code above the locale db is deleted before launching SUPMessageClient start. It is recommended to do that in the documentation BUT, if the connection does not succeed, the locale db is empty and the iPAd app can not be used anymore. IS there a way to check connectivity before launching the sync process ?

2) On the other hand, I've got a method creating new elements and I'm calling submitPending, but nothing happens in terms of update to the server. Should I do a subscribe to the package each time I want to interact with the remote SAP server ?

Accepted Solutions (0)

Answers (2)

Answers (2)

Herwig
Explorer
0 Kudos

Hi,

sorry for the long delay - but didn't check the forum frequently lately:

Maybe I could help answering your questions:

1) Although the tutorial source code example sugests, you don't have to delete the SUP-database on the iphone client at all. Also, you don't have to renew the SUP subcription every time launching the client application.

I've build an application, where I've a separate thread which does the synch jobs in the background. When it runs the very first time, it creates the database and subcribes the SUP package. Afterwards, only synchronisation is done with SUP.

2) Before you can successfully submit CRUD operations from the iphone client, you should check in Unwirde Workspace, if the corresponding CREATE (UPDATE, DELETE) operation with the ERP backend is working properly (you can test the operations from Unwired Workspace. I've observed, that the JCO-connection to SAP ERP RFC connections doesn't work (e.g. depending on JCO-version, I guess) if the INPUT/EXPORT structures contain SAP datatypes like DATS. Thus I've switched from RFC connections to Webservices, which you can easily create from the corresponding RFC).

Hope I could help a bit, best regards

Herwig

Edited by: Herwig Stecher on Jul 4, 2011 3:07 AM

Former Member
0 Kudos

Hi Herwig: with regards to your response which I have copied below:

1) Although the tutorial source code example sugests, you don't have to delete the SUP-database on the iphone client at all. Also, you don't have to renew the SUP subcription every time launching the client application.

I've build an application, where I've a separate thread which does the synch jobs in the background. When it runs the very first time, it creates the database and subcribes the SUP package. Afterwards, only synchronisation is done with SUP.

If I have the results of e.g. bapi_salesorder_getlist from the unwired server onto the local iPhone database,

is there a way to search within that resultset using the local database?

Herwig
Explorer
0 Kudos

Hi again,

yes, you can search for records in the local (iPad) database. Contrary to Apple's core data you don't have to use predictives but you have to define the query for a database search on the SUP. When modelling the attributes of your MBO in the Unwired Workspace, you can define the syntax of the query on right-most tabsheet (named "Object Queries"). The "findAll" and "findByPrimaryKey" query are the 2 default ones.

For instance, if you have a MBO called "TimeRecord", a query could look like:

SELECT x.* FROM TimeRecord x WHERE x.WBS_ELEMENT = :wbsNumber AND x.WORKDATE = :Workdate

where you have to define the parameters wbsNumber and Workdate which are mapped to the MBO-fields WBS_ELEMENT and WORKDATE respectively. The name of the query could be LookForTimerec

In xCode you can now simply type:


objTimeRecordList* timerecordlist = [objTimeRecord LookForTimerec:wbsElement withWorkdate:workDate];

where wbsElement and workDate are Objective-C variables (which you have to define).

objTimerecord is the class-Name of the MBO and objTimeRecordList is the SUPObjectList of Timerecords: both objects will be generated by SUP and are imported with the source code into your xCode project.

During runtime, the variables wbsElement and workDate will be mapped onto the query-parameters wbsNumber and Workdate.

Best regards

Herwig

Former Member
0 Kudos

Hi Herwig, thanks a million. I have not tried your recommendation as yet, but seems very logical and doable to me.

Could you please update your answer at this thread that I had created as a question?

(I would like to assign you points; I can do so in that thread.)

Former Member
0 Kudos

Hi,

I don't have an answer for you but could you please post the url of the tutorial you are using?

Thanks a lot,

Alex