Workflow - SWC_GET_ELEMENT
Hi
I have created an Attribute on a business object and am trying to get the data held within Workflow container element.
I am using the code:
"get_property email_confirmation changing container.
swc_get_element container 'wf_ini_email' w_email.
swc_set_element container 'Email_Confirmation' w_email.
end_property."
The workflow container element is wf_ini_email.
Unfortunately this is not returning any data from the workflow container into w_email in the Attribute.
Is it possible to get data held within workflow container elements directly from the Attribute? If yes do you have any example code that I could use?
Many thanks for your help in advance.
Daniel
I have added attribute(classroom) to a bor for Training and Event and this is the code to fill an attribute.
When creating an instance of the BOR
I hope this will help.
get_property classroom changing container.
data : it_resources like hrvres occurs 0 with header line.
clear object-classroom.
call function 'RH_GET_EVENT_DATA'
exporting
planversion = '01'
eventid = object-key-eventid
with_resources = 'X'
tables
resources = it_resources
exceptions
no_infty_found = 1
others = 2.
if sy-subrc eq 0.
clear object-classroom.
read table it_resources with key raumx = 'X'.
if sy-subrc eq 0.
object-classroom = it_resources-retxt.
endif.
endif.
swc_set_element container 'CLASSROOM' object-classroom.
end_property.
Similar Messages
-
Regarding the change status of leave workflow.
hi friends,
i have copied the standard leave worklfow "WS12300111" and customized it just to meet our requirement means for multiple approvers.
everything is working fine in production means if user ID "AIHR01' raise a leave request the workitem will go to "AIHR02" after his approving the workitem will go to the final approver means "AIHR03" after his approval the leave request will be completed and the status in the TC - PTARQ is coming as "APPROVED" means only after the approving of "AIHR03" the status is coming "APPROVED" but in some cases when user id "AIHR02" is approved instead of coming status "SENT" it is coming "APPROVED" in TC-PTARQ and because of this status the workitem is coming blank in UWL of "AIHR03".
I have already incorporated the given below method in the "WORKFLOW" just to change the status from "APPROVED" to "SENT" after the approval of user ID "AIHR02" but in some cases it is not working fine it is giving BUG.
begin_method changestatus changing container.
DATA:request TYPE ptreq_header-request_id,
wi_id TYPE swwwihead-wi_id.
DATA: request_instance TYPE REF TO if_pt_req_request,
event TYPE tim_req_xfer_event VALUE
cl_pt_req_const=>c_reqtrans_send,
ex_status TYPE tim_req_status,
container_wi TYPE swcont OCCURS 0,
agents TYPE STANDARD TABLE OF swhactor WITH HEADER LINE.
swc_get_element container 'REQUEST' request.
swc_get_element container 'Wi_id' wi_id.
DO.
CALL FUNCTION 'ENQUEUE_EPTREQ'
EXPORTING
MODE_PTREQ_HEADER = 'S'
MANDT = SY-MANDT
request_id = request
X_REQUEST_ID = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3
IF sy-subrc = 0.
EXIT.
ENDIF.
WAIT UP TO 60 SECONDS.
ENDDO.
IF sy-subrc = 0.
CALL METHOD ca_pt_req_header=>agent->get_request
EXPORTING
im_request_id = request
IMPORTING
ex_request = request_instance
EXCEPTIONS
request_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CALL METHOD request_instance->initiate_state_trans
EXPORTING
im_transfer_event = event
im_external_call = 'X'
im_ret_value = 0
ex_new_status = ex_status
ex_ret_code =
swc_set_element container 'Ex_Status' ex_status.
ENDIF.
CALL FUNCTION 'DEQUEUE_EPTREQ'
EXPORTING
MODE_PTREQ_HEADER = 'S'
MANDT = SY-MANDT
request_id = request
X_REQUEST_ID = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
ENDIF.
swc_create_container container_wi.
swc_set_element container_wi 'WI_ID' wi_id.
agents-otype = 'US'.
agents-objid = sy-uname.
APPEND agents.
CALL FUNCTION 'SWW_WI_START_SIMPLE'
EXPORTING
task = 'TS90000089'
called_in_background = 'X'
TABLES
agents = agents
wi_container = container_wi
EXCEPTIONS
id_not_created = 1
read_failed = 2
immediate_start_not_possible = 3
execution_failed = 4
invalid_status = 5
OTHERS = 6.
end_method.
Request you to plesase help me to solve this issue .why in some cases instead of coming status "SENT" it is coming "APPROVED" after the approval of user id "AIHR02".
BECAUSE of the "APPROVED" staus the same workitem is coming blank in the UWL OF "AIHR03".solved by own
-
Help needed in Rules in workflow
Hi all,
I am beginner in workflow. I was trying to apply custom rules in my workflow design. I did the following steps :
1. have created a custom rule through the transaction PFAC_INS.
2. There I have used a function module for the determination of agent. The custom function module will give me the superior name for an employee.I have used ztables to store the name of the employee and their superiors.
3. The Rule has been successfully created and has been tested. It is working as required. I have tested it in PFAC itself by using Simulation button.
The problem I am facing is
When I am trying to use this Rule in the workflow at the User decision Step it is not working. I have given the Rule number in the Agent section of the User decision step.
According to my Workflow design the email should go to the Superior of the employee but instead it is coming to my Inbox.
Please suggent me what to do.
Thanks in advance.
Points will be rewarded for good suggestions.
Thanks & Regards.
Reshmi Das.Hi Raj,
I have created a custom rule and its working fine. Please check the following steps:
The rule I have created gives the superior name of an user/agent.
Steps:
1. I have created a ztable( ztest_users)which will contain the name of users and their superiors.
2. Create a custom function module(ztest_find_superior) which will return back the table containing all the superior information for a particular user/agent.
Note: This custom function module created should have the same interface as that of the SAP standard function module RH_GET_ACTORS.
The following tables parameters have to exist in the custom function module.
ACTOR_TAB STRUCTURE SWHACTOR
AC_CONTAINER STRUCTURE SWCONT
Example:
FUNCTION ZTEST_FIND_SUPERIOR.
""Local Interface:
*" TABLES
*" ACTOR_TAB STRUCTURE SWHACTOR
*" AC_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*" NOBODY_FOUND
INCLUDE <cntn01>.
TYPES : BEGIN OF ty_users.
INCLUDE STRUCTURE ztest_users.
TYPES : END OF ty_users.
DATA: org_agent LIKE wfsyst-agent,
lt_holders TYPE STANDARD TABLE OF swhactor,
lwa_holders TYPE swhactor,
lt_users TYPE STANDARD TABLE OF ty_users,
lwa_users TYPE ty_users,
v_len TYPE i,
v_bname LIKE ztest_users-bname,
num_lines TYPE i.
*Read values assigned to the rule criteria
swc_get_element ac_container 'org_agent' org_agent.
*Get the superior
SELECT SINGLE * FROM ztest_users INTO CORRESPONDING FIELDS OF lwa_users
WHERE bname = org_agent.
IF NOT lwa_users IS INITIAL.
REFRESH lt_holders[].
lwa_holders-otype = 'US'.
lwa_holders-objid = lwa_users-zsuperior.
APPEND lwa_holders TO lt_holders.
APPEND LINES OF lt_holders TO actor_tab.
ENDIF.
DESCRIBE TABLE actor_tab LINES num_lines.
IF num_lines IS INITIAL.
RAISE nobody_found.
ENDIF.
ENDFUNCTION.
3. Now assign the function module on the rule.
Goto PFAC_INS to create the Custom Rule.
In the rule definition category select Agent Determination: Function to be executed.
In the Function module field give the name of the function module created (ZTEST_FIND_SUPERIOR).
Check the Terminate if Rule resolution without result check box.
4. Create a container element ( org_agent)for the agent or user which will be passed to the function module.
Type:
WFSYST-AGENT.
properties: import.
5. Test the Rule by the Simulation button on the application toolbar.
Enter the user name in the Container Element value section and press enter.
It displays the name of the superior for the agent/user and the Agent Found is displayed in Green color.
Now you can use this rule in your Workflow definition.
Thanks,
Reshmi -
Workflow changes - send reminder email on X - 1 days ... based on Molga
Hello Everyone,
I new to workflow and I came across a workflow scenario where I am confuse, that what should I do in order to make it work. Luckily we are running only one workflow in the system which is time off request, We copied standard workflow class u201CCL_PT_REQ_WF_ATTRIBSu201D to Z version and introduced some new method to send email to employees managers as well as employee and HR .
We also have something called workflow item cancel thing . Lets say if workflow is not approved by manger within X bossiness days it got cancel and employee has to submit the new time off request again. After doing a little bit research I came to know that there is standard job which checks and calculate the X days thing. Work flow is running fine from last 1 year.
Last week, we been asked to create reminder from X-1 day and sends to employee manager saying u201C This is a reminder and one day is left u201C .
I wanted to know how I can achieve that, I have to filter the employee by reading employeeu2019s molga as we want to do it for specific countries then I have to read employee manager which I can do using different FM and then I have to send email to employee's manager .
Like I said It should happen BEFORE x-1 business days when employee submits the time off u2026
Here what I am thinking , I can read table u201CSWWWIHEADu201D with field WI_TYPE = u2018Wu2019 . and pass work_id to FM " SWW_WI_CONTAINER_READ " and read the container like the INCLUDE MWS20000081HO01
CALL FUNCTION 'SWW_WI_CONTAINER_READ'
EXPORTING
wi_id = wi_id
READ_FOR_UPDATE = ' ' *
TABLES
wi_container = wi_container
EXCEPTIONS
container_does_not_exist = 1 "message from function
others = 99.
IF SY-SUBRC = 0.
SWC_GET_ELEMENT WI_CONTAINER 'ACTUALSTATE' ACTUALSTATE130100.
ELSE.
CLEAR ACTUALSTATE130100.
ENDIF.
IF ACTUALSTATE130100 = 'N'.
CALL TRANSACTION 'WS20000081M'.
LEAVE PROGRAM.
ENDIF.
From container I can read employee number and approver . Get molga via pernr and can filter the employee ..who ever submits the request system date u2013 4 .. I can send out the reminder email u2026
Is there any other way around or any other efficient way of doing that u2026 I hope you understand this thing is conditional u2026 As far as I am concern I new to workflow so please bear with me ..
Waiting
Khan
FYI- I have gone through several post which task about deadlines monitoring Etc .. using fork & wait blah blah .. but It didnu2019t get any clue where to start and how to start u2026Mike,
I think I am following you so for .. so here what I did ... I opened the "approve process" and slap in the same refer date/time in "Requested end date " with variables "&WFDATA.DEADLINEDATE&" "&WFDATA.DEADLINETIME&" with 1- DAY . I didnu2019t find this what it says in help " It is possible to specify a negative time interval. Negative time intervals should only be used in connection with an expression as a reference date/time. You then have the option of "backward deadlines"
Any way after that I changed action to "modeled" and say "outcome "reminder from UK " .
it creates a node with clock sign , now like you said , I can do many things here .. and I really need to do something for example , I need to check the employee if he/she is from UK , after that reads his/her manager and send an email to mangeru2019s outbox . UK gave us an email format which I have created in t-code SE60 - with Document Class "Dialog Text".
How to proceed further. Thanks for baby sitting me.
What I am thinking , I need to create a new activity as well as new method in my Zclass, in which I will check employee Molga i.e. U.K and I have to send out email based on my email text which I have created in SE61.
Iu2019m able to write code in existing method , being on the safe side I copied the existing workflow and made changes in to it . Now it comes to debugging part , Iu2019m able to find posts on SDN talks about workflow debugging . When I am entering time off request from ESS , and it is not stopping at external breakpoint , Also when I am looking at "PTARQ" to see submit WF items . It is showing me the old task "w90000012" which is original one and I copied it and my task is "w90000022" . What I have to do so when I submit time off request via ESS it calls my task . I created Task in PFTC . But nothing is happening . Please let me know what I am missing ..
I found the table for ESS leave request and able to see my task , Table name is "u2022 V_T554S_WEB"
But still waiting for answers the of above questions ...
Edited by: Saquib Khan on May 27, 2008 9:36 AM -
How to use the rule in workflow
Hi ,Guy ,
I am implementing the workflow project nowaday ,and when I use the rule to determine the step's agent , I often come across all kinds of strange problem and I do not know how to slove it goodly ,for example I do not know how to get the agent from orgainization unit etc .
can anybody give me some advices or some relevant docments(I have read the SAP standard material BIT601/BIT603/BIT610) .thank a lot .
Jialiang.QiuYes , you can define your own rule. You need to populate the table of type SWHACTOR with whatever agents you want to maintain . See the below code :
function z_cvwf_dwnam_approver_get.
""Local Interface:
*" IMPORTING
*" VALUE(ACT_PLVAR) LIKE P1208-PLVAR DEFAULT SPACE
*" VALUE(ACT_ISTAT) LIKE P1208-ISTAT DEFAULT '1'
*" VALUE(ACT_BEGDA) LIKE P1208-BEGDA DEFAULT SY-DATUM
*" VALUE(ACT_ENDDA) LIKE P1208-ENDDA DEFAULT SY-DATUM
*" TABLES
*" AC_CONTAINER STRUCTURE SWCONT
*" ACTOR_TAB STRUCTURE SWHACTOR
*" EXCEPTIONS
*" NO_ACTIVE_PLVAR
*" OBJTYP_NOT_VALID
*" NO_ACTOR_FOUND
data: l_user like draw-dwnam, "User
l_dokar like draw-dokar, "Document type
l_doknr like draw-doknr, "Document number
l_dokvr like draw-dokvr, "Document version
l_doktl like draw-doktl. "Document part
data: xausp like ausp.
*Data for AUSPC_V1 selection
data: xatinn(12) value 'APPROVER',
xklart like ausp-klart value '017',
xobjek like ausp-objek.
include <cntain>.
swc_get_element ac_container 'DOCUMENT' l_doknr.
swc_get_element ac_container 'DOCUMENTPART' l_doktl.
swc_get_element ac_container 'DOCUMENTTYPE' l_dokar.
swc_get_element ac_container 'DOCUMENTVERSION' l_dokvr.
Create objek from DRAW key fields
write: l_dokar to xobjek,
l_doknr to xobjek+3(25),
l_dokvr to xobjek+28(2),
l_doktl to xobjek+30(3).
Get Approver number
call function 'CONVERSION_EXIT_ATINN_INPUT'
exporting
input = xatinn
importing
output = xatinn.
From table AUSP
clear sy-subrc.
select single * from ausp
into xausp
where objek = xobjek
and atinn = xatinn
and klart = xklart.
Assign ATWRT to USER RESPONSIBLE FOR APPROVAL
if sy-subrc > 0.
raise no_actor_found.
endif.
actor_tab-otype = 'US'.
actor_tab-objid = xausp-atwrt.
append actor_tab.
endfunction. -
Calling Transaction through User Decision step in workflow
Hi all,
Pls help me calling a transaction through User Decision step in workflow. I have attached two buttons to my User decision and the one of the outcomes to a task where I am calling the transaction through a method of BOR. But the problem is I am unable to see the transaction when I press the button on my User Decision at test run.
Can you ppl let me know how can I achieve this?
Pls reply ASAP...
Thanks
SangharshHello Sangharsh ,
Please Check the paramater of of the method which you define.
e.g. I define CALL_TCODE_CJ03 method
which have the parameters FLAG,ProjectDefinition,WBSElement2,User
with export, import checkbox.
Pass the paratmeres in programs
e.g.
BEGIN_METHOD CALL_TCODE_CJ03 CHANGING CONTAINER.
DATA:
FLAG(1),
PROJECTDEFINITION TYPE PROJ-PSPID,
WBSELEMENT2 TYPE PRPS-POSID,
USER TYPE USR21-BNAME.
SWC_GET_ELEMENT CONTAINER 'FLAG' FLAG.
SWC_GET_ELEMENT CONTAINER 'ProjectDefinition' PROJECTDEFINITION.
SWC_GET_ELEMENT CONTAINER 'WBSElement2' WBSELEMENT2.
SWC_GET_ELEMENT CONTAINER 'User' USER.
GET PARAMETER ID 'PSP' FIELD PROJECTDEFINITION.
GET PARAMETER ID 'PRO' FIELD WBSELEMENT2.
SET PARAMETER ID 'PSP' FIELD PROJECTDEFINITION.
SET PARAMETER ID 'PRO' FIELD WBSELEMENT2.
CALL TRANSACTION 'CJ03' AND SKIP FIRST SCREEN.
SWC_SET_ELEMENT CONTAINER 'FLAG' FLAG.
SWC_SET_ELEMENT CONTAINER 'ProjectDefinition' PROJECTDEFINITION.
SWC_SET_ELEMENT CONTAINER 'WBSElement2' WBSELEMENT2. SWC_SET_ELEMENT CONTAINER 'User' USER.
END_METHOD.
I hope it will help you.
***Assigning points is the way to say thanks in SDN.***
Minaxi Shah -
Information on Globalization of Workflow Builder GUI
I am trying to determine if the Oracle Workflow builder application can display non-English characters in its menus, labels, dialogs, etc. Is there central site that describes the level of internationalization for this and other Oracle products? I have already looked in the "Products > Database > Oracle Workflow" forum and post a request there. Any point of contact would be helpful. Thank You.
Hi Srinivas,
Firstly when you create the container element for the task set is as an import parameter ( Double click on the container element-> Properties (Tab)-> Import(Field) ). Save the task. In SWDD select the activity. Put in the task and Click on Binding button. You will get a pop up showing all the workflow elements and the task elements. Map the workflow element to the task element here. Save and activate the workflow.
In SWO1 open the method for the business object. Click on parameters button and add an import parameter of the same data type as the task container element. In the program add the following code:
Data: newvariable type datatype
swc_get_element container 'NEWVARIABLE' newvariable.
Open the task definition and click on method binding. Map the task container element to the method input parameter.
After these steps you should be able to use the new variable in your code.
Regards
Bhooma -
hi there,
Object type: BUS1001006 (i hope this is std)
in this below parts are active:
methodds--
StandardMaterial.GetInternalNumber
StandardMaterial.Create
StandardMaterial.SaveData
StandardMaterial.Savereplica
StandardMaterial.MaterialGetAll
StandardMaterial.CreateViews
StandardMaterial.GetMissedViews
Events:
StandardMaterial.ViewCreated
StandardMaterial.Created
In work flow>triggering events tab>unde EVENT--VIEWCREATED
when we create a new material or extends a material>goes for approval>after approval of the material-->a method is calling to update mat status..like plant specific statu(mmsta)..
calling method is:
FUNCTION zam_mm_material_status_chng.
""Local interface:
*" IMPORTING
*" VALUE(MATERIAL) LIKE BAPIMATHEAD-MATERIAL
*" VALUE(IND_SECTOR) LIKE BAPIMATHEAD-IND_SECTOR
*" VALUE(MATL_TYPE) LIKE BAPIMATHEAD-MATL_TYPE
*" REFERENCE(NEW_STATUS) LIKE BAPI_MARA-PUR_STATUS
*" REFERENCE(PLANT) LIKE BAPI_MARC-PLANT OPTIONAL
*" REFERENCE(VAL_AREA) LIKE BAPI_MBEW-VAL_AREA OPTIONAL
*" REFERENCE(SALES_ORG) LIKE BAPI_MVKE-SALES_ORG OPTIONAL
*" REFERENCE(DISTR_CHAN) LIKE BAPI_MVKE-DISTR_CHAN
*" REFERENCE(REL_TYPE) LIKE MARC-MMSTA
*" EXPORTING
*" REFERENCE(RESULT) TYPE BAPIRET2-TYPE
*" REFERENCE(MESSAGE) TYPE BAPIRET2-MESSAGE
*// This function module is used to change the Material Status ( Plant
*// Sales ) using Standard BAPI.
*// Technical Consultant : K Vijayasekar ( IBM )
*// Functional Consultant : Kamal Sachdeva ( WHIRLPOOL - GIS )
DATA : t_bapimathead LIKE bapimathead,
t_plantdata LIKE bapi_marc,
t_plantdatax LIKE bapi_marcx,
t_salesdata LIKE bapi_mvke,
t_salesdatax LIKE bapi_mvkex,
t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = material
IMPORTING
output = material
EXCEPTIONS
OTHERS = 1.
t_bapimathead-material = material.
t_bapimathead-ind_sector = ind_sector.
t_bapimathead-matl_type = matl_type.
IF rel_type EQ 'E'.
t_plantdata-plant = plant.
t_plantdata-pur_status = new_status.
t_plantdata-pvalidfrom = sy-datum.
t_plantdatax-plant = plant.
t_plantdatax-pur_status = 'X'.
t_plantdatax-pvalidfrom = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = t_bapimathead
plantdata = t_plantdata
plantdatax = t_plantdatax
IMPORTING
return = t_return.
*// Removing entries from Log table "ZWF-TEMP" -
DELETE FROM zwf_temp WHERE objkey EQ material AND
plant EQ plant.
DELETE FROM zwf_temp WHERE objkey EQ material AND
valuation_area EQ plant.
ELSE.
t_salesdata-sales_org = sales_org.
t_salesdata-distr_chan = distr_chan.
t_salesdata-sal_status = new_status.
t_salesdata-valid_from = sy-datum.
t_salesdatax-sales_org = sales_org.
t_salesdatax-distr_chan = distr_chan.
t_salesdatax-sal_status = 'X'.
t_salesdatax-valid_from = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = t_bapimathead
salesdata = t_salesdata
salesdatax = t_salesdatax
IMPORTING
return = t_return.
DELETE FROM zwf_temp WHERE objkey EQ material AND
salesorg EQ sales_org.
ENDIF.
result = t_return-type.
message = t_return-message.
ENDFUNCTION.
plz help me how this method getting importing parameters?
the flow of this workflow?
when it is triggered...so on?
pls it's urgent i need to update and give a solution to org:)Hi,
This is the flow for parameter passing from workflow.
-> Start event will initiate the Workflow container elemets (In your case viewcreated will pass the BUS1001006 to the wokflow conatiner using binding).
-> Your workflow will conatin actvity steps(Workitem at runtime). Each activity will have its own container. So the binding will happen from workflwo conatiner to Activity step conatiner.
-> Each activity is assigned to Business object method which will be called in turn.
The variable from activity step conatiner will be passed to Method of business object. (Ex Zmethod of BUS1001006 ).
-> Method of business object will read the elements from conatiner using Macros swc_get_element etc.
-> Now each business object method can be associated with Z function module.
in your case 'zam_mm_material_status_chng.' . The elements read using macros in Business object method can be passed as Export and import parameters to function zam_mm_material_status_chng.
To conclude
<b>Start event -> Workflow -> Activity step -> Business object method -> Function modue.</b>
Reward if helps. Feel free to ask for clarificatios.
Thanks
Praveen -
Sending WD component link in email through Workflow
Hi ,
I have a Web dynpro component created.The WD application would trigger a Workflow through a Business Object event. In the workflow the user would receive an email on his outlook with the WD component link.
I have 2 questions:
1) How will we send the email to the outlook mail? And the link would be a fairly long string as it is of a WD application.How can we send the link?
2) There is 1 more requirement in which there is a inventory number,which is the key field for the WD screen.The person receiving the outlook email with the link will be getting the link as
eg: http://tcbdci20.xyz.net:8020/sap/bc/webdynpro/xyz/cbb_a4201_invmt?WiNr=4711.
Here the "WiNr" would be the Inventory number parameter name and "4711" would be the inventory number.This link should directly take the user to the inventory number data filled on the WD screen.
Is there any way thsis kind of link can be sent and generated?
Many thanks for your help.
Regards,
Ameya KulkarniHi,
Please see the below code by which I am able to send link more than 160 charecter.
*** BEGIN_METHOD SEND_MAIL_TO_USERS CHANGING CONTAINER.
* Data declaration
DATA:
lt_user_IDS type STANDARD TABLE OF SWHACTOR,
ls_user_IDS type SWHACTOR,
lt_EMAIL_ADDRESSES TYPE STANDARD TABLE OF ADR6-SMTP_ADDR,
ls_EMAIL_ADDRESSES type ADR6-SMTP_ADDR,
lv_STATUS TYPE CFS_STATUS-STATUS_ID,
Lv_Object_ID type crmd_orderadm_h-object_id,
ls_document_data TYPE sodocchgi1,
lt_text TYPE solisti1 OCCURS 0,
l_document_data TYPE sodocchgi1,
lt_receivers TYPE somlreci1 OCCURS 0,
ls_wa_receive TYPE somlreci1,
ls_text TYPE solisti1,
lv_link_title TYPE char50.
DATA: lv_link1 TYPE char200 VALUE
'http://golitsapd39.go-d01.local:8001/sap/bc/gui/sap/its/webgui?sap-',
lv_link2 TYPE char200 VALUE
'language=EN&sap-client=850&~transaction=DSWP_SAPSHORTCUT&~OkCode=',
lv_link3 TYPE char200 VALUE '/08&pcmd=CRMVW&pmsgnum=',
lv_link TYPE char200.
* Get container values
SWC_GET_table CONTAINER 'User_ids' lt_USER_IDS.
SWC_GET_table CONTAINER 'Email_addresses' lt_EMAIL_ADDRESSES.
SWC_GET_ELEMENT CONTAINER 'Status' lv_STATUS.
SWC_GET_ELEMENT CONTAINER 'Object_ID' lv_Object_ID.
*=======================================================================
* Createing final link
*=======================================================================
CONCATENATE lv_link1 lv_link2 lv_link3 lv_object_id INTO
lv_link.
*=======================================================================
* createing subject
*=======================================================================
Condense lv_status.
Translate lv_status to upper case.
CASE lv_status.
WHEN 'NEW'.
CONCATENATE 'Pls assign Support Msg ' lv_object_id
INTO ls_document_data-obj_descr SEPARATED BY space.
WHEN 'AUTHORIZED'.
CONCATENATE 'CR' lv_object_id 'is autorized'
INTO ls_document_data-obj_descr SEPARATED BY space.
WHEN 'CRCREATED'.
CONCATENATE 'Please authorize' lv_object_id
INTO ls_document_data-obj_descr SEPARATED BY space.
WHEN OTHERS.
CONCATENATE 'Support Msg' lv_object_id
'is in' lv_status 'status'
INTO ls_document_data-obj_descr SEPARATED BY space.
ENDCASE.
*=======================================================================
* createing Body
*=======================================================================
* Hi
CLEAR : ls_text.
ls_text = 'Hi,'.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '<br></br>'.
APPEND ls_text TO lt_text.
CASE lv_status.
WHEN 'NEW'.
*Support Message has been created or reassigned in NEW status.
CLEAR : ls_text.
CONCATENATE 'Support Messag' lv_object_id
'has been created or reassigned to you.'
INTO ls_text SEPARATED BY space.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '<br>'.
APPEND ls_text TO lt_text.
*Please raise a CR and waith untill it is aurorized then make the status
*ASSIGNED to continue further.
CLEAR : ls_text.
CONCATENATE
'Please raise a CR and waith untill it is aurorized then make the'
'status ASSIGNED to continue further.'
INTO ls_text SEPARATED BY space.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '</br>'.
APPEND ls_text TO lt_text.
WHEN 'AUTHORIZED'.
CLEAR : ls_text.
CONCATENATE 'CR' lv_object_id 'is authorized.'
INTO ls_text SEPARATED BY space.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '<br>'.
APPEND ls_text TO lt_text.
*Please check and make the status of the support message ASSIGNED
*status to continue further.
CLEAR : ls_text.
CONCATENATE 'Please check and make the status of the support'
'message ASSIGNED status to continue further.'
INTO ls_text SEPARATED BY space.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '</br>'.
APPEND ls_text TO lt_text.
WHEN 'CRCREATED'.
CLEAR : ls_text.
CONCATENATE 'CR' lv_object_id 'has been created.'
INTO ls_text SEPARATED BY space.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '<br>'.
APPEND ls_text TO lt_text.
*Please check and authorized it.
CLEAR : ls_text.
ls_text = 'Please check and authorized it.'.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '</br>'.
APPEND ls_text TO lt_text.
WHEN OTHERS.
CLEAR : ls_text.
CONCATENATE 'Support Message' lv_object_id
'is in' lv_status 'status now.'
INTO ls_text SEPARATED BY space.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '<br>'.
APPEND ls_text TO lt_text.
*Please check and start working as soon as possible.
CLEAR : ls_text.
ls_text = 'Please check and start working as soon as possible.'.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '</br>'.
APPEND ls_text TO lt_text.
ENDCASE.
*Blank Line
CLEAR : ls_text.
ls_text = '</br></br>'.
APPEND ls_text TO lt_text.
*Please click the following link to take a action.
CLEAR : ls_text.
ls_text = 'Please click the following link to take a action.'.
APPEND ls_text TO lt_text.
*inseting link
CLEAR : ls_text.
CONCATENATE 'VIEW/EDIT Object' lv_object_id INTO lv_link_title
SEPARATED BY space.
CONCATENATE '<A HREF=' lv_link '>'
INTO ls_text.
APPEND ls_text TO lt_text.
CLEAR : ls_text.
CONCATENATE '<H5>' lv_link_title '</H5></A>'
INTO ls_text.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '<br></br>'.
APPEND ls_text TO lt_text.
*Adding Signature
*WThanks and regards
CLEAR : ls_text.
ls_text = 'Thanks and regards,'.
APPEND ls_text TO lt_text.
*Blank Line
CLEAR : ls_text.
ls_text = '<br>'.
APPEND ls_text TO lt_text.
*WF-Batch
CLEAR : ls_text.
ls_text = 'WF-BATCH'.
APPEND ls_text TO lt_text.
* Receiver
Loop at lt_user_IDS into ls_user_IDS.
ls_wa_receive-rec_type = 'G'. "SAP User
ls_wa_receive-receiver = ls_user_IDS. "Mail Address
APPEND ls_wa_receive TO lt_receivers.
Endloop.
Loop at lt_EMAIL_ADDRESSES into ls_EMAIL_ADDRESSES.
ls_wa_receive-rec_type = 'U'. "Internet User
ls_wa_receive-receiver = ls_EMAIL_ADDRESSES. "Mail Address
APPEND ls_wa_receive TO lt_receivers.
Endloop.
*This function module is used to send mail
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = ls_document_data
document_type = 'HTM'
put_in_outbox = 'X'
commit_work = 'X'
TABLES
object_content = lt_text
receivers = lt_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 Mail Send Successful
IF sy-subrc EQ 0.
COMMIT WORK.
* Push mail out from SAP outbox
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN. "#EC CI_SUBMIT
ENDIF.
END_METHOD. ***
Thanks and regards,
SNJY -
Workflow Agent Function Module
I am trying to develop a workflow for the approval of CATS time entries. Users will enter their time data and specify a receiving maintenance work order (CATSD-RAUFNR). The approver of the CATS time entry should be the user ID identified in the Partner tab of the maintenance work order identified in the CATS record.
I am trying to determine the agent in a workflow task based on a default rule for agent assignment. My idea was to capture the work order number (stored in table AUFK) from the CATS entry, then reference plant maintenance partners table (IHPA) to get the user id to use as the agent in the workflow.
I have developed a function module that works when testing it in the function builder, but when I try to test it in the "Maintain Rule" transaction (PFAC_CHG), it does not work. Can anyone let me know how to make this code work in the Maintain Rule simulation?
Here is my code for the function module:
FUNCTION Z_GET_WO_PARTNER.
""Local Interface:
*" IMPORTING
*" VALUE(ORDER_NUMBER) TYPE AUFNR OPTIONAL
*" TABLES
*" ACTOR_TAB STRUCTURE SWHACTOR
*" AC_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*" NOBODY_FOUND
*INCLUDE .
TYPES: BEGIN OF PLANT_MAINT,
OBJECT TYPE IHPA-OBJNR,
PARTFUNC TYPE IHPA-PARVW,
PARTNER TYPE IHPA-PARNR,
END OF PLANT_MAINT.
TYPES: BEGIN OF ORDER_MASTER,
ORDER TYPE AUFK-AUFNR,
OBJECTN TYPE AUFK-OBJNR,
END OF ORDER_MASTER.
DATA: WA_MAINT TYPE PLANT_MAINT.
DATA: WA_ORDER TYPE ORDER_MASTER.
DATA: ITABIHPA TYPE STANDARD TABLE OF PLANT_MAINT.
DATA: ITABAUFK TYPE STANDARD TABLE OF ORDER_MASTER.
DATA: PARTNERVAR TYPE STRING.
DATA: OBJN TYPE STRING.
Get object number from order master
SWC_GET_ELEMENT AC_CONTAINER 'OrderNumber' ORDER_NUMBER.
CLEAR: ACTOR_TAB.
REFRESH: ACTOR_TAB.
SELECT SINGLE AUFNR OBJNR FROM AUFK INTO WA_ORDER
WHERE AUFNR = ORDER_NUMBER.
IF SY-SUBRC NE 0.
RAISE nobody_found.
ENDIF.
OBJN = WA_ORDER-OBJECTN.
*get Partner field (system user id) from Plant Maintenance: Partners table
SELECT SINGLE OBJNR PARVW PARNR FROM IHPA INTO WA_MAINT
WHERE OBJNR = OBJN AND PARVW = '§G'.
IF SY-SUBRC NE 0.
RAISE nobody_found.
ELSE.
ACTOR_TAB-OTYPE = 'US'.
ACTOR_TAB-OBJID = WA_MAINT-PARTNER.
APPEND ACTOR_TAB.
ENDIF.
ENDFUNCTION.
(sorry about the poor ABAP code...)To my guess, the function module interface is incorrect. The function module should contain only the following interface:
""Local Interface:
*" TABLES
*" ACTOR_TAB STRUCTURE SWHACTOR
*" AC_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*" NOAGENT_FOUND
You seem to be passing an order number. you need pass container elements using the table AC_Container and cannot send it directly. For further information, look at the following tutorial:
http://www.****************/Tutorials/Workflow/Rules/Create.htm
Hope this helps
SS -
Workflow for Cat2 Time approval
Hi All,
I am new to workflow, We need to trigger a workflow when employee fills time in Tcode CAT2. Standard workflow WS40001001 is working fine.
Here in workitem text it is displaying Approval for 00000000 instead it should display (Approval for Personal no and Name) which is assigned in standard task.
Example:
This how we wanted:
Approval for 00001234 SAPDEMO
This is was happening:
Approval for 00000000
Work item text : Approval for &TS_PERNR& &TS_ENAME& and standard task is TS20000460.
Kindly let me have some idea on this
Thanks in advance
Arun .Hi linganna,
This is standard task and it is binding when we assign the task.
And i am using org unit and made it as general task. Would i need to assign org unit yo task,
how to bind wokflow container element to Business object CATS?
Work item text I CHANGED : Approval for &TS_PERNR& &TS_ENAME& and standard task is TS20000460.
I DEBUGED AND FOUND THAT IN FM CATS_WF_APPROVAL VALUES ARE NOT POPULATING FOR PERNR AND ENAME
WHAT WOULD BE THE PROBLEM HERE?
SWC_GET_ELEMENT CONT_IMP 'TS_PERNR' PERNR_WF.
SWC_GET_ELEMENT CONT_IMP 'TS_ENAME' ENAME.
SWC_GET_ELEMENT CONT_IMP 'TS_DATE' DATE.
SWC_GET_ELEMENT CONT_IMP 'TS_TIME' TIME.
SWC_GET_ELEMENT CONT_IMP 'TS_UNAME' UNAME.
Regards,
Arun.
Edited by: Arun Kumaran on May 31, 2010 1:14 PM
Edited by: Arun Kumaran on May 31, 2010 1:36 PM -
hi all,
The senario is very simple i have linked my workflow with T-code MM02. any changes made in Material Master will need a approval from few users . once the approval ia done. the approvers name will be sent as email to the requester who made the changes.
i m not able to capture the approvers name .though i have declared only one agent as approver . but i m not able to get this thing done .
kindlyb help .. as we have " Executed by " in the worklflow container do v have any other work item where the approvers name is saved .. or is ther any method that i have to implemet to get approvers name
please help... usefull answers will surely be rewarded.
thanks in advance.
srinivasHi,
You can do it by using the Business Object BUS1001 for
aterial.
Copy that object to ZBUS1001 and you can write the Code in the program to send a mail to the required people.
see the sample code what I wrote for PO object to send mail:
begin_method sparesstatuschange changing container.
DATA: v_ebeln LIKE ekko-ebeln,
v_str(43), v_str1(4), v_str2(7), v_str3(2),v_text(90),
v_ernam LIKE ekko-ernam,
v_mstae1 LIKE mara-mstae,
v_sendor TYPE syuname,
v_receiver TYPE string,
v_header TYPE string,
v_body TYPE string.
CONSTANTS: v_sign VALUE ';'.
v_str = 'Please Change the Status of Spares Material'.
v_str2 = 'in PO #'.
v_str1 = 'from'.
v_str3 = 'to'.
DATA : BEGIN OF i_mat OCCURS 0,
ebeln LIKE ekko-ebeln, " PO Number
ebelp LIKE ekpo-ebelp, " PO Item
matnr LIKE ekpo-matnr, " Material Number
END OF i_mat.
DATA : BEGIN OF i_mara OCCURS 0,
matnr LIKE mara-matnr,
mstae LIKE mara-mstae,
END OF i_mara.
DATA: BEGIN OF i_text OCCURS 0,
text(90),
END OF i_text.
swc_get_element container 'ponum' v_ebeln.
CLEAR: v_ernam, v_text.
SELECT SINGLE ernam INTO v_ernam FROM ekko
WHERE ebeln = v_ebeln.
SELECT ebeln ebelp matnr
INTO TABLE i_mat
FROM ekpo
WHERE ebeln = v_ebeln.
SELECT matnr mstae INTO TABLE i_mara FROM mara.
LOOP AT i_mat.
Check for PO Spares Material Status
CLEAR i_mara.
READ TABLE i_mara WITH KEY matnr = i_mat-matnr.
IF sy-subrc = 0.
IF ( i_mara-mstae = 'CO' OR i_mara-mstae = 'RR' ).
IF i_mara-mstae = 'CO'.
v_mstae1 = 'CP'.
ELSEIF i_mara-mstae = 'RR'.
v_mstae1 = 'RP'.
ENDIF.
CONCATENATE v_str i_mat-matnr v_str2 i_mat-ebeln v_str1
i_mara-mstae v_str3 v_mstae1 INTO v_text SEPARATED BY space.
i_text-text = v_text.
APPEND i_text. CLEAR i_text.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR v_body.
LOOP AT i_text.
CONCATENATE v_body i_text-text INTO v_body SEPARATED BY v_sign.
ENDLOOP.
v_receiver = '[email protected]'.
v_sendor = v_ernam.
v_header = 'Check for PO Spares Material Status'.
Call Function Module To send mail
CALL FUNCTION 'UWSP_SEND_MAIL_TO_WEB'
EXPORTING
id_header = v_header
id_body = v_body
id_receiver = v_receiver
id_sender = v_sendor
ID_HTML_MAIL =
id_commit_work = 'X'
EXCEPTIONS
error = 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.
end_method.
reward if useful
Regards,
Anji -
To pass non key field data to workflow
Hello,
I want to pass data from webdynpro application to workflow. For this i used FM 'SWE_CREATE_EVENT' to trigger the workflow.
I filled the container table with following values
wa_cont-element = 'NAME2'
wa_cont-value = 'James Anderson'.
APPEND wa_cont to it_cont.
wa_cont-element = 'STRAS'
wa_cont-value = 'Hampshire'.
APPEND wa_cont to it_cont.
wa_cont-element = 'PSTLZ'
wa_cont-value = '104010'.
APPEND wa_cont to it_cont.
wa_cont-element = 'ORT01'
wa_cont-value = 'London'.
APPEND wa_cont to it_cont.
wa_cont-element = 'LAND1'
wa_cont-value = 'United Kingdom'.
APPEND wa_cont to it_cont.
Also i created a custom business object 'ZHRADCHO'. In which i decleared
KEY FIELDS as ->
PERNR
SUBTY
ENDDA
BEGDA
METHODS ->
send_data_to_wf
I created Import/Export parameters for this method ->
NAME2 (Import and Export parameter)
STRAS (Import and Export parameter)
PSTLZ (Import and Export parameter)
ORT01 (Import and Export parameter)
LAND1 (Import and Export parameter)
EVENTS ->
CHANGE
In SWDD transaction -> basic data -> binding
I did the following binding
&_EVT_CREATOR& => &_WF_INITIATOR&
&_EVT_OBJECT.PERSONNELNUMBER& => &WA_ZHRAD.PERNR&
&_EVT_OBJECT.SUBTYPE& => &WA_ZHRAD.SUBTY&
&_EVT_OBJECT.ENDDATE& => &WA_ZHRAD.ENDDA&
&_EVT_OBJECT.STARTDATE& => &WA_ZHRAD.BEGDA&
WA_ZHRAD is structure type of custom table ZHRAD in which i want the data. So in the workflow container i created the element of type ZHRAD. How do i get the rest of the fields which i declared in the method. I am able to get the data in the key fields which are binded as above. But if i bind the rest of the fields i get an error. How do i get the data in non-key field elements?
Regards,
Yayati EkboteHello Rick,
I am passing the other values through container only. But my question is, in workflow side, in which parameters will i recieve the values?
In the method of the BO i wrote in the automatically generated program.
swc_get_element container 'C/o ' CO.
swc_set_element container 'C/o ' CO.
swc_get_element container 'StreetHouseNo ' STREETHOUSENO.
swc_set_element container 'StreetHouseNo ' STREETHOUSENO.
Like wise for all non-key parameters.
So in SWDD transaction, which parameters should i bind to get the values in the fields of workflow container?
Regards,
Yayati Ekbote -
Passing value from method to Workflow
Hi All,
I am new to workflow. I am trying simple examples to understand the concepts of work flow.
I have copied a std business object and I have a method in that. Now, I am trying to pass some value to this method from the work flow and get back some value after manipulation with in this method.
In the program for the method, I need to get 2 parameters as input and one parameter as outut. With in this method I am trying to write the code for adding this 2 nos. I have seen some Help docs and came to know I should use SWC_GET_ELEMENT_CONTAINER and SWC_SET_ELEMENT_CONTAINER for this. But, I am ot sure of the syntax.
Can you help me with a sample program for this...
Any help is highly appreciated.
Thanks,
Jai Shankarhi Jai Shankar,
I give you the sample code of the method where i am finding number of agents
BEGIN_METHOD ZLCPRNUMBEROFUSERS CHANGING CONTAINER.
DATA:
TEMAILID LIKE SOLI OCCURS 0,
TAPPROVERS LIKE ZSAFAPPROVERS OCCURS 0,
WAPPROVERS LIKE TABLE OF ZSAFAPPROVERS WITH HEADER LINE.
DATA NUMBER LIKE VBAK-VBTYP.
DATA emailid TYPE STRING.
data userid type string.
this is the coding where the value that you give the method container
SWC_GET_TABLE CONTAINER 'TEmailId' TEMAILID.
SWC_GET_TABLE CONTAINER 'TApprovers' TAPPROVERS.
SWC_GET_ELEMENT CONTAINER 'NUMBER' NUMBER.
here you can use your own coding like (select query or any other)
CALL FUNCTION 'Z_LC_PR_NUMBER_OF_USERS'
TABLES
T_EMAIL_ID = TEMAILID
T_APPROVERS = TAPPROVERS
EXCEPTIONS
OTHERS = 01.
CASE SY-SUBRC.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
SWC_SET_TABLE CONTAINER 'TEmailId' TEMAILID.
SWC_SET_TABLE CONTAINER 'TApprovers' TAPPROVERS.
READ TABLE TAPPROVERS INDEX NUMBER INTO WAPPROVERS.
CALL FUNCTION 'Z_LC_GET_EMPLOYEE_INFO'
EXPORTING
USER_ID = WAPPROVERS-APPROVER_USRID
IMPORTING
EMP_EMAIL = emailid.
here i am doing some manupulation in the function module and i am getting that value to the method container as below.
SWC_SET_ELEMENT CONTAINER 'EMAILID' emailid.
SWC_SET_ELEMENT CONTAINER 'USERID' WAPPROVERS-APPROVER_USRID.
SWC_SET_TABLE CONTAINER 'EMAILID' emailid.
SWC_SET_TABLE CONTAINER 'TApprovers' TAPPROVERS.
END_METHOD.
I think it is helpful for you,
Regards,
Balaji E. -
Element Missing in Workflow Container
Hi,
I am facing a strange issue.
I am not finding a particular element in workflow container (both in the Container tab and also in Basic data->Workflow Builder->Workflow container->Element (R/3 4.70 Enterprise)) but at runtime - SWI1 (Workflow Log) when I execute with workflow instance id, I am getting that workflow container element with the value that I required. I am sure I haven't deleted that element from that container... since it's not appearing, again I went to workflow template and added the Element and now it's appearing and working. As of now my problem is solved but can you please tell why it was not appearing in definition.
Advance thanks.
Regards,
Balaji Viswanath.Is there any reason to pass single line element to multiline element?
Instead of that try to pass single line item to single line item and user
SWC_GET_ELEMENT CONTAINER ac_container <container> <single line element> to get the value.
After that you can pass the value to internal table(if required)
Aman
Maybe you are looking for
-
What is recovery mode and how do I get all of my stuff back?!
-
Creating PDF forms in Preview??
Do I HAVE to have another application other than Preview (e.g. Adobe Acrobat, or something) to create PDF forms? I'm trying to do a questionnaire-type thing, and so far haven't been successful in creating one. Thanks.
-
ALV Excel Output - Formatting of Columns
Hi guys, I have a requirement to format the date column output from an alv grid to a spreadsheet. The date in the alv is 01.01.2007 and they want this to appear as 01/01/2007 in the spreadsheet. I noticed in SE16N that this functionality exists, as t
-
My sim card is not detected...
What can I do? I check it in other phone and it's OK. By my iPhone all the time said: Your sim card is not detected.
-
Elderly person, faulty landline, endless excuses f...
My 85 year old mother's landline stopped working on June 6th, and we reported it on June 7th, when we were assured that, because of her age and living on her own, the case would be given priority. Hmm, right! A hole was dug for work to begin 11 days