Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How do I call get_ddic_reference?

Former Member
0 Likes
2,004

Hi,

I am trying to call the get_ddic_reference method. Here is my code:

TRY.

lr_column ?= lr_columns->get_column( columnname = 'CARRID' ).

CATCH cx_salv_not_found .

ENDTRY.

lr_column->get_ddic_reference( ).

It runs, but does not do anything. It seems obvious to me that there is nowhere to store the results of the "GET". how do I format this instruction "lr_column->get_ddic_reference( )" so that I capture the returned value(s)?

Thank you!

Andy

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,859

It has a returning parameter type as SALV_S_DDIC_REFERENCE. So you need to delare the structure for this, then call the method and specify the returning parameter.

data: ls_ddic_ref type SALV_S_DDIC_REFERENCE.

ls_ddic_ref = lr_column->get_ddic_reference( ).

Regards,

Rich Heilman

15 REPLIES 15
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,860

It has a returning parameter type as SALV_S_DDIC_REFERENCE. So you need to delare the structure for this, then call the method and specify the returning parameter.

data: ls_ddic_ref type SALV_S_DDIC_REFERENCE.

ls_ddic_ref = lr_column->get_ddic_reference( ).

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,859

Hi:

Declare the type of get_ddic_reference and then assign <variable> = lr_column->get_ddic_reference( ).

Regards

Shashi.

Read only

0 Likes
1,859

Shashi,

I am not sure of what you mean when you say "Declare the type of get_ddic_reference ".

Can you please explain that?

Thank you.

Andy

Read only

0 Likes
1,859

This is strange. when I TYPE ls_ddic_ref as follows:

ls_ddic_ref TYPE REF TO salv_s_ddic_reference

I get the compile error stated in the above post.

When I TYPE it like this:

ls_ddic_ref(60) TYPE c.

I get past the compile error. I get a different warning, but I do not get an error.

Andy

Read only

0 Likes
1,859

Check the signature of the method GET_DDIC_REFERENCE of class CL_SALV_COLUMN and declare the variable with same type.

I am not getting the compiler error when I use like:


* Method GET_DDIC_REFERENCE signature
* @7B\QReturning@	VALUE( VALUE )	TYPE SALV_S_DDIC_REFERENCE

  DATA: ls_ddic_ref TYPE salv_s_ddic_reference.   " Same as method returning type
  TRY.
      lr_column ?= lr_columns->get_column( 'CARRID' ).
    CATCH cx_salv_not_found.                            "#EC NO_HANDLER
  ENDTRY.
  ls_ddic_ref = lr_column->get_ddic_reference( ).

Regards,

Naimesh Patel

Read only

0 Likes
1,859

Naimesh,

My lr_columns reference is to CL_SALV_COLUMNS_TABLE, not to CL_SALV_COLUMN.

It appears as tho the method GET_DDIC_REFERENCE exists in both classes, but for some reason it is not working correctly when called from CL_SALV_COLUMNS_TABLE in my code, but does work correctly when called from CL_SALV_COLUMN in your code.

Does this make sense to you? Why would the method exist in CL_SALV_COLUMNS_TABLE but not work correctly?

I guess I picked a tough one to learn on!

Thanks for your help!

Andy

Edited by: Andrew Brusko on Apr 1, 2009 3:43 PM

Read only

0 Likes
1,859

I guess, you seems to be little confused here.

Your first post says:


TRY.
lr_column ?= lr_columns->get_column( columnname = 'CARRID' ).
CATCH cx_salv_not_found .
ENDTRY.

lr_column->get_ddic_reference( ).

From this code, it is clear that you are trying to get the COLUMN object from all the COLUMNS. So, your LR_COLUMN would be referring to CL_SALV_COLUMN_TABLE.

And I don't think GET_DDIC_REFERENCE in CL_SALV_COLUMNS_TABLE would make any sense because it should return the DDIC reference for one Column.


*... set the columns technical
  DATA: lr_columns TYPE REF TO cl_salv_columns_table,
        lr_column  TYPE REF TO cl_salv_column_table.
  DATA: ls_ddic_ref TYPE salv_s_ddic_reference.

  TRY.
      lr_column ?= lr_columns->get_column( 'CARRID' ).
    CATCH cx_salv_not_found.                            "#EC NO_HANDLER
  ENDTRY.

  ls_ddic_ref = lr_column->get_ddic_reference( ).

Regards,

Naimesh Patel

Read only

0 Likes
1,859

I'm sorry...you are right. I'm very new to this and still not relating everything correctly in my mind.

Let me restate this correctly (I'll take my time this time!):

I am creating my original ALV reference (gr_alv) from the following method call.

TRY.

cl_salv_table=>factory(

EXPORTING

list_display = if_salv_c_bool_sap=>false

container_name = 'my_control_area'

IMPORTING

r_salv_table = gr_alv

CHANGING

t_table = it_sflight

).

CATCH cx_salv_msg INTO gr_error.

ENDTRY.

From this reference (gr_alv), I create a reference to CL_SALV_COLUMNS_TABLE (lr_columns) as follows: lr_columns = gr_alv->get_columns( ).

From lr_columns I am calling GET_COLUMNS which I thought was retruning a reference (lr_column) to CL_SALV_COLUMN_TABLE, but it might be returning a reference to CL_SALV_COLUMN. Apparently these are to similar but slightly different classes. I'm not sure which class I am getting a reference to in this situation.

My call looks like this:

TRY.

lr_column ?= lr_columns->get_column( columnname = 'CARRID' ).

CATCH cx_salv_not_found .

ENDTRY.

So in your prior post you reference class CL_SALV_COLUMN, but I am wondering if I am really working with an instance of CL_SALV_COLUMN_TABLE and if this is why your version works and mine does not.

Sorry for misstating this the first time...hope this makes sense, and above all, Thanks For Reading!!!

Andy

Read only

0 Likes
1,859

Here are my declarations:

DATA: gr_alv TYPE REF TO cl_salv_table.

DATA: lr_columns TYPE REF TO cl_salv_columns_table.

DATA: lr_column TYPE REF TO cl_salv_column_table.

Read only

0 Likes
1,859

Have look at the class CL_SALV_COLUMN_TABLE. It is a subclass of the CL_SALV_COLUMN_LIST which is a subclass of the CL_SALV_COLUMN.


CL_SALV_COLUMN
  '---- CL_SALV_COLUMN_LIST
          '---- CL_SALV_COLUMN_TABLE

Mehtod GET_DDIC_REFERENCE is being inherited from the CL_SALV_COLUMN into the calss CL_SALV_COLUMN_TABLE. So, when we are calling the method, it actually calls the method from the CL_SALV_COLUMN. That's why I mentioned this class in my first reply


ls_ddic_ref = lr_column->get_ddic_reference( ).

Copy the program SALV_DEMO_TABLE_COLUMNS to the Z program and try to Put the code as given in previous post in the subroutine DISPLAY_FULLSCREEN.

Regards,

Naimesh Patel

Read only

0 Likes
1,859

Naimesh,

I don't know what to say. I did as you have suggested in program SALV_DEMO_TABLE_COLUMNS and it compiled perfectly.

The code that is in there is exactly the same as the code that I am using in my program, but it will not compile.

I have the following DATA declarations

  • Reference for COLUMNS subclass

DATA: lr_columns TYPE REF TO cl_salv_columns_table.

  • Reference for COLUMN subclass

DATA: lr_column TYPE REF TO cl_salv_column_table.

  • Define a variable TYPEd to salv_s_ddic_reference for GET_DDIC_REFERENCE method

DATA: ls_ddic_ref TYPE REF TO salv_s_ddic_reference.

And I have the following method calls:

    • Get a column instance to sample the GET methods

TRY.

lr_column ?= lr_columns->get_column( 'CARRID' ).

CATCH cx_salv_not_found .

ENDTRY.

  • Change the Short Text

l_shorttext = text-car.

lr_column->set_short_text( value = l_shorttext ).

  • Get DDIC Reference

  • ls_ddic_ref = lr_column->get_ddic_reference( ).

I put the set_short_text in to be sure that all the references were working and it is. When I un-comment the ls_ddic_ref = lr_column->get_ddic_reference( ). line I get the compile error.

I don't want to waste any more of your time. you have told me all the correct things to do...I have made some mistake somewhere.

Thank you very much for your time and help...you have spent more time that you should have to!

Andy

Read only

0 Likes
1,859

Naimesh,

I found what I was doing wrong...beginner mistake.

I was declaring my variables using TYPE REF TO instead of just TYPE.

Big difference!!!

Sorry for wasting your time...but you did make a lot of things more clear to me...thanks again!

Andy

Read only

0 Likes
1,859

Hello Andrew

There is a simple mistake in your coding:


...
* Define a variable TYPEd to salv_s_ddic_reference for GET_DDIC_REFERENCE method
DATA: ls_ddic_ref TYPE REF TO salv_s_ddic_reference.  " <<< It's a structure not a class/interface !!!

DATA: ls_ddic_ref   TYPE salv_s_ddic_reference.
...

Regards

Uwe

Read only

Former Member
0 Likes
1,859

Thank you both for your replies. I have a variable defined as follows:

DATA: ls_ddic_ref TYPE REF TO salv_s_ddic_reference.

and I changed the method call to the follwoing:

TRY.

lr_column ?= lr_columns->get_column( columnname = 'CARRID' ).

CATCH cx_salv_not_found .

ENDTRY.

ls_ddic_ref = lr_column->get_ddic_reference( ).

I am getting a compile error that states:

The result type of the function method cannot be converted into the type of LS_DDIC_REF.

Is there something about column 'CARRID' that might be causing the problem?

Thanks again,

Andy

Read only

Former Member
0 Likes
1,859

Uwe,

Thank you for the reply. I just found that mistake a few seconds before your post...I feel like a real beginner!!!

Thank you for responding!

Andy