1. 程式人生 > >ABAP--REUSE ALV GRID DISPLAY的i callback user command的呼叫跟蹤摘抄

ABAP--REUSE ALV GRID DISPLAY的i callback user command的呼叫跟蹤摘抄

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow

也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!

               

1、跟蹤呼叫關係列表

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  主程式 型別 處理過程名 程式碼單元
1 ZHRR0005 EVENT END-OF-SELECTION    
2 SAPLSLVC_FULLSCREEN FUNCTION REUSE_ALV_GRID_DISPLAY   LSLVC_FULLSCREENU01
3 SAPLSLVC_FULLSCREEN MODULE (PAI)
PAI   LSLVC_FULLSCREENI01
4 SAPLSLVC_FULLSCREEN Form PAI   LSLVC_FULLSCREENF01
5 CL_GUI_CFW METHOD DISPATH CL_GUI_CFW CL_GUI_CFW====================CM001
6 CL_GUI_ALV_GRID METHOD DISPATH
CL_GUI_ALV_GRID  
7 SAPLSLVC_FULLSCREEN METHOD HANDLE_DOUBLE_CLICK LCL_EVENT_RECEIVER LSLVC_FULLSCREENTOP
8 SAPLSLVC_FULLSCREEN FORM METHOD_DOUBLE_CLICK   LSLVC_FULLSCREENF02
9 SAPLSLVC_FULLSCREEN FORM USER_COMMAND   LSLVC_FULLSCREENF01
10 ZHRR0005 FORM USER_COMMAND    

 2、各個函式程式碼摘抄(紅色為斷點處)
第2步程式碼摘抄
function reuse_alv_grid_display.                            "#EC *
.....
  if i_screen_start_column is initial and
     i_screen_start_line   is initial and
     i_screen_start_column   is initial and
     i_screen_end_line     is initial.
    gt_grid-flg_popup = space.
    call screen 500.
  else.
    gt_grid-flg_popup = 'X'.
    call screen 700
              starting at i_screen_start_column i_screen_start_line
              ending   at i_screen_end_column i_screen_end_line.
  endif.
.....
endfunction.

第3步程式碼摘抄
螢幕500
process after input.
  module pai.
module pai input.
 
perform pai.
endmodule.                             " PAI  INPUT

第4步程式碼摘抄
form pai.
.....
      when '&IC1'.
        if not gt_grid-s_layout-f2code is initial.
          perform method_double_click using l_okcode.
        endif.
      when others.
        if l_okcode(4) eq '%_GC'.
          call method cl_gui_cfw=>dispatch.
          l_okcode = g_temp_ok_code.    "via double_click
        else.
          perform user_command using l_okcode lflg_refresh lflg_exit
                                     ls_stable.
          if lflg_exit = 'X'.
            e_exit_caused_by_caller = 'X'.
            perform exit.
          else.
*           IF LFLG_REFRESH = 'X'.
            if not lflg_refresh is initial.
              if lflg_refresh = 'X'.
                call method gt_grid-grid->refresh_table_display
                  exporting
                    is_stable = ls_stable.
              elseif lflg_refresh = 'S'.
                call method gt_grid-grid->refresh_table_display
                  exporting
                    is_stable      = ls_stable
                    i_soft_refresh = 'X'.
              endif.
              if not gt_grid-i_callback_top_of_page is initial.
                call method gt_grid-grid->list_processing_events
                  exporting
                    i_event_name = 'TOP_OF_PAGE'
                    i_dyndoc_id  = gt_grid-top.
              endif.
              if not gt_grid-i_callback_end_of_list is initial.
                call method gt_grid-grid->list_processing_events
                  exporting
                    i_event_name = 'END_OF_LIST'
                    i_dyndoc_id  = gt_grid-bottom.
              endif.
            endif.
          endif.
        endif.
....
endform.

第5步程式碼摘抄(CL_GUI_CFW)
METHOD DISPATCH .
   if  IS_SHELLEVENT = 'X' and eventid = 15.
      call method handle_dragdrop_event
        exporting
           SHELLID           = MY_SHELL
           CARGO             = CARGO.
   else.
*   Notify object
    CALL METHOD CFW_SUBSCRIBER-REF->DISPATCH
      EXPORTING
        EVENTID           = EVENTID
        IS_SHELLEVENT     = IS_SHELLEVENT
        CARGO             = CARGO
        IS_SYSTEMDISPATCH = SPACE.
   endif.
   call method pop_event
         exporting current_event = l_event.
...
ENDMETHOD.

第6步程式碼摘抄(CL_GUI_ALV_GRID)
METHOD DISPATCH .
      call method cl_gui_cfw=>flush.
      append ls_row to lt_row.
        call method me->map_row_to_roid
          exporting
            it_index_rows = lt_row
          importing
            et_row_no     = lt_roid.
        read table lt_roid into ls_row_no index 1.

      read table m_cl_variant->mt_fieldcatalog into ls_fieldcat
                 with key fieldname = ls_col-fieldname.

      if sy-subrc eq 0.
        if not mr_trace is initial.
          call method mr_trace->add_trace_item
            exporting
              i_trace_item = 'EVENT: DOUBLE_CLICK'
              ir_variant   = m_cl_variant
              it_data      = mt_data
              it_info      = mt_info.
        endif.
        raise event double_click exporting e_row     = ls_row
                                           e_column  = ls_col
                                           es_row_no = ls_row_no.
...
ENDMETHOD.


第7步程式碼摘抄
  method handle_after_user_command.
    g_after = 'A'.
    perform event_exit_check using e_ucomm
                                   g_after.
    if g_after = 'X'.
      perform method_user_command using e_ucomm.
    endif.

    if not gt_grid-i_callback_top_of_page is initial.
      call method gt_grid-grid->list_processing_events
        EXPORTING
          i_event_name = 'TOP_OF_PAGE'
          i_dyndoc_id  = gt_grid-top.
    endif.
    if not gt_grid-i_callback_end_of_list is initial.
      call method gt_grid-grid->list_processing_events
        EXPORTING
          i_event_name = 'END_OF_LIST'
          i_dyndoc_id  = gt_grid-bottom.
    endif.

    clear g_after.
  endmethod.                    "handle_after_user_command
*
  method handle_data_changed.
    perform method_data_changed using er_data_changed.
  endmethod.                    "handle_data_changed
*
  method handle_top_of_page.
    perform method_top_of_page using e_dyndoc_id.
  endmethod.                    "handle_top_of_page

  method handle_end_of_page.
    perform method_end_of_page.
  endmethod.                    "handle_end_of_page

  method handle_double_click.
    perform method_double_click using g_temp_ok_code.
  endmethod.                    "handle_double_click

第8步程式碼摘抄
form method_double_click using r_ucomm type sy-ucomm.
  data: l_ucomm type sy-ucomm.
  data: l_save_ucomm   type sy-ucomm.
  data: lflg_refresh(1) type c.
  data: lflg_exit(1) type c.
  data: ls_stable type lvc_s_stbl.
*
  l_ucomm = gt_grid-s_layout-f2code.
  if l_ucomm(1) = '&'.
    call method gt_grid-grid->set_function_code
      changing
        c_ucomm = l_ucomm.
  else.
    if l_ucomm = space.
      l_ucomm = '&IC1'.
    endif.
    l_save_ucomm = l_ucomm.
    perform user_command using l_ucomm
                               lflg_refresh lflg_exit ls_stable.
    if l_ucomm ne l_save_ucomm.
      r_ucomm = l_ucomm.
    else.
      r_ucomm = space.
    endif.
    if lflg_exit = 'X'.
      e_exit_caused_by_caller = 'X'.
      perform exit.
    else.
      if lflg_refresh = 'X'.
        call method gt_grid-grid->refresh_table_display
          exporting
            is_stable = ls_stable.
      elseif lflg_refresh = 'S'.
        call method gt_grid-grid->refresh_table_display
          exporting
            is_stable      = ls_stable
            i_soft_refresh = 'X'.
      endif.
    endif.
  endif.
endform.                               " METHOD_DOUBLE_CLICK

第9步程式碼摘抄
form user_command using r_ucomm type sy-ucomm
                        r_refresh
                        r_exit
                        rs_stable type lvc_s_stbl.
  data: ls_selfield type slis_selfield.
*
  check not gt_grid-i_callback_user_command is initial.
  check not i_callback_program is initial.

  perform selfield_get using ls_selfield.
  if r_ucomm is initial.
    r_ucomm = '&IC1'.
  endif.

  perform (gt_grid-i_callback_user_command)
                                    in program (i_callback_program)
                                    using r_ucomm
                                          ls_selfield.

  rs_stable-row = ls_selfield-row_stable.
  rs_stable-col = ls_selfield-col_stable.

  r_refresh = ls_selfield-refresh.
  r_exit    = ls_selfield-exit.
endform.                    "user_command

           

給我老師的人工智慧教程打call!http://blog.csdn.net/jiangjunshow

這裡寫圖片描述