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

ALV Grid

Former Member
0 Likes
1,715

I have a grid embedded in a custom control. I have

inserted some code in a PBO event to modify

several column attributes of the grid. The code

does not throw any exceptions, but the changes are

not reflected in the rendered grid.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,677

I think it has to do with this:

I am not using a table from the dictionary. Instead I am defining my own

table type within code.

And I believe there is some parameter that needs to be set to identify

the table as not coming from the dictionary.

I will do some more looking, but I am pretty sure this is the problem.

I have a grid embedded in a custom control. I have

inserted some code in a PBO event to modify

several column attributes of the grid. The code

does not throw any exceptions, but the changes are

not reflected in the rendered grid.

13 REPLIES 13
Read only

amit_khare
Active Contributor
0 Likes
1,677

Cant say much about the error without seeing the code, but it is not activating somehow, so best will be refer to any BCALV_* report in SAP only and check for it.

Regards,

Amit

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
1,677

Hi,

I mean you are describing about table control i.e., GRID which u r referring, what kind of attributes you are changing ? elaborate.

thanks,

sksingh

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,677

Can you please post your codeing of the PBO?

Regards,

Rich Heilman

Read only

former_member194669
Active Contributor
0 Likes
1,677

Usually we used to modify the fieldcatalog for changing the attributes. Are doing the same ?

aRs

Read only

Former Member
0 Likes
1,677

Here is some of the code in the PBO.

data salv_columns type ref to cl_salv_columns_table.

data salv_column type ref to cl_salv_column.

salv_columns = processed_salv_table->get_columns( ).

TRY.

salv_column = salv_columns->get_column( 'LINE_NUMBER' ).

salv_column->set_visible( if_salv_c_bool_sap=>false ).

salv_column->set_technical( if_salv_c_bool_sap=>false ).

CATCH cx_salv_not_found.

ENDTRY.

Read only

0 Likes
1,677

Ah, yes the ALV Object Model. Excellent.

Your coding actually work pretty good in my system. Can I see the rest of the program?

Is LINE_NUMBER the correct name for the field?

Regards,

RIch Heilman

Read only

0 Likes
1,677

As you can see in this simple example program, the setting of the attributes works fine. I have a screen 100 here with a single container in the dynpro called "CONTAINER'.



REPORT zrich_001.

DATA: ispfli TYPE TABLE OF spfli.

DATA: container    TYPE REF TO cl_gui_custom_container.

DATA: gr_table     TYPE REF TO cl_salv_table.
DATA: gr_functions TYPE REF TO cl_salv_functions.
DATA: gr_display   TYPE REF TO cl_salv_display_settings.
DATA: gr_columns   TYPE REF TO cl_salv_columns_table.
DATA: gr_column    TYPE REF TO cl_salv_column.

START-OF-SELECTION.
  SELECT * INTO TABLE ispfli FROM spfli.
  CALL SCREEN 100.
*
*&---------------------------------------------------------------------*
*&      Module  PBO  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.

  CREATE OBJECT container
           EXPORTING container_name = 'CONTAINER'.

  cl_salv_table=>factory( EXPORTING r_container  = container
                          IMPORTING r_salv_table = gr_table
                           CHANGING t_table      = ispfli ).

  gr_functions = gr_table->get_functions( ).
  gr_functions->set_all( abap_true ).

  gr_columns = gr_table->get_columns( ).
  gr_column = gr_columns->get_column( 'CITYTO' ).
  gr_column->set_visible( if_salv_c_bool_sap=>false ).
  gr_column->set_technical( if_salv_c_bool_sap=>false ).

  gr_table->display( ).

ENDMODULE.                 " PBO  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  PAI  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pai INPUT.

ENDMODULE.                 " PAI  INPUT

REgards,

RIch Heilman

Read only

Former Member
0 Likes
1,677

I have used the code in another application with no problems.

The problem arises when putting the grid

into a container. The grid is created in the PBO event, and I have

tried setting the column attributes inside the same PBO event, but

with no luck.

I have stepped into the code and see that the changelist is properly

updated with the coded requests. I have also tried putting the requested

changes in a PAI event just to test it. But again no luck here either.

Read only

0 Likes
1,677

Hmmm, intesting. Work good for me. What release and SP level are you at?

Regards,

RIch Heilman

Read only

Former Member
0 Likes
1,678

I think it has to do with this:

I am not using a table from the dictionary. Instead I am defining my own

table type within code.

And I believe there is some parameter that needs to be set to identify

the table as not coming from the dictionary.

I will do some more looking, but I am pretty sure this is the problem.

Read only

0 Likes
1,677

That senario seems to be working for me too.



REPORT zrich_001.

Types: begin of tspfli.
      include type spfli.
Types: line_number(6) type n.
Types: end of tspfli.

DATA: ispfli TYPE TABLE OF tspfli.
data: xspfli like line of ispfli.

DATA: container    TYPE REF TO cl_gui_custom_container.

DATA: gr_table     TYPE REF TO cl_salv_table.
DATA: gr_functions TYPE REF TO cl_salv_functions.
DATA: gr_display   TYPE REF TO cl_salv_display_settings.
DATA: gr_columns   TYPE REF TO cl_salv_columns_table.
DATA: gr_column    TYPE REF TO cl_salv_column_table.

START-OF-SELECTION.
  SELECT * INTO TABLE ispfli FROM spfli.
    Loop at ispfli into xspfli.
        xspfli-line_number = sy-tabix.
        modify ispfli from xspfli index sy-tabix.
    endloop.
  CALL SCREEN 100.
*
*&---------------------------------------------------------------------*
*&      Module  PBO  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.

  CREATE OBJECT container
           EXPORTING container_name = 'CONTAINER'.

  cl_salv_table=>factory( EXPORTING r_container  = container
                          IMPORTING r_salv_table = gr_table
                           CHANGING t_table      = ispfli ).

  gr_functions = gr_table->get_functions( ).
  gr_functions->set_all( abap_true ).

  gr_columns = gr_table->get_columns( ).
  gr_column ?= gr_columns->get_column( 'LINE_NUMBER' ).
  gr_column->set_long_text( 'Line Number' ).
  gr_column->set_visible( if_salv_c_bool_sap=>false ).
  gr_column->set_technical( if_salv_c_bool_sap=>false ).

  gr_table->display( ).

ENDMODULE.                 " PBO  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  PAI  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pai INPUT.

ENDMODULE.                 " PAI  INPUT

Regards,

Rich Heilman

Read only

former_member194669
Active Contributor
0 Likes
1,677

Hi,

Make force triiggering of PBO using

call method cl_gui_cfw=>set_new_ok_code

exporting

new_code = 'DUMY'.

Thanks

aRs

Read only

Former Member
0 Likes
1,677

Thanks for the code. Everything works fine now.