SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Displays Forms routines called from extended table



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Jan 26, 2008 4:57 pm    Post subject: Displays Forms routines called from extended table Reply with quote

Code:
REPORT z_alv_table_event_form.
*---------------------------------------------------------------------*
* This report displays Forms routines called from extended table      *
* (or view) maintenance - Double click on a line to display the form  *
*---------------------------------------------------------------------*
* Author : Michel PIOUD - Updated 24 dec 07                           *
* HomePage : http://www.geocities.com/mpioud                          *
*---------------------------------------------------------------------*
* Macro definition
DEFINE m_line.
  selection-screen :
    begin of line, comment 10(20) v_&1 for field &2.
  select-options &2 for &3.
  selection-screen end of line.
END-OF-DEFINITION.
*---------------------------------------------------------------------*

TYPE-POOLS slis.           " ALV Global types

*---------------------------------------------------------------------*
CONSTANTS :
  c_x VALUE 'X'.

*---------------------------------------------------------------------*
DATA :
  gs_tvimf   TYPE tvimf,   " User routines called from view maintenance
  gt_bdcdata TYPE TABLE OF bdcdata,
* Data to display
  gt_data    TYPE TABLE OF tvimf.

*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b0 WITH FRAME.
m_line 1 s_table gs_tvimf-tabname.                          "#EC NEEDED
m_line 2 s_event gs_tvimf-event.                            "#EC NEEDED
m_line 3 s_form  gs_tvimf-formname.                         "#EC NEEDED
SELECTION-SCREEN END OF BLOCK b0.
SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECTION-SCREEN :
BEGIN OF LINE, COMMENT 1(35) v_4 FOR FIELD p_max.           "#EC NEEDED
PARAMETERS p_max(3) TYPE n DEFAULT '200' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.

*---------------------------------------------------------------------*
INITIALIZATION.

  v_1 = 'Table or view'.
  v_2 = 'Event'.
  v_3 = 'Form name'.
  v_4 = 'Maximum number of selected entries'.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data.

*---------------------------------------------------------------------*
END-OF-SELECTION.

  PERFORM f_display_data.

*---------------------------------------------------------------------*
*       Form  F_READ_DATA
*---------------------------------------------------------------------*
FORM f_read_data.

* Read_data
  SELECT * UP TO p_max ROWS
         INTO TABLE gt_data
         FROM tvimf AS t
        WHERE tabname  IN s_table
          AND EXISTS ( SELECT * FROM dd02l WHERE tabname = t~tabname )
          AND event    IN s_event
          AND formname IN s_form
        ORDER BY PRIMARY KEY.

ENDFORM.                               " F_READ_DATA
*---------------------------------------------------------------------*
*      Form  f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.

* Macro definition
  DEFINE m_sort.
    add 1 to ls_sort-spos.
    ls_sort-fieldname = &1.
    ls_sort-up = &2.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.

  DATA:
    lt_sort   TYPE slis_t_sortinfo_alv,
    ls_sort   TYPE slis_sortinfo_alv,
    ls_layout TYPE slis_layout_alv.

  ls_layout-zebra             = c_x.
  ls_layout-cell_merge        = c_x.
  ls_layout-colwidth_optimize = c_x.
  ls_layout-group_change_edit = c_x.

  m_sort 'TABNAME' c_x.
  m_sort 'EVENT'   c_x.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = sy-cprog
      i_callback_user_command = 'USER_COMMAND'
      is_layout               = ls_layout
      i_structure_name        = 'TVIMF'
      it_sort                 = lt_sort
      i_save                  = 'A'
    TABLES
      t_outtab                = gt_data.

ENDFORM.                               " F_DISPLAY_DATA
*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm     TYPE syucomm
                        us_selfield TYPE slis_selfield.     "#EC CALLED

  DATA :
    ls_data TYPE tvimf.

  CASE u_ucomm.
    WHEN '&IC1'.                       " Pick
      READ TABLE gt_data INDEX us_selfield-tabindex INTO ls_data.
      CHECK sy-subrc EQ 0.
      PERFORM display_form USING ls_data.
  ENDCASE.

ENDFORM.                               " USER_COMMAND
*---------------------------------------------------------------------*
*       FORM DISPLAY_FORM                                             *
*---------------------------------------------------------------------*
FORM display_form USING us_data TYPE tvimf.

  REFRESH gt_bdcdata.

* Generate table view initial screen table/view
  PERFORM bdc_dynpro USING 'SAPMSVIM' '0050' '=SHOW'.
  PERFORM bdc_field  USING 'VIMDYNFLDS-ELEM_GEN' c_x.
  PERFORM bdc_field  USING 'VIMDYNFLDS-VIEWNAME' us_data-tabname.

* Events
  PERFORM bdc_dynpro USING 'SAPMSVIM' '0120' '=ADDR'.

* Find
  PERFORM bdc_dynpro USING 'SAPL0SVM' '0010' '=POSI'.

* Validate
  PERFORM bdc_dynpro USING 'SAPLSPO4' '0300' '=FURT'.
  PERFORM bdc_field  USING 'SVALD-VALUE(01)' us_data-event.

* Display form
  PERFORM bdc_dynpro USING 'SAPL0SVM' '0010' '=0001'.

* SE54 = Generate table view
  CALL TRANSACTION 'SE54' USING gt_bdcdata
                           MODE 'E'.

ENDFORM.                               " DISPLAY_FORM
*--------------------------------------------------------------------*
*       FORM bdc_dynpro                                              *
*--------------------------------------------------------------------*
FORM bdc_dynpro USING u_program TYPE bdc_prog
                      u_dynpro  TYPE bdc_dynr
                      u_okcode  TYPE bdc_fval.

  DATA :
    ls_bdcdata TYPE bdcdata.

  CLEAR ls_bdcdata.
  ls_bdcdata-program  = u_program.
  ls_bdcdata-dynpro   = u_dynpro.
  ls_bdcdata-dynbegin = c_x.
  APPEND ls_bdcdata TO gt_bdcdata.

  PERFORM bdc_field USING 'BDC_OKCODE' u_okcode.

ENDFORM.                               " BDC_DYNPRO
*---------------------------------------------------------------------*
*        FORM bdc_field                                               *
*---------------------------------------------------------------------*
FORM bdc_field USING u_fnam TYPE fnam_____4
                     u_fval TYPE any.

  DATA :
    ls_bdcdata TYPE bdcdata.

  CLEAR ls_bdcdata.
  ls_bdcdata-fnam = u_fnam.
  ls_bdcdata-fval = u_fval.
  APPEND ls_bdcdata TO gt_bdcdata.

ENDFORM.                               " BDC_FIELD
************** END OF PROGRAM Z_ALV_TABLE_EVENT_FORM ******************
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.