ALV GRID does not check input against value table and does not show matchcode

280 Views Asked by At

I've created a custom table with 5 fields:

  • MANDT: data element MANDT
  • VBELN: data element VBELN_VA
  • POSNR: data element POSNR_VA
  • EXT_ID: custom data element
  • VALUE: custom data element

I've defined foreign keys on VBELN (to VBAK), POSNR (to VBAP) and EXT_ID (to a custom value table consisting only of key fields MANDT and EXT_ID). The foreign keys' cardinality is "Key field / candidates" and 1:CN, and "Check required" is checked.

My problem is that when I display this table in an ALV grid, the matchcode / value help appears on fields VBELN and POSNR but not EXT_ID. Input in fields VBELN and POSNR is checked against their value tables but not input in EXT_ID.

I've set the appropriate value table on the field's domain. I've created a custom value help for EXT_ID and assigned it to the table field. It did not work either.

The maintenance table behaves as expected (matchcode is provided and input is checked for EXT_ID) which seems to indicate that the DDIC objects have been defined correctly, and that this is a bug in ALV grid ?

My code instantiates the ALV this way:

      go_alv = new cl_gui_alv_grid(
        i_parent                = cl_gui_custom_container=>default_screen
      ).

      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'ZEXT_ATT'
        CHANGING
          ct_fieldcat            = lt_fieldcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          others                 = 3
        .

      go_alv->register_edit_event(
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter
        EXCEPTIONS
          error      = 1
          others     = 2
      ).

      insert cl_gui_alv_grid=>mc_fc_pc_file         into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_views           into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_info            into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_print           into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_subtot          into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_sum             into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_find            into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_find_more       into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_call_xml_export into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_call_report     into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_pc_file         into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_send            into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_data_save       into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_send            into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_to_office       into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_views           into table lt_exclude.
      insert cl_gui_alv_grid=>mc_fc_html            into table lt_exclude.

      go_alv->set_table_for_first_display(
        EXPORTING
          is_layout                     = ls_layout
          it_toolbar_excluding          = lt_exclude
        CHANGING
          it_outtab                     = gt_ext_attr
          it_fieldcatalog               = lt_fieldcat
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          others                        = 4
      ).
      IF SY-SUBRC <> 0.
      ENDIF.
1

There are 1 best solutions below

0
On

If I remember correctly only Data Element level Search Help and Domain based checktable settings are universally preserved. The rest (foreign keys, search helps specified in tables/structures and such) can be lost depending on how you form the field catalogue.

This problem is persists in most (if not all) technologies you can create applications ABAP with (ALV, WebDynpro, FPM, RESTful).

In case of ALV in particular there are fields within field catalogue you have to mess around with to either set search help manually or inherit it.

  • ROLLNAME = (Data element name) is used to inherit search help from that DE.
  • CHECKTABLE = (table name) is self explanatory. I believe it is used for validation (prevent input that is not in that table), but I've never personally used it.
  • REF_TABLE and REF_FIELD can be used to specify table (structure should work too) name and fieldname in that structure to inherit some parameters from (including input help settings).

I believe what you need is modify the field catalog entry for that particular field

  • REF_TABLE = 'ZEXT_ATT'
  • REF_FIELD = 'EXT_ID'

A full pass of the following (after LVC_FIELDCATALOG_MERGE) would work too since your field catalog is fully based on that structure.

loop at lt_fieldcat assigning field-symbol(<ls_fieldcat>).
    <ls_fieldcat>-REF_TABLE = 'ZEXT_ATT'
    <ls_fieldcat>-REF_FIELD = <ls_fieldcat>-FIELDNAME.
endloop

If you end up testing it, please let me know if it worked. I'm rusty when it comes to ALV.