Posted: Sat Jan 26, 2008 4:55 pm Post subject: Вisplays data from table SGOSHIST (Object History)
Code:
REPORT z_alv_object_history.
*---------------------------------------------------------------------*
* This report displays data from table SGOSHIST (Object History) *
*---------------------------------------------------------------------*
* Author : Michel PIOUD - Updated 16-Nov-07 *
* HomePage : http://www.geocities.com/mpioud *
*---------------------------------------------------------------------*
* Macro definition
DEFINE m_ligne.
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.
CONSTANTS :
c_x VALUE 'X',
c_refresh TYPE syucomm VALUE '&REFRESH'.
*---------------------------------------------------------------------*
TYPE-POOLS slis. " ALV Global types
TYPES :
BEGIN OF ty_data,
sapname TYPE sgoshist-sapname, " SAP User name
name_last TYPE addr3_val-name_last, " User name
keyword TYPE swotbasdat-keyword, " Object type short text
objkey TYPE sgoshist-objkey, " Object key
objtype TYPE sgoshist-objtype, " Object type
timestamp TYPE sgoshist-timestamp, " Time stamp
tcode TYPE sgoshist-tcode, " Transaction code
ttext TYPE tstct-ttext, " Transaction text
END OF ty_data.
DATA :
g_bname TYPE ust04-bname, " Users
gs_sgoshist TYPE sgoshist, " Object History
gs_date TYPE range_s_dats,
gr_timestamp TYPE RANGE OF tzntstmps,
gs_timestamp LIKE LINE OF gr_timestamp,
gt_data TYPE STANDARD TABLE OF ty_data.
SELECTION-SCREEN :
SKIP, BEGIN OF LINE, COMMENT 1(35) v_6 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(3) TYPE n DEFAULT '200' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
LOOP AT s_date INTO gs_date.
CLEAR gs_timestamp.
gs_timestamp-sign = gs_date-sign.
gs_timestamp-option = gs_date-option.
IF NOT gs_date-low IS INITIAL.
CONVERT DATE gs_date-low TIME '000000'
INTO TIME STAMP gs_timestamp-low TIME ZONE sy-zonlo.
IF gs_date-high EQ '00000000'.
gs_timestamp-option = 'BT'.
CONVERT DATE gs_date-low TIME '235959'
INTO TIME STAMP gs_timestamp-high TIME ZONE sy-zonlo.
ENDIF.
ENDIF.
IF NOT gs_date-high IS INITIAL.
CONVERT DATE gs_date-high TIME '235959'
INTO TIME STAMP gs_timestamp-high TIME ZONE sy-zonlo.
ENDIF.
*---------------------------------------------------------------------*
* Form F_READ_DATA
*---------------------------------------------------------------------*
FORM f_read_data.
DATA l_adresse TYPE addr3_val.
FIELD-SYMBOLS <data> TYPE ty_data.
* Read data from SGOSHIST
SELECT * UP TO p_max ROWS
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM sgoshist
WHERE sapname IN s_sapnam
AND tcode IN s_tcode
AND objtype IN s_objtyp
AND objkey IN s_objkey
AND timestamp IN gr_timestamp
ORDER BY timestamp DESCENDING.
* Sort to improve performance of FM SUSR_USER_ADDRESS_READ
SORT gt_data BY sapname.
LOOP AT gt_data ASSIGNING <data>.
* Get Object type short text
CALL FUNCTION 'SWO_TEXT_OBJTYPE'
EXPORTING
objtype = <data>-objtype
IMPORTING
keyword = <data>-keyword.
* Get user address data
CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
EXPORTING
user_name = <data>-sapname "#EC DOM_EQUAL
IMPORTING
user_address = l_adresse
EXCEPTIONS
user_address_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CONCATENATE l_adresse-name_last l_adresse-name_first
INTO <data>-name_last SEPARATED BY space.
ELSE.
<data>-name_last = <data>-sapname.
ENDIF.
* Read transaction code text
CALL FUNCTION 'BAL_DSP_TXT_ALTCODE_READ'
EXPORTING
i_tcode = <data>-tcode
IMPORTING
e_text = <data>-ttext.
ENDLOOP.
ENDFORM. " F_READ_DATA
*---------------------------------------------------------------------*
* Form f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv,
lt_event_exit TYPE slis_t_event_exit,
ls_event_exit TYPE slis_event_exit,
ls_grid_settings TYPE lvc_s_glay.
ENDFORM. " F_DISPLAY_DATA
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm TYPE syucomm
us_selfield TYPE slis_selfield. "#EC CALLED
CASE u_ucomm.
WHEN c_refresh.
PERFORM f_read_data. " Refresh data
us_selfield-refresh = c_x.
ENDCASE.
ENDFORM. " USER_COMMAND
*---------------------------------------------------------------------*
* FORM PF_STATUS_SET *
*---------------------------------------------------------------------*
FORM pf_status_set USING ut_extab TYPE slis_t_extab. "#EC CALLED
* Display refresh button
DELETE ut_extab WHERE fcode = c_refresh.
SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'
EXCLUDING ut_extab.
ENDFORM. " PF_STATUS_SET
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
FORM top_of_page. "#EC CALLED
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.