Using the value property

The value property of an object can be used with radiobuttons in SAP.

The value property displays an interesting behavior when it is used with radiobuttons. This is due to the way in which Synactive handles the values associated with radiobuttons. These values are treated as a simple string before the object is created in a screen block. However, once you create the screen element object, the value associated with the radiobutton is stored in the '.value' property.

Therefore, once a radiobutton is defined in a script, it becomes a screen element object and as such, the 'value' property can be used to return the values of that object. In the following example we will demonstrate by creating three radiobutton objects:

radiobutton([11,25], "Hour", {"value":"H", "name":"z_act_unit"});
    radiobutton([11,37], "Day",  {"value":"DAY", "name":"z_act_unit"});
    radiobutton([11,49], "Each", {"value":"EA", "name":"z_act_unit"});
    

The radiobutton values are set using the 'value' option previously described. However, the objects associated with a particular screen are automatically destroyed once you depart from the screen and at that point the values are once again stored in strings, making it impossible to use the '.value' property to return those values - for example in a println statement as shown below:

println("****************activity unit Value (Outside) = " + z_act_unit.value);

The solution to this is for you to remember that while a radiobutton is created as an object, the value property can be returned using the '.value' property. However, outside of the object, it must be returned using a string - the '.value' property will not return the actual value of the radiobutton. An example of the two different methods for returning the radiobutton value is shown below:

      function process_enter() {
      println("****************activity unit Value (Outside) = " + z_act_unit.value);
      println("****************Allocation Cost Element Value (Outside) = " + z_cost_elem.value);

      onscreen "SAPLKMA6.0299"
      println("-----------------------------Activity unit Value (Inside) = " + z_act_unit);
      println("-----------------------------Cost Element Value (Inside) = " + z_cost_elem);