Wednesday, 4 November 2015

MR EStimation

exit:EXIT_SAPLELHR_003
include ZXELXU10



DATAx_reabld TYPE reabld .

IF sy-uname 'xxxxxx'.
  BREAK-POINT.
ENDIF.

IMPORT x_reabld TO x_reabld FROM MEMORY ID 'ZMRR'.
if x_reabld-ABLHINW is NOT INITIAL.

*"     VALUE(Y_ZWSTERW) LIKE  EABLH-I_ZWSTERW
*"     VALUE(Y_VERBERW) LIKE  EABLH-I_VERBERW

  CALL FUNCTION 'ZFM_METER_READING_ESTIMATE'
  EXPORTING
    ABLHINW         x_reabld-ablhinw
    GERNR           x_reabld-gernr
    ZWNUMMER        x_zwnummer
    MRDOCID         x_ablbelnr
    CURR_DATE       x_reabld-adat
  CHANGING
    ESTIMREAD       y_zwsterw.

Tuesday, 28 July 2015

PWB DOWNLOAD PDF AND SEND A MAIL

&---------------------------------------------------------------------*
*&   Form USER_EXIT_ZISU_END_EXITN
*&---------------------------------------------------------------------*
*&   This exit is processed AFTER the hierarchy has been processed.
*&
*&   Use this Exit to check or set
*    final settings in the form, if required.
*&---------------------------------------------------------------------*
FORM USER_EXIT_ZISU_END_EXITN .


DATA : V_BIN_FILESIZE TYPE I.
DATA :I_PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
data :  v_name                   TYPE string,
      v_path                   TYPE string,
      v_fullpath               TYPE string,
      v_filter                 TYPE string,
      v_uact                   TYPE i,
      v_guiobj                 TYPE REF TO cl_gui_frontend_services,
      v_filename               TYPE string,
      v_fm_name                TYPE rs38l_fnam.

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_BIN_FILESIZE
* BIN_FILE =
TABLES
OTF = GT_OTF[]
LINES = I_PDF
.


  CONCATENATE 'smrt' '.pdf' INTO v_name.
  CREATE OBJECT v_guiobj.
  CALL METHOD v_guiobj->file_save_dialog
    EXPORTING
      default_extension  = 'pdf'
      default_file_name  = v_name
      file_filter        = v_filter
    CHANGING
      filename           = v_name
      path               = v_path
      fullpath           = v_fullpath
      user_action        = v_uact.
  IF v_uact = v_guiobj->action_cancel.
    EXIT.
  ENDIF.


CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    BIN_FILESIZE = V_BIN_FILESIZE
    FILENAME     = v_name "'C:\Users\VIJAY\Desktop\VI.pdf'
    FILETYPE     = 'BIN'
  TABLES
    DATA_TAB     = I_PDF.

**************************************mail code


DATA:
        g_spool_no TYPE tsp01-rqident.

  DATA :
      g_sent_to_all   TYPE sonv-flag,
      g_tab_lines     TYPE i.
  "Types
  TYPES:
      t_document_data  TYPE  sodocchgi1,
      t_packing_list   TYPE  sopcklsti1,
      t_attachment     TYPE  solisti1,
      t_body_msg       TYPE  solisti1,
      t_receivers      TYPE  somlreci1,
      t_pdf            TYPE  tline.
  "Workareas
  DATA :

      wa_fkkop         TYPE  fkkop,
      wa_vkk_doc_id    TYPE  isu21_t_vkk_doc_id,

      w_document_data  TYPE  t_document_data,
      w_packing_list   TYPE  t_packing_list,
      w_attachment     TYPE  t_attachment,
      w_body_msg       TYPE  t_body_msg,
      w_receivers      TYPE  t_receivers,
      w_pdf            TYPE  t_pdf.
  "Internal Tables
  DATA :

      it_fkkop         TYPE STANDARD TABLE OF fkkop,
      it_vkk_doc_id    TYPE STANDARD TABLE OF isu21_t_vkk_doc_id,

      i_document_data  TYPE STANDARD TABLE OF t_document_data,
      i_packing_list   TYPE STANDARD TABLE OF t_packing_list,
      i_attachment     TYPE STANDARD TABLE OF t_attachment,
      i_body_msg       TYPE STANDARD TABLE OF t_body_msg,
      i_receivers      TYPE STANDARD TABLE OF t_receivers.
*      i_pdf            TYPE STANDARD TABLE OF t_pdf.




*Write the data.

  DATA:
  l_lay    TYPE pri_params-paart,
  l_lines  TYPE pri_params-linct,
  l_cols   TYPE pri_params-linsz,
  l_val    TYPE c.
*Types
  TYPES:
  t_pripar TYPE pri_params,
  t_arcpar TYPE arc_params.
  "Work areas
  DATA:
  lw_pripar TYPE t_pripar,
  lw_arcpar TYPE t_arcpar.


CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
    EXPORTING
      line_width_src              = 134
      line_width_dst              = 255
    TABLES
      content_in                  = i_pdf
      content_out                 = i_attachment
    EXCEPTIONS
      err_line_width_src_too_long = 1
      err_line_width_dst_too_long = 2
      err_conv_failed             = 3
      OTHERS                      = 4.
  IF sy-subrc NE 0.
    MESSAGE s000(0k) WITH 'Conversion Failed'.
    EXIT.
  ENDIF.





  "Write Packing List for Body
  DESCRIBE TABLE i_body_msg LINES g_tab_lines.
  w_packing_list-head_start = 1.
  w_packing_list-head_num   = 0.
  w_packing_list-body_start = 1.
  w_packing_list-body_num   = g_tab_lines.
  w_packing_list-doc_type   = 'RAW'.
  APPEND w_packing_list TO i_packing_list.
  CLEAR  w_packing_list.

  "Write Packing List for Attachment
  w_packing_list-transf_bin = 'X'.
  w_packing_list-head_start = 1.
  w_packing_list-head_num   = 1.
  w_packing_list-body_start = 1.
  DESCRIBE TABLE i_attachment LINES w_packing_list-body_num.
  w_packing_list-doc_type   = 'PDF'.
  w_packing_list-obj_descr  = 'PDF Attachment'.
  w_packing_list-obj_name   = 'PDF_ATTACHMENT'.
  w_packing_list-doc_size   = w_packing_list-body_num * 255.
  APPEND w_packing_list TO i_packing_list.
  CLEAR  w_packing_list.

  "Fill the document data and get size of attachment
  w_document_data-obj_langu  = sy-langu.
  READ TABLE i_attachment INTO w_attachment INDEX g_tab_lines.
  w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_attachment ).

  "Receivers List.
  w_receivers-rec_type   = 'B'.  " 'U' to Internet address
  w_receivers-receiver   = sy-uname ." p_mail.
  w_receivers-com_type   = 'INT'.
  w_receivers-notif_del  = 'X'.
  w_receivers-notif_ndel = 'X'.
  APPEND w_receivers TO i_receivers .
  CLEAR:w_receivers.

  "Function module to send mail to Recipients
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = w_document_data
      put_in_outbox              = 'X'
      commit_work                = 'X'
    IMPORTING
      sent_to_all                = g_sent_to_all
    TABLES
      packing_list               = i_packing_list
      contents_bin               = i_attachment
      contents_txt               = i_body_msg
      receivers                  = i_receivers
    EXCEPTIONS
      too_many_receivers         = 1
      document_not_sent          = 2
      document_type_not_exist    = 3
      operation_no_authorization = 4
      parameter_error            = 5
      x_error                    = 6
      enqueue_error              = 7
      OTHERS                     = 8.

  IF sy-subrc = 0 .
*    MESSAGE i303(me) WITH 'Mail has been Successfully Sent.'.
  ELSE.
    WAIT UP TO 2 SECONDS.
    "This program starts the SAPconnect send process.
    SUBMIT rsconn01 WITH mode = 'INT'
    WITH output = 'X'
    AND RETURN.
  ENDIF.


************************************
endform.

Thursday, 4 June 2015

pwb smartform odf

Need to maintain otf format in ext


*&  Form USER_EXIT_INIT_BILL
*&---------------------------------------------------------------------*
*&   Use this form e.g. to sort table XYT_DOC_HEADER or to load
*&   additional data from database
*&   This exit is processed *BEFORE* looping at XYT_DOC_HEADER
*&---------------------------------------------------------------------*
*&   <--> XYT_DOC_HEADER
*&---------------------------------------------------------------------*
form user_exit_init_bill
     tables
        xyt_doc_header structure erdk .

*sort XYT_DOC_HEADER by param1 ascending param2 descending .

 
C-ITCPO-TDGETOTF = 'X'.
C-ITCPO-TDpreview = 'X'.
C-ITCPO-TDnoprev = 'X'.

endform .     

than convert otf to pdf


&---------------------------------------------------------------------*
*&   Form USER_EXIT_ZISU_END_EXITN
*&---------------------------------------------------------------------*
*&   This exit is processed AFTER the hierarchy has been processed.
*&
*&   Use this Exit to check or set
*    final settings in the form, if required.
*&---------------------------------------------------------------------*
FORM USER_EXIT_ZISU_END_EXITN .


DATA : V_BIN_FILESIZE TYPE I.
DATA :I_PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
data :  v_name                   TYPE string,
      v_path                   TYPE string,
      v_fullpath               TYPE string,
      v_filter                 TYPE string,
      v_uact                   TYPE i,
      v_guiobj                 TYPE REF TO cl_gui_frontend_services,
      v_filename               TYPE string,
      v_fm_name                TYPE rs38l_fnam.

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_BIN_FILESIZE
* BIN_FILE =
TABLES
OTF = GT_OTF[]
LINES = I_PDF
.


  CONCATENATE 'smrt' '.pdf' INTO v_name.
  CREATE OBJECT v_guiobj.
  CALL METHOD v_guiobj->file_save_dialog
    EXPORTING
      default_extension  = 'pdf'
      default_file_name  = v_name
      file_filter        = v_filter
    CHANGING
      filename           = v_name
      path               = v_path
      fullpath           = v_fullpath
      user_action        = v_uact.
  IF v_uact = v_guiobj->action_cancel.
    EXIT.
  ENDIF.


CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    BIN_FILESIZE = V_BIN_FILESIZE
    FILENAME     = v_name "'
    FILETYPE     = 'BIN'
  TABLES
    DATA_TAB     = I_PDF.
IF  sy-subrc = 0.
MESSAGE 'Smartform downloaded' TYPE 'I'.
ENDIF.

ENDFORM .                             " USER_EXIT_ZISU_END_EXITN

Monday, 23 February 2015

Report to find Exits

*&---------------------------------------------------------------------*
*& Report  ZTESTV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZTESTV.

TABLES TSTC,

TADIR,

MODSAPT,

MODACT,

TRDIR,

TFDIR,

ENLFDIR,

SXS_ATTRT ,

TSTCT.

DATA JTAB LIKE TADIR OCCURS WITH HEADER LINE.

DATA FIELD1(30).

DATA V_DEVCLASS LIKE TADIR-DEVCLASS.

PARAMETERS P_TCODE LIKE TSTC-TCODE,

P_PGMNA LIKE TSTC-PGMNA .

DATA WA_TADIR TYPE TADIR.

START-OF-SELECTION.

IF NOT P_TCODE IS INITIAL.

SELECT SINGLE FROM TSTC WHERE TCODE EQ P_TCODE.

ELSEIF NOT P_PGMNA IS INITIAL.

TSTC-PGMNA P_PGMNA.

ENDIF.

IF SY-SUBRC EQ 0.

SELECT SINGLE FROM TADIR

WHERE PGMID 'R3TR'

AND OBJECT 'PROG'

AND OBJ_NAME TSTC-PGMNA.

MOVE TADIR-DEVCLASS TO V_DEVCLASS.

IF SY-SUBRC NE 0.

SELECT SINGLE FROM TRDIR

WHERE NAME TSTC-PGMNA.

IF TRDIR-SUBC EQ 'F'.

SELECT SINGLE FROM TFDIR

WHERE PNAME TSTC-PGMNA.

SELECT SINGLE FROM ENLFDIR

WHERE FUNCNAME TFDIR-FUNCNAME.

SELECT SINGLE FROM TADIR

WHERE PGMID 'R3TR'

AND OBJECT 'FUGR'

AND OBJ_NAME EQ ENLFDIR-AREA.

MOVE TADIR-DEVCLASS TO V_DEVCLASS.

ENDIF.

ENDIF.

SELECT FROM TADIR INTO TABLE JTAB

WHERE PGMID 'R3TR'

AND OBJECT IN ('SMOD''SXSD')

AND DEVCLASS V_DEVCLASS.

SELECT SINGLE FROM TSTCT

WHERE SPRSL EQ SY-LANGU

AND TCODE EQ P_TCODE.

FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.

WRITE:/(19'Transaction Code - ',

20(20P_TCODE,

45(50TSTCT-TTEXT.

SKIP.

IF NOT JTAB[] IS INITIAL.

WRITE:/(105SY-ULINE.

FORMAT COLOR COL_HEADING INTENSIFIED ON.

* SORTING THE INTERNAL TABLE

SORT JTAB BY OBJECT.

DATA WF_TXT(60TYPE C,

WF_SMOD TYPE ,

WF_BADI TYPE ,

WF_OBJECT2(30TYPE C.

CLEAR WF_SMODWF_BADI WF_OBJECT2.

*GET THE TOTAL SMOD.

LOOP AT JTAB INTO WA_TADIR.

AT FIRST.

FORMAT COLOR COL_HEADING INTENSIFIED ON.

WRITE:/1 SY-VLINE,

'Enhancement/ Business Add-in',

41 SY-VLINE ,

42 'Description',

105 SY-VLINE.

WRITE:/(105SY-ULINE.

ENDAT.

CLEAR WF_TXT.

AT NEW OBJECT.

IF WA_TADIR-OBJECT 'SMOD'.

WF_OBJECT2 'Enhancement' .

ELSEIF WA_TADIR-OBJECT 'SXSD'.

WF_OBJECT2 ' Business Add-in'.

ENDIF.

FORMAT COLOR COL_GROUP INTENSIFIED ON.

WRITE:/1 SY-VLINE,

WF_OBJECT2,

105 SY-VLINE.

ENDAT.

CASE WA_TADIR-OBJECT.

WHEN 'SMOD'.

WF_SMOD WF_SMOD + 1.

SELECT SINGLE MODTEXT INTO WF_TXT

FROM MODSAPT

WHERE SPRSL SY-LANGU

AND NAME WA_TADIR-OBJ_NAME.

FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

WHEN 'SXSD'.

* FOR BADIS

WF_BADI WF_BADI + .

SELECT SINGLE TEXT INTO WF_TXT

FROM SXS_ATTRT

WHERE SPRSL SY-LANGU

AND EXIT_NAME WA_TADIR-OBJ_NAME.

FORMAT COLOR COL_NORMAL INTENSIFIED ON.

ENDCASE.

WRITE:/1 SY-VLINE,

WA_TADIR-OBJ_NAME HOTSPOT ON,

41 SY-VLINE ,

42 WF_TXT,

105 SY-VLINE.

AT END OF OBJECT.

WRITE /(105SY-ULINE.

ENDAT.

ENDLOOP.

WRITE:/(105SY-ULINE.

SKIP.

FORMAT COLOR COL_TOTAL INTENSIFIED ON.

WRITE:'No.of Exits:' WF_SMOD.

WRITE:'No.of BADis:' WF_BADI.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(105'No userexits or BADis exist'.

ENDIF.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(105'Transaction does not exist'.

ENDIF.

AT LINE-SELECTION.

DATA WF_OBJECT TYPE TADIR-OBJECT.

CLEAR WF_OBJECT.

GET CURSOR FIELD FIELD1.

CHECK FIELD1(8EQ 'WA_TADIR'.

READ TABLE JTAB WITH KEY OBJ_NAME SY-LISEL+1(20).

MOVE JTAB-OBJECT TO WF_OBJECT.

CASE WF_OBJECT.

WHEN 'SMOD'.

SET PARAMETER ID 'MON' FIELD SY-LISEL+1(10).

CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

WHEN 'SXSD'.

SET PARAMETER ID 'EXN' FIELD SY-LISEL+1(20).

CALL TRANSACTION 'SE18' AND SKIP FIRST SCREEN.

ENDCASE.

Monday, 22 September 2014

Workflow event Through report


REPORT  ZWF_EVENT.


DATA:
W_OBJTYPE TYPE SWR_STRUCT-OBJECT_TYP,
W_OBJKEY  TYPE SWR_STRUCT-OBJECT_KEY,
W_EVENT   TYPE SWR_STRUCT-EVENT.

W_OBJKEY = '1234'.

W_OBJTYPE = 'MTRREADDOC'.

W_EVENT = 'CREATED'.

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
  EXPORTING
    OBJECT_TYPE             = W_OBJTYPE
    OBJECT_KEY              = W_OBJKEY
    EVENT                   = W_EVENT
   COMMIT_WORK             = 'X'
*   EVENT_LANGUAGE          = SY-LANGU
*   LANGUAGE                = SY-LANGU
*   USER                    = SY-UNAME
*   IFS_XML_CONTAINER       =
* IMPORTING
*   RETURN_CODE             =
*   EVENT_ID                =
* TABLES
*   INPUT_CONTAINER         =
*   MESSAGE_LINES           =
*   MESSAGE_STRUCT          =
          .

Monday, 8 September 2014

Report for abap flow diagram

*&---------------------------------------------------------------------*
*& Report  ZFLOW_CHART
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZFLOW_CHART.



include lcnetdat. "allg. Datendeklarationen
include lcnetcon. "Konstanten
*----------------------------------------------------------------------*
* CLASS flow_chart DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class flow_chart definition.
public section.
 databegin of w_secs,
 progm type sy-cprog,
 type,
 name type string,
 start type i,
end type i,
end of w_secs,
 t_secs like standard table of w_secs,
begin of w_nodes,
id type i,
 type,
 name type string,
end of w_nodes,
 t_nodes like standard table of w_nodes,
begin of w_calls,
 start,
 type,
 calledby type string,
 ntype,
 name type string,
end of w_calls,
 t_calls like standard table of w_calls.
 data: l_comp type ref to cl_abap_compiler,
 t_result type scr_glrefs,
 w_result like line of t_result,
 t_secst like t_secs,
 l_match type i,
 t_ref type scr_refs,
 w_ref type line of scr_refs.
 data: t_cprog type standard table of sy-cprog,
 l_cprog type sy-cprog.
 data: t_prog type standard table of char255,
 l_prog type char255,
 l_evnt type string,
 t_stmt type standard table of sstmnt,
 l_stmt type sstmnt,
 t_strc type standard table of sstruc,
 l_strc type sstruc,
 l_tabix type i,
 t_tokn type standard table of stokes.
methods get_chart importing p_cprog type sy-cprog.
methods find_data importing p_start type string p_end type string. methods find_pattern importing p_full type string p_last type string p_type type string
  changing p_subrc type i.
methods get_data importing value(p_pos) type i value(p_ntype) type char01 value(p_name) type
string.
endclass"flow_chart DEFINITION
*----------------------------------------------------------------------*
* CLASS flow_chart IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class flow_chart implementation.
method get_chart.
call function 'RS_GET_ALL_INCLUDES'
exporting
program = p_cprog
 with_inactive_incls = 'X'
tables
 includetab = t_cprog
exceptions
 not_existent = 1
 no_program = 2
others = 3.
append p_cprog to t_cprog.
loop at t_cprog into l_cprog.
read report l_cprog into t_prog.
scan abap-source t_prog tokens into t_tokn statements into t_stmt structures into t_strc.
 w_secs-progm = l_cprog.
 w_secs-type = 'F'.
call method find_data
exporting
 p_start = 'FUNCTION'
 p_end = 'ENDFUNCTION'.
 w_secs-type = 'S'.
call method find_data
exporting
 p_start = 'FORM'
 p_end = 'ENDFORM'.
 w_secs-type = 'D'.
call method find_data
exporting
 p_start = 'MODULE'
 p_end = 'ENDMODULE'.
 w_secs-type = 'M'.
call method find_data
exporting
 p_start = 'METHOD'
 p_end = 'ENDMETHOD'.
 w_secs-type = 'E'.
loop at t_strc into l_strc where type = 'E'.
read table t_stmt into l_stmt with key number = l_strc-stmnt_from.
read table t_prog into l_prog index l_stmt-trow.
translate l_prog to upper case.
translate l_prog using '. '.
 w_secs-name = l_prog.
 w_secs-start = l_stmt-trow.
read table t_stmt into l_stmt with key number = l_strc-stmnt_to.
 w_secs-end = l_stmt-trow.
append w_secs to t_secs.
 endloop.
 endloopcreate object l_comp
exporting
 p_name = p_cprog.
call method l_comp->get_all_refs
exporting
 p_local = 'X'
importing
 p_result = t_result.
loop at t_result into w_result.
call method find_pattern
exporting
 p_full = '\PR:*\TY:*\ME:*'
 p_last = '\ME:'
 p_type = 'M'
changing
 p_subrc = l_match.
if l_match ne 0.
call method find_pattern
exporting
 p_full = '\TY:*\ME:*'
 p_last = '\ME:'
 p_type = 'C'
changing
 p_subrc = l_match.
if l_match ne 0.
call method find_pattern
exporting
 p_full = '\FU:*'
 p_last = '\FU:'
 p_type = 'F'
changing
 p_subrc = l_match.
if l_match ne 0.
call method find_pattern
exporting
 p_full = '\PR:*\FO:*'
 p_last = '\FO:'
 p_type = 'S'
changing
 p_subrc = l_match.
if l_match ne 0.
 continue.
 endif.
 endif.
 endif.
 endif.
refresh t_ref.
call method l_comp->get_single_ref
exporting
 p_full_name = w_result-full_name
 p_grade = 2
importing
 p_result = t_ref
exceptions
 syntax_error = 1
 object_not_found = 2
 ref_not_found = 3
 parameter_error = 4
others = 5. t_secst[] = t_secs[].
loop at t_ref into w_ref where grade ne 0.
loop at t_secst into w_secs where start <= w_ref-line and end >= w_ref-line and progm = w_ref-statement->source_info->name.
delete t_secst index sy-tabix.
 w_calls-type = w_secs-type.
 w_calls-calledby = w_secs-name.
append w_calls to t_calls.
 endloop.
 endloop.
clear w_calls.
 endloop.
 data: w_cald like w_calls.
loop at t_calls into w_calls.
 l_tabix = sy-tabix.
 w_nodes-type = w_calls-type.
 w_nodes-name = w_calls-calledby.
append w_nodes to t_nodes.
 w_nodes-type = w_calls-ntype.
 w_nodes-name = w_calls-name.
append w_nodes to t_nodes.
read table t_calls into w_cald with key name = w_calls-calledby ntype = w_calls-type.
if sy-subrc ne 0.
 w_calls-start = 'X'.
modify t_calls from w_calls index l_tabix transporting start.
 endif.
 endloop.
sort t_nodes.
delete adjacent duplicates from t_nodes comparing all fields.
loop at t_nodes into w_nodes.
 w_nodes-id = sy-tabix.
modify t_nodes from w_nodes index sy-tabix.
 endloop.
loop at t_nodes into w_nodes.
 net_nodes_tab-id = w_nodes-id.
 net_nodes_tab-type = 0.
case w_nodes-type.
when 'F'.
 net_nodes_tab-type = 'F'.
when 'M'.
 net_nodes_tab-type = 'I'.
when 'S'.
 net_nodes_tab-type = 'S'.
when 'C'.
 net_nodes_tab-type = '0'.
when 'E'.
 net_nodes_tab-type = 'T'.
 endcase.
append net_nodes_tab to net_nodes_tab[].
 nvals_tab-id = net_nodes_tab-id.
 nvals_tab-fl = net_const-text_index_0.
 nvals_tab-val = w_nodes-name.
append nvals_tab to nvals_tab[].
if strlen( w_nodes-name ) > 19.
 nvals_tab-fl = net_const-text_index_1.
 nvals_tab-val = w_nodes-name+19.
append nvals_tab to nvals_tab[].
endif.
 endloop.
sort t_calls by type calledby.
loop at t_calls into w_calls where start is not initial.
delete t_calls index sy-tabix.
add 1 to lines_tab-id.
read table t_nodes into w_nodes with key type = w_calls-type name = w_calls-calledby.
if sy-subrc eq 0.
 lines_tab-pre = w_nodes-id.
read table t_nodes into w_nodes with key type = w_calls-ntype name = w_calls-name.
if sy-subrc eq 0.
 lines_tab-suc = w_nodes-id.
 lines_tab-ab = net_const-aob_ea.
append lines_tab to lines_tab[].
 endif.
 endif.
call method get_data
exporting
 p_pos = 4
 p_ntype = w_calls-ntype
 p_name = w_calls-name.
 endloop.
loop at lines_tab[] into lines_tab.
 lvals_tab-id = lines_tab-id.
 lvals_tab-fl = net_const-text_index_0.
 lvals_tab-val = space.
append lvals_tab to lvals_tab[].
 endloop.
 profile-gruppe = 'SCTX'.
 profile-name = 'CONTEXT'.
 profile-index = 0.
 do.
call function 'CNET_GRAPHIC_NETWORK'
exporting
 stat = stat
 profile = profile
 wait_for_input = space
importing
 m_typ = m_typ
tables
 clusters = clusters_tab
 cvals = cvals_tab
 deletions = delete_tab
 inodes = inodes_tab
lines = lines_tab
 lvals = lvals_tab
nodes = net_nodes_tab
 nvals = nvals_tab
 positions = positions_tab.
case m_typ.
when net_const-m_typ_d.
 exit.
when net_const-m_typ_i.
 stat = net_const-stat_4.
 endcase.
 enddo.
 endmethod"get_chart
method find_data.  data: l_tokn like line of t_tokn,
 w_tokn like l_tokn,
 l_tokt like l_tokn,
 l_cls type i.
loop at t_tokn into w_tokn where str = p_start.
 l_tabix = sy-tabix - 1.
read table t_tokn into l_tokn index l_tabix.
if l_tokn-row ne w_tokn-row.
 l_tabix = sy-tabix + 2.
if p_start = 'METHOD'.
 l_cls = sy-tabix + 1.
while l_cls > 0.
 l_cls = l_cls - 1.
read table t_tokn into l_tokt index l_cls.
if l_tokt-str = 'IMPLEMENTATION'.
 l_cls = l_cls - 1.
read table t_tokn into l_tokt index l_cls.
 exit.
 endif.
 endwhile.
 endif.
read table t_tokn into w_tokn index l_tabix.
 w_secs-name = w_tokn-str.
if l_tokt-str is not initial.
concatenate l_tokt-str '->' w_secs-name into w_secs-name.
 endif.
 w_secs-start = w_tokn-row.
loop at t_tokn into w_tokn from l_tabix where str = p_end.
 w_secs-end = w_tokn-row.
append w_secs to t_secs.
 exit.
 endloop.
 endif.
 endloop.
 endmethod"find_data
*&---------------------------------------------------------------------*
*& Form find_pattern
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
method find_pattern.
 p_subrc = 4.
 w_calls-ntype = p_type.
if w_result-full_name cp p_full.
find p_last in w_result-full_name match offset l_match.
 l_match = l_match + 4.
find regex '\\..:' in w_result-full_name+l_match.
if sy-subrc ne 0.
case p_type.
when 'F'.
 w_calls-name = w_result-full_name+l_match.
when 'M'.
 w_calls-name = w_result-full_name+4.
find regex '\\..:' in w_calls-name match offset l_match.
 l_match = l_match + 4.
 w_calls-name = w_calls-name+l_match.
replace regex '\\..:' in w_calls-name with '->'.
when 'C'.
 w_calls-name = w_result-full_name+4.
replace regex '\\..:' in w_calls-name with '->'when 'S'.
 w_calls-name = w_result-full_name+l_match.
 endcase.
clear p_subrc.
 endif.
 endif.
 endmethod"find_pattern
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
method get_data.
 data: l_pos type i,
 l_calls like w_calls.
 l_pos = p_pos + 3.
loop at t_calls into l_calls where calledby = p_name and type = p_ntype.
delete t_calls index sy-tabix.
read table t_nodes into w_nodes with key type = l_calls-type name = l_calls-calledby.
if sy-subrc eq 0.
add 1 to lines_tab-id.
 lines_tab-pre = w_nodes-id.
read table t_nodes into w_nodes with key type = l_calls-ntype name = l_calls-name.
if sy-subrc eq 0.
 lines_tab-suc = w_nodes-id.
 lines_tab-ab = net_const-aob_ea.
append lines_tab to lines_tab[].
 endif.
 endif.
call method get_data
exporting
 p_pos = l_pos
 p_ntype = l_calls-ntype
 p_name = l_calls-name.
 endloop.
 endmethod"get_data
endclass"flow_chart IMPLEMENTATION
parameters: p_cprog type sy-cprog.
start-of-selection.
 data: l_chart type ref to flow_chart.
create object l_chart.
call method l_chart->get_chart
exporting
 p_cprog = p_cprog.

Wednesday, 20 August 2014

WORK FLOW THROUGH REPORT

*&---------------------------------------------------------------------*
*& Report  ZVWORKFLOW_MAIL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZVWORKFLOW_MAIL.


TABLES SSCRFIELDS.

*--------------------------------------------------------------*
*Selection-Screen
*--------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : P_MDT AS CHECKBOX,
             P_MDLOAD AS CHECKBOX,
             P_MUPLAD AS CHECKBOX .
SELECTION-SCREEN:PUSHBUTTON /60(10) BUTTON1 USER-COMMAND but1,
                 PUSHBUTTON 75(10) BUTTON2 USER-COMMAND but2.
SELECTION-SCREEN END OF BLOCK b1.

*--------------------------------------------------------------*
*Initialization
*--------------------------------------------------------------*
INITIALIZATION.
  button1 = 'SEND'.
  button2 = 'CANCEL'.






**  *--------------------------------------------------------------*
*At Selection-Screen
*--------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sscrfields.
    WHEN 'BUT1'.
      PERFORM mail.
      MESSAGE 'Mail Sent Succesfully' TYPE 'I'.
    WHEN 'BUT2'.
      MESSAGE 'Your Action Cancelled' TYPE 'I'.
  ENDCASE.







*&---------------------------------------------------------------------*
*&      Form  mail
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM mail .


IF p_mdt = 'X'.


DATA : lt_container TYPE TABLE OF swr_cont,
       ls_container TYPE swr_cont.

*test to get the value throught the pgm

ls_container-element = 'FLAG1'.
ls_container-value   = 'X'.
APPEND ls_container TO lt_container.

ls_container-element = 'FLAG2'.
ls_container-value   = 'Y'.
APPEND ls_container TO lt_container.

DATA : P_TASK TYPE swr_struct-task.
P_TASK = 'WS90000032'.




*****This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
IF P_MDLOAD = 'X'.
  P_TASK = 'WS90000051'.



***
****This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
  ENDIF.
  IF P_MUPLAD = 'X'.

P_TASK = 'WS90000052'.




*This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
  ENDIF.
ENDFORM.                    " mail
*