Posted: Sat Jan 26, 2008 4:57 pm Post subject: Displays Forms routines called from extended table
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.
*---------------------------------------------------------------------*
* 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.
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'.
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.
ENDFORM. " BDC_DYNPRO
*---------------------------------------------------------------------*
* FORM bdc_field *
*---------------------------------------------------------------------*
FORM bdc_field USING u_fnam TYPE fnam_____4
u_fval TYPE any.
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.