Posted: Sat Jan 26, 2008 4:32 pm Post subject: ALV List of Sapscript Forms
Code:
REPORT z_alv_sapscripts.
*---------------------------------------------------------------------*
* ALV List of Sapscript Forms *
*---------------------------------------------------------------------*
* Author : Michel PIOUD *
* Email : HomePage : http://www.geocities.com/mpioud *
*---------------------------------------------------------------------*
* Macro definition
DEFINE mac_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',
c_refresh TYPE syucomm VALUE '&REFRESH'.
*---------------------------------------------------------------------*
TYPES :
BEGIN OF ty_s_data.
INCLUDE TYPE stxh.
TYPES :
devclass TYPE tadir-devclass,
tdline TYPE tline-tdline,
checkbox TYPE xfeld,
END OF ty_s_data.
DATA :
gt_data TYPE TABLE OF ty_s_data.
FIELD-SYMBOLS :
<data> TYPE ty_s_data.
*---------------------------------------------------------------------*
* Select-Options / Parameters
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(20) v_1 FOR FIELD s_mandt. "#EC NEEDED
SELECT-OPTIONS s_mandt FOR <data>-mandt DEFAULT sy-mandt
MATCHCODE OBJECT ddsef4clnt.
SELECTION-SCREEN END OF LINE.
mac_line 2 s_fname <data>-tdname. "#EC NEEDED
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(20) v_3 FOR FIELD s_luser. "#EC NEEDED
SELECT-OPTIONS s_luser FOR <data>-tdluser MATCHCODE OBJECT user_comp.
SELECTION-SCREEN END OF LINE.
mac_line 4 s_ldate <data>-tdldate. "#EC NEEDED
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(20) v_5 FOR FIELD s_fuser. "#EC NEEDED
SELECT-OPTIONS s_fuser FOR <data>-tdfuser MATCHCODE OBJECT user_comp.
SELECTION-SCREEN END OF LINE.
mac_line 6 s_fdate <data>-tdfdate. "#EC NEEDED
mac_line 7 s_dvclss <data>-devclass. "#EC NEEDED
mac_line 8 s_spras <data>-tdspras. "#EC NEEDED
SELECTION-SCREEN :
SKIP, BEGIN OF LINE, COMMENT 1(35) v_21 FOR FIELD p_string. "#EC NEEDED
PARAMETERS p_string TYPE tdtitle.
SELECTION-SCREEN :END OF LINE,
SKIP, BEGIN OF LINE, COMMENT 1(35) v_20 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(3) TYPE n DEFAULT '200' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
*---------------------------------------------------------------------*
INITIALIZATION.
*---------------------------------------------------------------------*
* Form F_INITIALIZATION
*---------------------------------------------------------------------*
FORM f_initialization.
DATA :
ls_fname LIKE LINE OF s_fname,
ls_dvclss LIKE LINE OF s_dvclss.
CONCATENATE 'ICP' 'Z*' INTO ls_fname.
APPEND ls_fname TO s_fname.
CONCATENATE 'ICP' 'Z*' INTO ls_dvclss.
APPEND ls_dvclss TO s_dvclss.
ENDFORM. " F_INITIALIZATION
*---------------------------------------------------------------------*
* Form F_READ_DATA
*---------------------------------------------------------------------*
FORM f_read_data.
DATA ls_address TYPE addr3_val.
* Read data from STXH
SELECT * UP TO p_max ROWS
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM tadir AS t
JOIN stxh AS s
ON t~obj_name = s~tdname CLIENT SPECIFIED
WHERE pgmid = 'R3TR'
AND object = 'FORM'
AND tdobject = 'FORM'
AND tdid <> 'DEF'
AND tdname IN s_fname
AND tdluser IN s_luser
AND tdfuser IN s_fuser
AND tdldate IN s_ldate
AND devclass IN s_dvclss
AND tdspras IN s_spras
AND mandt IN s_mandt.
* Sort to improve performance of FM SUSR_USER_ADDRESS_READ
SORT gt_data BY tdluser.
LOOP AT gt_data ASSIGNING <data>.
* Get user address data
CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
EXPORTING
user_name = <data>-tdluser "#EC
IMPORTING
user_address = ls_address
EXCEPTIONS
user_address_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CONCATENATE ls_address-name_last ls_address-name_first
INTO <data>-tdluser SEPARATED BY space.
ENDIF.
* Get user address data
CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
EXPORTING
user_name = <data>-tdfuser "#EC
IMPORTING
user_address = ls_address
EXCEPTIONS
user_address_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CONCATENATE ls_address-name_last ls_address-name_first
INTO <data>-tdfuser SEPARATED BY space.
ENDIF.
PERFORM fill_firstline USING <data>.
ENDLOOP.
ENDFORM. " F_READ_DATA
*---------------------------------------------------------------------*
* Form f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.
* Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
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.
ENDFORM. " F_DISPLAY_DATA
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm TYPE syucomm
is_selfield TYPE slis_selfield. "#EC CALLED
*
* Macro definition
DEFINE mac_dynpro.
clear ls_bdcdata.
ls_bdcdata-program = &1.
ls_bdcdata-dynpro = &2.
ls_bdcdata-dynbegin = c_x.
append ls_bdcdata to lt_bdcdata.
END-OF-DEFINITION.
* Macro definition
DEFINE mac_field.
clear ls_bdcdata.
ls_bdcdata-fnam = &1.
ls_bdcdata-fval = &2.
append ls_bdcdata to lt_bdcdata.
END-OF-DEFINITION.
DATA :
l_spras(2),
ls_bdcdata TYPE bdcdata,
lt_bdcdata TYPE TABLE OF bdcdata.
CASE i_ucomm.
WHEN '&IC1'. " Pick
READ TABLE gt_data INDEX is_selfield-tabindex ASSIGNING <data>.
CHECK sy-subrc EQ 0.
CHECK <data>-mandt EQ sy-mandt.
mac_dynpro 'SAPMSSCF' '1102'.
mac_field 'RSSCF-TDHEADEROB' c_x.
mac_field 'RSSCF-TDFORM' <data>-tdform.
WRITE <data>-tdspras TO l_spras.
mac_field 'RSSCF-TDSPRAS' l_spras.
* SAPscript form
CALL TRANSACTION 'SE71' USING lt_bdcdata MODE 'A'.
WHEN c_refresh.
PERFORM f_read_data.
is_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 FILL_FIRSTLINE
*---------------------------------------------------------------------*
FORM fill_firstline USING us_data TYPE ty_s_data.
DATA:
ls_lines TYPE tline,
lt_lines TYPE tline_t.
CALL FUNCTION 'READ_FORM'
EXPORTING
client = us_data-mandt
form = us_data-tdform
language = us_data-tdspras
TABLES
form_lines = lt_lines.
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_SAPSCRIPTS **************************
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.