Creating a New Scenario for Infotype 1222 (Part 2)
Creating a New Scenario for Infotype 1222 (Part 2)
Continuingāand at the same time concludingāthe topic of working with the attributes of infotype 1222, in this post weāll look at an example of using a scenario for infotype 1222 with the ability for users to select values from a Z* table. I will use a previously configured attribute and scenario as a base. As the source table, Iāll use the previously created table ZUSER_VALUES. That should be more than enough for now.
Letās open the configuration table T77OMATTR in transaction SM30, and modify our attribute by replacing the table and field names:

Unfortunately, standard functionality does not offer a configuration option that enables value selection from a Z* table. This is where good old ABAP comes ināit can help us retrieve values from any table we want. We need to create a function module with the following import/export parameters:


Below is the source code for the function module, which in no way claims to be the pinnacle of what ABAP code can be:
DATA: BEGIN OF ls_data,
id LIKE zuser_values-id,
text LIKE zuser_values-text,
END OF ls_data.
DATA lt_data LIKE TABLE OF ls_data.
DATA lt_zuser_values TYPE TABLE OF zuser_values.
DATA ls_return TYPE ddshretval.
DATA lt_return TYPE TABLE OF ddshretval.
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_data
FROM zuser_values.
CALL FUNCTION āF4IF_INT_TABLE_VALUE_REQUESTā
EXPORTING
retfield = āIDā
value_org = āSā
TABLES
value_tab = lt_data
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
READ TABLE lt_return INTO ls_return INDEX 1.
IF ( sy-subrc = 0 ).
sel_value = ls_return-fieldval.
ELSE.
sel_value = seark.
ENDIF.I think thereās no need to explain what to do if your field or table names differ from those shown above.
Letās continue with the setup: open the Attributes/Scenario node in table T77OMATTR, and enter the name of the function module we just created into the appropriate field:

Looks like weāre done. Time to start testingāopen transaction PPOMA, select an organizational position, and the attribute we created:

Looks about right.