Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9052

Re: use of swc_set_table

$
0
0

Hello

 

Wow! You are now slowly revealing the design!!

 

1) Trigger the workflow using SAP_WAPI_CREATE_EVENT or SAP_WAPI_CREATE_EVENT_EXTENDED (Check on SCN, there are a lot of posts on how to use them) ........ By the way, why do you need an implicit enhancement... isn't the standard triggering the Standard event when the material gets created????

 

 

2) Trigger the event only based on the key - Material ID - rest details you can fetch from within the WF - create your own class - call it's methods passing the material number and fetch the details and pass back to the workflow.

 

3) Alternatively you can use CREATE INSTANCE method as described in section 1.1.3.4.1 to create an instance of your custom class using the standard BO Key

 

 

Regards,

Modak

 

 

Still...if you are hell bent (or your business process needs) to pass data in the event container: here is the sample code using class based event triggering:

 

 

 

*&---------------------------------------------------------------------*
*& Report  ZSWF_TEST_DNTP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zswf_test_dntp.
DATA:   lv_objkey(8)        TYPE        c,                                  "***Change length based on your Object key
             lv_objcateg         TYPE        swf_clstyp VALUE 'CL', "*** or BO depending on your object
             lo_event_parameters TYPE REF TO if_swf_ifs_parameter_container.


PARAMETERS: p_pernr    TYPE pernr_d OBLIGATORY, "Employee number
            p_val1(10) TYPE c       OBLIGATORY,             "Value 1   "Just for my tests
            p_val2(10) TYPE c       OBLIGATORY,             "Value 2   "Just for my tests
            p_val3(10) TYPE c       OBLIGATORY,             "Value 3  "Just for my tests
            p_val4(10) TYPE c       OBLIGATORY.             "Value 4   "Just for my tests

 


* Get the Instance of Event Container - we need to fill it with values
CALL METHOD cl_swf_evt_event=>get_event_container
  EXPORTING
    im_objcateg  = lv_objcateg                         " CL = Class / BO = Business Object
    im_objtype   = 'ZCL_SWF_TEST_DNTP'   " Class Name / BO name ( example BUS2012 )
    im_event     = 'START_WORKFLOW'        " Event Name
  RECEIVING
    re_reference = lo_event_parameters.


*Using the event container instance - populate values for event parameters
CALL METHOD lo_event_parameters->set
  EXPORTING
    name  = 'Value1'
    value = p_val1.

 

CALL METHOD lo_event_parameters->set
  EXPORTING
    name  = 'Value2'
    value = p_val2.

CALL METHOD lo_event_parameters->set
  EXPORTING
    name  = 'Value3'
    value = p_val3.

CALL METHOD lo_event_parameters->set
  EXPORTING
    name  = 'Value4'
    value = p_val4.

 

*Never tried the above SET Method using a table - but give it a shot and see what happens

 


*Move entered employee number to object key format
MOVE: p_pernr TO lv_objkey.

*Call method to raise event and pass event parameters
TRY.
    CALL METHOD cl_swf_evt_event=>raise
      EXPORTING
        im_objcateg        = lv_objcateg                        " CL = Class / BO = BO Name
        im_objtype         = 'ZCL_SWF_TEST_DNTP'   " Class Name / BO name ( example BUS2012 )
        im_event           = 'START_WORKFLOW'        " Event Name
        im_objkey          = lv_objkey                              " Key field of Class / BO
        im_event_container = lo_event_parameters.    "Event Container


    COMMIT WORK AND WAIT. "Maybe leave the commit to the application from where you are triggering it
    WRITE: / 'Event Triggered.'.


  CATCH cx_swf_evt_invalid_objtype .
    WRITE: / 'Exception - CX_SWF_EVT_INVALID_OBJTYPE'.
  CATCH cx_swf_evt_invalid_event .
    WRITE: / 'Exception - CX_SWF_EVT_INVALID_EVENT'.
ENDTRY.


Viewing all articles
Browse latest Browse all 9052

Trending Articles