Go back to the main page

SAP Order-to-Cash Workflow

S/4HANA IDES — Automated OTC Data Generator via JCo RFC
All 5 Steps Operational

Overview

SAPOTCWorkflow is a Java program that automates the complete Order-to-Cash cycle in SAP S/4HANA IDES via JCo RFC calls. It creates realistic transactional data across the full OTC chain: from sales order entry through to incoming payment posting.

Runs locally on macOS. All programs execute from ~/SAP_OTC/, connecting to SAP via JCo RFC over the network. HANA SQL access is available via SSH tunnel + Python hdbcli.

SAP System

System
S/4HANA IDES (SID: S4H)
Release
758 (HANA DB)
Client
100
Host
sapidess4.fivetran-internal-sales.com
Instance Nr
03
User
IDES
Password
(see vault)

Sales Organization

Sales Org
1710
Dist. Channel
10
Division
00
Plant
1710
Shipping Point
1710
Currency
USD

HANA Database

Tenant DB
FIV
Instance
HDB00
Schema
SAPHANADB
User
SAPHANADB
Password
(see vault)
Local Port
30015 (via SSH tunnel)

Local Environment

Project Dir
~/SAP_OTC/
Java
OpenJDK 17 (Homebrew)
JCo
sapjco3.jar + libsapjco3.dylib (ARM64)
HANA Client
hdbcli (Python pip)
Platform
macOS (Apple Silicon)

Project Structure

Local Directory: ~/SAP_OTC/

FilePurpose
Java Sources
SAPOTCWorkflow.javaFull 5-step OTC workflow (Order + Delivery + GI + Billing + Payment)
SAPOTCOrderGenerator.javaStandalone order generator (orders only, no delivery)
SAPOTCExtractor.javaSAP table reader/verifier via RFC_READ_TABLE
Libraries
sapjco3.jarSAP Java Connector (JCo) library
libsapjco3.dylibJCo native library for macOS (ARM64 / Apple Silicon)
gson.jarGoogle Gson (JSON parsing)
Configuration
SAP_S4HANA.jcoDestinationJCo connection properties (host, sysnr, client, user, password)
Shell Scripts
compile.shCompile all Java sources locally
otcwf.shRun SAPOTCWorkflow — ./otcwf.sh full 5 --verbose
otcgen.shRun SAPOTCOrderGenerator — ./otcgen.sh 10
otc.shRun SAPOTCExtractor — ./otc.sh extract VBAK VBELN,ERDAT ...
HANA Database Access
hana_tunnel.shStart SSH tunnel to HANA (localhost:30015 → sapidess4)
hana_sql.pyPython HANA SQL client (single query or interactive mode)
Documentation
SAP_OTC_Workflow_Documentation.htmlThis documentation file
Generated Output
otc_extract/CSV files from SAPOTCExtractor queries

End-to-End Flow

Step 1 Sales Order
VBAK / VBAP
VBEP / VBPA
Step 2 Delivery
LIKP / LIPS
Step 3 Goods Issue
MKPF / MSEG
MATDOC
Step 4 Billing
VBRK / VBRP
Step 5 Payment
BKPF / BSEG
ACDOCA
Document Flow (VBFA) links all documents together. Each step creates a forward reference: Order → Delivery → GI Material Doc → Billing Doc → Accounting Doc. Use transaction VF03 or the status command to trace the complete chain.

LUW (Logical Unit of Work) Boundaries

Each step runs in its own LUW via JCoContext.begin(dest) / JCoContext.end(dest). This pins all BAPI calls + COMMIT to the same SAP connection (required by JCo connection pooling). Between steps, the LUW is ended and a new one started after a configurable pause.

Step 1 — Sales Order Creation

Create Sales Order

Creates a standard sales order (type TA) with randomized customer, materials, quantities, and dates spread over the last 30 days.

BAPI

Function ModulePurpose
BAPI_SALESORDER_CREATEFROMDAT2 Creates a sales order with header, items, schedule lines, and partners
BAPI_SALESORDER_CHANGE Releases credit block (clears DLV_BLOCK and BILL_BLOCK)
BAPI_TRANSACTION_COMMIT Persists changes (WAIT='X' for synchronous commit)

Import Parameters

StructureFieldValue
ORDER_HEADER_INDOC_TYPETA (Standard Order)
SALES_ORG1710
DISTR_CHAN10
DIVISION00
REQ_DATE_HRandom date (last 30 days)
PURCH_NO_COTC-WF-MMDD
ORDER_HEADER_INXUPDATEFLAGI (Insert)
LOGIC_SWITCHNO_CREDIT_CHECKX (bypass credit at creation)
ORDER_PARTNERSPARTN_ROLE / PARTN_NUMBAG (Sold-to) + customer number
ORDER_ITEMS_INITM_NUMBER, MATERIAL, PLANT, TARGET_QTY1-3 random items
ORDER_SCHEDULES_INITM_NUMBER, SCHED_LINE, REQ_DATE, REQ_QTYOne schedule line per item

Tables Populated

TableDescriptionKey Fields Written
VBAKSales Order HeaderVBELN, AUART, KUNNR, NETWR, ERDAT, BSTNK
VBAPSales Order ItemsVBELN, POSNR, MATNR, KWMENG, NETPR, WERKS
VBEPSchedule LinesVBELN, POSNR, ETENR, EDATU, WMENG
VBPAPartnersVBELN, POSNR, PARVW, KUNNR
VBFADocument FlowVBELV, VBELN, VBTYP_N='C'

Customer Pool

CustomerTypeNotes
0017100001DirectCMGST=A, passes credit check
0017100002DirectPasses credit check
0017100003DirectNo credit check, POD disabled via KNVV

Material Pool

MaterialUoMQty Range~Price (USD)
TG11ST1-20$17.55
TG12ST1-20$17.55
MZ-FG-R100ST1-10$565.00
MZ-FG-R300ST1-5$7,741.00
MZ-TG-Y240ST1-10$160.00
F-10AST1-50$18.65

Step 2 — Outbound Delivery

Create Outbound Delivery

Creates an outbound delivery (type LF) referencing the sales order. SAP automatically copies items and determines routes from the order.

BAPI

Function ModulePurpose
BAPI_OUTB_DELIVERY_CREATE_SLS Creates outbound delivery from sales order reference
BAPI_TRANSACTION_COMMIT Persists changes

Import Parameters

ParameterValueNotes
SHIP_POINT1710Shipping point
DUE_DATEToday's dateExtends delivery horizon for past-dated orders
SALES_ORDER_ITEMS.REF_DOCSales order numberAll items (REF_DOC_IT=000000)

Tables Populated

TableDescriptionKey Fields Written
LIKPDelivery HeaderVBELN, LFART='LF', ERDAT, KUNNR, VSTEL
LIPSDelivery ItemsVBELN, POSNR, MATNR, LFIMG, WERKS
VBFADocument FlowVBELV=order, VBELN=delivery, VBTYP_N='J'

Step 3 — Goods Issue (PGI)

Post Goods Issue

Posts Goods Issue for the delivery, consuming inventory and creating a material document. This is a two-phase operation: first reads delivery items from LIPS, then executes the GI using WS_DELIVERY_UPDATE_2.

Function Modules

Function ModulePurpose
RFC_READ_TABLE Reads delivery items (LIPS) to get quantities and materials
WS_DELIVERY_UPDATE_2 Performs picking confirmation + goods issue in a single call

WS_DELIVERY_UPDATE_2 Parameters

ParameterValuePurpose
VBKOK_WA.VBELN_VLDelivery numberDelivery reference
VBKOK_WA.WABUCXGoods issue flag
VBKOK_WA.WADAT_ISTTodayActual GI date
VBKOK_WA.KOMUEXPicking complete
DELIVERYDelivery numberDelivery reference
UPDATE_PICKINGXUpdate picking quantities
COMMITXAuto-commit
IF_DATABASE_UPDATE_1XDatabase update mode
SYNCHRONXSynchronous processing
NICHT_SPERREN_1XSkip lock check

VBPOK_TAB (Item Picking Data)

One row per delivery item with: VBELN, VBELN_VL, POSNN, POSNR_VL, LFIMG (delivery qty), PIKMG (picked qty).

Tables Populated

TableDescriptionKey Fields Written
MKPFMaterial Document HeaderMBLNR, MJAHR, BUDAT, USNAM
MSEGMaterial Document ItemsMBLNR, MJAHR, ZEILE, BWART='601', MATNR, MENGE
MATDOCMaterial Document (S/4HANA)Consolidated journal entry
VBFADocument FlowVBELV=delivery, VBELN=matdoc, VBTYP_N='R'
LIKPDelivery Header (updated)WBSTK='C' (fully picked), WADAT_IST
S/4HANA Note: WS_DELIVERY_UPDATE (original FM) is blocked by the S/4HANA RFC API Blocklist (SAP Note 2416705). The system uses WS_DELIVERY_UPDATE_2 instead, which requires the profile parameter ucon/rfc/check_blacklist = 0 to be set.

Step 4 — Billing

Create Billing Document

Creates an invoice (billing document) for the delivered goods. References the delivery document with billing category J (delivery-related billing).

BAPI

Function ModulePurpose
BAPI_BILLINGDOC_CREATEMULTIPLE Creates one or more billing documents from delivery references
BAPI_TRANSACTION_COMMIT Persists changes

Import Parameters

Table / FieldValueNotes
BILLINGDATAIN.REF_DOCDelivery numberReference document
BILLINGDATAIN.REF_DOC_CAJDelivery-related billing

Output

Billing document number is retrieved from the SUCCESS table (BILL_DOC field) or parsed from RETURN messages.

Tables Populated

TableDescriptionKey Fields Written
VBRKBilling Document HeaderVBELN, FKART, KUNRG, NETWR, FKDAT, WAERK
VBRPBilling Document ItemsVBELN, POSNR, MATNR, FKIMG, NETWR
VBFADocument FlowVBELV=delivery, VBELN=billing, VBTYP_N='M'
BKPFAccounting Document HeaderBUKRS, BELNR, GJAHR (auto-created by billing)
BSEGAccounting Document ItemsLine items for revenue + receivable
ACDOCAUniversal JournalS/4HANA single journal entry
Prerequisites: The billing BAPI required two fixes in this IDES system: (1) CL_SD_BP_ADDRESS_GET type mismatch fixed in SE24, (2) POD requirement disabled — TVLK.POBED cleared for delivery type LF, and KNVV.PODKZ cleared for customer 0017100003.

Step 5 — Incoming Payment

Post Incoming Payment

Posts an FI accounting document representing the customer's payment against the billing document. Creates a bank debit (GL) and customer credit (AR) entry.

BAPI

Function ModulePurpose
BAPI_ACC_DOCUMENT_POST Posts a general FI accounting document
RFC_READ_TABLE Reads billing amount from VBRK.NETWR
BAPI_TRANSACTION_COMMIT Persists changes

Document Header (DOCUMENTHEADER)

FieldValueNotes
BUS_ACTRFBUBusiness transaction type
USERNAMEIDESPosting user
COMP_CODE1710Company code
DOC_TYPEDZCustomer payment document type
DOC_DATETodayDocument date
PSTNG_DATETodayPosting date
REF_DOC_NOBilling doc numberCross-reference
HEADER_TXTOTC Workflow PaymentHeader text

Line Items

LineTableAccountAmountDetails
001 ACCOUNTGL GL 0011001000 (Main Bank) + (debit) HOUSEBANKID=USBK1, HOUSEBANKACCTID=USAC1
002 ACCOUNTRECEIVABLE Customer number − (credit) Clears the customer open item from billing

Amount Determination

The payment amount is read from VBRK.NETWR (billing document net value) via RFC_READ_TABLE. Both lines use the same absolute amount with opposite signs (debit/credit) in USD.

Tables Populated

TableDescriptionKey Fields Written
BKPFAccounting Document HeaderBUKRS, BELNR, GJAHR, BLART='DZ'
BSEGAccounting Document ItemsBUKRS, BELNR, GJAHR, BUZEI, KOART
ACDOCAUniversal JournalS/4HANA consolidated entry
BSADCleared Customer Items (index)Customer payment clearing

SAP Tables Reference

Sales & Distribution (SD) Tables

TableDescriptionCategoryPopulated By
VBAKSales Document: Header DataOrder HeaderStep 1
VBAPSales Document: Item DataOrder ItemsStep 1
VBEPSales Document: Schedule Line DataSchedule LinesStep 1
VBPASales Document: PartnerPartnersStep 1
VBKDSales Document: Business DataBusiness DataStep 1
VBFASales Document: Document FlowDocument FlowSteps 1-5
LIKPSD Document: Delivery Header DataDelivery HeaderStep 2
LIPSSD Document: Delivery Item DataDelivery ItemsStep 2
VBRKBilling Document: Header DataBilling HeaderStep 4
VBRPBilling Document: Item DataBilling ItemsStep 4

Materials Management (MM) Tables

TableDescriptionCategoryPopulated By
MKPFHeader: Material DocumentMat. Doc HeaderStep 3
MSEGDocument Segment: MaterialMat. Doc ItemsStep 3
MATDOCMaterial Document (S/4HANA)Unified Mat. DocStep 3
MARDStorage Location Data for MaterialStock LevelsStep 3 (updated)
MBEWMaterial ValuationValuationStep 3 (updated)

Financial Accounting (FI) Tables

TableDescriptionCategoryPopulated By
BKPFAccounting Document HeaderFI Doc HeaderSteps 4, 5
BSEGAccounting Document SegmentFI Doc ItemsSteps 4, 5
ACDOCAUniversal Journal Entry (S/4HANA)Universal JournalSteps 4, 5
BSIDAccounting: Secondary Index for Customers (Open Items)AR Open ItemsStep 4
BSADAccounting: Secondary Index for Customers (Cleared Items)AR Cleared ItemsStep 5

Configuration Tables (Modified for this Workflow)

TableDescriptionChange Applied
TVLKDelivery TypesPOBED cleared for LF (disabled POD requirement)
KNVVCustomer Sales DataPODKZ cleared for customer 0017100003
T001KValuation AreaMLCCS cleared (CCS deactivated for plant 1710)
MARVMM Period ControlAdvanced to 04/2026
CKMLPPML Period RecordsGap-filled from IDES through 2026
CKMLCRML Currency RecordsGap-filled (CURTP 10 + 30)
T012House BanksUSBK1 (pre-existing in IDES)
T012KHouse Bank AccountsUSAC1 mapped to GL 0011001000

Document Flow (VBFA) Type Codes

The VBTYP_N field in VBFA identifies the subsequent document type:

C Sales Order J Delivery R Goods Issue (Mat. Doc) M Billing Document P Payment h Return O Credit Memo

CDS Views Reference

Sales Order CDS Views

CDS ViewDescriptionBase Tables
I_SalesOrderSales order headerVBAK
I_SalesOrderAPI01Sales order header (API)VBAK
I_SalesOrderItemSales order itemVBAP
I_SalesOrderItemAPI01Sales order item (API)VBAP
I_SalesOrderScheduleLineSchedule lineVBEP
I_SalesOrderPartnerPartner functionsVBPA
I_SalesOrderPricingElementPricing conditionsPRCD_ELEMENTS
I_SalesOrderBillingPlanItemBilling plan itemsFPLT
I_SalesOrderTextSales order textsSTXL
C_SalesOrderConsumption: Manage Sales OrdersVBAK
C_SalesOrderItemConsumption: Sales Order ItemsVBAP

Delivery CDS Views

CDS ViewDescriptionBase Tables
I_DeliveryDocumentDelivery headerLIKP
I_DeliveryDocumentItemDelivery itemLIPS
I_DeliveryDocumentPartnerDelivery partnerVBPA
C_OutboundDeliveryConsumption: Outbound DeliveriesLIKP
C_OutbDeliveryItemConsumption: Delivery ItemsLIPS

Billing Document CDS Views

CDS ViewDescriptionBase Tables
I_BillingDocumentBilling headerVBRK
I_BillingDocumentItemBilling itemVBRP
I_BillingDocumentPartnerBilling partnerVBPA
I_BillingDocumentPricingElementBilling pricing conditionsPRCD_ELEMENTS
C_BillingDocumentConsumption: Manage Billing DocumentsVBRK
C_BillingDocumentItemConsumption: Billing ItemsVBRP

Material Document / Goods Issue CDS Views

CDS ViewDescriptionBase Tables
I_MaterialDocumentHeader_2Material doc headerMATDOC
I_MaterialDocumentItem_2Material doc itemMATDOC
I_GoodsMovementItemGoods movement itemMATDOC
I_MaterialStockMaterial stock overviewMARD

Document Flow CDS Views

CDS ViewDescriptionBase Tables
I_SalesDocumentFlowSales document flowVBFA
I_SDDocumentPredecessorPredecessor documentVBFA
I_SDDocumentSuccessorSuccessor documentVBFA

Accounting / Payment CDS Views

CDS ViewDescriptionBase Tables
I_JournalEntryAccounting doc headerACDOCA, BKPF
I_JournalEntryItemAccounting line itemACDOCA
I_OperationalAcctgDocItemOperational accountingACDOCA
I_CustomerLineItemCustomer line itemsACDOCA
I_CustomerOpenItemCustomer open items (AR)ACDOCA
I_CustomerClearedItemCustomer cleared items (AR)ACDOCA
I_ARAccountBalanceAccounts receivable balanceACDOCA
C_AROpenItemsConsumption: AR open itemsACDOCA

Master Data CDS Views

CDS ViewDescriptionBase Tables
I_CustomerCustomer general dataKNA1, BUT000
I_CustomerCompanyCustomer company code dataKNB1
I_CustomerSalesAreaCustomer sales area dataKNVV
I_CreditManagementCredit managementKNKK
I_BusinessPartnerBusiness Partner generalBUT000
I_ProductProduct/material generalMARA
I_ProductPlantBasicProduct plant dataMARC
I_ProductValuationProduct valuationMBEW
I_ProductSalesDeliveryProduct sales/delivery dataMVKE

BAPIs & Function Modules

StepFunction ModuleTypePurpose
1BAPI_SALESORDER_CREATEFROMDAT2BAPICreate sales order with header, items, schedule lines, partners
1BAPI_SALESORDER_CHANGEBAPIRelease credit/delivery/billing blocks on order
2BAPI_OUTB_DELIVERY_CREATE_SLSBAPICreate outbound delivery from sales order
3RFC_READ_TABLERFCRead delivery items (LIPS) for GI quantities
3WS_DELIVERY_UPDATE_2FMPicking confirmation + goods issue posting
4BAPI_BILLINGDOC_CREATEMULTIPLEBAPICreate billing document from delivery
5RFC_READ_TABLERFCRead billing amount from VBRK
5BAPI_ACC_DOCUMENT_POSTBAPIPost incoming payment (GL debit + AR credit)
*BAPI_TRANSACTION_COMMITBAPICommit transaction (WAIT='X') — after every step
InitBAPI_GOODSMVT_CREATEBAPIStock initialization (mvt 501, goods receipt w/o PO)

System Configuration Changes

RFC Blocklist Override

S/4HANA blocks WS_DELIVERY_UPDATE_2 by default (SAP Note 2416705).

ucon/rfc/check_blacklist = 0

Set in SAP instance profile.

MM Posting Period (MARV)

IDES was stuck at 12/2023. Advanced to 04/2026 via HANA SQL.

UPDATE MARV SET LFMON='04', LFGJA='2026',
  VMMON='03', VMGJA='2026',
  VJMON='04', VJGJA='2025'
WHERE BUKRS='1710'

Material Ledger (CCS Deactivation)

CCS control records were missing for 2026. Deactivated CCS:

UPDATE T001K SET MLCCS='' WHERE BWKEY='1710'
DELETE FROM TMLCCSHD WHERE BWKEY='1710'

POD Requirement Disabled

Proof of Delivery was blocking billing for delivery type LF:

UPDATE TVLK SET POBED=''
  WHERE MANDT='100' AND LFART='LF'
UPDATE KNVV SET PODKZ=''
  WHERE KUNNR='0017100003' AND PODKZ='X'

ABAP Class Fix (SE24)

CL_SD_BP_ADDRESS_GET had a type mismatch in IDES:

-- Changed in method GET_BP_ADDRESSES_FOR_CUSTOMER:
DATA lt_address TYPE if_md_bp=>addresses.
DATA ls_address TYPE if_md_bp=>address.

CKMLPP/CKMLCR Gap Fill

ML period records had gaps between IDES data (2023) and 2026:

-- Filled continuous periods for all 6 materials
-- CKMLPP: STATUS='10', CD_OK='X'
-- CKMLCR: CURTP 10 (company) + 30 (group)

Usage

Quick Start

cd ~/SAP_OTC

# First time: compile Java sources
./compile.sh

# Run full OTC workflow (1 order, all 5 steps)
./otcwf.sh full 1 --verbose

Full Workflow (All 5 Steps)

./otcwf.sh full 1 --verbose     # 1 order, all steps, verbose output
./otcwf.sh full 5               # 5 orders, all steps
./otcwf.sh full 100 --items 2   # 100 orders, max 2 items each
./otcwf.sh full 1000            # 1000 orders (~3.3 hours)

Individual Steps

./otcwf.sh step1-order 5             # 5 sales orders only
./otcwf.sh step2-delivery 0000005663 # Delivery for specific order
./otcwf.sh step3-goodsissue 80006341 # GI for specific delivery
./otcwf.sh step4-billing 80006341    # Billing for specific delivery
./otcwf.sh step5-payment 90004903    # Payment for specific billing doc

Utilities

./otcwf.sh status 0000005663    # Show document flow (VBFA)
./otcwf.sh stock-init --verbose # Initialize stock for all materials (mvt 501)

Options

FlagDescriptionDefault
--verbosePrint BAPI return messages and debug infooff
--dry-runValidate without saving (TESTRUN='X')off
--items NMaximum line items per order3
--pause NSeconds between steps2

Verification (SAPOTCExtractor)

# Sales orders
./otc.sh extract VBAK VBELN,ERDAT,AUART,KUNNR,NETWR "ERDAT >= '20260401'"
./otc.sh extract VBAP VBELN,POSNR,MATNR,KWMENG,NETPR "ERDAT >= '20260401'"

# Deliveries
./otc.sh extract LIKP VBELN,LFART,ERDAT,KUNNR "ERDAT >= '20260401'"
./otc.sh extract LIPS VBELN,POSNR,MATNR,LFIMG "ERDAT >= '20260401'"

# Billing documents
./otc.sh extract VBRK VBELN,FKART,NETWR,FKDAT "FKDAT >= '20260401'"
./otc.sh extract VBRP VBELN,POSNR,MATNR,NETWR "ERDAT >= '20260401'"

# Document flow
./otc.sh extract VBFA VBELV,VBELN,VBTYP_N "ERDAT >= '20260401'"

# Financial documents
./otc.sh extract BKPF BUKRS,BELNR,GJAHR,BLART,BUDAT "BUDAT >= '20260401'"

# Table tools
./otc.sh tables                 # List all OTC tables
./otc.sh describe VBAK          # Show table fields
./otc.sh count VBAK             # Row count

Development Workflow

# 1. Edit Java sources in ~/SAP_OTC/
# 2. Compile
./compile.sh

# 3. Test (JCo connects to SAP over the network)
./otcwf.sh full 1 --dry-run --verbose

# 4. Run for real
./otcwf.sh full 5

HANA Database Access

Direct HANA SQL access is available for configuration changes, debugging, and ad-hoc queries. Requires an SSH tunnel since HANA is not exposed publicly.

Start SSH Tunnel

# Start the tunnel (runs in background, idempotent)
./hana_tunnel.sh

Run SQL Queries

# Single query
python3 hana_sql.py "SELECT * FROM TVLK WHERE LFART='LF'"

# Interactive SQL prompt
python3 hana_sql.py interactive

# Override connection parameters
python3 hana_sql.py --port 30041 --db FIV "SELECT 1 FROM DUMMY"

Common HANA Queries

# Check MM posting period
python3 hana_sql.py "SELECT BUKRS,LFMON,LFGJA FROM MARV WHERE BUKRS='1710'"

# Check Material Ledger config
python3 hana_sql.py "SELECT BWKEY,MLBWA,MLBWV,MLAST,MLCCS FROM T001K WHERE BWKEY='1710'"

# Check customer POD settings
python3 hana_sql.py "SELECT KUNNR,VKORG,PODKZ FROM KNVV WHERE KUNNR IN ('0017100001','0017100002','0017100003') AND VKORG='1710'"

# Check delivery type POD
python3 hana_sql.py "SELECT LFART,POBED FROM TVLK WHERE LFART='LF'"

# Check house bank accounts
python3 hana_sql.py "SELECT BUKRS,HBKID,HKTID,HKONT FROM T012K WHERE BUKRS='1710' AND HBKID='USBK1'"

# Check ML period records
python3 hana_sql.py "SELECT KALNR,BDATJ,PESSION,STATUS FROM CKMLPP WHERE KALNR='000100000002' AND BDATJ='2026'"

# UPDATE example (autocommit is on)
python3 hana_sql.py "UPDATE TVLK SET POBED='' WHERE MANDT='100' AND LFART='LF'"

Connection Details

ParameterValueNotes
HostlocalhostVia SSH tunnel
Port30015HANA indexserver (instance 00)
Tenant DBFIVS/4HANA data lives here
SchemaSAPHANADBAll SAP tables (VBAK, LIKP, etc.)
UserSAPHANADBSchema owner, full read/write access
Password(see vault)Lifetime disabled, no expiry
Buffered tables: HANA SQL changes to buffered SAP tables (T001K, TVLK, KNVV, MARV) require an SAP restart to take effect in the application layer. RFC_READ_TABLE reads from the SAP buffer, not directly from HANA.

Performance

OrdersApprox. TimeRate
1~12s(includes JCo pool warmup)
5~60s~12s/order
10~2 min~12s/order
100~20 min~12s/order
1000~3.3 hours~12s/order

Each order passes through 5 BAPI/RFC calls + 3 commits + pauses (~2s each between LUW boundaries). The ~12s/order rate includes all 5 steps. Steps 1-2 only take ~3.5s/order.

Time Breakdown per Order

Step 1
~3s
Step 2
~2s
Step 3
~2.5s
Step 4
~2s
Step 5
~2s
Pauses
~6s (3x2s between LUWs)

Troubleshooting

ErrorCauseFix
Orders not persisting JCo routes BAPI + COMMIT to different connections Wrap with JCoContext.begin/end(dest)
CMGST=B (credit blocked) USCU_* customers have no credit limits Use 001710000x customers only
No schedule lines due for delivery Order date too far in past Set DUE_DATE on delivery BAPI
Incompatible Call Rejected S/4HANA RFC Blocklist Set ucon/rfc/check_blacklist = 0 in profile
M7/053 Posting period not open MM period stuck in old year Update MARV via HANA SQL
ML4HMASTER/229 CCS records missing CCS active but no 2026 period data Deactivate CCS: T001K.MLCCS='' + delete TMLCCSHD
C+/073 Error reading ML period records Gap in CKMLPP between IDES data and 2026 Fill all gap periods in CKMLPP + CKMLCR
C+/700 No period records found Missing CKMLPP/CKMLCR for current period Create CKMLPP (STATUS=10) + CKMLCR (CURTP 10/30)
Deficit of SL Unrestricted-use No stock for material Run otcwf stock-init
SYNTAX_ERROR in billing BAPI CL_SD_BP_ADDRESS_GET type mismatch Fix in SE24 (change to if_md_bp=>addresses)
POD report back not yet carried out POD required for delivery type/customer Clear TVLK.POBED for LF + KNVV.PODKZ per customer
House bank account doesn't exist T012K entry missing or wrong account ID Use existing T012K: USBK1/USAC1
G/L account not defined in chart Wrong chart of accounts Use 0011001000 (YCOA chart, company 1710)
JCoException: connect failed SAP system down or unreachable Verify network connectivity to SAP host