Case Studies

Real-Time SAP B1
Integration

Case Study
Executive Summary

Bridging field sales and SAP Business One

A Mumbai-based enterprise solutions company needed to bridge the gap between their field sales teams and their SAP Business One ERP system. We designed and built a custom field sales CRM with deep SAP B1 Service Layer integration — enabling real-time customer data sync, automated document generation, and seamless sales order and invoice management directly from a mobile application.

The core challenge was not just connecting two systems, but doing it reliably at scale with complex business logic, live field usage, and zero tolerance for data inconsistency.

Industry: Construction  ·  Stack: Java · Spring Boot · React Native · MySQL · AWS EC2 · Docker  ·  Integration: SAP Business One Service Layer (OData APIs)

The Business Problem

Field sales teams operating in isolation from SAP

Field sales teams were operating in isolation from the company's SAP Business One ERP. Every customer visit, sales order, and invoice involved manual re-entry of data — creating delays, duplicate records, and a fragmented view of customer accounts.

No visibility in the field

Sales reps had no visibility into customer outstanding invoices, order history, or account status when visiting clients on site.

Manual data re-entry into SAP

Sales orders created in the field had to be manually keyed into SAP by back-office staff — introducing delays and the risk of errors.

Invoice PDFs generated and shared manually

Invoice PDFs had to be generated separately and shared manually — a time-consuming process that slowed down collections and client communication.

No real-time pipeline visibility for managers

Sales managers had no real-time picture of field activity or pipeline status — decisions were made on stale data days after the fact.

No single source of truth

There was no single source of truth between the CRM and the ERP — duplicate records and mismatched data were a constant operational drag.

Technical Challenges

Six problems we solved to make this work

SAP Business One Service Layer integration looks straightforward on the surface but hides significant complexity in production. Here is what we encountered and how we solved each challenge.

01 — OData Pagination for Large Business Partner Datasets

SAP B1 OData pagination behaves differently from standard REST — $skip and $top interact with server-side session state. We built a paginated fetching engine in Spring Boot using cursor-based pagination with an application-level cache refreshed on a configurable schedule.

02 — Document Number Formatting & Series-Based Numbering

SAP B1 uses series-based numbering per document type with prefixes and sequences spread across multiple endpoints. We built a series cache that fetches configuration at startup, maps by document type, and applies the correct prefix logic when generating document numbers.

03 — PDF Generation from SAP Data with Custom Templates

SAP B1 provides data but not presentation. We implemented a pipeline using OpenHTMLToPDF with Thymeleaf HTML templates — SAP data is fetched, mapped to a document model, rendered to HTML, and converted to PDF. CSS running() patterns handle consistent headers and footers across multi-page documents.

04 — Lookup Caches for HSN Codes, Payment Terms & Sales Persons

Fetching SAP lookup entities on every request was too slow and created unnecessary load. We built a structured lookup cache layer that preloads at startup, serves from memory at runtime, and exposes a manual refresh endpoint for administrators when master data changes.

05 — Business Partner to SAP BP Schema Mapping

SAP's BP object is complex — nested address lines, multiple contact person structures, strict field validation. We reverse-engineered the BP object through the Service Layer metadata endpoint, built a strict field mapping layer with validation before any write, and validated against a SAP sandbox before going live.

06 — SAP Service Layer Session Management

SAP Service Layer uses session-based auth with tokens that expire — unlike standard OAuth refresh flows, re-login adds latency if not handled proactively. We built a session manager that tracks session age, proactively refreshes before expiry, and implements automatic retry logic for requests that fail due to timeout.

Solution Architecture

Clean layers,
reliable middleware.

The integration follows a clean layered architecture. The React Native mobile app communicates exclusively with the Spring Boot API, which handles all business logic, caching, and session management before talking to SAP B1 Service Layer. Nothing calls SAP directly from the client.

PDF pipeline: SAP Data → Spring Boot → Thymeleaf Template → OpenHTMLToPDF → PDF Output

Discuss Your Integration

React Native Mobile App

The field-facing layer. iOS and Android. All SAP data surfaces here — customer accounts, invoices, sales orders, product catalogue — with PDF generation on demand.

Spring Boot API · AWS EC2 · Docker

The middleware layer. Handles SAP session management, pagination, lookup caches, BP schema mapping, document series logic, and the PDF generation pipeline. PostgreSQL for application data.

SAP B1 Service Layer · OData APIs

Business Partners, Sales Orders, Invoices, and Master Data (HSN codes, Payment Terms, Document Series) — all accessed via SAP's OData Service Layer with session-based authentication.

Key Outcomes

What changed for the business

Eliminated manual data re-entry

Manual re-entry between the field CRM and SAP Business One was completely eliminated — data flows automatically, bidirectionally, with no back-office intervention.

Real-time SAP visibility on mobile

Field sales reps gained real-time visibility into customer accounts, outstanding invoices, and order history — directly from their mobile devices, before and during client visits.

Automated branded PDF generation

Invoices and sales order documents are now generated automatically — branded, print-ready PDFs produced directly from live SAP data, on demand, from the mobile app.

Single source of truth between CRM and ERP

CRM and SAP now share a single source of truth — no duplicate records, no mismatched data, no reconciliation overhead between field and back office.

Real-time pipeline visibility for sales managers

Sales managers gained a live view of field team activity and order pipeline — no more waiting days for data that was already happening in the field.

Lessons Learned

What we would tell any team starting this project.

Every complex integration teaches you something. These are the five things we would do differently — or insist on doing the same way — if we started this project again today.

Talk to Our Team

Test with production-scale data early

SAP Service Layer pagination behaves very differently with 5,000 Business Partners than with 50. Build data volume tests before you build your UI.

Build session retry logic from day one

Session expiry is not an edge case — it is a certainty in production. Design your HTTP client layer to handle it transparently from the start, not as an afterthought.

Treat the BP schema as a first-class concern

The Business Partner object touches almost everything in SAP — address, contact, payment, currency. A shallow mapping creates technical debt that is painful to fix later. Map it thoroughly upfront.

bg-cta
cta-main-wrapper

Got a similar
problem?
Let's talk.

If your team is working around your ERP instead of with it, we can help. Tell us about your workflow and we'll show you what's possible.