Skip to main content

Automating SAP B1 journal entries using JSON, Google Sheets, and GPT-4o

Workflow preview

Workflow preview
100%
Automating SAP B1 journal entries using JSON, Google Sheets, and GPT-4o preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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...

Best for

  • Document Extraction automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.httprequest, n8n-nodes-base.switch, n8n-nodes-base.set, n8n-nodes-base.googlesheets, @n8n/n8n-nodes-langchain.openai, n8n-nodes-base.code, n8n-nodes-base.merge

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Raquel Giugliano.

Original n8n.io source

1.1 Workflow description

Title
Automating SAP B1 journal entries using JSON, Google Sheets, and GPT-4o
Workflow name
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:

1. 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.

2. Use These Environment Variables (Recommended) or replace the data in the corresponding container:
  • SAP_USER, SAP_PASSWORD, SAP_COMPANY_DB

  • SAP_URL

3. 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

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Webhook Trigger

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 1

Block 2 - SAP Login

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 3 - Route by Source

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 4 - Map JSON Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 5 - Post Journal (JSON)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 6 - Log Success (JSON)

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 7 - Log Error (JSON)

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 8 - LLM Transform (Manual)

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 9 - Post Journal (Manual)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 10 - Log Success (Manual)

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 11 - Log Error (Manual)

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 12 - Set SAP Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Load Sheet Data

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 14 - Shape Sheet Lines

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 15 - Parse Sheet JSON

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - LLM Transform (Sheet)

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 17 - Build Journal Body

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 18 - Merge Header & Lines

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 19 - Post Journal (Sheet)

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 20 - Log Success (Sheet)

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 21 - Log Error (Sheet)

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 22 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 25 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Automating SAP B1 journal entries using JSON, Google Sheets, and GPT-4o
Complexity advanced
Nodes 25
Categories Document Extraction, AI Summarization
Author Raquel Giugliano
Published 26 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/5378/5378.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automating SAP B1 journal entries using JSON, Google Sheets, and GPT-4o do?

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...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Document Extraction, AI Summarization use case.