cancel
Showing results for 
Search instead for 
Did you mean: 

get_ddic_reference( ) returns blanks

luis_rod
Participant
0 Kudos
398

Hi all:

When using CL_SALV_TABLE, how do I get the catalog info for a specific column (e.g., the table name)?

I’m trying this (showing only the most relevant lines):In this case, get_ddic_reference returns blank data (ddic-table = ‘ ‘).

DATA cols  TYPE REF TO cl_salv_columns_table.
DATA col1  TYPE REF TO cl_salv_column_table.
DATA ddic  TYPE salv_s_ddic_reference.
cl_salv_table=>factory(
IMPORTING
  r_salv_table = alv
CHANGING
  t_table      = itab ).
col1 ?= cols->get_column( ‘MY_COLUMN’ ).
ddic = col1->get_ddic_reference( ).

ddic-table returns blanks. Any ideas? Running 7.50

TIA,

Luis

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor

No issue for me.

Minimum reproducible example:

REPORT ztest.
DATA table_sflight TYPE TABLE OF sflight.

SELECT * FROM sflight INTO TABLE @table_sflight.
CALL METHOD cl_salv_table=>factory
  IMPORTING
    r_salv_table = DATA(salv)
  CHANGING
    t_table      = table_sflight.
DATA(ddic_reference) = salv->get_columns( )->get_column( 'CARRID' )->get_ddic_reference( ).
ASSERT ddic_reference = VALUE salv_s_ddic_reference( field = 'CARRID'
                                                     table = 'SFLIGHT' ).
luis_rod
Participant
0 Kudos

Sandra. That's interesting. Your example works perfectly but, if my itab references an in-program type, it does not work.

REPORT ztest.

TYPES:
  BEGIN OF ty_itab,
    zuonr      TYPE vbrk-zuonr,
    vbrk_vbeln TYPE vbrk-vbeln,
  END OF ty_itab.

DATA itab TYPE TABLE OF ty_itab.

cl_salv_table=>factory(
  IMPORTING
    r_salv_table = DATA(salv)
    CHANGING
    t_table      = itab ).

DATA(ddic_reference) = salv->get_columns( )->get_column( 'ZUONR' )->get_ddic_reference( ).
Sandra_Rossi
Active Contributor
OK. It has always worked like that, SALV cannot "deduce" due to a limitation in RTTS. You need to set the DDIC reference yourself (hardcoding).

Answers (2)

Answers (2)

luis_rod
Participant

If you want a column to be "F4 capable" it needs to have the correct DDIC reference. If not, the F4 does not work, so you have to define it yourself.

I'm writing a class with several "black box" methods in order to try that my coworkers stop using  "REUSE_ALV_GRID_DISPLAY" in their programs (and that's the function they are using right now, not even _LVC).

 

raymond_giuseppi
Active Contributor
0 Kudos

You forgot some code, try some code such as

 

" defintions
DATA: cols TYPE REF TO cl_salv_columns_table,
      col1 TYPE REF TO cl_salv_column,
      ddic TYPE salv_s_ddic_reference.
" call methods (you can merge in one statement)
cols = alv->get_columns( ).
col1 = cols->get_column( 'MY_COLUMN' ).
ddic = col1->get_ddic_reference( ).

 

Of course field MY_COLUMN must exist in the internal table and use some ddic reference in its declaration. 

luis_rod
Participant
0 Kudos
Raymond, As stated before, I wrote only the most relevant lines.
raymond_giuseppi
Active Contributor
0 Kudos
So now post the MY_COLUMN definition
raymond_giuseppi
Active Contributor
Basically define your itab structure as a ddic structure and not in your code.
luis_rod
Participant
0 Kudos
After reading Sandra's answer regarding the method's limitations I did as you suggested (" Basically define your itab structure as a ddic structure and not in your code."). Thanks for your posts (and, by the way, I don't really like the comment's section. It makes really hard to edit long texts)