Posted: Sat Jan 26, 2008 4:07 pm Post subject: ALV List of standard text
Code:
REPORT z_alv_standard_text .
*---------------------------------------------------------------------*
* ALV List of standard text
*---------------------------------------------------------------------*
* Author : Michel PIOUD *
* Email : [email protected] HomePage : http://www.geocities.com/mpioud *
*---------------------------------------------------------------------*
CONSTANTS :
c_x VALUE 'X',
c_refresh TYPE syucomm VALUE '&REFRESH'.
*---------------------------------------------------------------------*
TYPE-POOLS :
slis. " ALV Global types
*---------------------------------------------------------------------*
TYPES BEGIN OF ty_data.
INCLUDE TYPE stxh.
TYPES: tdline TYPE tline-tdline,
checkbox(1) TYPE c.
TYPES: END OF ty_data.
*---------------------------------------------------------------------*
DATA: gs_stxh TYPE stxh.
DATA gt_data TYPE TABLE OF ty_data.
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK standard WITH FRAME.
SELECT-OPTIONS:
s_mandt FOR gs_stxh-mandt DEFAULT sy-mandt
MATCHCODE OBJECT ddsef4clnt,
s_tdname FOR gs_stxh-tdname,
s_id FOR gs_stxh-tdid,
s_spras FOR gs_stxh-tdspras.
SELECTION-SCREEN END OF BLOCK standard.
SELECTION-SCREEN BEGIN OF BLOCK extension WITH FRAME.
SELECT-OPTIONS:
s_title FOR gs_stxh-tdtitle NO INTERVALS,
s_macod1 FOR gs_stxh-tdmacode1 NO INTERVALS,
s_macod2 FOR gs_stxh-tdmacode2 NO INTERVALS,
s_fuser FOR gs_stxh-tdfuser MATCHCODE OBJECT user_comp,
s_fdate FOR gs_stxh-tdfdate,
s_freles FOR gs_stxh-tdfreles,
s_luser FOR gs_stxh-tdluser MATCHCODE OBJECT user_comp,
s_ldate FOR gs_stxh-tdldate,
s_lreles FOR gs_stxh-tdlreles.
SELECTION-SCREEN END OF BLOCK extension.
SELECTION-SCREEN BEGIN OF BLOCK max WITH FRAME.
PARAMETERS:
p_string TYPE tdtitle,
p_max TYPE numc3 DEFAULT '100'.
SELECTION-SCREEN END OF BLOCK max.
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
*---------------------------------------------------------------------*
* Form f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.
FIELD-SYMBOLS <data> TYPE ty_data.
SELECT * FROM stxh CLIENT SPECIFIED
INTO TABLE gt_data
UP TO p_max ROWS
WHERE tdobject = 'TEXT'
AND mandt IN s_mandt
AND tdname IN s_tdname
AND tdid IN s_id
AND tdspras IN s_spras
AND tdfuser IN s_fuser
AND tdfdate IN s_fdate
AND tdfreles IN s_freles
AND tdluser IN s_luser
AND tdldate IN s_ldate
AND tdlreles IN s_lreles
AND tdmacode1 IN s_macod1
AND tdmacode2 IN s_macod2
AND tdtitle IN s_title.
LOOP AT gt_data ASSIGNING <data>.
PERFORM fill_firstline USING <data>.
ENDLOOP.
ENDFORM. " F_READ_DATA
*---------------------------------------------------------------------*
* Form f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.
DATA:
l_pos TYPE i,
ls_print TYPE slis_print_alv,
ls_layout TYPE slis_layout_alv,
ls_sort TYPE slis_sortinfo_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_event_exit TYPE slis_event_exit,
lt_event_exit TYPE slis_t_event_exit.
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 '&IC1'.
PERFORM f_lines USING us_selfield-tabindex.
WHEN c_refresh.
PERFORM f_read_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 f_lines *
*---------------------------------------------------------------------*
FORM f_lines USING u_index TYPE sytabix.
DATA :
ls_thead TYPE thead,
ls_data TYPE ty_data,
lt_lines TYPE tline_t.
READ TABLE gt_data INDEX u_index INTO ls_data.
CHECK sy-subrc EQ 0.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = ls_data-mandt
object = ls_data-tdobject
name = ls_data-tdname
id = ls_data-tdid
language = ls_data-tdspras
IMPORTING
header = ls_thead
TABLES
lines = lt_lines
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
CALL FUNCTION 'SAPSCRIPT_MESSAGE'.
EXIT. " Exit Form
ENDIF.
CALL FUNCTION 'CHECK_TEXT_AUTHORITY'
EXPORTING
activity = 'SHOW'
object = ls_data-tdobject
name = ls_data-tdname
id = ls_data-tdid
language = ls_data-tdspras
EXCEPTIONS
OTHERS = 4.
IF sy-subrc NE 0.
* No authorization to display text &1 &2 &3
MESSAGE s613(td) WITH ls_data-tdspras
ls_data-tdid
ls_data-tdname.
EXIT.
ENDIF.
CALL FUNCTION 'EDIT_TEXT'
EXPORTING
header = ls_thead
display = c_x
TABLES
lines = lt_lines
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
CALL FUNCTION 'SAPSCRIPT_MESSAGE'.
ENDIF.
ENDFORM. "f_lines
*---------------------------------------------------------------------*
* Form FILL_FIRSTLINE
*---------------------------------------------------------------------*
FORM fill_firstline USING us_data TYPE ty_data.
DATA:
l_msgline(72) TYPE c,
ls_lines TYPE tline,
lt_lines TYPE tline_t.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = us_data-mandt
id = us_data-tdid
language = us_data-tdspras
name = us_data-tdname
object = us_data-tdobject
TABLES
lines = lt_lines
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
l_msgline = 'Selected text module &1 not found'(011).
REPLACE '&1' WITH us_data-tdname INTO l_msgline.
MESSAGE s030(td) WITH l_msgline.
EXIT.
ENDIF.
LOOP AT lt_lines INTO ls_lines WHERE NOT tdline IS INITIAL.
us_data-tdline = ls_lines-tdline.
EXIT.
ENDLOOP.
IF NOT p_string IS INITIAL.
LOOP AT lt_lines INTO ls_lines WHERE NOT tdline IS INITIAL.
IF ls_lines-tdline CS p_string.
us_data-tdline = ls_lines-tdline.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " FILL_FIRSTLINE
****************** END OF PROGRAM Z_ALV_STANDARD_TEXT ******************
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.