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

Problem with flow control using ALV grid

jrgkraus
Active Contributor
0 Likes
772

Hi to all,

i was writing a program to display batch job definitions in an ALV grid. The grid was placed in a docking container. After creating the ALV object, I registered two event handlers like this:

CREATE OBJECT go_handler.

  CALL METHOD go_alv_list->register_delayed_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_delayed_change_select.
  SET HANDLER go_handler->job_clicked FOR go_alv_list.
  SET HANDLER go_handler->angeklickt FOR go_alv_list.

The handler methods are defined like this:


    methods job_clicked for EVENT double_click of cl_gui_alv_grid
            IMPORTING E_ROW
                      E_COLUMN.


    methods angeklickt for event DELAYED_CHANGED_SEL_CALLBACK
            of cl_gui_alv_grid.

the coding of method double_click and called modules:

    perform usercomm using 'PICK' e_row-index e_column-fieldname.
-------------------------------------------------
FORM usercomm  USING r_ucomm LIKE sy-ucomm
                     iv_index iv_fieldname.

  DATA ls_list LIKE LINE OF gt_list.

  CASE r_ucomm.
(...)
     WHEN 'PICK'.
      READ TABLE gt_list INTO ls_list INDEX iv_index.
      CHECK sy-subrc = 0.
      CALL METHOD zcl_jobc_xbp=>job_sm37_zeigen
        EXPORTING
          jobname = ls_list-jobname.

     call method cl_gui_cfw=>flush.

  ENDCASE.

endform.
--------------------------------------------------
method JOB_SM37_ZEIGEN.


  submit z_jobc_show_sm37
         with jobname = jobname
         and return.


endmethod.

The called report contains a call of the function module "BP_JOB_MANAGEMENT" in order to display information about the double-clicked job in the SM37 way.

What the problem is:

when the user quits the SM37-like display, the event double_click is being fired immediately again. The function is called once again. This happens not every time, but in about 60% of all tries.

How do I get the program to exit the function module and return reliable to the main list?

Thanks to all

4 REPLIES 4
Read only

RaymondGiuseppi
Active Contributor
0 Likes
665

We don't have all the coding but it seems that your program call two forms when double-click is performed

(1) the event double_click raise the method job_clicked

=> First call ?

(2) user_command, 'PICK' raise the form

=> Second call ?

Try to comment the OK_CODE = 'PICK' coding.

Regards

Read only

0 Likes
665

job_clicked is called from the event doubleclick of the ALV Class. The handler method then calls the FORM user_command with the "PICK" command. There is no double callinng of any module.

Read only

Former Member
0 Likes
665

Why don't you in the double click method make a PERFORM (XXX) in PROGRAM (YYYY) if found.

Create the calling program name an instance attribute in your class.

Note don't pass this as SY-REPID but as a variable of type sy-repid.

In the ON_DOUBLE_CLICK method call your OWN double click facility passing the required parameters.

In your Own double click method make a call to a form in the calling program.

My Display Grid method receives the program name as an import parameter so it's available for the double click method in my class.

Then in the application program you can easily see where the double click is coming from and react accordingly.

example

I haven't shown the whole class -- I'm using my own reference to cl_gui_alv_grid.

Data definitions for using the class.

z_object type ref to zcl_alv_grid (my grid handling class)

grid1 type ref to cl_gui_alv_grid (the standard SAP OO ALV grid)



method constructor .
create object grid_container1
        exporting
*           container_name = 'CCONTAINER1'.
    container_name = cfname.
    create object  grid1
       exporting
          i_parent = grid_container1.
    set handler z_object->on_user_command for grid1.
    set handler z_object->on_toolbar for grid1.
    set handler z_object->handle_data_changed for grid1.
    set handler z_object->handle_data_changed_finished for grid1.
    set handler z_object->on_dubbelklik for grid1.
    set handler z_object->on_hotspot for grid1.
    call method grid1->register_edit_event
        exporting
           i_event_id = cl_gui_alv_grid=>mc_evt_enter.
  endmethod.

method on_dubbelklik .
call method me->dubbelklik
        exporting
           e_row  = e_row
           e_column =  e_column
           es_row_no = es_row_no.

* ...
endmethod.


method dubbelklik .
perform dubbelklik in program (caller)  if found

     using
      e_row
      e_column
      es_row_no.

* ...
endmethod.

in the application program



create object z_object  "instantiate my GRID class
       exporting
                  z_object = z_object
                  cfname = 'CCONTAINER1'.
     assign z_object to <fs1>.

"........ code to buiild data table and field catalog
"......   code to display grid

form dubbelklik using
        e_row   type lvc_s_row
        e_column type lvc_s_col
        es_row_no type lvc_s_roid.
  read table <dyn_table> index e_row into wa_elements.

.......
endform.

now you can check in the application program what cell was actually double clicked and take the relevant action.

Cheers

jimbo

Read only

jrgkraus
Active Contributor
0 Likes
665

The problem was the multiple registration of event handlers.