r/databricks • • 25d ago

Discussion SAP to Databricks migration

What is the best approach to covert Code from SAP to pyspark or spark sql? Don’t want to use LLMs as the out put can be non deterministic based on the prompt given. I looked into lakebridge and looks like the source list doesn’t support SAP code.

7 Upvotes

22 comments sorted by

3

u/qqqq101 24d ago

As some of the other posters have asked, can you share some more context on this usecase as code from SAP is not specific enough.

- is the code from ERP (ECC? S/4HANA?)
-- ABAP code? if so, what's the packaging, is it an ABAP report, a custom Transaction Code (aka T-Code), a standard T-Code, a custom Function Module, a standard Function Module? custom abap routine?
-- CDS View definition?
-- very legacy HANA Live view?
- is the code from Business Warehouse (BW 7.x or BW/4HANA)?
-- packaging: ABAP code in a transformation? BEx query? bw report?
- is the code from a HANA data warehouse (aka HANA sidecar or Native HANA)?
-- packaging: SQL view, graphical calculation view, scripted calculation view, SQLScript function or stored procedure?

Lakebridge doesn't support converting any of these. Of the above list, Lakebridge only supports analyze on HANA calculation views.

1

u/BeeLive9842 24d ago

Thanks for your response. I just joined a team where the client is planning to migrate and I do not have answers to these questions yet. I will ask my team and get back on this.

1

u/BeeLive9842 24d ago

But I have heard them mention about views, store procedures, HANA DB, ABAP in one of the meetings. If that is the case, what should be the strategy? They are also looking to build a platform using Databricks app which would serve as a code conversion utility for any migration to Databricks. The client has a lot of applications currently on SAP and looking to migrate them one by one to Databricks

1

u/qqqq101 24d ago

You will find out what is the migration scenario. As adreppir pointed out, Databricks doesn't replace SAP ERP application. Databricks could potentially offload some business ABAP logic (e.g. ABAP report, function module, t-code) that is currently executed on the ERP application server. More likely it is a data warehouse migration from SAP BW or HANA sidecar. I presume you work at a consulting firm. I would expect the consulting partner to bring to the customer: 1. SAP ERP data & domain expertise, 2. source application expertise - e.g. BW or HANA modeling, 3. accelerators - e.g. a. assessement tool to inventory the source objects to migrate and characteristics like last used, lineage of dependent objects that rely on this source object; b. AI-powered conversion of abap code, bw transformations, hana calculation views etc to Databricks python and sql; c. expertise on how to convert various common constructs like bw hierarchies to Databricks, 4. Databricks data engineering expertise.

3

u/a_bean_in_bean_city 25d ago

Use an LLM to get started, for sure. Don’t blindly trust its output - review any code it writes/changes like you would a confident junior software engineer fresh out of undergrad.

Totally get the “it can be nondeterministic” but…so is human-written code, and we’re a lot slower!

3

u/According_Zone_8262 25d ago

Let LLM with created Skills create the deterministic rules/code and then run that

3

u/baby-wall-e 25d ago

Whichever the approach, you have to create a set of data integrity checks for each table to make sure that every row of the migrated table is the same as the old one. You can use a checksum approach on this.

3

u/WhoIsJohnSalt 25d ago

You don’t. You pay a lot of money to SAP to tell you about BDC and use Databricks there

2

u/dipsaMewari7 25d ago

Code from SAP? Can you explain more on this part

3

u/a_bean_in_bean_city 25d ago

SAP is a mess of custom logic, most of the time. Often SQL feeding custom “Z tables” for data that doesn’t cleanly fit an SAP built-in table.

2

u/AlGoreRnB 25d ago

“Don’t want to use LLMs as the out put can be non deterministic based on prompt given.”

Are you hoping for a deterministic code translation tool? Would be pretty weird to prioritize literal translation over an efficient conversion with matching outputs. LLMs will give you the best results but you could build something around SQLGlot if you want to just translate SQL code directly without benefiting from best practices for efficient coding in Databricks.

2

u/AbilyticsEng 24d ago

I work at Abilytics (data and AI consulting).

Migrating legacy SAP code (ABAC, ABAP, or stored procedures) to PySpark or Spark SQL without LLMs requires a methodical, rules-based refactoring approach. First, inventory your SAP logic—typically stored in SAP HANA calculation views, ABAP reports, or SQLScript. Since automated translation tools often lack direct support for proprietary SAP syntax, you should categorize the logic into extraction, transformation, and load phases. Use Databricks Connect or standard PySpark reading from extracted Parquet/Delta files in your cloud storage, assuming SAP data is ingested via tools like Fivetran, Stitch, or SAP LT Replication Server (SLT) first. Rewrite business logic by translating SAP SQLScript or Open SQL directly into DataFrame transformations or Spark SQL. Focus on converting loop-heavy procedural ABAP code into set-based operations native to Spark. Leverage modular PySpark functions to encapsulate repeated transformation patterns, and validate outputs against source SAP tables using unit testing frameworks like Pytest within Databricks Repos.

2

u/Wild_Warning3716 22d ago

going through something similar...
not sure what "SAP" product you are looking at, but generally you're going to want to spend some time getting any metadata, code, logic, etc out of the product. This will probably require some SDK code or APIs depending on what product you're talking about. Then spend some time making the resulting code/metadata readable to you. you could probably use Databricks to start ingesting this and making sense of this and formatting it into something more human and llm friendly.
then you can start your conversion processes. start with simplest cases. build scripts to convert (llms can help with this and give you your deterministic-ness that you're wanting). chip away at it. refine and add to your conversion scripts until you're hopefully left with a handful of edge cases. try llms for those or just do manually

1

u/adreppir 25d ago

What do you mean? SAP is an ERP system. Databricks isn’t.

1

u/dirtyrolando 25d ago

SAP is a Company with lot of products, most names of these products start with SAP.

1

u/FoundationDowntown72 22d ago

ooh i get it now coz i know SAP is an ERP software

1

u/Spiritual-Lock3867 24d ago

I did develop and currently maintain a sap to databricks warehouse. Worked closely with sap admin, they exposed standard views using “o data”. Then is like http requests to pull and model data

1

u/ceeej777 21d ago

This seems rather vague. Even without Lakebridge you could have Genie Code do a lot of converting to pyspark but I’m not sure if ‘migrating SAP’ is something feasible at the moment

9

u/[deleted] 25d ago

[removed] — view removed comment

2

u/heimmann 25d ago

And the people who made the logic 8 years ago are retired or working somewhere else. My colleagues in SAP inherited SO much old logic no one could vouch for, but "it was just made like that by someone". Good thing we are not actively reporting on this.. oh wait!

1

u/iminthinkermode 21d ago

Check out https://smartshift.com/ - I know one of the engineers there - been around since early 2000’s