on 12-12-2014 11:41 AM
Hi Experts,
I would like to delete some agreements created for testing.
I would like to do it through scripting. What are the classes and methods that I need to use.
Can you please provide me some guidance.
Thanks
Krish
Hi Krish,
You Cannot delete the Agreements once created in the System but what you can inactivate the agreements either by workbook or via script also.
But it would be easier to inactivate via workbook.
Prepare the workbook and import
If you want to write a script then you have to make an explicit script and in the script you have to make use of Query IAPI.
below link will guide you further:
http://scn.sap.com/community/sourcing/blog/2012/08/08/query-iapis--a-good-alternative-for-dbhandle
Hope it help!
Thanks,
Kushagra A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krish,
Try below piece of code:
//ZERI_DELETING_MA
import com.sap.eso.api.contracts.ContractIBeanHomeIfc;
import com.sap.odp.api.ibean.IBeanHomeLocator;
maHome=IBeanHomeLocator.lookup(session,ContractIBeanHomeIfc.sHOME_NAME);
maBean=maHome.findByUniqueDocName("MA-2014-002003");
maHome.upgradeToEdit(maBean);
maHome.delete(maBean);
What I can suggest is:
1. Make a query which will fetch all the inactive MAs which you want to delete from the System
2. Make an explict called script and write the code as stated above.
3. Call the query in the explicit script, for this refer below blog:
http://scn.sap.com/community/sourcing/blog/2012/08/08/query-iapis--a-good-alternative-for-dbhandle
Let me know if you have any query.
Hope it will help you!
Regards,
Kushagra A
Hi Krish,
It is working fine in my case. I did not set those fields to past date.
Below is the code:
//ZERI_DELETING_MA
import com.sap.eso.api.contracts.ContractIBeanHomeIfc;
import com.sap.odp.api.ibean.IBeanHomeLocator;
import com.sap.odp.api.comp.query.IapiQueryExecFactory;
import com.sap.odp.api.comp.query.IapiQueryExecIfc;
import com.sap.odp.api.comp.query.IapiQueryResultSetIfc;
void deleteMAs(maBean)
{
maHome=IBeanHomeLocator.lookup(session,ContractIBeanHomeIfc.sHOME_NAME);
maHome.upgradeToEdit(maBean);
maHome.delete(maBean);
}
void processMAs()
{
queryExec=IapiQueryExecFactory.createQueryExec(session, "ZQUE_INACTIVE_MAs");
paramSet=queryExec.getParameterSet(session, "ZQUE_INACTIVE_MAs");
resultSet = queryExec.execute(new HashMap());
metaData = resultSet.getMetaData();
while(resultSet.next())
{
maID=resultSet.getString(0);
logMessage("maID:"+maID,0);
maHome=IBeanHomeLocator.lookup(session,ContractIBeanHomeIfc.sHOME_NAME);
maBean=maHome.findByUniqueDocName(maID);
deleteMAs(maBean);
}
}
/* Main Script*/
processMAs();
Hope it help!
Regrads,
Kushagra A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.