Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

report program and workflow

Former Member
0 Kudos

i am writing the report program, in which i am selecting the person and his superior..i want

the name of the function module so that i can pass these parameters to the function module..

ii)the same function module should trigger the event in the workflow.

III)when iam passing the parameters for the workflow through the function module,the name of

the superior i should get that to the address of the mail-activity and name of the person

should be in the content of the mail.(i am using email as an step in the workflow)

iv) have doubt how to place those values in the workflow ???particularly in to address and

the email content??how to transport it???and also i have created my own object and

assignedkey to that which is the table i am using above to extract the person and

supervisor..

1 ACCEPTED SOLUTION

former_member927251
Active Contributor
0 Kudos

Hi Rajkumar,

I am sorry to misunderstand the question.

Refer the following code. Here you can use the event_container table to pass the values to the workflow.

* Data for workflow trigger
DATA: objtype LIKE swetypecou-objtype,
objkey LIKE sweinstcou-objkey,
event LIKE swetypecou-event,
event_container LIKE swcont OCCURS 0 WITH HEADER LINE.

objtype = 'ZBUS1001'. "Material [sub object of BUS1001]
MOVE v_wfmatnr TO objkey. "V_WFMATNR is material number
event = 'CreatePLMMaterial'."Custom Event defined in 
* ZBUS1001 [Tcode SWO1]
REFRESH event_container.
*Following are the Event parameters required in the *Workflow 
swc_set_element event_container 'Attachment' v_wfattachment.
swc_set_element event_container 'Material' v_wfmatnr.
swc_set_element event_container 'TisGroup' v_wftisgroup.
swc_set_element event_container 'SchDate' v_schdate.

CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = objtype
objkey = objkey
event = event
TABLES
event_container = event_container
EXCEPTIONS
objtype_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
COMMIT WORK.

Reward points if it helps.

Message was edited by: Amit Mishra

12 REPLIES 12

former_member188685
Active Contributor
0 Kudos

Hi,

you need to call the FM <b>SWE_EVENT_CREATE</b> with appropriate parameters to raise the work flow event.

Regards

vijay

0 Kudos

hi vijay..i found thqat function module to create the event ..but i need to transport some fields to the workflow from report program..is it possible using the same FM???

0 Kudos

Hi raj,

in that case you need to have Business object, and should have some method or event to be triggered from that object.

and in my code i am passing PO,date,repid,message,SO# from report to workflow.

 CONCATENATE 'Exception on Invoice for PO# ' L_PORDER INTO L_TEXT.
  SWC_SET_ELEMENT MY_CONTAINER 'PurchaseOrder' L_PORDER.
  SWC_SET_ELEMENT MY_CONTAINER 'IdocCreateDate'   V_CREDAT.
  SWC_SET_ELEMENT MY_CONTAINER 'RepId' L_REPID.
  SWC_SET_ELEMENT MY_CONTAINER 'Message' L_TEXT.

  IF L_ORDER = '  '.
    SWC_SET_ELEMENT MY_CONTAINER 'Agent' 'A 50003012'.
  ELSE.
    SWC_SET_ELEMENT MY_CONTAINER 'Agent' ''.
    SWC_SET_ELEMENT MY_CONTAINER 'SalesOrder' L_ORDER.
  ENDIF.

  CALL FUNCTION 'SWE_EVENT_CREATE'
    EXPORTING
      OBJTYPE           = OBJTYP
      OBJKEY            = OBJKEY
      EVENT             = WFEVENT
    TABLES
      EVENT_CONTAINER   = MY_CONTAINER
    EXCEPTIONS
      OBJTYPE_NOT_FOUND = 1
      OTHERS            = 2.


  IF SY-SUBRC = 0.
    COMMIT WORK.
  ENDIF.

Regards

Vijay

former_member927251
Active Contributor
0 Kudos

Hi Rajkumar,

I am sorry to misunderstand the question.

Refer the following code. Here you can use the event_container table to pass the values to the workflow.

* Data for workflow trigger
DATA: objtype LIKE swetypecou-objtype,
objkey LIKE sweinstcou-objkey,
event LIKE swetypecou-event,
event_container LIKE swcont OCCURS 0 WITH HEADER LINE.

objtype = 'ZBUS1001'. "Material [sub object of BUS1001]
MOVE v_wfmatnr TO objkey. "V_WFMATNR is material number
event = 'CreatePLMMaterial'."Custom Event defined in 
* ZBUS1001 [Tcode SWO1]
REFRESH event_container.
*Following are the Event parameters required in the *Workflow 
swc_set_element event_container 'Attachment' v_wfattachment.
swc_set_element event_container 'Material' v_wfmatnr.
swc_set_element event_container 'TisGroup' v_wftisgroup.
swc_set_element event_container 'SchDate' v_schdate.

CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = objtype
objkey = objkey
event = event
TABLES
event_container = event_container
EXCEPTIONS
objtype_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
COMMIT WORK.

Reward points if it helps.

Message was edited by: Amit Mishra

0 Kudos

Hi,

Thanks for ur reply.I have a doubt regarding that swc_set_element part.Is that a macro? If so could u plz provide me the actual implementation part of the macro?

Or it would be very helpful if u could provide me the entire code for it.

0 Kudos

Hi,

it is macro, you need not to worry about it. and the information is enough to raise the workflow event.

this <b>INCLUDE <CNTN01>.</b> must when you are working with workflows in programs, this if for workflow macros.

<b>INCLUDE <CNTN01>.</b>

*- Trigger workflow

      PERFORM TRIGGER_WORKFLOW USING IT_AGENT
                                     P_PROJ
                                     L_SCN
                                     L_WADAT
                                     P_MESS.

FORM TRIGGER_WORKFLOW USING P_AGENT STRUCTURE IT_AGENT

P_P_PROJ LIKE VBAK-ZZPROJECT_NBR

P_ZZSHCONUM LIKE VBAP-ZZSHCONUM

P_WADAT LIKE VBEP-WADAT

P_P_MESS.

  DATA : L_OBJTYP  LIKE SWETYPECOU-OBJTYPE, " Object type
         L_OBJKEY  LIKE  SWEINSTCOU-OBJKEY, " Object key
         L_WFEVENT LIKE  SWETYPECOU-EVENT,  " Event
         L_EVENT LIKE  SWEDUMEVID-EVTID,    " Event
         MY_CONTAINER LIKE SWCONT OCCURS 0 WITH HEADER LINE.


  L_OBJTYP = 'ZDELNOTE'.
  L_OBJKEY = '00000000000000'.
  L_WFEVENT  = 'Send_ZVDSR'.

  SWC_SET_ELEMENT MY_CONTAINER 'ProjID'   P_P_PROJ.
  SWC_SET_ELEMENT MY_CONTAINER 'SCNNO'    P_ZZSHCONUM.
  SWC_SET_ELEMENT MY_CONTAINER 'PGIDate'  P_WADAT.
  SWC_SET_ELEMENT MY_CONTAINER 'AGENT'    P_AGENT.
  SWC_SET_ELEMENT MY_CONTAINER 'Message'  P_P_MESS.

*-SWE_EVENT_CREATE
  CALL FUNCTION 'SWE_EVENT_CREATE'
    EXPORTING
      OBJTYPE         = L_OBJTYP
      OBJKEY          = L_OBJKEY
      EVENT           = L_WFEVENT
    IMPORTING
      EVENT_ID        = L_EVENT
    TABLES
      EVENT_CONTAINER = MY_CONTAINER.
  COMMIT WORK.
ENDFORM.                    " TRIGGER_WORKFLOW

regards

vijay

0 Kudos

hi,

Thank for the valuable information given by you..is there anyother possible way to send the values as well as to trigger the workflow at the same time without using the macros??..if there is any way..plz let me know..

0 Kudos

have no idea. this is what i was using for all these days..

Regards

vijay

0 Kudos

HI,

i got cleared with all those ideas..its working fine..my code is as follows..

REPORT ZHR_COPY.

INCLUDE <CNTN01>.

DATA : L_OBJTYP LIKE SWETYPECOU-OBJTYPE, " Object type

L_OBJKEY LIKE SWEINSTCOU-OBJKEY, " Object key

L_WFEVENT LIKE SWETYPECOU-EVENT, " Event

L_EVENT LIKE SWEDUMEVID-EVTID, " Event

MY_CONTAINER LIKE SWCONT OCCURS 0 WITH HEADER LINE.

L_OBJTYP = 'ZMYOBJECT'.

L_OBJKEY = 'EMPNAME'.

L_WFEVENT = 'GETUP'.

SWC_SET_ELEMENT MY_CONTAINER 'EMPNAME' 'RAJ'.

SWC_SET_ELEMENT MY_CONTAINER 'SUPERVISOR' 'RAJKUMAR'.

*-SWE_EVENT_CREATE

CALL FUNCTION 'SWE_EVENT_CREATE'

EXPORTING

OBJTYPE = L_OBJTYP

OBJKEY = L_OBJKEY

EVENT = L_WFEVENT

IMPORTING

EVENT_ID = L_EVENT

TABLES

EVENT_CONTAINER = MY_CONTAINER.

COMMIT WORK.

i am able to get the event triggered for my workflow..but

i)i want to pass the value 'raj' in the email address of the workflow.

ii)i want to pass the 'rajkumar' in the content of the mail..

can u plz tell me how to assign those values by using the container elements..i double clicking the container element there i am giving the BOR type and name of the object i created..

where i can see the values i assigned in the particular object???

please help me how to go in the further steps???clearly??

0 Kudos

Hi,

it depends on your Business object, what parameters it will take ?

in my case these are the parameters....

PurchaseOrder           
IdocCreateDate          
RepId                   
Message                 
Agent                   
SalesOrder             

can you check it in SWO1 by giving the Bus object and see what parameters it can take.

Regards

vijay

Former Member
0 Kudos

Hi Raj,

instead of SWE_EVENT_CREATE, I recommend you use SAP_WAPI_CREATE_EVENT. It is the official and most supported interface to SAP workflow functionality.

I remember it has an exactly the same import/export params as SWE_EVENT_CREATE so it shouldn't be hard migrating to it.

-Mikko