[ABAP] Text zu Wert in einem Datenbankfeld auslesen

Variante 1 (einzelner Feldwert)

DATA: lv_text TYPE text255.
DATA: lv_found TYPE flag_x.
DATA: it_identifier TYPE txid_t_text_identifier_result.

TRY.
    DATA(o_text) = NEW cl_text_identifier( ).
* Text für EBAN-STATU zu Feldwert 'B' holen
    o_text->read_text( EXPORTING
                         tabname    = 'EBAN'   " Tabelle
                         fieldname  = 'STATU'  " Feld
                         fieldvalue = 'B'      " Feldwert
                       IMPORTING
                         text                    = lv_text
                         text_for_value_read     = lv_found
                         text_identifier_results = it_identifier ).

    IF lv_found = abap_true.
* gefundenen Text ausgeben
      WRITE: / lv_text.

      LOOP AT it_identifier ASSIGNING FIELD-SYMBOL(<i>).
        WRITE: / <i>-tabname, <i>-fieldname, <i>-fieldvalue, <i>-text.
      ENDLOOP.
    ENDIF.
  CATCH cx_root INTO DATA(e_txt).
    WRITE: / e_txt->get_text( ).
ENDTRY.

Variante 2 (Datensatz)

PARAMETERS: p_banf TYPE eban-banfn OBLIGATORY.

START-OF-SELECTION.
* Datensatz holen
  DATA: lv_eban TYPE eban.
  SELECT SINGLE * FROM eban INTO lv_eban WHERE banfn EQ p_banf.

  IF sy-subrc = 0.
    DATA: lv_text TYPE text255.
    DATA: lv_found TYPE flag_x.
    DATA: it_identifier TYPE txid_t_text_identifier_result.

    TRY.
* Datensatz: Text zu Feld 'STATU' holen
        DATA(o_text) = NEW cl_text_identifier( ).
        o_text->read_text( EXPORTING
                             tabname          = 'EBAN'    " Tabelle
                             fieldname        = 'STATU'   " Feld
                             record           = lv_eban   " Struktur mit Wert für EBAN-STATU
                             record_specified = abap_true
                           IMPORTING
                             text                    = lv_text
                             text_for_value_read     = lv_found
                             text_identifier_results = it_identifier ).

        IF lv_found = abap_true.
* gefundenen Text ausgeben
          WRITE: / lv_text.

          LOOP AT it_identifier ASSIGNING FIELD-SYMBOL(<i>).
            WRITE: / <i>-tabname, <i>-fieldname, <i>-fieldvalue, <i>-text.
          ENDLOOP.
        ENDIF.
      CATCH cx_root INTO DATA(e_txt).
        WRITE: / e_txt->get_text( ).
    ENDTRY.
  ENDIF.

[ABAP] ALV-Grid: Standard F4-Suchhilfe für Spalten aktivieren

* im LVC-Feldkatalog müssen für die Felder der F4-Spalten folgende Parameter gesetzt werden:
* tabname = 'MARA'.
* ref_table = 'MARA'.
* domname = 'MATNR'.
* f4availabl = abap_true.

DATA: o_alv TYPE REF TO cl_gui_alv_grid.

...

* F4-Hilfe festlegen
DATA(it_f4help) = VALUE lvc_t_f4( ( fieldname = 'MATNR'
                                    register = abap_true
                                    chngeafter = abap_true ) ).

o_alv->register_f4_for_fields( it_f4help ).