Skip to Content
0

Create a Flavor to populate the variant automatically

Mar 05 at 04:52 PM

52

avatar image
Former Member

Hi,

I want to create a flavor for V.26 t-code where I have the variant to populate the document date dynamically change.

How do I create a Personas flavor for this T-code to populate the variant automatically when the user access ? So that the user need not to fill the dates every day when they access the flavor.

Thanks,

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Tamas Hoznek
Mar 05 at 09:39 PM
0

It is not exactly clear what is your goal.

You say that you have a variant that dynamically populates the document date. If so, this means you would want to select this existing variant which you should be able to do easily with an onLoad script that navigates to variant selection and picks the appropriate variant.

Or are you saying that you want to calculate the date dynamically within your Personas flavor? That is also doable with a proper onLoad script.

Show 7 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Tamas,

I want to select the existing variant and the flavor to select onload. How do you write the onLoad script for this ?

Thanks,

-Sundaram

0

You record your steps when manually selecting the variant and assign that script to the onLoad screen event.

0
Former Member
Tamas Hoznek

Will the script recognize the variant name ?. Since the number of variants in the selection may change and the users may add new variants for the same T-code.

0
Former Member
Tamas Hoznek

Tamas,

I am able to record up-to the point of selecting the screen for variant and recorded below. However after getting the variant screen......how do I select the particular variant from the list ? any example code which I can use ? V.26 Tcode.

session.findById("wnd[0]/usr/txtSTATUS").setFocus();
session.findById("wnd[0]/tbar[1]/btn[17]").press();

0
Former Member

Tamas.....

Your input is appreciated.....Please let me know.

Thanks

Sundaram

0

Please see the response by Thomas Mangler below for the solution.

0

Hi,

the script will not record the variant name, the script will select the variant at the position that you have recorded.
If users save their own variant names your variant postion becomes arbitrary and you will get trouble ;)

If you want to select a special variant name that has no fixed position you have to read the variant table to determine the variant position. At this position you can do a "scripting doubleclick".

Example (coding in your script instead of your recorded doubleclick)

var xtable = session.findById("wnd[1]/usr/##############/shell");
if (xtable.rowCount > 0) {	
	xtable.firstVisibleRow = 0;
	var topRow = xtable.visibleRowCount - 1;
	// loop through all the rows
	for (var rowIndex = 0; rowIndex < xtable.rowCount; rowIndex++) {
		// If there is more than one page of variants scroll forward
		if (rowIndex > topRow) {
			if (topRow + xtable.visibleRowCount > xtable.rowCount) {
				xtable.firstVisibleRow = xtable.rowCount - xtable.visibleRowCount;
			} 
			else {
				xtable.firstVisibleRow = topRow + 1;
			}
			topRow += xtable.visibleRowCount;
		}
		//Check the value, if it fits do a double-click
		var xvariant = xtable.getCellValue(rowIndex, "VARIANT");
		if  (xvariant === "YOURVARIANTNAME"){
			xtable.doubleClick(rowIndex, "VARIANT");
			break;	
		}
	}
}

For more information about reading tables check the Screen Personas Wiki

https://wiki.scn.sap.com/wiki/display/Img/Copying+Table+data+into+a+variable

1