cancel
Showing results for 
Search instead for 
Did you mean: 

SyncBO Connectivity from JSP

Former Member
0 Kudos

Hi All,

I have developed BAPI Wrappers and using that i have created SyncBo of type Upload.

After generating meRepMeta.xml file i have imported it inot NWDS.

By doing this i got

<b>detail_syncboinstance.jsp

overview_syncboinstances.jsp

overview_syncbonames.jsp</b>

Now what im trying to do is , as per my requirement i have created JSP files i.e

firstJSP gets some input and when i press on 'Next' button calls secondJSP after entering some other fields and submit i have to call the SyncBO and run the Bapi wrapper.

Pl. suggest how to attain this.

Rgds,

Kiran Joshua

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kiran,

You can define your MVC architecture.You need to define certain classes like controller,DAO and JSP's.Then you can create your own customized application.Please check the MDK Link for MI Api's and some smartsync examples are also givcen for reference.

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

Also check this thread.

Thanks

Regards

Devendra

Former Member
0 Kudos

Thank you Devendra,

My question is after displaying of JSPs when i click on Save button , onclick of the save button wat shud i do..

how to call the syncbo which i have created..and how does this scenario run...how are Controllar and DBA classes involved.

Rgds,

Kiran Joshua

Former Member
0 Kudos

HI Kiran,

You can define some events on click of the submit button and Then you can define that event in your controller class.Which in turn should call your DAO class.

In your DAO class you have to write queries to fetch data using row descriptor and field descriptor and MI Api's.

Thanks

Regards

Devendra

Former Member
0 Kudos

Hi Devendra,

>>>Which in turn should call your DAO class.

>>>In your DAO class you have to write queries to fetch data using row descriptor >>>and field descriptor and MI Api's.

I want to know how this can be achieved thru coding.Can you pl. provide me the code snippet.How the syncBo is called and utilized..

Rgds,

Kiran Joshua

Former Member
0 Kudos

Hi Kiran,

You must have got the MeREpMeta.XML file which holds the Sync BO structure.

After this you need to call certain Smart Sync API for accessing the SyncBO fields.

Here is a code Snippet which will give u a clear picture:

SyncBoDescriptorFacade descriptorFacade =SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade();

SyncBoDescriptor boDescriptor = descriptorFacade.getSyncBoDescriptor("SyncBOName");

SyncBoDataFacade dataFacade=SmartSyncRuntime.getInstance().getSyncBoDataFacade();

SyncBo newSyncBO= dataFacade.createEmptySyncBo(boDescriptor);

RowDescriptor Tow = boDescriptor.getTopRowDescriptor();

Row syncboHead = newSyncBO.getTopRow();

syncboHead.setFieldValue(FieldName,FieldValue);

dataFacade.insertSyncBo(newSyncBO);

You need to write this code in your DAO class , and this DAO class will be called in your Controller class.

Regards

Priya Ghosh

Former Member
0 Kudos

Hi Priya,

I started feeling my problem will have some solution seeing ur reply.

Now my scenario is i developed some jsps under <b>app-root/jsp</b> folder.

When i enter some text in the field and press Submit button,

How do i connect with smartsync process.

How do i pass this entered input as the import parametr to the BAPI so that it will post some material document.

Im using Synbo of type U01 Upload.

How do i really connect these all to happen one after the other..

As i have imported the merepMeta.xml file these lines are already present in my code.

Regards,

Kiran Joshua

Former Member
0 Kudos

Hi Kiran,

Upload(U01) type of SyncBO is one directional syncBo. You can only create the record from client. When you Sync from the client, this data resides in backend and will not come to the client again. If you want that data back in client then you have to use T01/S01 type of syncBo to retrieve.

Example code to create the SyncBo Instance on your code. This is not the only code, there are different logic's you can use.

This is the code generated by NWDS, You can see this code in your SmartSyncDBAccess java file.

public void addRowInDB(String syBName, String[] newValues)

throws SmartSyncException, PersistenceException {

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();

}

Here syBName = your SyncBOName

newValues [] = Values given in your Create JSP

You have to define this event in Servlet. This servlet calls TableContentProvider and then TCP calls SmartSyncDBAccess.

Hope this helps

Best Regards,

Lakshmi

Former Member
0 Kudos

Hi Kiran,

when you hit the submit button, you call an event say "Submit"

Now if you take a look into your servlet class , there will be various events defined in that, here you map this "Submit" event and in the processing of the event call the method from SmartSyncDBAccess class which will create the SyncBO instance.

I hope you got the flow of events happening after the submit button is hit.

Regards

Priya Ghosh

Former Member
0 Kudos

ThanQ Laxmi,

as i told in the first post that default <b>three</b>I jsps are created, but wat im doing is im calling directly my jsp as the first screen to appear ....

nextJSP = JSP_VEHICLEDISPLAY;

Now in that JSP i have an UI element button and called "_event_save".

<INPUT type="button" value="Save" name="_event_Save" >

Hope im making sense....

Now where does the control go and can you plz tell me how exactly the process happen in my case.

>>>You have to define this event in Servlet. This servlet calls TableContentProvider

>>>and then TCP calls SmartSyncDBAccess.

Can you throw some more light on this...

Pl. suggest

Kiran Joshua

Former Member
0 Kudos

Hi Priya,

U mean i shud call the addRowInDB method???

pl. suggest.

rgds,

Kiran Joshua

Former Member
0 Kudos

Hi Kiran,

1) JSP's have to be declared in Constants

Example:- String JSP_VEHICLEDISPLAY="/jsp/"YOUR JSP NAME".jsp";

2) Navigation events has to declared in Constants

In your case i guess u have given as name="_event_Save". Declare this.

Example:- String EVENT_GOTOSAVE="Save";

3) Now when the Event occurs it should hit the Servlet. Hence implement the code there

Example:-

if(eventName.equals(EVENT_GOTOSAVE)){

nextJSP= SyncBoSave(request); // this will call the below method in Servlet

}

public void SyncBoSave(HttpServletRequest request){// your request has newly created data

// store your request in String[]

tcp.save(SyncBoName,Pass the request in the form of String [])

return // to your JSP

}

4) write a method called "save" in TableContentProvider

Example :-

public void save(String SyncBoName, your request in the form of String[] ){

dbAccess.addRowInDB(syncboName,your request in the form of String[])// This will call addRowInDB method in dbAccess.

}

5) Now use this code which is generated by NWDS by default

public void addRowInDB(String syBName, String[] newValues)

throws SmartSyncException, PersistenceException {

-


}

You can implement your own logic in the SmartsyncDbAccess. But the flow will be as mentioned above.

Hope this helps,

Best Regards,

Lakshmi

Former Member
0 Kudos

Hi Laxmi,

Thank you for the detail description ...now im able to move further..

Now , my problem is when im performing the action, i dont know wats happening..

Can i check the msgs or warnings..how can i do these...

Pl.suggest

Kiran Joshua

Former Member
0 Kudos

Hi Kiran,

You can use "DEBUG" to know, whats happening in action.

Best Regards,

Lakshmi

Answers (1)

Answers (1)

Former Member
0 Kudos

HI Kiran!

In a SmartSync scenario Data would be downloaded on to your local client and would reside in your Local Database(DB2E ) in the case of data fetch. Same is the case with upload also. First it would be written into your local DB and then upon synchronization data would be inserted into your R/3 through MI server .

Now either you can manually sync or use sync API to write a line of code to force a synchronization for your program itself.

When you create a smartsync project in your IDE out of the set of classes one will be your servlet instance , If you go through it will know how to create and event and trigger it.

So simply in your JSP page while you submit the page or click the button fire an event .

In the previous post it has already been discussed how to insert data into your local DB .

Hope its clear now,

Gud Luck,

Mohan.

Sorry kiran!

In a Normal insert or update scenario it writes into a local DB but upload its a different case it doesn't write into Local DB

Message was edited by:

krishnaMohan Adiraju

Former Member
0 Kudos

Just to Add to my previous post.

In the Case of U01:

Once the data is sent to the back-end system it is removed from the mobile client.

You can use this SyncBO type if It is not required to keep the data on the mobile client once it is added to the back-end system.

I hope its clear now.

Regards

Mohan.