TheDocumentation 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.
Intercompany class lives in the Inter_Hechiz.Data namespace and is the single engine that drives all data replication across the nine SAP Business One company databases. Every method is public static, meaning no instance is ever constructed — callers invoke methods directly through the class name, as seen throughout Program.Main(). The class reads its Service Layer base URL from [ServiceLayer] UrlSL in config.ini on every call, so the URL can be changed without recompilation. All network traffic passes through the internal EnviaSapPorBasicAuth helper, which handles HTTP request construction, SSL bypass, and response deserialization.
Master Data Methods
These methods keep reference data consistent across all branches. Each one queries the Hechizo (origin) database for records that do not yet exist in the destination company and posts them through the SAP Business One Service Layer REST API.Fabricante
OMRC (Manufacturers) in the Hechizo HANA schema, then for each manufacturer that is absent from the destination schema it calls POST /Manufacturers via the Service Layer.
The SAP HANA schema name of the destination company (e.g.
Conexion.BD_sur). Resolved to the physical database name via the internal ConsultarBD helper.The
Basic <base64> authorization token for the destination Service Layer session (e.g. Conexion.token_sur).GrupoArt
OITB (Item Groups) in the source schema and posts any missing entries to POST /ItemGroups on the destination Service Layer.
Destination company schema name.
Basic Auth token for the destination Service Layer.
GrupoSN
OCRG (BP Groups) and posts missing groups to POST /BusinessPartnerGroups.
Destination company schema name.
Basic Auth token for the destination Service Layer.
condicionespago
OCTG (Payment Terms) and posts missing records to POST /PaymentTermsTypes.
Destination company schema name.
Basic Auth token for the destination Service Layer.
CreararticuloTODASV2
bdDestino key string, queries OITM joined with pricing and group data, then for each missing item posts POST /Items via EnviaSapPorSesion (session-cookie authentication). This is the V2 replacement for the deprecated CreararticuloTODAS.
Company key string identifying the source company (e.g.
"hogar", "sur", "omdo"). Internally resolved to a HANA schema name via ConsultarBD.Respuesta — Codigo = 0 on success; negative on error.
CreararticuloTODASV2 uses session-cookie authentication (EnviaSapPorSesion) rather than Basic Auth. A valid session cookie must already be established via conecta_service_layer before calling this method.ActualizararticuloTODASV2
PATCH /Items('{ItemCode}').
Company key string identifying the source company.
Respuesta.
CrearSOCIOTODAS
OCRD (Business Partners) from bdOrigen and posts each missing record to POST /BusinessPartners using Basic Auth.
Company key string for the source (e.g.
"hogar").Company key string for the destination.
Basic Auth token for the destination Service Layer.
Respuesta.
ActualizaSOCIOTODAS
PATCH /BusinessPartners('{CardCode}').
Company key string for the source.
Company key string for the destination.
Basic Auth token for the destination Service Layer.
Respuesta.
CrearGrupoDescuento
GET to check existence before POST /SpecialPrices on the Service Layer.
Destination company schema name.
Basic Auth token for the destination Service Layer. (Note: parameter name contains a typo in source —
TokenDetino.)Respuesta.
Crearvendedores
POST /SalesPersons via session-cookie authentication.
Company key string for the destination.
Respuesta.
Actualizarvendedores
PATCH /SalesPersons({SalesEmployeeCode}).
Company key string for the destination.
Respuesta.
CrearEmpleados
POST /EmployeesInfo.
Company key string for the destination.
Respuesta.
ActualizarEmpleados
PATCH /EmployeesInfo({EmployeeID}).
Company key string for the destination.
Respuesta.
Document Flow Methods
These methods implement the intercompany purchase-to-pay cycle: purchase requests flow from branches to Hechizo, become sales orders in Hechizo, and return to branches as purchase orders. Invoices and credit notes mirror in the same direction.ProcesarSolictComp
OPRQ) from a branch database and creates corresponding purchase requests in the Hechizo company via POST /PurchaseRequests. This is the first step of the intercompany replenishment workflow.
Company key string for the branch originating the purchase request.
Basic Auth token for the Hechizo Service Layer (the destination in this direction).
ProcesarEnOrdVentaHechizo
ProcesarSolictComp) into sales orders by posting to POST /Orders. After a successful order is created the originating purchase request is closed via POST /PurchaseRequests({DocEntry})/Close.
Basic Auth token for the Hechizo Service Layer.
ProcesarEnOrdCompra
ORDR for unprocessed orders referencing the branch CardCode, then posts each to POST /PurchaseOrders on the branch Service Layer.
Company key string for the destination branch.
Basic Auth token for the destination branch Service Layer.
ActualizarEnOrdCompra
U_Actualiza = 'Y') to existing branch purchase orders via PATCH /PurchaseOrders({DocEntry}).
Company key string for the destination branch.
Basic Auth token for the destination branch Service Layer.
ProcesarFacturaProveEnSucursales
PurchaseInvoices) in a branch company derived from open AR invoices (OINV) in Hechizo that reference the branch’s CardCode. Posts to POST /PurchaseInvoices.
Company key string for the destination branch.
Basic Auth token for the destination branch Service Layer.
ProcesarNotasCredProveEnSucursales
PurchaseCreditNotes) in a branch company from Hechizo AR credit notes (ORIN) that reference the branch’s CardCode. Posts to POST /PurchaseCreditNotes.
Company key string for the destination branch.
Basic Auth token for the destination branch Service Layer.
ProcesarNotasCredProveEnSucursalesV1
omdo branch which requires a different document query. Functionally equivalent to ProcesarNotasCredProveEnSucursales but uses an alternative SQL query against ORIN.
Company key string for the destination branch (typically
"omdo" for this variant).Basic Auth token for the destination branch Service Layer.
ActualizarEnFacturaProvee
U_Actualiza = 'Y') to the corresponding branch AP invoices via PATCH /PurchaseInvoices({DocEntry}). The B1S-ReplaceCollectionsOnPatch header is not sent for this method (Usar = "N" passed to EnviaSapPorBasicAuth), preserving existing document lines.
Company key string for the destination branch.
Basic Auth token for the destination branch Service Layer.
ActualizarEnNotaCredProvee
U_Actualiza = 'Y') to the corresponding branch AP credit notes via PATCH /PurchaseCreditNotes({DocEntry}). Like ActualizarEnFacturaProvee, this method passes Usar = "N" to suppress collection replacement on patch.
Company key string for the destination branch.
Basic Auth token for the destination branch Service Layer.
ProcesarCuentasdesdeHechizoV2
proceso parameter selects the operation: ProcesoCuenta.Crear calls POST /ChartOfAccounts; ProcesoCuenta.Actualizar calls PATCH /ChartOfAccounts('{AcctCode}').
Company key string for the destination branch.
Basic Auth token for the destination branch Service Layer.
Controls the operation.
ProcesoCuenta.Crear to create new accounts; ProcesoCuenta.Actualizar to update existing ones.ProcesarEnPagoRecibido
ORCT) records from an origin branch to a destination company via POST /IncomingPayments. This enables cash receipt visibility across entities.
Company key string for the branch where the payment was received.
Company key string for the destination company.
Basic Auth token for the destination Service Layer.
Infrastructure Methods
These methods support the synchronization framework itself rather than individual document or master data flows.SINCROERROR_V2
@SINCROERROR user-defined table in the Hechizo database by calling the stored procedure SP_LIMPIA_SINCROERROR. This method is invoked once at the very start of Program.Main() to reset the error registry before each synchronization run.
SINCROERROR_V2 supersedes the earlier SINCROERROR method, which issued a direct TRUNCATE TABLE only when the current time was before 07:00. The V2 version delegates all cleanup logic to the stored procedure and runs unconditionally.EnviaSapPorBasicAuth
HttpWebRequest, attaches the Authorization header, serializes the JSON body (if any), sends the request, and deserializes the response.
HTTP verb:
"GET", "POST", or "PATCH".The request body. Pass
null for GET requests.Full Service Layer endpoint URL (e.g.
UrlServiceLayer + "PurchaseOrders").The
Basic <base64> authorization token appended to the Authorization header.When
"Y" (default) and Metodo is "PATCH", the request header B1S-ReplaceCollectionsOnPatch: true is added, causing the Service Layer to replace child collections (lines, addresses, etc.) entirely. Set to "N" to perform a partial header-only patch and preserve document lines.Success. The response body has been deserialized into the static
Marketing object (ObjSap), which exposes the new document’s DocEntry and DocNum.Exception. An unhandled .NET exception occurred (e.g. network timeout, DNS failure). The error message is stored in the private static field
RR.Service Layer error. The API returned an error response body. The
error.message.value string from the JSON error envelope is stored in RR.Enums
ProcesoCuenta
Intercompany class. Controls the behavior of ProcesarCuentasdesdeHechizoV2 — whether it creates new G/L accounts in the destination (Crear) or updates existing ones (Actualizar).
Return Type
Most methods that return a value use theRespuesta class, defined at the bottom of Intercompany.cs:
void (such as Fabricante, GrupoArt, ProcesarSolictComp, and the document flow methods) write results directly to the log via RegistroLog.Graba and update the @SINCROERROR UDT table on failure through the private Inserterror helper.