Maintaining Variants Automatically (Advanced)
You can create a RedwoodScript process definition to change one or more values of a variant directly, without the need to manually edit the variant. In the script you modify the values for the variants with legal values and then submit process definition SAP_StoreVariant to save the variant in the SAP System. This is especially useful when you want to have dynamic variants, for instance, a parameter that would contain the current date. With Redwood Server, this is easily implemented, as you could schedule a process daily which changes the parameter value of the variant and fills it with the current date.
note
XBP 3.0 requires a logical system for the client, see Setting Up Logical Systems for more information on creating logical systems for clients.
See Creating and Modifying Variants for step-by-step instructions on how to modify variants using the Redwood Server user interface and the syntax to specify parameters and select options.
Prerequisites
- An RFC connection has been established between the central Redwood Server and a BI or BW system, as outlined in Connecting to SAP Systems.
Additionally, the SAP System must have one of the following:
- XBP 3.0 support
- The Redwood transport files must have been installed
Example
The below example shows how to change the FLDATE select option of the KL variant of ABAP program BALVEX01 in SAP System D00.
note
The below example does not include the submit of process definition SAP_StoreVariant, which can be done in RedwoodScript or in a following step of the chain.
{
// get the SAP System D00
SAPSystem sapSystem = jcsSession.getSAPSystemByName("D00");
// ABAP program BALVEX01
SAPAbapProgram abap = sapSystem.getSAPAbapProgramByName("BALVEX01");
// variant KL in client 200
SAPAbapProgramVariant variant = abap.getSAPAbapVariantByNameClientNumber("KL", "200");
// values of the select option FLDATE
Iterator<String> it = variant.getSAPAbapVariantSeloptByName("FLDATE").getSAPAbapVariantSeloptValues();
if(it.hasNext())
{
// set the value of the first one to the current date
String fldate = it.next();
fldate.setLow(Time.now().toyyyyMMDDString());
// persist our change
jcsSession.persist();
}
}