starting a workflow periodically

Ulrich Mende wug at mende-edv-beratung.de
Wed Mar 27 07:22:54 EST 2002


Hi Ronen -
here is a simple report that does the job. If you do need parameters or
an object reference in your workflow, remove the '*' and fill the values
of the swc_* macros. You need a container even if it is empty.
Do not transfer SY-UNAME directly to the FM - this gives a dump.
 
Best regards Uli
 
*#####################################################################
report  zwfstart .
include <cntn01>.
 
constants task  type swwwihead-wi_rh_task value 'WS93600014'.
data:     subrc type sy-subrc,
          wi_id type swwwihead-wi_id.
 
perform start_workflow using task wi_id subrc.
if subrc = 0.
  write: 'Task', task, 'successfully startet under wi_id', wi_id.
else.
  write: / 'Error calling SWW_WI_START =', subrc.
endif.
 
*------------------------------------------------------------
form start_workflow using value(p_task) type swwwihead-wi_rh_task
                          p_wi_id type swwwihead-wi_id
                          p_subrc like sy-subrc.
 
  data: CREATOR TYPE SWWWIHEAD-WI_CREATOR,
        container like swcont occurs 0 with header line,
        objref type swc_object.
 
* Do not transfer SY-UNAME directly to the parameter CREATOR
  creator = sy-uname.
 
*===================================================== if needed
*set import-variables of workflow if needed
*swc_set_element container 'WAERS' 'USD'.
 
* create object and set it in the container if needed
*swc_create_object objref 'FORMABSENC' '0001'.
*swc_set_element container 'AbsenceForm' objref.
*===================================================== if needed
 
  call function 'SWW_WI_START'
       EXPORTING
            creator                      = creator
            task                         = p_task
            workitem_type                = 'F'
       IMPORTING
            wi_id                        = p_wi_id
       TABLES
            wi_container                 = container
       EXCEPTIONS
            id_not_created               = 1
            read_failed                  = 2
            immediate_start_not_possible = 3
            execution_failed             = 4
            invalid_status               = 5
            others                       = 6.
  subrc = sy-subrc.
endform.
*################################################################
 
 
 
???? ???? <Ronen at mccann-kb.co.il> schrieb am 27.03.2002, 12:03:25:
> Hello Jocelyn and Uli
>
> Since I am not a programmer, I would appreciate if you could send me a more specific example of how to use the FM SWW_WI_START in an abap report. the input parameter will be the task name.
> there is no business object involved. only the task has to be started without any input data
> very similar to running transaction SWUS with the task name and no input data
>
> i tried to write something like the following example, but it doesn't seem to work
>
> thanks,
> ronen (that's my name here)
>
>
> sample of code
>
>
>
> REPORT Z_START_WORKFLOW .
>
> parameters task like SWU_WFSTRT-TASK.
>
>
>
>
>
> CALL FUNCTION 'SWW_WI_START'
>   EXPORTING
> *   CALLBACK_FB                        = ' '
> *   CHECKED_WI                         = NO_ID
> *   CONFIRM                            = ' '
>     creator                            = SY-UNAME
> *   DESIRED_END_ACTION                 = TSWW-WI_DEF_DH_ACT
> *   DESIRED_END_DATE                   = NO_DATE
> *   DESIRED_END_TIME                   = NO_TIME
> *   DESIRED_START_DATE                 = NO_DATE
> *   DESIRED_START_TIME                 = NO_TIME
>    LANGUAGE                           = SY-LANGU
> *   LATEST_END_ACTION                  = TSWW-WI_DEF_DH_ACT
> *   LATEST_END_DATE                    = NO_DATE
> *   LATEST_END_ESCALATION              = NO_ESC
> *   LATEST_END_TIME                    = NO_TIME
> *   LATEST_START_ACTION                = TSWW-WI_DEF_DH_ACT
> *   LATEST_START_DATE                  = NO_DATE
> *   LATEST_START_TIME                  = NO_TIME
> *   MAX_EVENT_COUNT                    = EI_DEF_MAX_EVT_CNT
> *   PRIORITY                           = NO_PRIO
>     task                               = TASK
>
> *   WORKITEM_TYPE                      = ' '
> *   DO_COMMIT                          = 'X'
> *   DO_SYNC_CALLBACK                   = ' '
> *   TEXT                               = ' '
> *   DO_SYNC_WI_CHAIN                   = ' '
> *   CREATED_BY_USER                    = SY-UNAME
> *   CREATED_BY_ADDRESS                 = ' '
> *   CALLED_IN_BACKGROUND               = ' '
> *   STEP_MODELED_WI_DISPLAY            = ' '
> *   NO_DEADLINE_PARAMETERS             = ' '
> *   RESTRICTED_LOG                     = ' '
> *   SECONDS_UNTIL_TIMEOUT              =
> *   CREATE_EVENT                       = ' '
> *   STATUS_EVENT                       = ' '
> *   WLC_FLAGS                          =
> * IMPORTING
> *   WI_ID                              =
> *   WI_HEADER                          =
> *   RETURN                             =
> *   WI_RESULT                          =
> *  tables
> *   AGENTS                             =
> *   DEADLINE_AGENTS                    =
> *   DESIRED_END_AGENTS                 =
> *   LATEST_START_AGENTS                =
> *   EXCLUDED_AGENTS                    =
> *   NOTIFICATION_AGENTS                =
> *   SECONDARY_METHODS                  =
> *    wi_container                       =
> *   COMP_EVENTS                        =
> * EXCEPTIONS
> *   ID_NOT_CREATED                     = 1
> *   READ_FAILED                        = 2
> *   IMMEDIATE_START_NOT_POSSIBLE       = 3
> *   EXECUTION_FAILED                   = 4
> *   INVALID_STATUS                     = 5
> *   OTHERS                             = 6
>           .
> IF sy-subrc  0.
> * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
> *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
> ENDIF.
>
> -----Original Message-----
>> From: Dart, Jocelyn [mailto:jocelyn.dart at sap.com]
> Sent: Wednesday, March 27, 2002 12:38 AM
> To: SAP-WUG at MITVMA.MIT.EDU
> Subject: Re: starting a workflow periodically
>
>
> Hi Uli and ...
> Please include  not  -  was the
> very very old include (3.0 something),  should be used instead in
> all systems.
> Regards,
>         Jocelyn Dart
> Consultant (EBP, BBP, Ecommerce, Internet Transaction Server, Workflow)
> SAP Australia
> Email jocelyn.dart at sap.com
> Tel: +61 412 390 267
> Fax: +61 2 9935 4880
>
>
> -----Original Message-----
>> From: Ulrich Mende [mailto:wug at mende-edv-beratung.de]
> Sent: Tuesday, 26 March 2002 7:05 PM
> To: SAP-WUG at MITVMA.MIT.EDU
> Subject: Re: starting a workflow periodically
>
>
> Hi ... (sorry, your name appears cryptic in the mail)
>
> I would write a report, that determines the object instance on which the
> workflow should run. In the report I would call FM SWE_EVENT_CREATE to
> start a workflow via event or FM SWW_WI_START to start it directly. Then
> I would put this report in a periodic job (TA SM36).
>
> Since you will have to create an object (swc_create_object) and fill a
> container (swc_set_element) , don't forget to include .
>
> Best regards Uli
>
>
> xepo tewq  schrieb am 26.03.2002, 07:03:02:
> > what is the neatest way to have a workflow 'start' every week on a fixed
> date ?
> >
> > thanks and happy passover
> > peace to all
> >
> > ronen
> >
> > periodically
 


More information about the SAP-WUG mailing list