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: 

Display different record in ALV Grid after provide different selection

Former Member
0 Kudos
118

Hi All,

I am a newbie.

This is my situation:

Firstly, on dropdown list, I select 'Annual'. Then, the alv grid display all records for 'Annual'.

Then, I select 'Sick', I'd like to use the same ALV Grid to display all records for 'Sick'.

I'd like to know if this is doable. If yes, can you show me some sample of coding which I can use as references.

If it is not possible, I'd like to ask for y'all opinion whether it is efficient to use different ALV Grid for different selection?

Hope to hear from you soon. Thank you very much.

1 ACCEPTED SOLUTION

former_member205763
Active Contributor
0 Kudos
88

Based on the value selected, populate different data in your final internal table and pass this table to ALV method/FM.

is your data differentiated by rows or columns?

if you require different column depending on the value in listbox then maintain different layouts and set the layout in the code itself.

10 REPLIES 10

former_member205763
Active Contributor
0 Kudos
89

Based on the value selected, populate different data in your final internal table and pass this table to ALV method/FM.

is your data differentiated by rows or columns?

if you require different column depending on the value in listbox then maintain different layouts and set the layout in the code itself.

0 Kudos
88

Hi,

Thanks for the respond.

I already made it like this: when user choose another selection, the table will be populated with new records based on the selection.

My data is differentiated by rows.

0 Kudos
88

since you have already have the logic to populate your table based on user selection, then are you still facing the issue with the ALV now?

0 Kudos
88

Yes. The ALV Grid do not display the records from the new selection.

0 Kudos
88

can you show me the code

0 Kudos
88

Hi,

whenever you change data in your internal table you need to refresh the alv grid display. Use the method

yourgridvariable->refresh_table_display.

Best Regards.

Aswath

0 Kudos
88

This is the snippet of the code:

if l_rbtlvreqlvid = 'X'.

"search based on leave id

select *

into gw_leave

from zabmd_leave

where lv_id = l_lvreqlvid.

append gw_leave to gt_leave.

endselect.

if g_lvreq_cus_cont is initial.

create object g_lvreq_cus_cont

exporting

container_name = 'L_LVREQCONT2'.

create object g_lvreq_alv_grid

exporting

i_parent = g_lvreq_cus_cont.

g_lvreq_alv_grid->set_table_for_first_display(

exporting

i_structure_name = 'zabmd_leave'

changing

it_outtab = gt_leave

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4

).

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

call screen 222.

else.

g_lvreq_alv_grid->refresh_table_display(

exceptions

finished = 1

others = 2

).

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

call screen 222.

endif.

0 Kudos
88

have your alv method outside all conditions:

if  cond1.
  populate gt_leave1.
elseif cond2
  populate gt_leave2.
endif.

if gt_leave1 is not initial.
  gt_leave = gt_leave1.   "or u may prefer to use 'append lines of' if u have addtional data
elseif gt_leave2 is not initial.
  gt_leave = gt_leave2.   "or u may prefer to use 'append lines of' if u have addtional data
endif.  
g_lvreq_alv_grid->set_table_for_first_display(
exporting
i_structure_name = 'zabmd_leave'
changing
it_outtab = gt_leave
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
).

0 Kudos
88

Hi,

The code snippet is not at all a problem if you have written it in PBO.

and call refresh_table_display just after you change your internal table in PAI.

Best regards.

Aswath

0 Kudos
88

Hi,

Thanks everyone for the respond. I have solved it on my own.

Again, thank you very much for the respond.