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: 

Loop not working in oo-alv method

Former Member
0 Kudos
184

Dear Friends,

I am working on oo-alv interactive report.

the first list displaying properly.

but the code in the method of double_click event is not working.

Actually i have the detailed data in it_final2.

IN the first secondary screen i have to display the detailed data of the selected line.

I attached my second fcat to the respective set_table_for.... but it is stil displaying the first fcat fields only.

can anyone help me.

14 REPLIES 14

Former Member
0 Kudos
111

Edited by: kishan P on Jan 31, 2012 11:50 AM

Edited by: ch.prameela on Jan 31, 2012 7:31 AM

0 Kudos
111

Hi,

you have to clear container and clear first field catalog internal table .

0 Kudos
111

Dear kirthi,

i am using different containers and different fieldcats.

even though i refresh the first fcat.

0 Kudos
111

Hi Anurag,

Are you using different screens for both alv or made two different containers in one screen?

If you are using the same two different containers you have to make one container parent and the secondary alv in child container.

Best Regards.

Aswath.

0 Kudos
111

Hi Aswastha,

i am using screen 100 & 101.

cont1 & cont2.

Can anyone please help me.

I am not getting the second fcat in the second screen.

why the loop-endloop are not working .. ?

0 Kudos
111

Hi Anurag,

Would you please place here the code you have on the double-click event & the loop...endloop you are saying.

Thanks!

-Michael

0 Kudos
111

Hi Sumaya,



* In below it_final1 has collective sum of bukrs saknr wrbtr
* it_final2 has collective sum of bukrs saknr lifnr wrbtr.
class handle_events definition.
  public section.
    methods : handle_dclick for event double_click of cl_gui_alv_grid
                                      importing       e_row.
endclass.                    "handle_events DEFINITION

class handle_events implementation.
  method handle_dclick.
    read table it_final1 into wa_final1 index e_row-index.
    call screen 101.
  endmethod.                    "handle_dclick
endclass.     

**at 101 screen**
 MODULE get_data.
 MODULE STATUS_0101.
module get_data.
loop at it_final2 into wa_final2 where bukrs eq wa_final1-bukrs.
                                                  and  saknr eq wa_final1-saknr.
wa_final3-bukrs = wa_final2-bukrs.
wa_final3-lifnr   = wa_final2-lifnr.
wa_final3-name1 = wa_final2-name1.
wa_final3-wrbtr  = wa_final2-wrbtr.
collect wa_final3 into it_final3.
clear : wa_final2, wa_final3.
endloop.

module status_0101 output.
  set pf-status 'ZJSTATUS'.

  create object o_container1
    exporting
      container_name = 'CONTAINER1'.

  create object o_grid1
    exporting
      i_parent = o_container1.

    call method o_grid1->set_table_for_first_display
  exporting
    is_variant                     = w_variant
    i_save                         = w_save
    i_default                      = 'X'
    is_layout                      =  w_layout1
*     is_print                     =
  changing
    it_outtab                      =      it_final3
    it_fieldcatalog                =      it_fcat1.

endmodule.                 " STATUS_0101  OUTPUT

0 Kudos
111

Hi Anurag,

Couple of points to check/consider::

1. You can move the code (LOOP...ENDLOOP) in MODULE get_data inside the METHOD handle_dclick just after the READ table statement (You forgot also the ENDMODULE statement for MODULE get_data).

2. Debug after the loop to check if it_final3 contains records.

3. I'm seeing 1's in the object references (o_container1,o_grid1,w_layout1,it_fcat1) but i'll just assume that the first objects in the screen 100 were named differently. With that, I see no problems...

0 Kudos
111

Dear Sumaya,

i moved the loop statement into method.

it is working fine .. but when i click on first record it is giving the detailed list.

when i come back and click on another row it is displaying the previous record details i.e. it is giving the previous data.

and also the second fcat is not displayed.

and if i use double clik three times in the first screen i have to click back button thrice.. can't we control it.

KIndly help me please.

0 Kudos
111

Hi Anurag,

when i come back and click on another row it is displaying the previous record details i.e. it is giving the previous data.

Clear the workarea/Refresh internal tables first before re-assigning values.


method handle_dclick.
  clear wa_final1.
  read table it_final1 into wa_final1 index e_row-index.
  ...


module get_data.
  refresh it_final3.
  loop at it_final2 into wa_final2 where bukrs eq wa_final1-bukrs.
  ...

and also the second fcat is not displayed.

refresh the it_fcat1then rebuild it before using. and you can use this code


CALL METHOD o_grid1->set_frontend_layout
  exporting
    is_layout = it_fcat1

and if i use double clik three times in the first screen i have to click back button thrice.. can't we control it.

check if the object references are already created to prevent duplicating...


module status_0101 output.
  ...
  if o_container1 is initial.
    create object o_container1
    ...
  endif.
  if o_grid1 is initial. "Create the first instance
    create object o_grid1
    ...
    call method o_grid1->set_table_for_first_display
    ...
  else. "Refresh the grid
    call method o_grid1->refresh_table_display.
  endif.
endmodule.

Edited by: Michael.Sumaya on Jan 31, 2012 10:39 AM

0 Kudos
111

Dear Sumaya,

I get resolved all the issues except the back button(i have to press that many times of double click).

in the ucomm_module

i wrote ' leave to screen 0'.

Second Fcat is displaing properly.

Displaying the Detailed is also workin fine.

Edited by: anurag.radha on Jan 31, 2012 11:34 AM

0 Kudos
111

Hi friends,

i have changed the field fROM WRBTR to DMBTR.

it is not displaying the output list.

i passed the following fcat for dmbtr..


  clear wa_fcat.
  cntr = cntr + 1.
  wa_fcat-col_pos   = cntr.
  wa_fcat-fieldname = 'DMBTR'.
  wa_fcat-Cfieldname = 'DMBTR'.
  wa_fcat-coltext   = 'Total Amt'.
  wa_fcat-ref_table = 'IALV'.
  wa_fcat-hotspot   = 'X'.
  wa_fcat-outputlen = '13'.
  append wa_fcat to it_fcat.

if any changes required kindly help me.

Edited by: anurag.radha on Jan 31, 2012 1:22 PM

0 Kudos
111

Thank you sumaya,

issue resolved.. that field is hidden in layout.

Former Member
0 Kudos
111

Check ALv Example BCALV_GRID_02 in SE38.