Synchronization of Companies and Branches

The functionality of synchronization of companies and branches is about import and synchronization of companies and branches registered in TOTVS ERP system for SIGADW. The configuration of this functionality is necessary for other two SIGADW functionalities:

Embedded SQL: It helps standard SQL creation, relating the type of sharing for the table.
Native Indicators: used to analyze SIGADW data for each Company/Branch.

Note that by using the functionality of Native Indicators, all dimensions, data sources, and connections necessary for native indicators are automatically created. For this, you just need to import specific cubes and dimensions.

While using the functionality of Embedded SQL, some procedures must be previously followed. These procedures create some dimensions, connections, and data sources that native indicators also need (mainly EMPFIL dimension and its dependences).

Embedded SQL

Embedded SQL was developed to facilitate writing and reading of SQL queries in the System environment. For this aim, a syntax was defined in order to enable you to write SQL query by accessing tables and registers of System environment.

Example:

SELECT

SE2.E2_PREFIXO,

SE2.E2_NUM

FROM

%table:SE2% SE2,

%table:QEK% QEK

WHERE

SE2.E2_FILIAL= %xfilial:SE2%

AND SE2.E2_EMISSAO <> %exp:date()%

AND SE2.%notDel%

ORDER BY

%Order:SE2%

 

Where:

Code parts that must be replaced appear between % signs.
Expressions or functions appear starting with %exp: %;
%table:<alias>% to access Protheus tables.
%notDel% is replaced with D_E_L_E_T_= ' ';
%Order:<alias>% is used to order per field, and it can be done through 3 ways:
%Order: <cAlias> %;
%Order: <cAlias>, <nIndice>%;
%Order: <cAlias>, <cNick>%.

 

By using Embedded SQL in a data source, SIGADW can suggest a SQL query based on information about sharing of System environment tables. To make SIGADW suggest SQL query, the synchronization of companies and branches is required, following some steps:

1. Create EMPFIL dimension, that is the dimension used to recover ERP and to store the register of Companies and Branches present in ERP.

2. Create data source and connection used in synchronization of the register of companies and branches (synchronized with sigamat.emp file).

3. Synchronization of companies and branches.

4. Check sharing of companies and branches.

Attention:

Sigamat Synchronization menu is only visually available after the 1st step: Create EMPFIL dimension.

Step 1 - Create EMPFIL Dimension

To create EMPFIL dimension, access the menu Definitions / Dimensions, and normally create, as explained before, a dimension with the name EMPFIL (this name is reserved specially for this purpose).

Note that SIGADW identifies the creation of EMPFIL dimension, creating automatically an attribute called M0_CODIGO. This name is reserved to identify the company code to be used in synchronization of companies in SIGADW.

If the identification per branches is necessary, manually create a field to identify the branch (the name M0_CODFIL is suggested). In this case, this field must also be as a single key.

Step 2 - Create Data Source and Connection

To synchronize companies and branches, EMPFIL dimension needs a data source connecting it to sigamat.emp file of Microsiga Protheus® ERP environment.

Connection with sigamat.emp file

Create a direct connection by accessing the menu Support / Connections / Protheus-Direto, as explained before. Remember this connection must use Microsiga Protheus® environment, from where companies and branches must be recovered for SIGADW.

Create Data Source

Create a data source for EMPFIL dimension, as explained before. This data source must use the connection previously created, and it must access sigamat.em file.

After creating connection and data source, import EMPFIL dimension.

Step 3 - Synchronization of Companies and Branches

Access the menu Tools / Sigamat Synchronization / Companies/Branches, and start the synchronization process by clicking Start. A process is started for synchronization of companies/branches.

This step is important to identify the relationships that exist in the registers of companies/branches as well as the sharing modes adopted (per company or branch).

Note that synchronized sharing of register/tables of Microsiga Protheus® environment is only the register that is being used in SIGADW at the moment, that is: some data source of some dimension or cube must refer to the register/table.

Step 4 - Check Sharing of Companies and Branches

After synchronizing companies/branches in step 3, you can check which sharing of companies/branches was synchronized. For this, access the menu Tools / Sigamat Synchronization / Sharing.

All relationships used in SIGADW that were synchronized and the respective sharing mode are displayed.

At this moment, SIGADW environment is ready to use Embedded SQL.