cancel
Showing results for 
Search instead for 
Did you mean: 

Create a Flavor to populate the variant automatically

Former Member
0 Kudos

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,

Accepted Solutions (0)

Answers (1)

Answers (1)

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.

Former Member
0 Kudos

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

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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();

Former Member
0 Kudos

Tamas.....

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

Thanks

Sundaram

Thomas_Mangler
Active Participant

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

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

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