cancel
Showing results for 
Search instead for 
Did you mean: 

How to run script in Test Mode

Former Member
0 Kudos

Hi All

We are working on SAP e sourcing 5.1. I have written a method wherein I am trying to deploy a while loop. However I am a bit skeptical about this resulting in an infinite loop and that is why I want to run this script in test mode first. Is there any way in e sourcing for achieving the same. Plz guide

-


SetRenewalDate (ContractIBeanIfc masterAgreement)

{

ExpirationDate = masterAgreement.getExpirationDate().getDate();

Calendar cal=Calendar.getInstance();

Calendar currentcal= Calendar.getInstance();

cal.setTime(ExpirationDate);

currentcal.set(currentcal.get(Calendar.YEAR),

currentcal.get(Calendar.MONTH), currentcal.get(Calendar.DAY_OF_MONTH));

While(!(cal.after(currentcal)))

{

Calendar cal2=Calendar.getInstance();

cal2.setTime(ExpirationDate);

durationYear = masterAgreement.getExtensionField("RENEWAL_DUR_YEAR").get();

cal2.add(Calendar.YEAR,durationYear);

if(masterAgreement.isObjectAccessModeEdit())

{

masterAgreement.setExpirationDate(TypeFactory.createSysDate(cal2.getTime()));

masterAgreement.getExtensionField("DAT_EXP").set(masterAgreement.getExpirationDate());

cal= masterAgreement.getExpirationDate().getDate();

}

else

{

masterAgreement.getIBeanHomeIfc().upgradeToEdit(masterAgreement);

masterAgreement.setExpirationDate(TypeFactory.createSysDate(cal2.getTime()));

masterAgreement.getExtensionField("DAT_EXP").set(masterAgreement.getExpirationDate());

masterAgreement.getIBeanHomeIfc().save(masterAgreement);

masterAgreement.getIBeanHomeIfc().downgradeToView(masterAgreement);

cal= masterAgreement.getExpirationDate().getDate();

}

}

}

-


Regards

Mudit Saini

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mudit -

Unfortunately, there is not a "test" mode that can be used to test scripts outside of the normal operation of the system.

My first response would be that a "development" or "test" landscape is hopefully available to you where you perform your development and test your work.

An alternative solution is to add a condition to the code such that it only executes for your login. For example, you could have your code use this construct:


if (session.getAccount().getUserName().equals("<YOUR USERNAME HERE>"))
{
    // Execute the code to test
}

I hope one of these approaches is workable for you.

Regards,

Rob

Former Member
0 Kudos

Hi Rob

Thanks for your reply! but the problem that I am facing is one of my script it seems has entered an infinite loop and is overpopulating the disk by creating logs.There is 0 byte disk space available now.

Looking at the latest thread, it seems thread "RequestHandler.RqThread: tb_script" is causing the problem. How do I resolve this issue. Any idea? and How do I make sure this doesnot happen in the future?

Kindly suggest

Mudit Saini

Former Member
0 Kudos

Hi Mudit -

Could you explain the requirement of the script? I don't understand the need for a while loop, but since I don't know the requirement, it is hard for me to suggest an alternative coding construct.

In the current code, the while loop will never get finished because the value of "cal" is never changing once the loop begins.

Regards,

Rob

Former Member
0 Kudos

Hi Rob

Requirement for while loop:

There is a business requirement for contract to get renewed by "RENEWAL_DUR_YEAR" in case there is a value put in it.

For e.g. there is a privious contract effective from 1950 with expiration date as 31st dec 1960. At a later date it was decided that this contract would be renewed on a periodic basis for 5 years every time it would reach it expiration date till company decides to cancel periodic renewal

i.e. istead of having a fixed expiration date of 31st dec 1960, this contract would be extended by 5 years on 31st dec 1960, and then 5 more years on 31st dec 1965 till the company decides to cancell periodic renewal (this would be done my removing value from RENEWAL_DUR_YEAR ).

All these old contracts are uploaded into the system and now in order to satisfy the business needs script was required

While loop is deployed to move the expiration date forward by RENEWAL_DUR_YEAR till today's date is after expiration date.

value of cal is never changing once the loop begins

I am trying to change the value of cal in the if-else construct using statement cal= masterAgreement.getExpirationDate().getDate() to update it to the latest expiration date.

Kindly suggest if you see any loopholes.

Regards

Mudit Saini

Edited by: Mudit_UCB on May 26, 2011 1:07 PM

Answers (0)