Drop-down Lists

 
 

Drop-down List INCLUDE

For each drop-down list field that is being filled using the FLM for HR framework, the include /FLMHR/F4_PREPOP must be added into the F4 user-exit.
 
 

This include and related configuration table provide a single framework to increase the reusability of ABAP code and reduce complexity in the FLM F4 user exit. This include must be manually added to the field level F4 level user exit code for each DD field using the HR for FLM framework.

 

The selection of remote destinations and calling of functions is driven from a configuration table (/FLMHR/F4_CNTRL) based on field name (and if necessary form type). Each function can share one of three different possible interface signatures, if relevant all form data and the current field can be passed in, and in all cases a table of possible codes and display values is returned.

 

There are two main sources of dropdown values, a simple F4 based on SAP screen fields or function modules (Arch-delivered or custom). You can also use both simple F4 and functions in which case the results of the simple call are available for use and manipulation in the custom one. Once the list of values has been generated there are three further options that can be applied as below

-          You can REMOVE entries from the list by creating an ID on the project variables table (or custom variables) and storing in here ranges or single code values to exclude

-          You can define the sort to be by SAP Code or Display Value (Ascending or Descending)

-          You can set the display to include both the code and value, separated by a dash. Note that the sort above is applied before the code and value are merged

-          You can set a flag to add a blank row into the list which is useful for resetting optional dropdowns (only relevant for PDF -  See FLM for HR Notes)

 

The list is then returned to the field level F4 user exit where you can place further form and field specific ABAP if requirements have not been met. E.g. To move the “United Kingdom” entry to the top of the list of countries, previously read from SAP, filtered and then sorted by value.

 

 

Drop-down List Configuration Table

This table is used by the field level F4 user exit include (/FLMHR/F4_PREPOP) to set the sequence of functions which must be called to successfully pre-populate any dropdown values in a form using FLM for HR.

 

 
 
Customer
Customer Code
 
Form Type
Form Type (could be left blank if the same logic is required in all forms)
 
Version
Form version (Can be left blank to reduce table entries)
 
Status
Not currently used (dropdown user exits are always triggered at every status)
 
Form Fieldname
The name of the form field
 
F4 Screen Field
SAP Screen field
 
F4 Code Field
Code field from the SAP search help
 
F4 Value Field
Description field from the SAP search help
 
Function Module
Used if data is being returned by function module
 
RFC Dest
Used if data is being returned by remote function module
 
F4 Filter ID
ID referencing an entry in FLM Project Settings table that defines a filter to remove unwanted entries from the returned drop-down list
 
F4 Sort
Control to sort by the list by Code or the Description, Acdending or Descending.
 
Display Code and Description Flag
Flag to concatenate the Code and the Description into the returned Description.
 
 

Simple Drop-down List Function

Use the 'simple drop-down list function' /FLMHR/HRF4_GET_SIMPLE to help determine the Code and Description fields, and to discover whether a standard SAP search help can deliver the drop-down list entries you require.
 
SAP provides “possible values” for most input fields with F4, and in most cases for FLM Form fields can take advantage of this same functionality. Behind the screen fields are search helps, which provide a list of possible values, normally a code and description.

 

In all cases you must pass into this function the column name which holds the code and one that holds the text you wish to display on the form dropdown. The column names are derived by the SAP search help and will not be known until the function is run for the first time. Therefore you can (and must) run first in test mode using transaction SE37 and then review the output table (EX_RETURN_VALUES) to indentify the separate fieldname for the code and relevant text.

 

For a worked example we will review how the Ethnic Origin dropdown from infotype 0077 would be configured. The first input parameter is the screen field (IM_SCREEN_FIELD) and needs to be in the format TABLE-FIELD and can be determined by pressing F1 on your selected SAP field and navigation to the technical details tab.

 

 

For the first test pass we enter just this single import value and execute, leave others inputs blank or with default values. The function will return in table EX_RETURN_VALUES the set of fields and values from which the “key” and “text” fields can be selected for the final run and configuration.

 

 

On our system there are 489 rows returned and on inspection these are in sets of records, each with three fields.

 

 

For each country grouping the code (RACKY) and description (LTEXT) can be seen. Please note that the FLM for HR dropdown include will automatically filter on country grouping based on TXT_MOLGA and by language based on the current user logon language.

 

In cases where there is no suitable key you can provide RECORDPOS as the code and the row number for this entry will be used. Please note that in the event of the number of entries changing any historical forms may not display with the correct values.

 

Once you have identified the screen field, code and value parameters you can rerun the function and this time a final table of keys/descriptions are returned (EX_FORM_DATA). The setting of IM_CODEVAL will determine if the key is also shown in the description. Our example results based on GB are as follows. 

 

 

For some input fields existing screen values are taken into account to further restrict the values. For example the value of “Employee Group” is used to filter “Employee Subgroup” out of possible selections. This functionality is not supported by the simple function and an existing or new F4 function module will need to be developed.  

 

If the dependant field “Employee Group” is pre-populated at the point of form render then custom functions can read the current form values and use this as a basis for making restricted selections for “Employee Subgroup”.

 

Cascading Drop-down Lists

There are many cases where dropdown values are dependent on the value of other form fields where the value is not known until a user makes a selection on the form. Complex dropdowns, sometimes referred to as cascading, are used to support this functionality. Following the previous example once a user chooses an employee group, the subgroup value would need to be cleared and any possible dropdown values refreshed.

To support this functionality the form needs

-          to hold ALL the child subgroups and their relationship to the parent employee group

-          some scripting added to the “exit” event on the template for the parent field  e.g. Employee Group

 

An array should consist of a single string of values holding the parent key and its related child data (key and description) separated by tilde (~) with each record ending with a semicolon (;).

 

So, for employee group and subgroup we might expect a string as below.

 

EG A~ESG A1~Sub Group A1; EG A~ESG A2~Sub Group A2;EG B~ESG B0~Sub Group B0

 

This string can be broken back to indicate there are two possible employee groups, EGA and EGB. For EGA there are two subgroups, ESG A1 / ESG A2, and for EGB only one.  On the template the delivered script object soDropdown and related methods (splitData, filterData and loadData) can be applied to the “exit” event of employee group.

 

Many arrays can be built based on the results of a simple F4 dropdown where the parent/child fields are returned in the EX_RETURN_VALUES table. Delivered function /FLMHR/HRF4_GET_ARRAY is used in a similar way to /FLMHR/HRF4_GET_SIMPLE but rather than passing code and value field a list of multiple fields is passed. The values from these fields are then concatenated together with a separator (~) and at the end of each RECORDPOS the delimiter (;) is added automatically. The order of the fields in the array string will match the field order in the record structure. Therefore a review of the soDropdown script parameters will be required to confirm the correct values are being used for both parent key and child key/values.

 

Note that for fields with large numbers of entries the size of the FLM form when opened will be increased and maybe a check-cycle or web service call should be considered as an alternative.

 

Delivered function /FLMHR/HRF4_GET_ACTION_REASON shows how to call function /FLMHR/HRF4_GET_ARRAY to build a drop-down list of action reasons for an action.

 

For in-form building of the cascading drop-down lists on PDF templates use the following code snippet, typically on the enter event of the child field (eg Employee SubGroup, Personnel SubArea etc:

 

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
// Get the SOM expression of the array text field
var childData = xfa.resolveNode("form..AR_EMPGRP") ; 

// create a child data array based the array text field
var cd = soDropdown.splitData(childData) ; 

// Call function to filter the array entries by the value in the parent field
var data = soDropdown.filterData(xfa.resolveNode("form..DD_EMPGROUP").rawValue, cd, 0, 1, 2) ; 

// Call function to fill this field's options based on the filtered array
soDropdown.loadData(data, this.somExpression, 0, 1) ;

 

For HTML templates  use the following snippet within the onchangeMethod to reset the dropdown

 

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
// add in switch(objId)
case "DD_EMPGROUP" :

// Only process if we have an array
var pm = document.getElementById("AR_EMPGRP").value ; 
if (pm.length > 1 && obj.value > "")
	{
// Set the target dropown object
	target = document.getElementById("DD_EMPSUBGRP") ;
// Split the Array into records
	var sd = flm.splitData(document.getElementById("AR_EMPGRP")) ;
// Filter out records where first "element" (0) matches active object (Emp Group)
	sd = flm.selectData(sd, 0, obj.value);
// Remove duplicates	
	sd = flm.distinctData(sd, 1);
// Load target using source passing correct elements into code
// Note after distinct YOU ONLY EVER LOAD ELEMENT 1
	flm.loadData(sd, target, 1, 1);					
// If the user changed the form after it was lodaed then clear the target value to force reselection
	if (!flm.LOADING) document.getElementById("DD_EMP_PAY_AREA").value = "" ;
	}
break;

Other Delivered Functions

/FLMHR/HRF4_GET_ACTION_REASON
Builds a drop-down list of Action Reasons based on the form action in form field 'TXT_ACTION'.
 
/FLMHR/HRF4_GET_WAGETYPES_IT
Builds a drop-down list of Wage Types from tables T512Z and T511, based on other form fields:
  • TXT_MOLGA
  • DD_PERSAREA
  • DD_PERSSUBAREA
  • DD_EMPGROUP
  • DD_EMPSUBGROUP
The function uses a filter '<fieldname>_WT_LIST' to remove any unwanted wage types from the list.
In order to read infotype-specific configuration (eg wage type for infotype 0008), the variable ''<fieldname>_WT_LIST_IT' is used to store the infotype.
Both the filter and the variable are stored in the FLM Project Settings table.
 
/FLMHR/HRF4_GET_WORK_SCHEDULE
Builds a drop-down list of Work Schedule entries, built from field 'AR_WORKSCHED'.
 

Custom Functions

Custom functions can be built to store logic for building drop-down lists, and then re-used across many form types.
The import parameter, i_data, stores all the form data.
The output parameter, ex_form_data, returns a table of NAME and VALUE options, where NAME is the bound code and VALUE is the human-readable description of the code.
 
Example code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
FUNCTION z_flm_f4_acttype .
*----------------------------------------------------------------------
* Local Interface:
*  IMPORTING
*     VALUE(I_DATA) TYPE  /FLM/XML_TAB_T
*  EXPORTING
*     VALUE(EX_FORM_DATA) TYPE  /FLM/SFS_FORM_DATA_T
*----------------------------------------------------------------------

  DATA: t_cslt       TYPE TABLE OF cslt,
        wa_cslt      TYPE cslt,
        ls_form_data TYPE /flm/form_data.

  SELECT * FROM cslt INTO TABLE t_cslt WHERE
         kokrs EQ 'MPC' AND
         spras EQ 'EN'  AND
         datbi GT sy-datum.

* Process Array
  LOOP AT t_cslt INTO wa_cslt.
    ls_form_data-name  = wa_cslt-lstar.
    CONCATENATE wa_cslt-lstar '-' wa_cslt-ltext 
           INTO ls_form_data-value separated by space.
    APPEND ls_form_data TO ex_form_data.
  ENDLOOP.

ENDFUNCTION.
  

Using FLM Project Settings Table For Drop-down List Filters

The FLM Project Settings configuration table can be used to store data ranges to be excluded from drop-down lists.
For example, this might include specific values that are no longer used and so should be omitted from the options offered to the user on the form.
 
The range in configured in the table using the following fields:
 
 
SID
SAP System ID
 
Client
SAP Client Number
 
Customer
FLM Customer Code
 
Form Type
The Form Type.  This can be left blank if the fields is relevant for ALL forms.
 
Template Option (previously Language)
Not used for drop-down list filters.
 
Version
Not used for drop-down list filters.
 
Field Name
Typically use the pattern 'F4_FILTER_<fieldname>' where <fieldname> is the name of the field.  See the example 'F4_FILTER_DD_TITLE' above.
 
Sequence
Not used for HR form pre-population.
 
Sign
Use 'I' (Include)
 
Option
Use 'EQ' (Equals), 'BT' (Between) etc.
 
Low Value
Enter the start of the range
 
High Value
Enter the end of the range
 
Text
Free text
  
In the above example, entries where the value is greater the 5 are removed for the field 'DD_TITLE' for all form types. 
 

Example Configuration Table Entries

 

Entries based on SAP F4

 

FIELD_NAME

F4_SCREEN_FIELD

F4_CODE_FIELD

F4_VALUE_FIELD

NOTES

DD_CTYPE_0001

P0001-ANSVH

ANSVH

ATX

Contract Type (IT0001)

DD_BUSAREA

P0001-GSBER

GSBER                        

GTEXT

Business Area

DD_EMPGRP

P0001-PERSG

PERSG

PTEXT

Employee Group

DD_PERSAREA

P0001-WERKS

PERSA

NAME1

Personnel Area

DD_ EMP_TITLE

P0002-ANRED

ANRED

ATEXT

Title (IT0002)

DD_MARITAL_STAT

P0002-FAMST

FAMST

FTEXT

Marital Status

DD_COB

P0002-GBLND

LAND1

LANDX

Country of Birth

DD_GENDER

P0002-GESCH

_LOW

_TEXT

Gender

DD_RELIGION

P0002-KONFE

KONFE

KTEXT

Religion

DD_NATIONALITY

P0002-NATIO

LAND1                        

NATIO

Nationality

DD_COUNTRY

P0006-LAND1

LAND1

LANDX

Country

DD_TMGMT_STATUS

P0007-ZTERF

ZTERF

ZTEXT

Time Management Status

DD_BPAY_REASON

P0008-PREAS

PREAS

RTEXT

Reason for Basic Pay (Change)

DD_PSCALE_TY

P0008-TRFAR

TRFAR

TARTX

Pay Scale Type

DD_PSCALE_AREA

P0008-TRFGB

TRFGB

TGBTX

Pay Scale Area

DD_CTYPE_0016

P0016-CTTYP

CTTYP

CTTXT

Contract Type (IT0016|

DD_EE_NOTICE

P0016-KDGF2

KDGFR

KTEXT

Employee Notice Period

DD_ER_NOTICE

P0016-KDGFR

KDGFR

KTEXT

Employer Notice Period

DD_CDETA_0016

P0016-KONSL

KOSL1

KON

Contract Detail

DD_PROB_UNIT

P0016-PRBEH

ZEINH

ETEXT

Probation Units

DD_CORP_FUNC

P0034-FUNKT

SUBTY

STEXT

Corporate Function

DD_OOL_ITEM

P0040-LEIHG

SUBTY

STEXT

Object on Loan item

DD_LOAN_TYPE

P0045-DLART

SUBTY

STEXT

Loan Type

DD_P46_STATE

P0065-P46CLS

_LOW

_TEXT

GB Tax - P46 Statement

DD_TAX_SOURCE

P0065-TDSRC

_LOW

_TEXT

GB Tax – Tax Code Source

DD_ETHNIC_ORIGIN

P0077-RACKY

RACKY

LTEXT

Ethnic Origin

DD_POS_VAC_STATUS

HRP1007-STATUS

_LOW

_TEXT

Position Vacancy Status

 

Entries based on delivered Function Modules

 

FIELD_NAME

Function Module

NOTES

DD_ACT_REASON

/FLMHR/HRF4_GET_ACTION_REASON

Reads hidden field TXT_ACTION to filter correct reasons

DD_WAGE_TYPE_BPAY

/FLMHR/HRF4_GET_WAGETYPES_IT

Reads entry in project variables table (field name with _IT suffix) to provide infotype number (0008) for automatic filtering.

DD_WAGE_TYPE_AD

/FLMHR/HRF4_GET_WAGETYPES_IT

Reads entry in project variables table (field name with _IT suffix) to provide infotype number (0014) for automatic filtering.

DD_WAGE_TYPE_AP

/FLMHR/HRF4_GET_WAGETYPES_IT

Reads entry in project variables table (field name with _IT suffix) to provide infotype number (0015) for automatic filtering.

 

Entries based on custom Function Modules

 

FIELD_NAME

Function Module

NOTES

DD_EMPSGRP

Z_FLM_GET_EMPSUBGROUP_F4

Reads hidden field DD_EMPGROUP to filter correct reasons

DD_PERSUBAREA

Z_FLM_GET_PERSUBAREA_F4

Reads hidden field DD_PERSAREA to filter correct sub areas

DD_POSITION

Z_FLM_GET_POSITION_F4

Reads field DD_ORG_UNIT to filter positions in and below this org

DD_REGION

Z_FLM_GET_REGION_F4

Reads field DD_COUNTRY to filter correct regions

DD_POS_REP_TO

Z_FLM_GET_REP_TO_F4

Uses evaluation paths PERSCM2, O-O_DOWN and BOSSONLY