REPORT z_alv_smartforms.
*---------------------------------------------------------------------*
* ALV List of Smart forms *
*---------------------------------------------------------------------*
* Author : Michel PIOUD *
* Email : mpioud@yahoo.fr 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 stxfadm.
TYPES :
caption TYPE tdtext,
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
mac_line 1 s_fname <data>-formname. "#EC NEEDED
mac_line 3 s_dvclss <data>-devclass. "#EC NEEDED
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(20) v_2 FOR FIELD s_luser. "#EC NEEDED
SELECT-OPTIONS s_luser FOR <data>-lastuser MATCHCODE OBJECT user_comp.
SELECTION-SCREEN END OF LINE.
mac_line 6 s_ldate <data>-lastdate. "#EC NEEDED
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(20) v_5 FOR FIELD s_luser. "#EC NEEDED
SELECT-OPTIONS s_fuser FOR <data>-firstuser MATCHCODE OBJECT user_comp.
SELECTION-SCREEN END OF LINE.
mac_line 7 s_fdate <data>-lastdate. "#EC NEEDED
mac_line 4 s_langu <data>-masterlang. "#EC NEEDED
mac_line 8 s_ftype <data>-formtype. "#EC NEEDED
SELECTION-SCREEN :
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.
PERFORM f_initialization.
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM f_read_data.
*---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM f_display_data.
*---------------------------------------------------------------------*
* Form F_INITIALIZATION
*---------------------------------------------------------------------*
FORM f_initialization.
DATA :
ls_fname LIKE LINE OF s_fname,
ls_ftype LIKE LINE OF s_ftype,
ls_dvclss LIKE LINE OF s_dvclss.
v_1 = 'Smart form name'.
v_2 = 'Last changed by'.
v_3 = 'Developpment Class'.
v_4 = 'Masterlang'.
v_5 = 'Created by'.
v_6 = 'Changed on'.
v_7 = 'Created on'.
v_8 = 'Form type'.
v_20 = 'Maximum number of selected entries'.
CONCATENATE 'ICP' 'Z*' INTO ls_fname.
APPEND ls_fname TO s_fname.
CONCATENATE 'ICP' 'Z*' INTO ls_dvclss.
APPEND ls_dvclss TO s_dvclss.
CONCATENATE 'IEQ' ' ' INTO ls_ftype.
APPEND ls_ftype TO s_ftype.
ENDFORM. " F_INITIALIZATION
*---------------------------------------------------------------------*
* Form F_READ_DATA
*---------------------------------------------------------------------*
FORM f_read_data.
DATA ls_address TYPE addr3_val.
* Read data from TADIR and STXFADM
SELECT formname t~masterlang version firstuser firstdate firsttime
lastuser lastdate lasttime formtype t~devclass
UP TO p_max ROWS
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM tadir AS t
JOIN stxfadm AS s
ON t~obj_name = s~formname
WHERE pgmid = 'R3TR'
AND object = 'SSFO'
AND obj_name IN s_fname
AND lastuser IN s_luser
AND t~devclass IN s_dvclss
AND t~masterlang IN s_langu
AND firstuser IN s_fuser
AND lastdate IN s_ldate
AND formtype IN s_ftype.
* Sort to improve performance of FM SUSR_USER_ADDRESS_READ
SORT gt_data BY lastuser.
LOOP AT gt_data ASSIGNING <data>.
* Get user address data
CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
EXPORTING
user_name = <data>-lastuser "#EC DOM_EQUAL
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>-lastuser SEPARATED BY space.
ENDIF.
* Get user address data
CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
EXPORTING
user_name = <data>-firstuser "#EC DOM_EQUAL
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>-firstuser SEPARATED BY space.
ENDIF.
* Read description from STXFADMT
SELECT SINGLE caption
INTO <data>-caption
FROM stxfadmt
WHERE formname = <data>-formname
AND langu = <data>-masterlang.
ENDLOOP.
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.
ls_sort-down = &3.
ls_sort-group = &4.
append ls_sort to lt_sort.
END-OF-DEFINITION.
* 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_layout TYPE slis_layout_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_event_exit TYPE slis_t_event_exit,
ls_event_exit TYPE slis_event_exit.
ls_layout-zebra = c_x.
ls_layout-cell_merge = c_x.
ls_layout-group_change_edit = c_x.
ls_layout-colwidth_optimize = c_x.
ls_layout-box_fieldname = 'CHECKBOX'.
* Build sort table
m_sort 'LASTDATE' '' c_x ''.
m_sort 'LASTTIME' '' c_x ''.
*
* Build field catalog table
m_fieldcat 'FORMNAME' 'STXFADM'.
m_fieldcat 'MASTERLANG' 'STXFADM'.
m_fieldcat 'CAPTION' 'STXFADMT'.
m_fieldcat 'LASTUSER' 'STXFADM'.
m_fieldcat 'LASTDATE' 'STXFADM'.
m_fieldcat 'LASTTIME' 'STXFADM'.
m_fieldcat 'FIRSTUSER' 'STXFADM'.
m_fieldcat 'FIRSTDATE' 'STXFADM'.
m_fieldcat 'FIRSTTIME' 'STXFADM'.
m_fieldcat 'DEVCLASS' 'STXFADM'.
m_fieldcat 'FORMTYPE' 'STXFADM'.
m_fieldcat 'VERSION' 'STXFADM'.
* Activate refresh button
CLEAR ls_event_exit.
ls_event_exit-ucomm = c_refresh. " Refresh
ls_event_exit-after = c_x.
APPEND ls_event_exit TO lt_event_exit.
* Display data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'PF_STATUS_SET'
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
it_event_exit = lt_event_exit
i_save = 'A'
TABLES
t_outtab = gt_data.
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 :
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.
mac_dynpro 'SAPMSSFO' '0100'.
mac_field 'RB_SF' c_x.
mac_field 'SSFSCREEN-FNAME' <data>-formname.
* SAP Smart Forms
CALL TRANSACTION 'SMARTFORMS' 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
************ END OF PROGRAM Z_ALV_SMARTFORMS **************************
읭 이건뭥?...ㅋ아직 개초보라 잘 모르겠네요...;;ㅎㅎ