I have a DDIC structure containing fields BUKRS
and SAKNR
. A foreign key is defined for field SAKNR
on check table SKB1
, using keys MANDT
, BUKRS
, SAKNR
.
A table of that structure is displayed in an ALV grid (CL_GUI_ALV_GRID). Field SAKNR
is set to editable in the field catalog. BUKRS
is not.
By using the search-help on SAKNR
and picking a value of SAKNR
that exists only associated with a certain value of BUKRS
, the value of BUKRS
changes in the ALV.
I want field BUKRS
to restrict the search, not change value.
How can I either:
- Prevent changes of values that are not editable
- Grey-out foreign key values in the search help dialog (BUKRS should be greyed-out as a fixed value when searching for a value of SAKNR)
I’ve tried setting all cells of other fields as “disabled” in the corresponding STYLE tab, that did not work either. I would rather not create custom search helps to solve this, as this would require tremendous work given the number of standard fields that could cause this.
Sample code:
DATA: lt_fcat type lvc_t_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZTEST_SAKNR'
CHANGING
ct_fieldcat = lt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
others = 3
.
lt_fcat[ fieldname = 'SAKNR' ]-edit = abap_true.
data(lo_alv) = new cl_gui_alv_grid(
i_parent = cl_gui_container=>default_screen
).
DATA: lt_test type table of ztest_saknr.
SELECT * FROM SKB1 INTO CORRESPONDING FIELDS OF TABLE @lt_test.
lo_alv->set_table_for_first_display(
CHANGING
it_outtab = lt_test
it_fieldcatalog = lt_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
).
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL SCREEN 1000.