Raquel Giugliano
Templates by Raquel Giugliano
Sap service layer login
This minimal utility workflow connects to the SAP Business One Service Layer API to verify login credentials and return the session ID. It's ideal for testing access or using as a sub-workflow to retrieve the B1SESSION token for other operations. ++โ๏ธ HOW IT WORKS:++ ๐น 1. Trigger Manually The workflow is initiated using a Manual Trigger. Ideal for testing or debugging credentials before automation. ๐น 2. Set SAP Login Data The Set Login Data node defines four key input variables: sap_url: Base URL of the SAP B1 Service Layer (e.g. https://sap-server:50000/b1s/v1/) sap_username: SAP B1 username sap_password: SAP B1 password sap_companydb: SAP B1 Company DB name ๐น 3. Connect to SAP A HTTP Request node performs a POST to the Login endpoint. The body is structured as: { "UserName": "yoursapusername", "Password": "yoursappassword", "CompanyDB": "yoursapcompanydb" } If successful, the response contains a SessionId which is essential for authenticated requests. ๐น 4. Return Session or Error The response is branched: On success โ the sessionID is extracted and returned. On failure โ the error message and status code are stored separately. ++๐ SETUP STEPS:++ 1๏ธโฃ Create SAP Service Layer Credentials Although this workflow uses manual inputs (via Set), it's best to define your connection details as environment variables for reuse: SAP_URL=https://your-sap-host:50000/b1s/v1/ SAPUSER=yoursapuser SAPPASSWORD=yourpassword SAPCOMPANYDB=your_companyDB Alternatively, update the Set Login Data node directly with your values. 2๏ธโฃ Run the Workflow Click "Execute Workflow" in n8n. Watch the response from SAP: If successful: sessionID will be available in the Success node. If failed: statusCode and errorMessage will be available in the Failed node. ++โ USE CASES:++ ๐ Reusable Login Module Export this as a reusable sub-workflow for other SAP-integrated flows. ๐ Credential Testing Tool Validate new environments, test credentials before deployment.
Flexible currency rate uploads for SAP B1 with AI validation & multiple sources
This workflow automates currency rate uploads into SAP Business One via Service Layer, using flexible input sources such as JSON (API), SQL Server, Google Sheets, or manual values. It leverages logic branching, AI validation, and logging for complete control and traceability. ++โ๏ธ HOW IT WORKS:++ ๐น 1. Receive Data via Webhook The workflow listens on the endpoint /formulario-datos via HTTP POST. The request body should include: origen: one of JSON, SQL, GoogleSheets, or Manual Depending on the value, the flow branches accordingly. ๐น 2. Authenticate with SAP Business One A POST request is sent to SAP B1โs Login endpoint. A session cookie (B1SESSION) is retrieved and used in all subsequent API calls. ๐น 3. Switch by Origin The flow branches into four processing paths based on origen: JSON: The payload is normalized using OpenAI to extract an array of rates. Each rate is sent to SAP individually after parsing. SQL: The SQL query provided in the payload is executed on a connected Microsoft SQL Server. The results are checked by AI to validate the date format. If valid, rates are sent to SAP. GoogleSheets: Rates are pulled from a connected spreadsheet. Each entry is sent to SAP in sequence. Manual: Uses currency, rate, and rateDate directly from the webhook payload. Sends the result directly to SAP. ๐น 4. AI-Powered Enhancements (Optional but enabled) Normalize JSON: Uses OpenAI (LangChain node) to convert any messy structure into a uniform array under the key rate. Date Formatting: Another OpenAI call ensures RateDate is in yyyyMMdd format (required by SAP), converting from ISO, timestamp, or other formats. ๐น 5. Send to SAP Business One (Service Layer) All paths send a POST request to: /SBOBobService_SetCurrencyRate With a payload such as: { "Currency": "USD", "Rate": "0.92", "RateDate": "20250612" } ๐น 6. Log Results All success/failure results are appended to a Google Sheets log (LOGS_N8N) The log includes method, URL, sent payload, status code, and message. ++๐ SETUP STEPS:++ 1๏ธโฃ Create Required Credentials: Go to Credentials > + New Credential and configure: SAP Business One (Service Layer) Type: HTTP Request Auth or Token Base URL: https://<your-host>:50000/b1s/v1/ Provide Username, Password, and CompanyDB via variables or fields Google Sheets OAuth2 connection to a Google account with access Microsoft SQL Server SQL login credentials and host OpenAI API key with access to models like GPT-4o 2๏ธโฃ Environment Variables (Recommended) Set these variables in n8n โ Settings โ Variables: SAP_URL=https://<host>:50000/b1s/v1/ SAPUSER=yourusername SAPPASSWORD=yourpassword SAPCOMPANYDB=your_companyDB 3๏ธโฃ Prepare Google Sheets Sheet 1: RATE (for charging the data) Columns: Currency, Rate, RateDate Sheet 2: LOGS_N8N (to save the logs, success or failed) Columns: workflow, method, url, json, status_code, message 4๏ธโฃ Activate and Test Deploy the webhook and grab the URL. ++โ BONUS++ Built-in AI assistance for input validation and structure Logs all results for compliance and audit Flexible integration paths: perfect for hybrid or transitional systems
Automating SAP B1 journal entries using JSON, Google Sheets, and GPT-4o
HOW IT WORKS: This workflow automates the creation of Journal Entries in SAP Business One (SAP B1). Depending on the source of the input data, it dynamically transforms and sends accounting records in the appropriate format using the Service Layer API. It supports three input types: ๐ฆ JSON payloads ๐ Google Sheets data ๐งโ๐ป Manual structured entries (via prompt + LLM) Each transaction is logged to Google Sheets for traceability. ๐น 1. Webhook Input Reception A Webhook node waits for a POST request containing accounting data and metadata: The origen field determines the data source (JSON, GoogleSheets, or Manual) The sap_url, username, password, and companydb are used to connect to SAP B1 Payload can be a JSON list or tabular data (e.g., from Google Sheets) ๐น 2. SAP B1 Login Credentials are securely injected from the request body. A login request is sent to SAP B1's Service Layer to retrieve a valid session cookie (B1SESSION). ๐น 3. Dynamic Branching via Switch Node Depending on the value of origen, one of the following branches is activated: JSON: Sends the JSON payload directly to SAP after restructuring GoogleSheets: Loads rows, builds JSON, and merges context Manual: Transforms data via OpenAI LLM prompt and generates SAP-compatible format ๐น 4. Data Transformation via LLM In Manual and GoogleSheets flows, the workflow uses an OpenAI node to: Parse line entries and convert them to JournalEntryLines[] Format the final JSON structure required by SAP LLM prompts are carefully crafted to return only clean JSON โ no code blocks, comments, or explanations. ๐น 5. POST to SAP B1 Data is sent to {{SAP_URL}}/JournalEntries using the Service Layer's POST method with the B1SESSION cookie attached. The body includes all JournalEntryLines. ๐น 6. Logging Success & Errors Each result (success or failure) is logged into a centralized Google Sheets log document: โ Success: Includes HTTP status, source URL, and JSON payload โ Failure: Logs the error code and message for review and traceability SETUP STEPS: Create Required Credentials: Google Sheets OAuth2 API (to log all responses and fetch data) OpenAI API Key (used with the LangChain OpenAI node) SAP Service Layer login data is passed securely via body parameters. Use These Environment Variables (Recommended) or replace the data in the corresponding container: SAPUSER, SAPPASSWORD, SAPCOMPANYDB SAP_URL Prepare Google Sheets: ๐ Sheet 1: For source entries (e.g., for GoogleSheets origin) ๐งพ Sheet 2: For logging execution results Make sure the logging spreadsheet contains these columns: workflow, method, url, json, status_code, message EXTRA NOTES: ๐ง Uses OpenAI GPT-4o for natural language transformation of accounting rows ๐งฉ Modular logic with error-handling for all branches ๐ Can be reused across multiple accounting integrations by changing the data source