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

Dynamically changing ALV grid output

Former Member
0 Likes
1,104

Hi all,

i have a selection screen on which there are 6

checkboxes. depending on the combination of check

boxes selected the no of colums in the ALV grid output

should change.

for eg. if check box 3 , check box 5 , and check box 6

are selected then a fieldcatalog should be created which

will have fields corresponding to check box 3, then 5

and then 6 .

if only 5 ,6 are selected columns corresponding to only

them should be shown.

i cant write the code to populate fieldcat for each

of the combination of the 6 chkbox.

is there any other way to do it??

Regards,

Tarang

5 REPLIES 5
Read only

dani_mn
Active Contributor
0 Likes
771

HI,

You can use <b>'NO_OUT'</b> option to hide columns depending on selection. In this way you have to build only one field catalog.

Regards,

HRA

Read only

Former Member
0 Likes
771

hi HRA,

but this way also i will have to write

several if statements like.

1. if chk1 = 'X'

2. if chk1 = 'X' and Chk3 = 'X'

3. if chk3 = 'X' and chk 7 = 'X'.

and so on...

so there will be (2 raise to 6 )i.e 64 combinations

any other way

Read only

Former Member
0 Likes
771

Hello,

U can try like this. When u r populating the field catalog, U check for the checkbox values.

IF P_CHK1 = 'X' and P_CHK2 = 'X' and P_CHK3 = 'X'.

Populate the fieldcatalog values for the particular field.

ENDIF.

If useful reward.

Vasanth

Read only

Former Member
0 Likes
771

Hi,

Based on your Check box selection , use the Fieldcat option <b>TECH = 'X'</b>.

if check = 'X'.
fieldcat-tech = 'X'.
endif.

TECH = 'X' will not show the column in the output.

Regards

vijay

Read only

naimesh_patel
Active Contributor
0 Likes
771

Hello,

Ya that's true that you can't write statment for all but you can proceed in this way.

Make one internal table,

data: begin of it_col occurs 0,

check(10),

field(10),

end of it_col.

Fill this table as,

it_col-check = 'CHK1'.

it_col-field = 'FLD11'.

append it_col.

it_col-check = 'CHK1'.

it_col-field = 'FLD12'.

append it_col.

it_col-check = 'CHK2'.

it_col-field = 'FLD13'.

append it_col.

it_col-check = 'CHK2'.

it_col-field = 'FLD11'.

append it_col.

Now,

depending upon your selection of checkboxes,

if chk1 = 'X'.

loop at it_col where check = 'CHK1'.

  • populate your field catalog.

endloop.

endif.

if chk2 = 'X'.

loop at it_col where check = 'CHK2'.

  • populate your field catalog.

endloop.

endif.

At last you will be having your fields in catalog.

regards,

Naimesg