Posted: Sun Oct 14, 2007 9:41 pm Post subject: Retrives workflow data and show in HTML
Code:
REPORT Z_RMTIWARI_WORKFLOW_WEBVIEWER .
*----------------------------------------------------------------------*
* ABAP Code WebViewer Beta Version - Date - 08.05.2005
*----------------------------------------------------------------------*
* Written By: Ram Manohar Tiwari
*----------------------------------------------------------------------*
* Presented By: http://www.rmtiwari.com
*----------------------------------------------------------------------*
* This utility tool retrives workflow data and prepares a graphical
* representation in HTML.
*-----------------------------------------------------------------------
* This utility is developed on MiniSAP and should be compatible with
* SAP4.7 version. Though with slight modifications to remove
* the value added aspects will make it compatible with any versions of
* SAP.
*-----------------------------------------------------------------------
* SELECTION SCREEN
*-----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_WFID TYPE SWD_HEADER-WFD_ID obligatory,
P_VERS TYPE SWD_HEADER-VERSION obligatory.
SELECTION-SCREEN END OF BLOCK b1 .
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: P_OUTDIR LIKE rlgrap-filename obligatory.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
*----------------------------------------------------------------------*
* Type declaration
*----------------------------------------------------------------------*
* Type for report
TYPES : BEGIN OF TY_MATRIX,
X1(20),
X2(20),
X3(20),
X4(20),
X5(20),
X6(20),
X7(20),
X8(20),
X9(20),
X10(20),
X11(20),
X12(20),
X13(20),
END OF TY_MATRIX.
data : GV_DIRECTORY LIKE rlgrap-filename,
GV_FILE_NAME TYPE STRING,
GV_WORKFLOW_FILE_NAME TYPE trdir-name.
DATA : BEGIN OF GT_HTML OCCURS 0,
REC(1000) TYPE c,
END OF GT_HTML.
DATA : GV_APPEND TYPE C value ' '.
DATA : GT_MATRIX type table of TY_MATRIX with HEADER line.
*----------------------------------------------------------------------*
* CONSTANTS *
*----------------------------------------------------------------------*
CONSTANTS : GC_FALSE(1) TYPE c VALUE ' ',
GC_TRUE(1) TYPE c VALUE 'X',
GC_QUOTES1(1) TYPE c VALUE '''',
GC_ASTERIK(1) TYPE c VALUE '*',
GC_COMMA(1) TYPE c VALUE ',',
GC_QUOTES(1) TYPE c VALUE '"',
GC_PERCENT(1) TYPE c VALUE '%'.
*----------------------------------------------------------------------*
* Data declaration
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form get_file_name
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_directory_name using X_FILE_FIELD_NAME
changing Y_DIRECTORY_NAME.
class CL_GUI_FRONTEND_SERVICES definition load.
data : LV_FILE_PATH type rlgrap-filename,
LV_FILE_NAME type rlgrap-filename,
LV_OUTDIR type string,
LV_DIRECTORY type string.
CONSTANTS : LC_WINDOW_TITLE type string
value 'Select workflow download folder'.
PERFORM READ_SCREEN_VALUES USING X_FILE_FIELD_NAME
CHANGING Y_DIRECTORY_NAME.
READ TABLE LT_DYNPVALUETAB INDEX 1.
MOVE: LT_DYNPVALUETAB-fieldvalue TO Y_VALUE.
ENDIF.
ENDFORM. " read_screen_values
*&---------------------------------------------------------------------*
*& Form selection_screen_validations
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selection_screen_validations .
* MESSAGE e001(AQ) WITH
* 'This Report does not exist'.
CONCATENATE P_WFID '.html' into GV_WORKFLOW_FILE_NAME.
ENDFORM. " selection_screen_validations
*&--------------------------------------------------------------------*
*& Form prepare_file_name
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->x_directory text
* -->x_program_name text
* -->y_file_name text
*---------------------------------------------------------------------*
FORM prepare_file_name USING X_DIRECTORY
X_FILE
CHANGING Y_FILE_NAME.
CONCATENATE X_DIRECTORY '\' X_FILE into Y_FILE_NAME.
ENDFORM. " prepare_file_name
*&---------------------------------------------------------------------*
*& Form download_workflow_file_on_pc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM download_workflow_file_on_pc tables XT_DOWNLOAD
using X_OUTFILE type string.
* Use gui_download if file is located on the local PC.
* WS_download only works in foreground
IF SY-batch EQ 'X'.
MESSAGE e001(AQ) WITH
'This program cannot be executed in background'.
* ERROR: Unable to download locally stored files when running in
* background
ELSE.
WHEN OTHERS.
* Upload unsuccessful - error message
MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDCASE.
ENDIF.
ENDFORM. " download_workflow_file_on_pc
*&---------------------------------------------------------------------*
*& Form get_workflow_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_workflow text
*----------------------------------------------------------------------*
FORM get_workflow_data TABLES YT_MATRIX.
DATA : LV_TASK TYPE SWD_AHEAD-TASK,
LV_WFDKEY TYPE SWD_WFDKEY,
LV_OBJ_EXT TYPE RHOBJECTS-OBJECT.
DATA : LS_HEADER TYPE SWD_AHEAD,
LS_GLOBAL TYPE SWDIGLOBAL,
LS_CONTAINER TYPE REF TO IF_SWF_CNT_CONTAINER.
TYPES: BEGIN OF TY_HEADER_TABLE,
HEADER type CHAR100,
END OF TY_HEADER_TABLE.
DATA :LT_HEADER TYPE standard table of SWD_AHEAD
with HEADER line,
LT_GLOBAL TYPE standard table of SWDIGLOBAL
with HEADER line,
LT_CONTAINER TYPE standard table of REF TO
IF_SWF_CNT_CONTAINER with HEADER line.
DATA : LT_TEXT TYPE standard table of SWD_TEXT with HEADER line,
LT_BINDING TYPE standard table of SWD_BINDEF with HEADER line,
LT_STEPS TYPE standard table of SWD_ASTEP with HEADER line,
LT_LINES TYPE standard table of SWD_ALINES with HEADER line,
LT_METHOD TYPE standard table of SWD_IMETHD with HEADER line,
LT_CONDITION TYPE standard table of SWD_CONDEF with HEADER line,
LT_TEMPLATES TYPE standard table of SWUOPROP with HEADER line,
LT_FORMS TYPE standard table of SWDIFORMS with HEADER line,
LT_TASKS TYPE standard table of SWD_ITASKS with HEADER line,
LT_EVENTS TYPE standard table of SWD_IEVNTS with HEADER line,
LT_CONTEXT TYPE standard table of SWD_WFCTXT with HEADER line.
LV_COUNTER = 1.
* SORT lt_lines BY PRED_NODE.
* LOOP AT lt_lines.
*
* IF lv_old_node ne lt_lines-PRED_NODE.
* if sy-tabix ne 1.
* APPEND lt_matrix.
* endif.
* CLEAR lt_matrix.
* CLEAR lv_counter.
* lt_matrix-x7 = lt_lines-PRED_NODE.
* lv_counter = 1.
*
* ELSE.
LV_COUNTER = lv_counter + 1.
CASE LV_COUNTER.
WHEN 1.
LT_MATRIX-x6 = LT_LINES-SUCC_NODE.
WHEN 2.
LT_MATRIX-x6 = LT_LINES-SUCC_NODE.
WHEN 3.
LT_MATRIX-x8 = LT_LINES-SUCC_NODE.
WHEN 4.
LT_MATRIX-x5 = LT_LINES-SUCC_NODE.
WHEN 5.
LT_MATRIX-x9 = LT_LINES-SUCC_NODE.
WHEN 6.
LT_MATRIX-x4 = LT_LINES-SUCC_NODE.
WHEN 7.
LT_MATRIX-x10 = LT_LINES-SUCC_NODE.
WHEN 8.
LT_MATRIX-x3 = LT_LINES-SUCC_NODE.
WHEN 9.
LT_MATRIX-x11 = LT_LINES-SUCC_NODE.
WHEN 10.
LT_MATRIX-x2 = LT_LINES-SUCC_NODE.
WHEN 11.
LT_MATRIX-x12 = LT_LINES-SUCC_NODE.
WHEN 12.
LT_MATRIX-x1 = LT_LINES-SUCC_NODE.
WHEN 13.
LT_MATRIX-x13 = LT_LINES-SUCC_NODE.
ENDCASE.
* ENDIF.
LV_OLD_NODE = LT_LINES-PRED_NODE.
* ENDLOOP.
APPEND LT_MATRIX.
YT_MATRIX[] = LT_MATRIX[].
ENDFORM. " get_workflow_data
*&---------------------------------------------------------------------*
*& Form convert_table_to_html
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_REP_TABLE text
* -->P_GT_HTML text
*----------------------------------------------------------------------*
FORM convert_table_to_html TABLES XT_MATRIX
YT_HTML.
add_html '<TABLE>'.
data : LV_TABLE_FIELD(15) type c.
FIELD-SYMBOLS : <fs_table_value> TYPE ANY.
data : LV_FIELD_NO type i.
LOOP AT XT_MATRIX.
add_html '<TR>'.
LV_FIELD_NO = 0.
DO 13 times.
LV_FIELD_NO = lv_field_no + 1.
add_html '<TD>'.
* concatenate 'XT_MATRIX-X' lv_field_no into lv_table_field.
* MOVE (lv_table_field) TO lv_table_value.
ASSIGN COMPONENT LV_FIELD_NO of structure XT_MATRIX to
<fs_table_value>.
add_html <fs_table_value>.
add_html '</TD>'.
ENDDO.
add_html '</TR>'.
ENDLOOP.
add_html '</TABLE>'.
* Close HTML Tags
add_html '</PRE>'.
add_html '</BODY>'.
add_html '</HTML>'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form show_workflow_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->X_FILE_NAME text
*----------------------------------------------------------------------*
FORM show_workflow_file USING X_FILE_NAME.
data : LV_URL(200) type c.
LV_URL = X_FILE_NAME.
CALL FUNCTION 'CALL_BROWSER'
EXPORTING
URL = LV_URL.
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.