Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Control not found error with Personas 2.0

Hi all

I am trying to create a script which will auto-populate the Validity End field in txn ME21N.  But each time I get an error saying that the Control does not exist... why?

Am I missing something?

The screen looks as follows:

The script is as follows:

The script works as follows:

  1. Copy the value in the 'days' field (marked 1)
  2. Refresh the screen (don't ask me why but if I put this step 1st the JavaScript does not work!)
  3. Add this to the existing date
  4. Paste the date as determined in (2) into field marked (3) - this is just a check to make sure the Javascript works and will be removed
  5. If the Validity End control exists...
  6. Paste the date as determined in (2) into Vaility End field
  7. If the Validity End control does not exist...
  8. Return error in field marked (7)

Thanks for your help!

Gareth

Tags:
Former Member
Former Member replied

Thanks all for your help.

For some reason the original script simply started working - it recognised the control and pasted the values in.

Now, after some playing - and using the suggestions above - I have a working script that sets the validity period based on a drop-down selected by the user.

The screen looks as follows:

The user selects the appropriate validity period from the drop-down and clicks the button.  The following script runs:

The steps are (simple enough):

  1. Copy the number of months from the drop-down
  2. Run the Javascript to convert the current date (from_date) and the calculated end date (to_date) into a string in the format dd.mm.yyyy
  3. Paste the value into Validity Start field
  4. Paste the value into Validity End field

The Javascript is as follows:

var d1 = new Date();

var d2 = new Date();

var day = d2.getDate();

if  (day >= 29) {

    d2.setDate(1);

  d2.setMonth(d2.getMonth() + parseInt(args.months) + 1);

  d2.setDate(d2.getDate() - 1);

} else {

  d2.setMonth(d2.getMonth() + parseInt(args.months));

}

args.from_date = ("0" + (d1.getDate())).slice(-2) + "." + ("0" + (d1.getMonth() + 1)).slice(-2) + "." + d1.getFullYear();

args.to_date = ("0" + (d2.getDate())).slice(-2) + "." + ("0" + (d2.getMonth() + 1)).slice(-2) + "." + d2.getFullYear();

The script works as follows:

  1. If the current date is the 29th or greater it goes to the first day in x+1 months and then goes one day back - to get to the last day of the month in x months' time.**
  2. If not it adds x months to the current month.

** This step is required to handle short months (less than 31 days).

Here's hoping it keeps working!

Regards

Gareth

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question