Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

When an App loads it may be necessary to default some data. There are three four ways of doing this.
 

...

  1. Providing default values for the Fields in the FAB Workbench 

...

  1. Assigning a User Parameter ID (e.g. Parameter ID WRK from the User Master record)
  2. Implementing methods DETERMINE_INITIAL_FIELD_VALUES or DETERMINE_FIELD_VALUES_ON_LOAD

...

  1. Setting the values during load of the

...

  1. Application using Javascript

...

1. Providing default values

...

for the fields in the FAB Workbench

...

Using the Fields editor, enter the default value in the 'Default' column

Image Modified

...

 2. Assigning a User Parameter ID

Note

Default values set in #1 is overwritten by this setting.

Default initial values onto the form specific to a user

Setup a PID in your user profile. 

Use SAP tcode SU01 and go to Parameters tab.

Image Added

In this example the PID for WRK for this user has been set to 1000.

In your App assign the PID name to you variable. It will automatically assign the value of the PID to the field.

Image Added

3. Implementing methods DETERMINE_INITIAL_FIELD_VALUES

...

or DETERMINE_FIELD_VALUES_ON_LOAD

A. DETERMINE_INITIAL_FIELD_VALUES

...

Note

Values set using methods #1 and #2 are overwritten by this implementation

If you haven't already, create an Implementation Class for your project.  Either press the "Code" button Image Modified  or edit the implementation class directly using transaction SE24.  It is useful to press the "Display Object List" button of SE24 to obtain a tree view of the class. Image Modified
 
Expand the tree to Methods->Inherited Methods
 
Locate the method DETERMINE_INITIAL_FIELD_VALUES, then right-click, Redefine

Image Modified


In the code editor you can code your logic for determining the default values for fields when the Form is opened for the first time.
Note: for defaulting field values after a form has already been submitted at least once (ie as part of a workflow), implement method DETERMINE_FIELD_VALUES_ON_LOAD
Important: always call the SUPER method in this implementation so that system fields such as the current user name will be determined correctly at run-time.
 
A typical implementation would be as follows:

 Image Modified


The procedure is to read parameter CT_FIELD_VALUES with the key ZFIELD_NAME equal to the Form field which is to be modified, then set the attribute ZFIELD_VALUE to the desired value.
 
Save and Activate.

...

B.

...

 DETERMINE_FIELD_VALUES_ON_LOAD

This method is used to provide default data and to overwrite existing Form data at various stages through out the Form life-cycle.
 
This method provides a parameter I_HEADER_INSTANCE which allows the method to determine the current state of the Form via fields such as
 

...

 
This method is called once for each field in the form via parameter I_FIELD_NAME and the method may set the value of each field using the parameter E_FIELD_VALUE.
 
A typical implementation is as follows:

4. Set values on load of the

...

Application using Javascript

Note

Values set using methods #1, #2 and #3 are overwritten by this implementation

On the function defined in the OnLoad of the Page, the values can be set.

Filter by label (Content by label)
showLabelsfalse
max5
spacesIFAB
showSpacefalse
sorttitle
typepage
cqllabel in ("app-life-cycle","code","parameter-id","fabworkbench","javascript") and type = "page" and space = "IFAB"
labelsruntime default values

...