Google Search - Blog...........

Displaying Workflow Items Based On The Created User.

REPORT zworkflow.

*-----------------------------------------------------------------------
* T Y P E P O O L S
*-----------------------------------------------------------------------

TYPE-POOLS: slis.

*-----------------------------------------------------------------------
* T A B L E S
*-----------------------------------------------------------------------
TABLES : swwwihead,
usr02.

*-----------------------------------------------------------------------
* T Y P E S
*-----------------------------------------------------------------------

TYPES: BEGIN OF ty_final.
INCLUDE STRUCTURE swwwihead.
TYPES: END OF ty_final.

*-----------------------------------------------------------------------
* I N T E R N A L T A B L E S
*-----------------------------------------------------------------------

DATA: t_mm003 TYPE TABLE OF swwwihead WITH HEADER LINE,
t_mm004 TYPE TABLE OF swwwihead WITH HEADER LINE,
t_mm005 TYPE TABLE OF swwwihead WITH HEADER LINE,
lw_swwuserwi TYPE swwuserwi.

DATA: t_final TYPE TABLE OF swwwihead WITH HEADER LINE.

DATA: t_fieldcat TYPE slis_t_fieldcat_alv,
w_fieldcat LIKE LINE OF t_fieldcat,
w_layout TYPE slis_layout_alv,
wa_indx TYPE indx.


*-----------------------------------------------------------------------
* V A R I A B L E  D E C L A R A T I O N S
*-----------------------------------------------------------------------

*-----------------------------------------------------------------------
* M A C R O S
*-----------------------------------------------------------------------

*-----------------------------------------------------------------------
* S E L E C T - O P T I O N S A N D P A R A M E T E R S
*-----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_date FOR sy-datum,
s_task FOR swwwihead-wi_rh_task,
s_stat FOR swwwihead-wi_stat NO INTERVALS.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS: r_po RADIOBUTTON GROUP g1,
r_rfq RADIOBUTTON GROUP g1,
r_cont RADIOBUTTON GROUP g1.
SELECT-OPTIONS : s_userid FOR usr02-bname NO-DISPLAY.

SELECTION-SCREEN END OF BLOCK b2.

*-----------------------------------------------------------------------
* I N I T I A L I Z A T I O N
*-----------------------------------------------------------------------
INITIALIZATION.

s_stat-option = 'EQ'.
s_stat-sign = 'I'.
s_stat-low = 'READY'.
APPEND s_stat.

*-----------------------------------------------------------------------
* A T S E L E C T I O N - S C R E E N
*-----------------------------------------------------------------------
AT SELECTION-SCREEN.

*-----------------------------------------------------------------------
* S T A R T - O F - S E L E C T I O N
*-----------------------------------------------------------------------
START-OF-SELECTION.

*-----------------------------------------------------------------------
* T O P - O F - P A G E
*-----------------------------------------------------------------------
TOP-OF-PAGE.
*-----------------------------------------------------------------------
* E N D - O F - S E L E C T I O N
*-----------------------------------------------------------------------
END-OF-SELECTION.

PERFORM build_fieldcat .
PERFORM build_layout.
PERFORM display_alv.
*-----------------------------------------------------------------------
* F O R M S
*-----------------------------------------------------------------------


*&---------------------------------------------------------------------*
*& Form FIELDAT
*----------------------------------------------------------------------*
FORM fieldat USING p_fieldname TYPE slis_fieldcat_main0-fieldname
p_desc TYPE slis_fieldcat_main1-reptext_ddic.

w_fieldcat-fieldname = p_fieldname.
w_fieldcat-reptext_ddic = p_desc.

APPEND w_fieldcat TO t_fieldcat.
CLEAR w_fieldcat.

ENDFORM. " FIELDAT
*&---------------------------------------------------------------------*
*& Form GET_TASKLIST
*----------------------------------------------------------------------*
FORM get_tasklist .

IF r_po = 'X'.

s_task-option = 'EQ'.
s_task-sign = 'I'.
s_task-low = 'TS90000072'.
APPEND s_task.

ELSEIF r_rfq = 'X'.

s_task-option = 'EQ'.
s_task-sign = 'I'.
s_task-low = 'TS90000078'.
APPEND s_task.

ELSEIF r_cont = 'X'.
s_task-option = 'EQ'.
s_task-sign = 'I'.
s_task-low = 'TS90000077'.

APPEND s_task.


ENDIF.

ENDFORM. " GET_TASKLIST
*&---------------------------------------------------------------------*
*& Form GET_WORKFLOW_ITEMS
*----------------------------------------------------------------------*
FORM get_workflow_items .

SELECT * FROM swwwihead
INTO TABLE t_final
WHERE wi_cd IN s_date
AND wi_rh_task IN s_task
AND wi_stat IN s_stat.

IF sy-subrc = 0.
SORT t_final BY wi_text.
ELSE.
MESSAGE i398(00) WITH 'No Data Selected for the given selection'.
LEAVE TO SCREEN 0.
ENDIF.

LOOP AT t_final.
SELECT SINGLE * FROM swwuserwi INTO lw_swwuserwi
WHERE wi_id = t_final-wi_id
AND user_id = sy-uname
AND no_sel = space.
IF sy-subrc NE 0.
DELETE t_final.
ENDIF.
ENDLOOP.

ENDFORM. " GET_WORKFLOW_ITEMS
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*----------------------------------------------------------------------*
FORM build_fieldcat .

PERFORM fieldat USING 'WI_TEXT' 'Work item text'.
PERFORM fieldat USING 'WI_CD' 'Created Date'.
PERFORM fieldat USING 'WI_CRUSER' 'Created By'.
PERFORM fieldat USING 'WI_STAT' 'Status'.

ENDFORM. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*----------------------------------------------------------------------*
FORM build_layout .

w_layout-colwidth_optimize = 'X'.
w_layout-zebra = 'X'.

ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*----------------------------------------------------------------------*
FORM display_alv .

DELETE ADJACENT DUPLICATES FROM t_final COMPARING wi_text.

v_title = sy-title.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = w_layout
it_fieldcat = t_fieldcat
TABLES
t_outtab = t_final.

ENDFORM. " DISPLAY_ALV

*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.

CASE :r_ucomm.

WHEN '&IC1'.

READ TABLE t_final INDEX rs_selfield-tabindex.

SET PARAMETER ID 'WID' FIELD t_final-wi_id.

CALL TRANSACTION 'SBWP' AND SKIP FIRST SCREEN.

WHEN 'OTHERS'.
ENDCASE.

rs_selfield-refresh = 'X'.

ENDFORM. " BUILD_LAYOUT

No comments:

Post a Comment