Application Development 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: 

ALV using Reuse_Alv_grid_display

Former Member
0 Kudos

Hi Abapers,

I have designed one ALV for displaying training details. There can be max 4 trainers for every course..

1. Trainer1

2. Trainer2

3. Trainer3

4. Trainer4

My requirement is that Trainer2 should be displayed only if there is a second trainer for any of the courses being displayed. I have written logic for this by setting no_out = 'X' when there is no value for trainer2 by looping my internal table..

It's working fine when there are no default layouts being set up.

But it's not working when a default layout is existing with 4 trainers.

Please help me to achieve this functionality even when there is layout..

My code: Set no_out = 'X' based on flags being used for trainers.

LOOP AT tb_data INTO wa_data.

l_count = l_count + 1.

*--Trainer 1 Details

IF l_count EQ 1.

alv_itab-reftyp = wa_data-reftyp.

alv_itab-refid = wa_data-refid.

alv_itab-refshort = wa_data-refshort.

alv_itab-refname = wa_data-refname.

*--Trainer 2 Details

ELSEIF l_count EQ 2.

alv_itab-reftyp2 = wa_data-reftyp.

alv_itab-refid2 = wa_data-refid.

alv_itab-refshort2 = wa_data-refshort.

alv_itab-refname2 = wa_data-refname.

g_flag2 = c_x.

*--Trainer 3 Details

ELSEIF l_count EQ 3.

alv_itab-reftyp3 = wa_data-reftyp.

alv_itab-refid3 = wa_data-refid.

alv_itab-refshort3 = wa_data-refshort.

alv_itab-refname3 = wa_data-refname.

g_flag3 = c_x.

*--Trainer 4 Details

ELSEIF l_count EQ 4.

alv_itab-reftyp4 = wa_data-reftyp.

alv_itab-refid4 = wa_data-refid.

alv_itab-refshort4 = wa_data-refshort.

alv_itab-refname4 = wa_data-refname.

g_flag4 = c_x.

ELSE.

EXIT.

ENDIF.

CLEAR wa_data.

ENDLOOP.

Many Thanks in Advance!!

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Try with TECH instead of NO_OUT

FIELDCAT-TECH = 'X'.

5 REPLIES 5

former_member188685
Active Contributor
0 Kudos

Try with TECH instead of NO_OUT

FIELDCAT-TECH = 'X'.

0 Kudos

Hi Vijay,

Many Thanks for your help!!

Now its working irrespective of the saved layout as desired.. But i have one doubt, for one course trainer2,3,4 details are not available so, its just displaying trainer1 which is correct but these are getting displayed at the last irrespective of coloumn positions?

Also when i clicked on changed layout, I didnt find trainer2,3,4 columns in hidden set also.. If the user want to select these fields how to select?

Please reply..

Edited by: Premraj Cheguri on Sep 18, 2008 10:37 AM

0 Kudos

>Also when i clicked on changed layout, I didnt find trainer2,3,4 columns >in hidden set also.. If the user want to select these fields how to select?

TECH = 'X' will completely make the fields invisible.

But i Suggest you to to make use of Layout variants First Save the Layout with out using the TECH = 'X'.

and Now come to the code and use TECH = 'X' , so you will have two kinds of layout. you can choose the generic one when ever you want, there you can see all the fields

0 Kudos

Hi Vijay,

Can you please give me some sample code to save layout and use that layout..

0 Kudos

Saving the Layout can work only in the program level. so i will tell you how to do that.

First Save a Variant using TECH = ' '.

and second time save a variant using TECH = 'X' both will be availbe for you , which ever you want you can use in the output.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = sy-repid
      it_fieldcat        = it_fieldcat
      it_sort            = it_sort
      is_layout          = layout   "<--pass this too
      i_save             = 'X'          "<----pass this, this enable Save option
    TABLES
      t_outtab           = it_data
    EXCEPTIONS
      program_error      = 1.

Now you can see the Save layout option in the ALV output.