Custom help in a selection screen

I had to use a custom help in a program because I was not able to do it properly with the standard matchcode (I failed miserabily trying to pass the F4 a pre-filter). I had to do a workaround, and I must prevent my failing memory to forget it forever… here we come, just a bit of plain code.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_parameter.
DATA: t_dyn TYPE TABLE OF dynpread,
w_dyn TYPE dynpread.
DATA: BEGIN OF w_val,
field_name TYPE the_same_as_p_parameter,
END OF w_val,
t_val LIKE TABLE OF w_val.

w_dyn-fieldname = ‘PARAMETER_NAME’.
APPEND w_dyn TO t_dyn.

CALL FUNCTION ‘DYNP_VALUES_READ’
EXPORTING
dyname               = sy-repid
dynumb               = sy-dynnr
translate_to_upper   = ‘X’
TABLES
dynpfields           = t_dyn
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield  = 2
invalid_dynproname   = 3
invalid_dynpronummer = 4
invalid_request      = 5
no_fielddescription  = 6
invalid_parameter    = 7
undefind_error       = 8
double_conversion    = 9
stepl_not_found      = 10
OTHERS               = 11.
IF sy-subrc <> 0.
RETURN.
ELSE.
READ TABLE t_dyn INTO w_dyn INDEX 1.
p_parameter = w_dyn-fieldvalue.
IF plant IS INITIAL.
MESSAGE iNNN(XXXX) WITH text-e03.
RETURN.
ENDIF.
SELECT field
INTO TABLE t_val
FROM table
WHERE parameter = parameter.
IF sy-subrc <> 0.
MESSAGE iNNN(XXXXX) WITH text-e02.
RETURN.
ENDIF.
ENDIF.

CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST’
EXPORTING
retfield        = ‘P_PARAMETER’
dynpprog        = sy-repid
dynpnr          = sy-dynnr
dynprofield     = ‘P_PARAMETER’
value_org       = ‘S’
TABLES
value_tab       = t_val
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS          = 3.
IF sy-subrc <> 0.
CLEAR sy-subrc.
ENDIF.

Things to notice:

  1. The screen read function does NOT translate field contents automatically, I had to do by myself (throug the proper parameter, of course).
  2. If you try to show an error message, a DUMP occurs… I had to use type I messages with a nice RETURN after them.
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s