cancel
Showing results for 
Search instead for 
Did you mean: 

Data I/O in Client side in MI

Former Member
0 Kudos

Hi ,

Can you tell me how Data Persistence API is used to store data in SAP . I have developes a JSP page then I need to store the data in the MI client database how can this be done . I am seeing options avilable are like JDBC, File System , Bytearray .

I Would like File system to be implemented since I am new to Java I would like to

have a file system .. Can anyone help me how to proceed on this ..

Regards

Abhilash

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Abilash

Inorder to persist your data on the MI Client, you can use the persistence API's exposed by the MI Framework. For API documentation refer to <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/21eba3a7-0601-0010-b982-92f1fca3258a">Online MDK</a> . Under this go to API references in the index and here you can use the APIs available under packages <i><b>com.sap.ip.me.api.persist</b></i>.* Refer to the persistence examples available in the same link (Persistence Example JSP) inorder to know what APIs you need to use and also how effectively you can use these APIs.

Hope this helps.

Best Regards

Sivakumar

Former Member
0 Kudos

Hi Sivakumar ,

I am new to the entire setup . Can you help me with the Step by step process to do the MI clientsetting . MDK seems to be bit high standarad guy who has only basic idea of java ..

I hava JSP page with me .. with 2 filed and a submit button . I have SyncBOC developed in the server side .. I need to invoke the JSP page in mobile and store data in the local database and later on syncronise it to Server side ..

Can you help me in proceedign on this

Regards

Abhilash

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Abhilash,

Check this blog ..

/people/kishor.gopinathan/blog/2006/05/29/smart-sync-application-development-using-sp-09v-of-developer-studio

Check out if this is useful to you..or else wait for our article to be published

Hope this helpful

Cheers,

Karthick

Former Member
0 Kudos

Hi Abhilash,

MI client Framework is based on MVC Architecture.

Modal- JavaBeans

View - JSP

Controller-Servlet

When we create the Smart Sync project using Netweaver developer studio, five java files are

generated.

Constants: All Program constants are defined here.

SmartSyncServlets:Central servlet that receives http request evaluates user action, requests table data from TableContentProvider, fills TableViewBean with this data and dispatches to JSP.

TableViewBean: Bean used for data transport between servlet and JSPs.

SmartSyncDBAccess: All calls into Smart Sync API are done here and used for storing/retrieving the data from/to the backend.

TableContentProvider:Acts as a mediator between the TableView bean and SmartSyncDBAccess. Packs the data it requested from SmartSyncDbAccess into a Vector that matches the form of the JSP table

All the Jsp's created has to be decalared in the constants

Example: String JSP_CREATE_ROOM="/jsp/create_room.jsp";

All the Events has to be decalared in Conatants

Example : String EVENT_CREATESYNCBOSELECTED="createSyncBos";

Whenever the event occurs, that should hit the Servlet and request the data to/from SmartSyncDBAccess through TableContentProvider. These data is transported from the Servlet to JSP through TableViewBean.

For Example: if you Save any data in the JSP, An Event occurs hence Servlet is called, which inturn calls and stores the data in SmartSyncDBAccess through TableContentProvider.

SmartSyncDBAccess uses MI API to store the data. please refer this link

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/21eba3a7-0601-0010-b982-92f...

Hope this is helpful

Thanks & Regards,

Lakshmi

Former Member
0 Kudos

Hi ,

Can you explain little bit in detail on how the database storage and acess happens .. Do I need JDBC connection to be set up or the file ..if it is file will this database mapping happen automatically

Regards

Abhilash

Former Member
0 Kudos

Hi Abhilash,

When you click the save in the JSP, an event occurs and Servlet is called. Take the request(which as data) in servlet and give the data to smartsyncDBaccess through Tablecontentprovider.

Example code to create the instance of syncBo in client (this code is written in smartsyncDBAccess)

// first an empty synbo is created and than the values are set

public void addRowInDB(String syBName, String[] newValues)// newValues is your data and syBName is your SyncBO name

{

String syncBoName = syBName;

SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor(syncBoName);

SmartSyncTransactionManager transactionManager;

// Create new syncbo

SyncBo newsyncBo = dataFacade.createEmptySyncBo(sbd);

// A transaction manager is valid for one action starting with beginTransaction and ending with commit/rollback

// In this example we commit (save) every row we add - no rollback.

transactionManager = dataFacade.getSmartSyncTransactionManager();

transactionManager.beginTransaction();

for (int i = 0; i < arrayHeaderFieldNames.length; i++) {

if (newValues<i> != null) {

setHeaderFieldValue(

newsyncBo,

arrayHeaderFieldNames<i>,

newValues<i>);

}

}

dataFacade.insertSyncBo(newsyncBo);

//Commit the transaction

transactionManager.commit();

}

you can use other logic also. This is just a sample code.

Hope this is helpful.

Best regards,

Lakshmi

Former Member
0 Kudos

Hi Lakshmi ,

Thanks for the reply.. DO you have any link .. for this part so that I can see a bit more detailed explanation .. How are the key fields determined while the storage of data happens .. and the retrevial code also ?

Regards

Abhilash

Former Member
0 Kudos

Hi Abhilash,

Sorry i am not aware of any such links. But Please refer this link https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/21eba3a7-0601-0010-b982-92f.... Here in "Go and Create" you have Smart Sync Example JSP war file. That would be helpful to know how it works.

Hope this is helpful

Best regards,

Lakshmi

Former Member
0 Kudos

Hi Lakshmi ,

As I told I am new to JSP .. I have generated the five file in NDS .. and written the code .. can you tell me how should I execute the same .. how does the JSP page gets called initally ...

Regards

Abhilash

Former Member
0 Kudos

Hi Abhilash,

You have to generate the war file and upload it in NWA/Webconsole then assign it to the client and sync. you will be able to see the application(jsp) on the client.

Best Regards,

Lakshmi

Former Member
0 Kudos

Hi ,

Can you get me any documentation on this

Regard

Abhilash

Former Member
0 Kudos

If use a Data Persistence API do the I/O file will it get configured automatically? ( I read in a thread) .. How will the whole integration happen in the client side happen I mean integration happen with SyncBOc and with my JSP page happen