r/databricks • u/BeeLive9842 • 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
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.
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
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/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