Using Workflow to Audit Tables

3 minute read time.

Workflow functionality in X3 can be used to accomplish a variety of tasks.

It is most commonly used for controlling transaction documents in the system such as Purchase Requests, Purchase Orders, master data creation and modification, through an approval process via signature circuits.

Workflow can be set up to relay messages through e-mail systems, send notifications, trigger actions, update tables in the X3 database, print reports and execute batch tasks.

In this example, we audit tables for some data and send an alert to relevant personnel for their attention. The aim is to monitor stock level records in X3 in some folder and alert a buyer.

1. Setting Up e-mail functionality in X3

Mail Server set up

A free open source e-mail server, hMail Server was installed and a domain, sage.local and some e-mail accounts created.

The screen shot below shows the hMailServer Administrative panel and some of the settings created.

X3 User e-mail address on users function (GESAUS)

Outlook mail account(s) set up

Test e-mail in Outlook confirming successful set up.

Notification Server set up

X3 has a notification server which can be used for workflow notifications.

This is setup under Administration. Administration->Servers-> Notification servers

An interesting feature is the "Default theme" field which allows beautification of the e-mail messages rather than just plain black and white text.

Notification Server set up test result.

The "Theme" setting is also available on the Workflow function (GESAWA) as highlighted below.

Workflow General parameters set up

Some general parameters must be set up under Chapter SUP Supervisor and Group WRK Workflow

2. Setting up the Workflow

The workflow event type is set to "Manual" and the workflow type as "Line" and the lines are grouped by site with the expression, [F:ITF]STOFCY

We created a Data Model, ZSTKALRT, where we specify the relevant stock tables, ITMMVT, ITMFACILIT and ITMMASTER, from which the stock levels will be determined.

Under conditions, we set the stock level determination expression, ([F:ITV]PHYSTO+[F:ITV]ORDSTO-[F:ITV]PHYALL)<[F:ITF]SAFSTO & [F:ITF]SAFSTO>0

We want to trigger e-mail and send it to the relevant recipients.

The Message block is where we set up the message to be sent and how the stock level calculation result is displayed.

The Object is the message header: [S]nomap(0) will display the current folder that the user is logged onto.

In the Text block, we format how the results will be displayed. |[F:ITF]STOFCY| will display the site and |LIG| will display the stock levels according to the expression and formatting in Line

under Management, [F:ITM]ITMREF +space$(5)+[F:ITM]ITMDES1+space$(5)+num$([F:ITV]PHYSTO+[F:ITV]ORDSTO-[F:ITV]PHYALL)+space$(5)+ num$([F:ITF]SAFSTO)

3. Testing the Workflow

We can now save, validate the workflow and test it by launching it manually (SAIWRKMAN).

We then check on the e-mail client (Outlook) and lo and behold!

The alert shows all products for which the stock levels are below the Safety stock level, field SAFSTO on the Planning tab on the product site (GESITF)

The Workflow can be launched through a scheduled batch task. We create a Recurring batch task set to run once everyday late at night.

Then click on the "Parameters" to enter the Workflow rule.

At the set time, 23:50 in our example, the manual workflow task SAIWRKMAN will launch the manual workflow and the messages can be retrieved from the e-mail client as done above.

I hope this gives some insight on just one way that workflow in X3 can be set up for a crucial business process such as stock alerts.