on 04-11-2006 3:42 PM
Hi all,
I have a SyncBo S01. I have done a test with MDK_inventory smart application. (MI 2.5 sp15)
This is my syncBO:
<Property name="CLIENT.BUILDNUMBER">1.2</Property>
<Property name="C_APPLRESOLVE" />
<Property name="DATA_VISIBLE_SHARED">X</Property>
<Property name="E_APPLRESOLVE" />
<Property name="FACADE_C_CLIENT">X</Property>
<Property name="FACADE_E_CLIENT">X</Property>
<Property name="HOMEPAGE.INVISIBLE" />
<Property name="INITVALUE">X</Property>
<Property name="RUNTIME">JSP</Property>
<Property name="TYPE">APPLICATION</Property>
- <SyncBO id="ZTEST3" version="2" type="twoWay" allowCreate="true" allowModify="true" allowDelete="true" reqDirectSync="true">
- <TopStructure name="TOP"
This SyncBO not have a Item.
For add new record in my syncBo, I have this code:
dbAccess.loadHeaderFieldNames(SYNCBO_CID);
String names[]=dbAccess.getArrayHeaderFieldNames();
String values[]=new String[names.length];
for (int i=0;i < names.length;i++){
if (names<i>.equalsIgnoreCase("SHORT")){
values<i>="SHORT TEST1";
}else{
if (names<i>.equalsIgnoreCase("STEXT")){
values<i>="STEXT TEST1";
}else{
values<i>="";
}
}
}
try{
dbAccess.addRowInDB(SYNCBO_CID,values);
}catch(Exception e){
}
I insert only 2 values in the header while the other fields are empty.
client not have problem and not have error, the sync is exececute in correct mode.
But in the MW I not found the new record and I think that is not even called the Create BAPI wrapper.
Can someone help me ?
Hi Santiago,
I feared that this was the solution....
If I have to create new istance the my syncBO, I have modify the my definition?
This is the definition in the xml file of the my TOP:
- <TopStructure name="TOP">
+ <Field name="SYNC_KEY" type="N" length="10" decimalLength="0" signed="false" isKey="true" isIndex="true">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
- <Field name="PLVAR" type="C" length="2" decimalLength="0" signed="false" isKey="false" isIndex="false">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
- <Field name="OTYPE" type="C" length="2" decimalLength="0" signed="false" isKey="false" isIndex="false">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
- <Field name="OBJID" type="N" length="8" decimalLength="0" signed="false" isKey="false" isIndex="false">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
All "input type" are "false": I have to change in true?
This code is correct for you for create a new istance:
SyncBoDataFacade dataFacade=SmartSyncRuntime.getInstance().getSyncBoDataFacade();
SmartSyncTransactionManager transactionManager;
transactionManager = dataFacade.getSmartSyncTransactionManager();
transactionManager.beginTransaction();
//dbAccess.addRowInDB(SYNCBO_CID,values);
SyncBoDescriptor sbd = SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade().getSyncBoDescriptor(SYNCBO_CID);
SyncBoDescriptorFacade descriptorFacade =
SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade();
SyncBoDescriptor boDes = descriptorFacade.getSyncBoDescriptor(SYNCBO_CID);
SyncBo myBO=dataFacade.createEmptySyncBo(sbd);
for (int i=0;i < names.length;i++){
dbAccess.setHeaderFieldValue(myBO,namesField<i>,valuesfield<i>);
}
dataFacade.insertSyncBo(myBO);
transactionManager.commit();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello rocco,
your metadata attributes should have been assigned with
input types for create and modify to true if the field
mappings of your syncbo are properly done.
you may change them to true for your instances to be
modifiable, but take note however, that you should have
the correct field mapping in your syncbo definition in the
middleware for you instances to be uploaded (i.e. created)
successfully in the backend thru your create bapi.
regards
jo
I Jo,
in MW I have insert flag "MAP" only this field (in the TOP structure): SHORT and STEXT (whitout initial value)
I have this metadata:
- <MeRepApplication schemaVersion="1.1" id="TEST" version="1.3">
<Property name="CLIENT.BUILDNUMBER">1.3</Property>
<Property name="C_APPLRESOLVE" />
<Property name="DATA_VISIBLE_SHARED">X</Property>
<Property name="E_APPLRESOLVE" />
<Property name="FACADE_C_CLIENT">X</Property>
<Property name="FACADE_E_CLIENT">X</Property>
<Property name="HOMEPAGE.INVISIBLE" />
<Property name="INITVALUE">X</Property>
<Property name="RUNTIME">JSP</Property>
<Property name="TYPE">APPLICATION</Property>
- <SyncBO id="ZTEST_CID4" version="2" type="twoWay" allowCreate="true" allowModify="true" allowDelete="true" reqDirectSync="true">
- <TopStructure name="TOP">
- <Field name="SYNC_KEY" type="N" length="10" decimalLength="0" signed="false" isKey="true" isIndex="true">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
- <Field name="SHORT" type="C" length="12" decimalLength="0" signed="false" isKey="false" isIndex="false">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
- <Field name="STEXT" type="C" length="40" decimalLength="0" signed="false" isKey="false" isIndex="false">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
</TopStructure>
</SyncBO>
</MeRepApplication>
When i try insert a new SyncBo I have this exception:
exception e:[<b>]Creation on Field cZTEST_CID4_TOP_SHORT with value SHORT TEST1 is not allowed because SyncBo of Row 0000000001 is NEW and CreateInputQualifyType is FORBIDDEN[</B>]
I have to insert (MANDATORY?) the initial value for this field? Why?
Hi Rocco,
u just rename that filedname SHORT to some other name and try..
<< <Field name="SHORT" type="C" length="12" decimalLength="0" signed="false" isKey="false" isIndex="false"> >>
just try it and let me know..
one more thing .. hope u have mapped these fields in the CREATE BAPI Wrapper also..
Regards
Kishor Gopinathan
Hi Kishor,
this is my CREATE BAPI wrapper
Parameter I_TOP
Index 1 / 1
Field Name MapManValue ID Mapping Description
PLVAR
OTYPE
OBJID
BEGDA
ENDDA
ISTAT
HISTO
SHORT x Map From : TOP-SHORT
STEXT x Map From : TOP-STEXT
REALO
This is my field in the new meta data:
- <TopStructure name="TOP">
- <Field name="SYNC_KEY" type="N" length="10" decimalLength="0" signed="false" isKey="true" isIndex="true">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
<Field name="SHORT" type="C" length="12" decimalLength="0" signed="false" isKey="false" isIndex="false" />
<Field name="STEXT" type="C" length="40" decimalLength="0" signed="false" isKey="false" isIndex="false" />
</TopStructure>
How I do to change name to the field (SHORT is a field of the OBJEC standard structure)
If the I rename field only in the file. xml, it doesn't see the changes...
Hi Rocco,
if u r using ur own BAPI wrappers , then there is no problem.. just copy OBJEC that to another structure , then rename it and use that in the wrapper .. u have to make changes appropriately in the code.
if u r using standard bapi wrappers , then use this BAPIs in ur custom wrapper and follw the above step in the case of structure.
just paste ur java code u have written for insertion.
Regards
Kishor Gopinathan
I use this code for insert new syncBO:
dbAccess.loadHeaderFieldNames(SYNCBO_CID);
String names[]=dbAccess.getArrayHeaderFieldNames();
Object values[]=new Object[names.length];
for (int i=0;i < names.length;i++){
if (names<i>.equalsIgnoreCase("SHORT")){
values<i>=new String("SHORT TEST1");
}else{
if (names<i>.equalsIgnoreCase("STEXT")){
values<i>=new String("STEXT TEST1");
}else{
values<i>="0";
}
}
}
try{
SyncBoDataFacade dataFacade=SmartSyncRuntime.getInstance().getSyncBoDataFacade();
SmartSyncTransactionManager transactionManager;
transactionManager = dataFacade.getSmartSyncTransactionManager();
transactionManager.beginTransaction();
SyncBoDescriptor sbd = SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade().getSyncBoDescriptor(SYNCBO_CID);
SyncBoDescriptorFacade descriptorFacade =
SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade();
SyncBoDescriptor boDes = descriptorFacade.getSyncBoDescriptor(SYNCBO_CID);
SyncBo myBO=dataFacade.createEmptySyncBo(sbd);
for (int i=0;i < names.length;i++){
dbAccess.setHeaderFieldValue(myBO,names<i>,values<i>);
}
<b>dataFacade.insertSyncBo(myBO);</b>
transactionManager.commit();
}catch(Exception e){
e.printStackTrace();
System.out.println("exception e:"+e.getMessage());
}
The code in last my post, it causes this exception:
com.sap.ip.me.api.smartsync.ModificationNotAllowedException: Creation on Field cZTEST_CID4_TOP_SHORT with value SHORT TEST1 is not allowed because SyncBo of Row 0000000001 is NEW and CreateInputQualifyType is FORBIDDEN
at com.sap.ip.me.smartsync.data.AbstractRow.verifyFieldInputQualifierType(AbstractRow.java:138)
at com.sap.ip.me.smartsync.data.TopRow.verifyRowInsert(TopRow.java:185)
at com.sap.ip.me.smartsync.data.TopRow.insert(TopRow.java:153)
at com.sap.ip.me.smartsync.data.SyncBoDataFacadeImpl.insertSyncBo(SyncBoDataFacadeImpl.java:402)
at com.rfi.sap.rfid.mi.dataaccess.IOSyncBOs.insertRecord(IOSyncBOs.java:389)
at it.rfi.sap.rfid.mi.utility.CheckUser.searchUserInSyncBo(CheckUser.java:58)
at it.rfi.sap.rfid.mi.utility.CheckUser.<init>(CheckUser.java:50)
at it.rfi.sap.rfid.mi.DispatcherAction.runAction(DispatcherAction.java:59)
at it.rfi.sap.rfid.mi.DispatcherAction.<init>(DispatcherAction.java:39)
at it.rfi.sap.rfid.mi.RFIDSmartSycClass.doHandleEvent(RFIDSmartSycClass.java:107)
at com.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet.doGetNotThreadSafe(AbstractMEHttpServlet.java:346)
at com.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet.doGet(AbstractMEHttpServlet.java:678)
at com.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet.doPost(AbstractMEHttpServlet.java:695)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at com.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet.service(AbstractMEHttpServlet.java:326)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
at
This is strange: <b>Row 0000000001 is NEW and CreateInputQualifyType is FORBIDDEN</b>....can someone explain me it?
Hi Rocco,
u have written like this ... in ur code..
<<
for (int i=0;i < names.length;i++){
<b>dbAccess.setHeaderFieldValue(myBO,names,values);</b>}
>>
here exactly -the parameters of setHeaderFieldValue
public boolean setHeaderFieldValue(
<b>SyncBo sb,
String headerFieldName,
Object value)</b>
here in place of headerFieldName , <b>u r passing the entire string array values as names instead of individual elements in names array</b> just use this method ---
public boolean setHeaderFieldValue(
SyncBo sb,
String headerFieldName,
Object value) {
SyncBoDescriptor sbd = sb.getSyncBoDescriptor();
RowDescriptor trd = sbd.getTopRowDescriptor();
FieldDescriptor fd = trd.getFieldDescriptor(headerFieldName);
if (fd != null) {
BasisFieldType bft = fd.getFieldType();
Row header = sb.getTopRow();
try {
// Integer operator
if (bft == BasisFieldType.N) {
NumericField nf = header.getNumericField(fd);
if (nf != null) {
BigInteger ii = new BigInteger(value.toString());
nf.setValue(ii);
return true;
} else {
return false;
}
}
// Character operator
if (bft == BasisFieldType.C) {
CharacterField cf = header.getCharacterField(fd);
if (cf != null) {
cf.setValue(value.toString());
return true;
} else {
return false;
}
}
// Decimal operator
if (bft == BasisFieldType.P) {
DecimalField df = header.getDecimalField(fd);
if (df != null) {
BigDecimal bd = new BigDecimal(value.toString());
df.setValue(bd);
return true;
} else {
return false;
}
}
// Similar operation for time and date operator fields
if (bft == BasisFieldType.D) {
DateField df = header.getDateField(fd);
if (df != null) {
if (value.toString().equals("0")) {
Date dat = Date.valueOf("0000-00-00");
df.setValue(dat);
} else if (!value.toString().equals("")) {
Date dat = Date.valueOf(value.toString());
df.setValue(dat);
} else {
Calendar cal = Calendar.getInstance();
java.sql.Date bd =
new java.sql.Date(cal.getTime().getTime());
df.setValue(bd);
}
return true;
} else {
return false;
}
}
// Similar operation for time and date operator fields
} catch (SmartSyncException ex) {
System.out.println(ex.getMessage());
} catch (PersistenceException e) {
System.out.println(e.getMessage());
}
}
return false;
}
Regards
Kishor Gopinathan
Message was edited by: Kishor Gopinathan
hello rocco,
did you redeploy your application with this new metadata?
- <TopStructure name="TOP">
- <Field name="SYNC_KEY" type="N" length="10" decimalLength="0" signed="false" isKey="true" isIndex="true">
<Input type="create">false</Input>
<Input type="modify">false</Input>
</Field>
<Field name="SHORT" type="C" length="12" decimalLength="0" signed="false" isKey="false" isIndex="false" />
<Field name="STEXT" type="C" length="40" decimalLength="0" signed="false" isKey="false" isIndex="false" />
</TopStructure>
with this metadata, you will be able to modify your field
values...
if your syncbo attribute has allowCreate="true" etc, you
will be able to insert new syncbo into your data facade.
if the "insert forbidden" exception appears, try
redeploying your xml metadata.
regards
jo
Hi Jo,
after add new SyncBo (in local it's all OK), this code is execute for upload new syncBo in backend system:
SmartSyncRuntime ssRuntime = SmartSyncRuntime.getInstance();
SyncBoOutDeltaFacade boDeltaFacade = ssRuntime.getSyncBoOutDeltaFacade();
SyncBoDescriptorFacade descF = ssRuntime.getSyncBoDescriptorFacade();
SyncBoDescriptor myBO = descF.getSyncBoDescriptor(SYNCBO_CID);
boDeltaFacade.setSendType(myBO, SyncBoOutDeltaSendType.SEND_DIRECT);
SyncManager.getInstance().synchronizeWithBackend(VisibilityType.USER_SHARED);
But I have seen that the bapi that is recalled it is <b>always</b> the <b>DETAIL</b> bapi wrapper (i have the log in each bapi wrapper).
Why?
It should be recalled the <b>CREATE</b> bapi wrapper?
Best Regards
Hi Rocco,
just make it sure that ur "Create BAPI Wrapper" is working properly or not.(by manually running that BAPI Wrapper).
check whether the version of Sync Bo in the Framework and in the MCD are same or not..(check that meRepMeta.xml filew in the uploaded application also..)
hope u could see the values u have inserted in the client end .
if not.. just refer these forums..
i have already written some sample codes in these forums..(for inserting new top row and item row..)..
Regards
Kishor Gopinathan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kishor,
I have read your code and i try it:
try{
SyncBoDataFacade dataFacade=SmartSyncRuntime.getInstance().getSyncBoDataFacade();
SmartSyncTransactionManager transactionManager;
transactionManager = dataFacade.getSmartSyncTransactionManager();
transactionManager.beginTransaction();
//dbAccess.addRowInDB(SYNCBO_CID,values);
//SyncBoDescriptor sbd = SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade().getSyncBoDescriptor(SYNCBO_CID);
SyncBoDescriptorFacade descriptorFacade =
SmartSyncRuntime.getInstance().getSyncBoDescriptorFacade();
SyncBoDescriptor boDes = descriptorFacade.getSyncBoDescriptor(SYNCBO_CID);
RowDescriptor rowDesc = boDes.getTopRowDescriptor();
SyncBo mySyncBO=dataFacade.getSyncBo(boDes,SYNCBO_CID);
//RowDescriptor rowDesc=sbd.getTopRowDescriptor();
SyncBo unlinkedCopy = mySyncBO.createUnlinkedCopy();
Row newRow = unlinkedCopy.createEmptyRow(rowDesc);
FieldDescriptor fd1 = rowDesc.getFieldDescriptor("SHORT");
FieldDescriptor fd2 = rowDesc.getFieldDescriptor("STEXT");
newRow.setFieldValue(fd1,"TEST1".toString());
newRow.setFieldValue(fd1,"TEST2".toString());
// Set some values to the new row
// Insert the row into the syncbo
unlinkedCopy.insertRow(newRow);
// Commit the txn
dataFacade.insertSyncBo(unlinkedCopy);
//Commit the transaction
transactionManager.commit();
But this line
SyncBo mySyncBO=dataFacade.getSyncBo(boDes,SYNCBO_CID);
gives an exception (with SYNCBO_CID="ZSYNC_ONE")
java.lang.NumberFormatException: For input string: "Z"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:468)
at java.math.BigInteger.<init>(BigInteger.java:314)
at java.math.BigInteger.<init>(BigInteger.java:447)
at com.sap.ip.me.smartsync.data.SyncBoDataFacadeImpl.getSyncBo(SyncBoDataFacadeImpl.java:112)
at com.rfi.sap.rfid.mi.dataaccess.IOSyncBOs.insertRecord(IOSyncBOs.java:371)
at it.rfi.sap.rfid.mi.utility.CheckUser.searchUserInSyncBo(CheckUser.java:58)
at it.rfi.sap.rfid.mi.utility.CheckUser.<init>(CheckUser.java:50)
at it.rfi.sap.rfid.mi.DispatcherAction.runAction(DispatcherAction.java:59)
at it.rfi.sap.rfid.mi.DispatcherAction.<init>(DispatcherAction.java:39)
at it.rfi.sap.rfid.mi.RFIDSmartSycClass.doHandleEvent(RFIDSmartSycClass.java:107)
at com.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet.doGetNotThreadSafe(AbstractMEHttpServlet.java:346)
at com.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet.doGet(AbstractMEHttpServlet.java:678)
at com.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet.doPost(AbstractMEHttpServlet.java:695)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at com.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet.service(AbstractMEHttpServlet.java:326)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:534)
hello rocco,
it will cause an exception because the second parameter should
be a synckey which is numeric in nature.
thus the code
SyncBo mySyncBO=dataFacade.getSyncBo(boDes,SYNCBO_CID);
gives an exception (with SYNCBO_CID="ZSYNC_ONE")
will throw an exception because SYNCBO_CID is invalid!
synckey is generally assigned by the framework when you
insert your syncBo or if the syncbo came from the middleware.
regards
jo
Hi, thanks for your help.
Now I have another exception:
SyncBoCollection syncBOS= dataFacade.getSyncBos(boDes);
MeIterator it = syncBOS.iterator();
String key="";
for (MeIterator i = syncBOS.iterator() ; i.hasNext() {
SyncBo x=(SyncBo) i.next();
key=x.getSyncKey();
}
SyncBo mySyncBO=dataFacade.getSyncBo(boDes,key);
//RowDescriptor rowDesc=sbd.getTopRowDescriptor();
SyncBo unlinkedCopy = mySyncBO.createUnlinkedCopy();
RowDescriptor rowDesc = unlinkedCopy.getSyncBoDescriptor().getTopRowDescriptor();
<b>Row newRow = unlinkedCopy.createEmptyRow(rowDesc);</b>
FieldDescriptor fd1 = rowDesc.getFieldDescriptor("SHORT");
FieldDescriptor fd2 = rowDesc.getFieldDescriptor("STEXT");
newRow.setFieldValue(fd1,"TEST1".toString());
newRow.setFieldValue(fd1,"TEST2".toString());
// Set some values to the new row
// Insert the row into the syncbo
unlinkedCopy.insertRow(newRow);
// Commit the txn
dataFacade.insertSyncBo(unlinkedCopy);
//Commit the transaction
transactionManager.commit();
This line gives the exception:
Row newRow = unlinkedCopy.createEmptyRow(rowDesc);
The error in my code is that I try to insert a Row in the TOP structure...this not possible?
The my object (it map in my SyncBO) in the MW is a "flat" object,without the classic structure header->item, but only header.
In this case if i need add others rows on my client, which the correct process?
hello rocco,
the top row of a SyncBo instance CANT be replaced...
if you need to modify the header values, get the reference
thru SyncBo.getTopRow() and use the Row methods to change
them. if you need to add, you have to create a syncbo
instance, change the header values and and insert it into
your datafacade.
syncbo and header is 1:1.
regards
jo
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.