Upload
vocong
View
234
Download
2
Embed Size (px)
Citation preview
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 1 Public
How to Optimize Business Processes with Workflow in SAP B1 Philippe BERNARD/Local Product Expert Ecosystem & Channels readiness May 26-28, 2015 Customer
SAP Business One Innovation summit - Barcelona
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 2 Public
Agenda
§ Activate the Workflow Service for the Company
§ Manage Configuration Log File Settings
§ Design the Workflow Template
§ Import and Activate the Workflow Template in SAP Business One
§ Execute the Workflow
Activate Workflow Service for the Company
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 4 Public
Activate Workflow for Company
1
1
2
5
4
3
6 7
8 9
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 5 Public
Services Necessary for Workflow
Name :SBO_WorkflowDataAccess.exe
Name :B1_Workflow_Service.exe Depends on SAP Business One Workflow Data Access
!!! If you create new UDF,UDT or UDO services should be restarted
Manage Configuration Settings
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 7 Public
Configuration File of the Workflow Service
C:\Program Files (x86)\SAP\SAP Business One ServerTools\Workflow\b1-workflow-manager.xml
Frequency to evaluate conditional Start Event 1 minute
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 8 Public
Manage Log File and Debug
These settings in the configuration file affect the log information
Name & Location of Log File
Information Error Warning Debug 0 : Don’t write in the file 1: Write in the log file
Information are generated by instruction «print» in script
Design the Workflow Template
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 10 Public
SAP Business One Studio
To create a workflow you need SAP Business One Studio
It is available in 32-bit and 64-bit versions. It is also possible to include it in Visual studio 2010
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 11 Public
Workflow for Replenishment of Warehouse 02
Each night we want to create a Stock Transfer Request to replenish Warehouse 2 from Warehouse 1. In the morning the manager of Warehouse 2 creates a stock transfer based on the Stock Transfer Request
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 12 Public
Timer Start Event
Run at 3:10 am
Run once a day
First run on 2015/05/03 no end date
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 13 Public
Script Task
Script Task are always assigned to user «Workflow»
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 14 Public
Script Task - Javascript
Code will be explained in detail in some slides.
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 15 Public
User Task
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 16 Public
Customized Data Object
This object is mainly used to store variables.
These variables will be read, written or updated by script task or user
Name of variable
Type of variable
Initial Value
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 17 Public
SAP Business One Data Object
These objects represent object of SAP Business One.
These objects are used as input or output object of tasks.
Activities Bill of Exchange Business Partner Sales Marketing Documents Deposits Dunning Terms Incoming Payments Inventory Entry Inventory Exit Inventory Transfer Request
Items Journal Entries Journal Vouchers Landed Cost Material revaluation Material Groups Production Orders Bill of Material Purchase Marketing Document Sales Forecast
Sales Opportunities Service Calls Stock Transfer Users Outgoing Payments payment Wizard ...
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 18 Public
Exclusive Gateway
If condition is not true this branch is executed
If condition is true this branch is executed
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 19 Public
Some Recommendations for Javascript
Use debug (« print » instruction)
Write your scripts step by step
Consult file « SAP Business One Workflow API Reference.html » to know object, method and properties.
Pay attention to variables type
Pay attention to the case, don’t forget that Javascript is case sensitive !
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 20 Public
SAP Business One Workflow API Reference.html
1
2
3
4
5
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 21 Public
Color Code in the script
To make the following script more understandable we apply the following color codes
Method
Standard Javascript Comment
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 22 Public
Script 1/4
// Create a variable of class RecordsetParams var param = company.getRecordsetParams();
// Define the query var query = "SELECT ItemCode, ( MinStock - (OnHand + OnOrder - IsCommited) ) AS \"Qty\" FROM OITW WHERE (WhsCode = \'02\') AND ((OnHand + OnOrder - IsCommited) < MinStock)";
//For debug purpose print("In the script task the SQL query is : " + query);
param.setQuery(query);
// Initialize a variable of class "Recordset" var recordset=company.getRecordset();
// Execute the query recordset.doQuery(param);
…
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 23 Public
Script 2/4
var xnew = "Y"; // Loop to read all record while (recordset.read())
{ if (xnew == "Y") { // Create an object DIService var invtrfreqService = company.getBusinessService('1250000001'); // Create an Object of type "Inventory Transfer Request" var transferDoc = company.createDIObject('StockTransfer'); // Define Source Warehouse transferDoc.setFromWarehouse('01'); // Define Destination Warehouse transferDoc.setToWarehouse('02'); // Write a comment in the field Remark transferDoc.setComments("Generated by the workflow"); // Create a Collection for Lines of Inventory Transfer Request var collLines = transferDoc.getStockTransferLines();
if (collLines == null) { collLines=company.createDIObject('StockTransferLines'); } xnew ="N"; }
Where can we find this value ?
From where these strings are coming from ?
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 24 Public
Script 3/4
// Create a new Line in document var transferLine= company.createDIObject('StockTransferLine');
// Read first field of Query [ItemCode] var field0 = recordset.getField(0); var fieldValue0 = field0.getColumnValue();
// Set the Item transferLine.setItemCode(fieldValue0);
// Read second field of Query var field1 = recordset.getField(1); var fieldValue1 = field1.getColumnValue();
// Enter the Quantity transferLine.setQuantity(parseFloat(fieldValue1));
// Add the Line to the collection collLines.add(transferLine);
}
Pay attention there are 2 objects :
• StockTransfertLines (Collection)
• StockTrasfertLine (Line itself)
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 25 Public
Script 4/4
// If a document has been created, save it if (xnew == "N")
{ // Add Collection of Lines to the document transferDoc.setStockTransferLines(collLines);
// Add New Inventory transfer request in the DataBase var invtrfreqParams = invtrfreqService.add(transferDoc);
// Read Number of created Inventory Transfer Request var docNum = invtrfreqParams.getDocEntry();
// Update Inventory Transfer Request Key CurrentProcess.DataObject('transRequest').putItem("Key",docNum.toString());
// Update local variable "convert" CurrentProcess.DataObject('do1').putItem('convert',1); print("The inventory transfer request " + docNum + " has been created");
}
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 26 Public
getBusinessServices(String objectType)
// Create an object DIService var invtrfreqService = company.getBusinessService('1250000001');
To find these value use SDK HELP for DI/API then search for “BoObject Types Enumeration”, then search for row containing your object. The value is in column “Value” it should be passed as String.
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 27 Public
createDIObject(String clsName)
// Create an Object of type "Inventory Transfer Request" var transferDoc = company.createDIObject('StockTransfer'); .. collLines=company.createDIObject('StockTransferLines'); .. var transferLine= company.createDIObject('StockTransferLine');
The string is the Class Name, you can find it in the file
« SAP Business One Workflow API Reference.html ».
Import and Activate Workflow in SAP Business One
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 29 Public
Import Workflow in SAP Business One 1/2
3
4
5
6
1 2
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 30 Public
Import Workflow in SAP Business One 2/2
10
9
7 8
You cannot re-import an existing Workflow template with the same name and version, even if it has been deleted in the Workflow Manager. If you change the template, change the version. The concatenation of name and version should be unique in the Database
Execute the workflow
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 32 Public
2
3
Launch the Workflow
1
4
5
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 33 Public
Follow Workflow Execution
This task is completed
This task can be picked
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 34 Public
Pick Up the Task
1 3
2
4
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 35 Public
User Task Execution
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 36 Public
Use Case
Creation of new partner to segregate tasks between sales department and bookkeeping
Creation of Item to segregate tasks between purchase, sales and production
Create batch processing on various objects exposed in workflow
Include manual tasks in workflow
Create workflow on UDO (for example leave request)
…
Appendix
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 38 Public
Write in
Data model related to Workflow
Workflow Manager
OWMG
Is used in Workflow Instance
OWFI
Workflow Task Detail
OWLS Potential Processor of Task
WLS1
Input Data for Task
WLS2 Task Note
WLS3
Output Data for Task
WLS4
Create By
Read By
Composed of
Be Done by
Error Messages
OWFER (1,1) (0,n)
(1,n)
(1,1)
(1,1) (1,n)
(1,1)
(1,1)
(0,n)
(0,n)
(0,n)
(1,1)
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 39 Public
Workflow Manager
OWMG
TemplateKey
Name
Version
StartType Status
Desc
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 40 Public
Workflow Instance
OWFI
WFInstID
Creator StartDate & StartTime
Status
EndDate & EndTime
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 41 Public
Task Detail
OWLS TaskID
TaskName
Operation
EnterDate
DueDate Priotity
Status
Owner DuraDays DuraHours
TaskDesc
TaskType
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 42 Public
Participant (Processor of task)
WLS1
Candidate
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 43 Public
Input Data for Tasks
WLS2
ObjectType ObjKey
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 44 Public
Note information in task
WLS3
LineID
Note
Creator
Notedate
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 45 Public
Task Output Data
WLS4
ObjectType ObjKey
© 2015 SAP SE or an SAP affiliate company. All rights reserved.
Thank you
Contact information: Philippe BERNARD Local Product Expert Address Phone number
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 47 Public
© 2015 SAP SE or an SAP affiliate company. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 48 Public
© 2015 SAP SE oder ein SAP-Konzernunternehmen. Alle Rechte vorbehalten.
Weitergabe und Vervielfältigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, ohne die ausdrückliche schriftliche Genehmigung durch SAP SE oder ein SAP-Konzernunternehmen nicht gestattet.
SAP und andere in diesem Dokument erwähnte Produkte und Dienstleistungen von SAP sowie die dazugehörigen Logos sind Marken oder eingetragene Marken der SAP SE (oder von einem SAP-Konzernunternehmen) in Deutschland und verschiedenen anderen Ländern weltweit. Weitere Hinweise und Informationen zum Markenrecht finden Sie unter http://global.sap.com/corporate-de/legal/copyright/index.epx.
Die von SAP SE oder deren Vertriebsfirmen angebotenen Softwareprodukte können Softwarekomponenten auch anderer Softwarehersteller enthalten.
Produkte können länderspezifische Unterschiede aufweisen.
Die vorliegenden Unterlagen werden von der SAP SE oder einem SAP-Konzernunternehmen bereitgestellt und dienen ausschließlich zu Informations-zwecken. Die SAP SE oder ihre Konzernunternehmen übernehmen keinerlei Haftung oder Gewährleistung für Fehler oder Unvollständigkeiten in dieser Publikation. Die SAP SE oder ein SAP-Konzernunternehmen steht lediglich für Produkte und Dienstleistungen nach der Maßgabe ein, die in der Vereinbarung über die jeweiligen Produkte und Dienstleistungen ausdrücklich geregelt ist. Keine der hierin enthaltenen Informationen ist als zusätzliche Garantie zu interpretieren.
Insbesondere sind die SAP SE oder ihre Konzernunternehmen in keiner Weise verpflichtet, in dieser Publikation oder einer zugehörigen Präsentation dargestellte Geschäftsabläufe zu verfolgen oder hierin wiedergegebene Funktionen zu entwickeln oder zu veröffentlichen. Diese Publikation oder eine zugehörige Präsentation, die Strategie und etwaige künftige Entwicklungen, Produkte und/oder Plattformen der SAP SE oder ihrer Konzern- unternehmen können von der SAP SE oder ihren Konzernunternehmen jederzeit und ohne Angabe von Gründen unangekündigt geändert werden. Die in dieser Publikation enthaltenen Informationen stellen keine Zusage, kein Versprechen und keine rechtliche Verpflichtung zur Lieferung von Material, Code oder Funktionen dar. Sämtliche vorausschauenden Aussagen unterliegen unterschiedlichen Risiken und Unsicherheiten, durch die die tatsächlichen Ergebnisse von den Erwartungen abweichen können. Die vorausschauenden Aussagen geben die Sicht zu dem Zeitpunkt wieder, zu dem sie getätigt wurden. Dem Leser wird empfohlen, diesen Aussagen kein übertriebenes Vertrauen zu schenken und sich bei Kaufentscheidungen nicht auf sie zu stützen.