Hechizo SAP Intercompany uses a hub-and-spoke topology across ten SAP Business One company databases running on a single SAP HANA instance. The hub company — referred to internally asDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/FCS-Consultores/hechizo-SAP-intercompany/llms.txt
Use this file to discover all available pages before exploring further.
ORIGEN — is Hechizo (10071_HECHIZO_DEP). It serves as the single source of truth for all master data: item manufacturers, item groups, business partner groups, payment terms, and items. Each of the nine branch companies is a spoke that receives replicated data from the hub and participates in intercompany purchase-order and invoice flows. All ten companies live in the same HANA system and are addressed by their HANA schema name, which is what config.ini stores under [ConexionHanaProd].
Hub-and-spoke model
Hub — Hechizo (ORIGEN)
The master database. Sync methods query this schema for master data and then push any missing records to each branch. Identified by
Conexion.BD_Hechizo at runtime.Branch companies (9 spokes)
Each branch has its own SAP B1 company database. At startup,
Conexion.cs reads each branch’s schema name from config.ini and stores it in a static string field (e.g. BD_sur, BD_omdo, …).Fabricante, GrupoArt, GrupoSN, and condicionespago) follow this pattern:
- Query the hub database (cross-schema HANA SQL) for records not yet present in the branch.
- Serialize the missing records as JSON.
- POST each record to the branch company via the Service Layer REST API using that branch’s authentication token.
Company database reference
The table below lists every company, itsconfig.ini key under [ConexionHanaProd], its role in the topology, and the actual HANA schema name used in production.
| Config key | C# static field | Role | Production DB name |
|---|---|---|---|
ORIGEN | Conexion.BD_Hechizo | Hub | 10071_HECHIZO_DEP |
sur | Conexion.BD_sur | Branch | 10071_DEPORTES_SUR |
omdo | Conexion.BD_omdo | Branch | 10071_OMDO |
nedn | Conexion.BD_nedn | Branch | 10071_NEDN |
hogar | Conexion.BD_hogar | Branch | 10071_HOGAR_IDEAL |
flores | Conexion.BD_flores | Branch | 10071_FLORES_DEP |
vital | Conexion.BD_vital | Branch | 10071_ENC_VITAL |
emde | Conexion.BD_emde | Branch | 10071_EMDE |
central | Conexion.BD_central | Branch | 10071_AVECENTRAL |
desampa | Conexion.BD_desampa | Branch | 10071_3_102_956112 |
Business partner code mapping — [CodSocio]
Every intercompany transaction (purchase order, vendor invoice, payment) requires both a source and a destination company. To create a purchase order in a branch, the sync method needs to know the SAP Business One CardCode that the branch uses to identify its counterpart supplier (Hechizo or another branch) in its own BP master.
The [CodSocio] section stores these codes as seen from Hechizo’s perspective: the value under each key is the CardCode that represents that branch (or Hechizo itself) inside the Hechizo (ORIGEN) company database.
| Config key | CardCode in Hechizo | Business partner name |
|---|---|---|
ORIGEN | PL00001 | Hechizo (self, used as vendor when Hechizo is destination) |
sur | 2703 | Deportes Sur |
omdo | 2704 | OMDO |
nedn | 2706 | NEDN |
hogar | 2776 | Hogar Ideal |
flores | 2731 | Flores Deportes |
vital | 2775 | Encanto Vital |
emde | 2705 | EMDE |
central | 2738 | Ave Central |
desampa | CL00041 | Desamparados company |
ConsultarCardCode(bdDestino) looks up the branch schema name in Intercompany.cs and returns the matching CardCode so that transaction headers can be populated correctly.
How Conexion.cs reads database names at startup
All ten database name fields are declared as public static string fields in the Conexion class. They are initialised once — at class-load time — by calling a dedicated private static method for each company. The pattern is identical for every branch; the example below shows Consultar_sur():
IniFile handle, reads the named key from [ConexionHanaProd], and returns the string value (whitespace is stripped by the Windows GetPrivateProfileString API). If the key is missing or the file cannot be opened, the method catches the exception, writes it to the log, and returns an empty string — causing that branch’s sync operations to silently skip with HANA cross-schema queries targeting an empty schema name.
The static fields are declared and initialised in declaration order:
token_* fields are also initialised in this same class before the BD_* fields — they internally call the Consultar_* methods themselves, so the database names are resolved twice on startup (once for the token, once for the field).
ODBC connection string
Theconexionhana() method assembles a single ODBC connection string used for all direct HANA SQL queries across every company schema:
[ConexionHanaProd]:
SYSTEM user has cross-schema visibility and the queries use fully-qualified table references (e.g. "10071_HECHIZO_DEP"."OMRC").