Go back to the main page

SAP Procure-to-Pay Workflow

S/4HANA IDES — Automated PTP Data Generator via JCo RFC
Operational

Overview

Procure-to-Pay (PTP) automated data generator that creates end-to-end P2P documents via JCo RFC: purchase requisition, purchase order, goods receipt, and invoice verification. This tool generates realistic SAP transaction data on S/4HANA IDES, similar to the OTC data generator.

Same SAP system as OTC. All programs connect to the same S/4HANA IDES instance. 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)

Purchasing Organization

Company Code
1710
Purchasing Org
1710 (Purch. Org. 1710)
Purchasing Group
001 (Group 001), 002, 003
Plant
1710
Storage Locations
171A (primary)
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
/Users/antonio.carbone/P2P/
Java
OpenJDK 17 (Homebrew)
JCo
sapjco3.jar + libsapjco3.dylib (ARM64)
HANA Client
hdbcli (Python pip)
Platform
macOS (Apple Silicon)

Vendor Pool

All vendors below have company code 1710 (LFB1) + purchasing org 1710 (LFM1), USD currency, not blocked. Reconciliation account 0021100000 (AP domestic).

VendorNamePayment TermsNotes
0017300001Domestic US Supplier 10004Most info records, primary vendor
0017300002Domestic US Supplier 20004Several info records
0017300006Domestic US Supplier 6 (Returns)0004QM materials
0017300010Domestic US Supplier 100004
0017300080Domestic US Supplier (Ariba Network)0004
0017300081Domestic US Supplier (Ariba Sourcing)0004
0017300082Domestic US Supplier (Ariba Sourcing)0004
0017300083Domestic US Supplier (Ariba Sourcing)0004
0017300273Domestic US Supplier CPD0004
EWM17-SU01(EWM Supplier)0004EWMS4 materials
Excluded vendors: 0017300003 (ERS), 0017300007 (subcontractor), 0017300031/50/51 (foreign currency EUR/CAD), 0017300015/16/17/19 (supplier financing/VCard), 0017300030/32/33/34 (withholding tax), 0017300090 (Ariba FIN), 0017300095/96 (commission/royalties).

Material Pool (Purchasable)

All ROH (raw material) materials below have BESKZ='F' (external procurement), standard price (VPRSV=S), and purchasing info records with vendor 0017300001 in purch org 1710.

No overlap with OTC materials (TG11, TG12, MZ-FG-R100, MZ-FG-R300, MZ-TG-Y240, F-10A). P2P uses ROH/HIBE materials only. Safe for parallel use with no risk to OTC workflow.

Standard Price Materials (Recommended)

MaterialDescriptionUoMStd PriceVendor PricePurch Group
RM12RAW12, Repetitive Manuf.ST$1.00$1.05001
RM120RAW120, Quality ManagedST$1.25$1.31002
RM15RAW15ST$0.20$0.21001
RM16RAW16ST$0.25$0.24001
R-302RAW302, PDST$0.08$0.60001
R-401RAW401, D1ST$1.00$0.80001
R-410RAW410, PDST$1.00001
R-411RAW411, PDST$3.00001
R-412RAW412, PDST$2.00001
MZ-RM-R100-01BKR-100 FrameST$145.87Z90
MZ-RM-R100-02BKR-100 Handle BarsST$2.86Z90

Moving Average Price Materials (Use with Caution)

MaterialDescriptionUoMMov Avg PriceVendor PricePurch Group
HB01Operating Supply 01ST$51.00$60.00002

Moving average price materials will have their MBEW.VERPR updated on GR/IR posting. This is normal SAP behavior but means the valuation price may shift over time.

End-to-End Flow

Step 1 Purchase Req
EBAN
EBKN
Step 2 Purchase Order
EKKO / EKPO
EKET / EKKN
Step 3 Goods Receipt
MATDOC
(MKPF / MSEG)
Step 4 Invoice
RBKP / RSEG
Step 5 Payment
ACDOCA
REGUH / REGUP
Step 6 GR/IR Clear
ACDOCA
BKPF / BSEG
Document Flow: PR → PO (EBAN.EBELN) → GR (MATDOC.EBELN/EBELP, EKBE.VGABE=1) → IR (RSEG.EBELN/EBELP, EKBE.VGABE=2) → Payment (ACDOCA) → GR/IR Clearing (MR11). Use ME23N → Environment → Document Flow to trace the complete chain.

Step 1 — Purchase Requisition

Create Purchase Requisition

Creates an internal request for procurement. Can be created manually, via MRP, or programmatically via BAPI. The PR triggers the purchasing workflow and may require release approval.

Transaction Codes

TcodePurpose
ME51NCreate Purchase Requisition
ME52NChange Purchase Requisition
ME53NDisplay Purchase Requisition

BAPI

Function ModulePurpose
BAPI_PR_CREATECreate purchase requisition with items and account assignments
BAPI_PR_CHANGEChange existing purchase requisition
BAPI_PR_GETDETAILRead purchase requisition details
BAPI_TRANSACTION_COMMITPersist changes (WAIT='X')

Tables Populated

TableDescriptionKey Fields Written
EBANPurchase RequisitionBANFN, BNFPO, BSART, MATNR, TXZ01, MENGE, MEINS, WERKS, LGORT, EKGRP, EKORG, AFNAM, LFDAT, PREIS, PEINH, WAERS
EBKNPR Account AssignmentBANFN, BNFPO, ZEBKN, SAKTO, KOSTL, AUFNR, PS_PSP_PNR, WRBTR

Release Strategy

Config TableDescription
T16FCRelease groups
T16FDRelease codes (approval steps)
T16FSRelease strategies
T16FERelease strategy assignment (characteristics)

EBAN fields: FRGKZ (release indicator), FRGST (release status), FRGRL (complete flag), FRGSX (release strategy). Workflow template: WS20000075.

Test Results (2026-04-09)

PR NumberItemMaterialQtyVendorReleasedStatus
001000149400010R-30297 ST0017300001FRGRL=XOK

BAPI: BAPI_PR_CREATEBAPI_TRANSACTION_COMMIT (WAIT='X').
Header: PR_TYPE='NB' (standard).
Item fields: PREQ_ITEM, MATERIAL, PLANT, QUANTITY, UNIT, DELIV_DATE, PURCH_ORG, PUR_GROUP, PREQ_NAME, DES_VENDOR.
Note: Item structure is BAPIMEREQITEMIMP — uses DES_VENDOR (not VENDOR), no DOC_TYPE at item level.
Warning: 06/418 “Can delivery date be met?” — normal when using today's date (lead time ~15 days).

Verification Query

-- HANA SQL: Verify PR
SELECT BANFN, BNFPO, MATNR, MENGE, FRGRL, EBELN FROM EBAN WHERE BANFN = '0010001494';

Step 2 — Purchase Order

Create Purchase Order

Creates a purchase order (doc type NB = standard PO) with header, items, schedule lines, and account assignments. Can reference a PR or be created directly.

Transaction Codes

TcodePurpose
ME21NCreate Purchase Order
ME22NChange Purchase Order
ME23NDisplay Purchase Order
ME29NRelease Purchase Order
ME28Mass Release POs
ME59NAutomatic PO Generation from PRs

BAPI

Function ModulePurpose
BAPI_PO_CREATE1Create PO with header, items, schedule lines, account assignments
BAPI_PO_CHANGEChange existing PO
BAPI_PO_GETDETAIL1Read PO details
BAPI_PO_RELEASERelease PO programmatically
BAPI_TRANSACTION_COMMITPersist changes (WAIT='X')

Import Parameters (BAPI_PO_CREATE1)

StructureFieldValue
POHEADERCOMP_CODE1710
DOC_TYPENB (Standard PO)
VENDORVendor number
PURCH_ORGPurchasing organization
PUR_GROUPPurchasing group
POHEADERXCOMP_CODE, DOC_TYPE, VENDOR, PURCH_ORG, PUR_GROUPX (flags)
POITEMPO_ITEM, MATERIAL, PLANT, STGE_LOC, QUANTITY, PO_UNIT, NET_PRICE, PRICE_UNIT, TAX_CODEPer item
POSCHEDULEPO_ITEM, SCHED_LINE, DELIVERY_DATE, QUANTITYOne schedule line per item
POACCOUNTPO_ITEM, SERIAL_NO, GL_ACCOUNT, COSTCENTERFor account-assigned items

Tables Populated

TableDescriptionKey Fields Written
EKKOPO HeaderEBELN, BUKRS, BSTYP='F', BSART, LIFNR, EKORG, EKGRP, WAERS, BEDAT
EKPOPO ItemsEBELN, EBELP, MATNR, TXZ01, MENGE, MEINS, NETPR, PEINH, WERKS, LGORT, MWSKZ
EKETSchedule LinesEBELN, EBELP, ETENR, EINDT, MENGE
EKKNAccount AssignmentEBELN, EBELP, ZEKKN, SAKTO, KOSTL, AUFNR
PRCD_ELEMENTSPricing ConditionsKNUMV, KPOSN, KSCHL, KBETR, KWERT

PO Release Strategy

Same T16F* tables as PR. EKKO fields: FRGKE (release status), FRGSX (strategy), FRGRL (complete). Release docs in EKAB. Workflow template: WS20000076.

Test Results (2026-04-09)

PO NumberItemMaterialQtyNet PriceFrom PRStatus
450000181900010R-30297 ST0.60 USD0010001494OK

BAPI: BAPI_PO_CREATE1BAPI_TRANSACTION_COMMIT (WAIT='X').
Export field: EXPPURCHASEORDER (not PURCHASEORDER).
PR linkage: Set PREQ_NO and PREQ_ITEM in POITEM to link PO to PR. Verified EBAN.EBELN updated.
Warning: Price difference: info record price (0.60) vs material std price (0.08) — normal for IDES.

Step 3 — Goods Receipt

Post Goods Receipt

Posts a goods receipt against the purchase order (movement type 101). Creates a material document and triggers accounting postings (stock debit / GR-IR clearing credit).

Transaction Codes

TcodePurpose
MIGOGoods Movement (GR against PO, mvt type 101)

BAPI

Function ModulePurpose
BAPI_GOODSMVT_CREATEPost goods movement (GR, GI, transfer posting)
BAPI_TRANSACTION_COMMITPersist changes (WAIT='X')

Import Parameters (BAPI_GOODSMVT_CREATE)

StructureFieldValue
GOODSMVT_HEADERPSTNG_DATEToday (posting date)
DOC_DATEToday (document date)
REF_DOC_NOPO number (cross-reference)
GOODSMVT_CODEGM_CODE01 (GR for purchase order)
GOODSMVT_ITEMMATERIALMaterial number
PLANTPlant
STGE_LOCStorage location
MOVE_TYPE101 (GR against PO)
ENTRY_QNTQuantity received
ENTRY_UOMUnit of measure
PO_NUMBERPO number
PO_ITEMPO item number

Movement Types

Mvt TypeDescription
101GR against purchase order
102GR reversal
103GR to blocked stock
105Release from blocked stock
122Return to vendor
161Return delivery

Tables Populated

TableDescriptionKey Fields Written
MATDOCMaterial Document (S/4HANA unified)MBLNR, MJAHR, ZEESSION, BWART='101', MATNR, WERKS, LGORT, MENGE, EBELN, EBELP, SHKZG, BUDAT
MKPFMaterial Doc Header (compat view)MBLNR, MJAHR, BUDAT, USNAM
MSEGMaterial Doc Items (compat view)MBLNR, MJAHR, ZEILE, BWART, MATNR, MENGE
EKBEPO History (updated)EBELN, EBELP, VGABE='1' (GR), BELNR, GJAHR
MARDStorage Location Stock (updated)MATNR, WERKS, LGORT, LABST (increased)
ACDOCAUniversal JournalStock account debit (BSX), GR/IR clearing credit (WRX)
Accounting Impact: GR creates two ACDOCA entries via automatic account determination (OBYC/T030): Stock account debit (transaction key BSX) and GR/IR clearing account credit (transaction key WRX).

Test Results (2026-04-09)

Mat DocYearPOMaterialQtyAmountEKBE.VGABEStatus
500000245020264500001819R-30297 ST58.20 USD1 (GR)OK

BAPI: BAPI_GOODSMVT_CREATEBAPI_TRANSACTION_COMMIT.
GOODSMVT_CODE: is a structure (not string) — set gmCode.setValue("GM_CODE", "01").
MVT_IND: set to B (PO reference) on each item.
Material Ledger fix: Required inserting continuous CKMLHD + CKMLPP + CKMLCR records (client 100, 2022/012 → 2026/012) for all P2P materials. Error C+/065 = missing CKMLHD, C+/073 = missing period records. No gaps allowed in period chain.

Step 4 — Invoice Verification

Post Supplier Invoice

Enters and verifies the vendor's invoice against the purchase order and goods receipt. Creates an invoice document (RBKP/RSEG) and corresponding accounting entries.

Transaction Codes

TcodePurpose
MIROEnter Incoming Invoice
MIR4Display Invoice
MIR7Park Invoice
MIRAFastEntry (background)
MRBRRelease Blocked Invoices

BAPI

Function ModulePurpose
BAPI_INCOMINGINVOICE_CREATEPost supplier invoice with PO reference
BAPI_INCOMINGINVOICE_CHANGEChange existing invoice
BAPI_TRANSACTION_COMMITPersist changes (WAIT='X')

Import Parameters (BAPI_INCOMINGINVOICE_CREATE)

StructureFieldValue
HEADERDATAINVOICE_INDX (invoice, not credit memo)
DOC_TYPERE (incoming invoice)
DOC_DATEInvoice date
PSTNG_DATEPosting date
COMP_CODE1710
CURRENCYUSD
GROSS_AMOUNTInvoice gross amount
CALC_TAX_INDX (calculate tax)
ITEMDATAINVOICE_DOC_ITEMItem number
PO_NUMBERPO reference
PO_ITEMPO item
TAX_CODETax code
ITEM_AMOUNTItem net amount
QUANTITYInvoice quantity
PO_UNITUnit of measure

Tables Populated

TableDescriptionKey Fields Written
RBKPInvoice Doc HeaderBELNR, GJAHR, BLART, BLDAT, BUDAT, BUKRS, LIFNR, WAERS, RMWWR, WMWST1
RSEGInvoice Doc ItemsBELNR, GJAHR, BUZEI, EBELN, EBELP, MENGE, WRBTR, MWSKZ
RBCOAccount AssignmentBELNR, GJAHR, BUZEI, SAKTO, KOSTL
EKBEPO History (updated)EBELN, EBELP, VGABE='2' (IR), BELNR, GJAHR
BKPFAccounting Doc HeaderBUKRS, BELNR, GJAHR, BLART, BUDAT (auto-created)
ACDOCAUniversal JournalGR/IR clearing debit, Vendor liability credit, Tax

Tolerances

Config TableDescription
T169Tolerance keys (AN=amount, AP=amount/item, BD=qty, BW=%)
T169PTolerance limits per company code

Invoices exceeding tolerance are blocked (RBKP.ZLSPR). Release via MRBR. Workflow template: WS20001000.

Accounting Impact: Invoice creates ACDOCA entries: GR/IR clearing account debit (clears the GR posting) and vendor liability credit. Three-way match: PO quantity/price vs GR quantity vs Invoice quantity/amount.

Test Results (2026-04-09)

Inv DocYearPOGross AmountTax CodeEKBE.VGABEStatus
51000013372026450000181958.20 USDI02 (IR)OK

BAPI: BAPI_INCOMINGINVOICE_CREATEBAPI_TRANSACTION_COMMIT.
Export field: INVOICEDOCNUMBER, FISCALYEAR.
Tax code: Use I0 (A/P Sales Tax, exempt) for TAXUSJ procedure. V0 is invalid.
DIFF_INV: Set to vendor number (invoicing party).
REF_DOC_NO: External invoice reference (free text).

Step 5 — Vendor Payment

Post Vendor Payment

Pays the vendor by creating an outgoing payment document. Can be done manually (F-53) or via the Automatic Payment Program (F110). Debits the vendor account and credits the bank account.

Transaction Codes

TcodePurpose
F110Automatic Payment Program
F-53Manual outgoing payment
FBL1NVendor line items
F.13Automatic clearing

BAPI

Function ModulePurpose
BAPI_ACC_DOCUMENT_POSTPost outgoing payment (GL credit + vendor debit)
RFC_READ_TABLERead open vendor items (BSIK) for payment amount
BAPI_TRANSACTION_COMMITPersist changes (WAIT='X')

Document Header (DOCUMENTHEADER)

FieldValueNotes
BUS_ACTRFBUBusiness transaction type
USERNAMEIDESPosting user
COMP_CODE1710Company code
DOC_TYPEKZVendor payment document type
DOC_DATETodayDocument date
PSTNG_DATETodayPosting date
REF_DOC_NOInvoice doc numberCross-reference
HEADER_TXTP2P Workflow PaymentHeader text

Line Items

LineTableAccountAmountDetails
001 ACCOUNTPAYABLE Vendor number + (debit) Clears the vendor open item from invoice
002 ACCOUNTGL Bank GL account − (credit) HOUSEBANKID, HOUSEBANKACCTID

Tables Populated

TableDescriptionKey Fields Written
BKPFAccounting Document HeaderBUKRS, BELNR, GJAHR, BLART='KZ'
ACDOCAUniversal JournalVendor debit + Bank credit
BSAKCleared Vendor Items (index)Vendor payment clearing
REGUHPayment Data (settlement)LAUFD, LAUFI, LIFNR, VBLNR, RBETR (F110 only)
REGUPPayment ItemsLAUFD, LAUFI, BUKRS, BELNR, GJAHR (F110 only)
PAYRPayment MediumCheck/wire details (F110 only)
Note: REGUH/REGUP/PAYR are only populated when using the Automatic Payment Program (F110). Manual payments via BAPI_ACC_DOCUMENT_POST only create BKPF/ACDOCA entries.

Payment Method Configuration (IDES 1710)

Important: Vendor 0017300001 has LFB1.ZWELS = CDIP, meaning only payment methods C (Check), D (ACH CCD), I (ISO PAIN.001), P (ACH PPD) are allowed. Method T (ACH CTX) is not in the vendor master — F110 will reject it.
MethodDescriptionT042ZT042E (1710)Vendor LFB1
CCheckYesYesYes
DBank transfer (ACH CCD)YesYesYes
IISO PAIN.001 Credit TransferYesYesYes
PBank transfer (ACH PPD)YesYesYes
TBank transfer (ACH CTX)YesYesNo

House bank: USBK1 / Account 0001 (T012K, company 1710).
Doc type: All methods use BLART = ZP (payment document).

IDES open items warning: Vendor 0017300001 has ~150 old open items (BSIK) from 2019–2022 totaling hundreds of thousands of USD. F110 picks up all due items for the vendor, causing a “doc.balance not zero” error when the total exceeds limits. Use Free Selection to filter by document number, or use F-53 for individual invoice payment.

SAP GUI Procedure — Option A: Automatic Payment (F110)

Recommended for production-like testing. Use payment method D and filter to specific invoices.

#ActionDetails
1Open F110Automatic Payment Transactions
2Fill HeaderRun Date: today (e.g. 09.04.2026), Identification: unique ID (e.g. P2P2)
3Fill Parameter tab Company Code: 1710
Payment methods: D (ACH CCD) — must be in vendor's LFB1.ZWELS
Next payment date: today or future
Vendor: 0017300001 to 0017300001
4Fill Free Selection tab Add field BELNR (document number)
Values: 5100001337 to 5100001338
This restricts F110 to only the P2P invoices, excluding old IDES open items.
5Run ProposalClick Proposal → Start immediately. Wait for completion, then check Proposal log. Invoices should appear as payable items.
6Run PaymentClick Payment run → Start immediately. Check Payment log for payment document number.
7VerifyFBL1N: vendor 0017300001, company 1710 — invoices should show as cleared.

SAP GUI Procedure — Option B: Manual Payment (F-53)

Simpler, single-invoice payment. Avoids the old open items problem entirely.

#ActionDetails
1Open F-53Post Outgoing Payment
2Fill header fields Document Date: today
Company Code: 1710
Currency: USD
Bank Account (G/L): look up via T012K → HKONT for HBKID=USBK1, HKTID=0001
Amount: 58.20 or 31.80 (matching the invoice)
Vendor: 0017300001
3Process Open ItemsPress Process Open Items — all open invoices appear. Double-click only the P2P invoice to select it (deselect everything else).
4PostClick Post (Ctrl+S). Note the payment document number.

Prerequisites

RequirementConfig LocationIDES 1710 Value
House bank configuredT012 (house bank), T012K (account)HBKID=USBK1, HKTID=0001
Payment method on vendorLFB1.ZWELSCDIP — use C or D in F110
Payment method per companyT042E (ZBUKR + ZLSCH)C, D, I, P, T all configured
Payment method definitionT042Z (LAND1 + ZLSCH)Country US, all methods BLART=ZP
Bank G/L accountT012K.HKONTCheck via SELECT HKONT FROM T012K WHERE BUKRS='1710'

Verification Queries

-- Vendor open items (before payment)
SELECT BUKRS, BELNR, GJAHR, BUZEI, DMBTR, ZLSCH FROM BSIK
WHERE LIFNR = '0017300001' AND BUKRS = '1710' AND GJAHR = '2026';

-- Vendor cleared items (after payment)
SELECT BUKRS, BELNR, GJAHR, AUGBL, AUGDT FROM BSAK
WHERE LIFNR = '0017300001' AND BUKRS = '1710' AND GJAHR = '2026';

-- Payment run details (F110 only)
SELECT LAUFD, LAUFI, LIFNR, VBLNR, RBETR FROM REGUH
WHERE LIFNR = '0017300001' AND ZBUKR = '1710';

Step 6 — GR/IR Clearing

GR/IR Account Clearing

Clears the GR/IR clearing account (differences between goods receipt and invoice receipt amounts). This is a periodic maintenance step, not part of the individual transaction flow.

Transaction Codes

TcodePurpose
MR11GR/IR Account Maintenance (maintain clearing account)
F.13Automatic Clearing
When GR and IR match exactly (same quantity and price), the GR/IR clearing account nets to zero automatically. MR11 is needed when there are residual differences.

SAP Tables Reference

Purchasing Tables

TableDescriptionCategoryPopulated By
EBANPurchase Requisition ItemsPRStep 1
EBKNPR Account AssignmentPRStep 1
EKKOPurchasing Document HeaderPO HeaderStep 2
EKPOPurchasing Document ItemPO ItemsStep 2
EKETSchedule LinesPO ScheduleStep 2
EKKNAccount AssignmentPO Acct AssgmtStep 2
EKBEPO History (GR, IR, etc.)PO HistorySteps 3, 4
EKABPO Release DocumentationPO ReleaseStep 2
EKPAPartner Functions in PurchasingPO PartnersStep 2
PRCD_ELEMENTSPricing Conditions (S/4HANA)PricingStep 2
EINAPurchasing Info Record (General)Master DataConfig
EINEPurchasing Info Record (Purch Org)Master DataConfig
EORDSource ListMaster DataConfig

Materials Management (MM) Tables

TableDescriptionCategoryPopulated By
MATDOCMaterial Document (S/4HANA unified)Mat. DocumentStep 3
MKPFMaterial Doc Header (compat view)Mat. Doc HeaderStep 3
MSEGMaterial Doc Items (compat view)Mat. Doc ItemsStep 3
MARDStorage Location StockStock LevelsStep 3 (updated)
MBEWMaterial ValuationValuationStep 3 (updated)

Invoice Verification Tables

TableDescriptionCategoryPopulated By
RBKPInvoice Document HeaderInvoice HeaderStep 4
RSEGInvoice Document ItemsInvoice ItemsStep 4
RBCOInvoice Account AssignmentInvoice AcctStep 4
RBWSTax Data per Invoice ItemInvoice TaxStep 4

Financial Accounting (FI) Tables

TableDescriptionCategoryPopulated By
ACDOCAUniversal Journal Entry (S/4HANA)Universal JournalSteps 3, 4, 5
BKPFAccounting Document HeaderFI Doc HeaderSteps 4, 5
BSEGAccounting Document Segment (compat view)FI Doc ItemsSteps 4, 5
BSIKOpen Vendor Items (secondary index)AP Open ItemsStep 4
BSAKCleared Vendor Items (secondary index)AP Cleared ItemsStep 5

Payment Tables

TableDescriptionCategoryPopulated By
REGUHPayment Data (Settlement)Payment HeaderStep 5 (F110)
REGUPPayment ItemsPayment ItemsStep 5 (F110)
PAYRPayment Medium (Check/Wire)Payment MediumStep 5 (F110)

Vendor Master Tables

TableDescriptionCategory
BUT000Business Partner General (S/4HANA primary)BP General
BUT020BP AddressesBP Addresses
BUT100BP Roles (FLVN01 = supplier)BP Roles
LFA1Vendor General Data (synced via CVI)Vendor General
LFB1Vendor Company Code DataVendor CoCode
LFM1Vendor Purchasing Org DataVendor PurchOrg
LFBKVendor Bank DetailsVendor Bank

Material Master Tables

TableDescriptionCategory
MARAMaterial General DataGeneral
MARCMaterial Plant Data (MRP, Purchasing)Plant
MARDStorage Location StockStock
MAKTMaterial DescriptionsTexts
MBEWMaterial ValuationValuation
MARMMaterial Units of MeasureUoM

Configuration Tables

TableDescriptionPurpose
T001Company CodesCompany code 1710
T001KValuation AreaPlant-to-company code assignment
T001WPlantsPlant definitions
T001LStorage LocationsStorage location definitions
T024EPurchasing OrganizationsPurch org definitions
T024Purchasing GroupsBuyer group definitions
T030Account Determination (OBYC)BSX, WRX, GBB, PRD transaction keys
T161Purchasing Document TypesNB=standard PO, etc.
T169/T169PTolerance Keys / LimitsInvoice verification tolerances
T16FC/FD/FS/FERelease Strategy ConfigPR and PO approval workflow
T042/T042ZPayment MethodsPayment method configuration
T052Payment TermsDue dates, discounts
MARVMM Posting PeriodCurrent posting period (LFMON/LFGJA)
CKMLPP/CKMLCRML Period/Currency RecordsMaterial Ledger period data

Account Determination (OBYC / T030)

Transaction KeyAccount TypePosting
BSXStock accountGR debit (stock increase)
WRXGR/IR clearing accountGR credit / IR debit
GBBOffsetting entryCost of goods consumed
PRDPrice difference accountStandard price variance
KDMExchange rate differenceFX differences on invoice

S/4HANA vs ECC Table Changes

AreaECC TablesS/4HANA TableNotes
Material DocumentsMKPF + MSEGMATDOCSingle unified table
AccountingBSEG + FAGLFLEXA + COEPACDOCAUniversal Journal
PricingKONVPRCD_ELEMENTSPricing in documents
StockMCHB, MSKA, MSSL, etc.MARD + MATDOCConsolidated
Vendor MasterLFA1 (standalone)BUT000 (BP) + CVIBP mandatory
Material LedgerOptionalAlways activeML infrastructure mandatory

CDS Views Reference

Purchase Requisition CDS Views

CDS ViewDescriptionBase Tables
I_PurchaseRequisitionPR header compositeEBAN
I_PurchaseRequisitionItemPR item with all fieldsEBAN
I_PurReqnAcctAssgmtPR account assignmentEBKN
I_PurReqnItemPurOrdRefPR item to PO referenceEBAN
C_PurchaseReqnHeaderConsumption: Manage PRsEBAN
C_PurreqnreleasestatusConsumption: PR release overviewEBAN

Purchase Order CDS Views

CDS ViewDescriptionBase Tables
I_PurchaseOrderPO headerEKKO
I_PurchaseOrderAPI01PO header (API)EKKO
I_PurchaseOrderItemPO itemEKPO
I_PurchaseOrderItemAPI01PO item (API)EKPO
I_PurchaseOrderScheduleLinePO schedule lineEKET
I_PurchaseOrderHistoryPO history (GR, IR)EKBE
I_PurchaseOrderItemAccountAssignmentPO account assignmentEKKN
I_PurchaseOrderPricingElementPO pricing conditionsPRCD_ELEMENTS
I_PurchaseOrderPartnerPO partner functionsEKPA
I_PurOrdReleaseStatusPO release statusEKKO
C_PurchaseOrderHeaderConsumption: Manage POsEKKO
C_PurchaseOrderItemConsumption: PO itemsEKPO
C_PORelOverviewPageConsumption: PO release overviewEKKO

Material Document / Goods Receipt CDS Views

CDS ViewDescriptionBase Tables
I_MaterialDocumentHeader_2Material doc headerMATDOC
I_MaterialDocumentItem_2Material doc itemMATDOC
I_GoodsMovementItemGoods movement itemMATDOC
I_MaterialStockMaterial stock overviewMARD
C_MaterialDocumentItemConsumption: Mat doc itemsMATDOC
C_GoodsReceiptForPurOrdConsumption: GR for POMATDOC, EKPO

Supplier Invoice CDS Views

CDS ViewDescriptionBase Tables
I_SupplierInvoiceInvoice headerRBKP
I_SupplierInvoiceAPI01Invoice header (API)RBKP
I_SupplierInvoiceItemInvoice itemRSEG
I_SupplierInvoiceItemPurOrdRefInvoice to PO referenceRSEG
I_SupplierInvoiceItemAcctAssgmtInvoice account assignmentRBCO
I_SupplierInvoiceTaxInvoice tax dataRBWS
C_SupplierInvoiceHeaderConsumption: Manage invoicesRBKP
C_SuplrInvcItemBlkdConsumption: Blocked invoicesRBKP

Accounting / Payment CDS Views

CDS ViewDescriptionBase Tables
I_JournalEntryAccounting doc headerACDOCA, BKPF
I_JournalEntryItemAccounting line itemACDOCA
I_OperationalAcctgDocItemOperational accountingACDOCA
I_GLAccountLineItemG/L line itemsACDOCA
I_VendorLineItemVendor line itemsACDOCA
I_VendorOpenItemVendor open itemsACDOCA
I_VendorClearedItemVendor cleared itemsACDOCA
I_APAccountBalanceAccounts payable balanceACDOCA
I_PaymentProposalPayment proposalREGUH
I_PaymentRunPayment runREGUH
C_APOpenItemsConsumption: AP open itemsACDOCA

Master Data CDS Views

CDS ViewDescriptionBase Tables
I_SupplierSupplier general dataLFA1, BUT000
I_SupplierCompanySupplier company code dataLFB1
I_SupplierPurchasingOrgSupplier purchasing org dataLFM1
I_SupplierBankAccountSupplier bank detailsLFBK
I_BusinessPartnerBusiness Partner generalBUT000
I_ProductProduct/material generalMARA
I_ProductPlantBasicProduct plant dataMARC
I_ProductPlantProcurementProduct procurement dataMARC
I_ProductValuationProduct valuationMBEW
I_PurchasingInfoRecordInfo record generalEINA
I_PurchasingInfoRecordOrgDataInfo record purch orgEINE
I_SourceOfSupplySource of supplyEORD

OData Services (Strategic APIs for S/4HANA 2023)

ServicePurpose
API_PURCHASEREQ_PROCESS_SRVPurchase Requisition CRUD
API_PURCHASEORDER_PROCESS_SRVPurchase Order CRUD
API_MATERIAL_DOCUMENT_SRVGoods Movements
API_SUPPLIERINVOICE_PROCESS_SRVInvoice Verification
API_BUSINESS_PARTNERBP/Vendor Master CRUD

BAPIs & Function Modules

StepFunction ModuleTypePurpose
1BAPI_PR_CREATEBAPICreate purchase requisition
1BAPI_PR_CHANGEBAPIChange purchase requisition
2BAPI_PO_CREATE1BAPICreate purchase order with header, items, schedules, accounts
2BAPI_PO_CHANGEBAPIChange existing purchase order
2BAPI_PO_RELEASEBAPIRelease purchase order
3BAPI_GOODSMVT_CREATEBAPIPost goods receipt (mvt type 101 against PO)
4BAPI_INCOMINGINVOICE_CREATEBAPIPost supplier invoice with PO reference
5BAPI_ACC_DOCUMENT_POSTBAPIPost outgoing payment (vendor debit + bank credit)
5RFC_READ_TABLERFCRead open vendor items for payment amount
*BAPI_TRANSACTION_COMMITBAPICommit transaction (WAIT='X') — after every step

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. Same connection as the OTC workflow.

Start SSH Tunnel

# Start the tunnel (runs in background, idempotent)
ssh -f -N -L 30015:127.0.0.1:30015 root@sapidess4

Run SQL Queries

# Using the shared hana_sql.py tool
python3 /tmp/sap-otc-workflow/hana_sql.py "SELECT * FROM EBAN WHERE BANFN='0010000001'"

# Interactive SQL prompt
python3 /tmp/sap-otc-workflow/hana_sql.py interactive

Common P2P Queries

# Check purchasing organizations
python3 /tmp/sap-otc-workflow/hana_sql.py "SELECT EKORG,EKOTX,BUKRS FROM T024E WHERE BUKRS='1710'"

# Check purchasing groups
python3 /tmp/sap-otc-workflow/hana_sql.py "SELECT EKGRP,EKNAM FROM T024"

# Check vendors for company code 1710
python3 /tmp/sap-otc-workflow/hana_sql.py "SELECT LIFNR,AKONT,ZTERM FROM LFB1 WHERE BUKRS='1710'"

# Check PO history
python3 /tmp/sap-otc-workflow/hana_sql.py "SELECT EBELN,EBELP,VGABE,BELNR,GJAHR FROM EKBE WHERE EBELN='4500000001'"

# Check MM posting period
python3 /tmp/sap-otc-workflow/hana_sql.py "SELECT BUKRS,LFMON,LFGJA FROM MARV WHERE BUKRS='1710'"

# Check open vendor items
python3 /tmp/sap-otc-workflow/hana_sql.py "SELECT BUKRS,LIFNR,BELNR,GJAHR,DMBTR,SHKZG FROM BSIK WHERE BUKRS='1710' AND LIFNR='0000100000'"

# Check GR/IR clearing account balance
python3 /tmp/sap-otc-workflow/hana_sql.py "SELECT RACCT,SUM(HSL) FROM ACDOCA WHERE RBUKRS='1710' AND RACCT='0021100000' GROUP BY RACCT"

Connection Details

ParameterValueNotes
HostlocalhostVia SSH tunnel
Port30015HANA indexserver (instance 00)
Tenant DBFIVS/4HANA data lives here
SchemaSAPHANADBAll SAP tables
UserSAPHANADBSchema owner, full read/write access
Password(see vault)Lifetime disabled, no expiry
Buffered tables: HANA SQL changes to buffered SAP tables (T001K, T024E, T169, MARV, etc.) require a buffer refresh (/$SYNC or /$TAB) to take effect in the application layer.

Usage

Program: SAPP2PWorkflow.java

Located at /Users/antonio.carbone/P2P/SAPP2PWorkflow.java. Uses JCo RFC to drive the P2P process.

Compilation

cd /Users/antonio.carbone/P2P
javac -cp .:../SAPjco/sapjco3.jar SAPP2PWorkflow.java

Shell Scripts

ScriptPurpose
./ptpgen.sh <count> [stage]Bulk data generator — create N cycles stopping at chosen stage
./ptpwf.sh <command> [args]Passthrough wrapper to SAPP2PWorkflow

Quick Examples (ptpgen.sh)

./ptpgen.sh 1 # 1 full cycle (PR→PO→GR→INV)
./ptpgen.sh 10 po # 10x PR→PO only
./ptpgen.sh 100 gr # 100x PR→PO→GR
./ptpgen.sh 100 ir # 100x full pipeline
./ptpgen.sh 10 gr --items 3 --verbose

Direct Java Commands

# Individual steps
./ptpwf.sh step1-pr 1 --verbose
./ptpwf.sh step2-po <prNumber>
./ptpwf.sh step3-gr <poNumber>
./ptpwf.sh step4-ir <poNumber>

# Full cycle with stage control
./ptpwf.sh full 10 --stop-at gr --items 3

# Check document status
./ptpwf.sh status <docNumber>

Options

FlagDescription
--verbosePrint BAPI details and all return messages
--dry-runValidate only (no BAPI_TRANSACTION_COMMIT)
--items NMax items per document (default: 2)
--stop-at STAGEStop after stage: pr, po, gr, ir (default: ir)
--pause NSeconds between steps (default: 3)

Test Results (2026-04-09)

Individual step testing, then full end-to-end cycle.

RunPRPOGR (MatDoc)InvoiceAmountStatus
Individual 00100014944500001819 50000024505100001337 58.20 USD 4/4 OK
Full cycle 00100014954500001820 50000024515100001338 31.80 USD 4/4 OK

2/2 cycles — 100% success rate across Steps 1-4. Step 5 (Payment) via F110 in SAP GUI.

Troubleshooting

ErrorCauseFix
DOC_TYPE is not a member of BAPIMEREQITEMIMP BAPI_PR_CREATE item structure has no DOC_TYPE field Set PR_TYPE in PRHEADER only; use DES_VENDOR for vendor at item level
06/418 Can delivery date be met? Requested delivery date is within lead time window Warning only — PR/PO is still created. Use future date (+15 days) to avoid
PURCHASEORDER not in OUTPUT BAPI_PO_CREATE1 export field name is different Use EXPPURCHASEORDER (not PURCHASEORDER)
GOODSMVT_CODE conversion error GOODSMVT_CODE is a structure, not a string Use getStructure("GOODSMVT_CODE").setValue("GM_CODE", "01")
C+/065 Error reading ML header No CKMLHD record for client 100 (only client 400 exists) Insert CKMLHD with MANDT='100' for each material's KALN1 from MBEW
C+/073 Error reading ML period Gap in CKMLPP period records (e.g. 2022/011 → 2026/004) Insert continuous CKMLPP + CKMLCR (CURTP 10+30) for all missing months. STATUS='10' for closed, '01' for open
FICORE/704 Tax code V0 invalid V0 does not exist in TAXUSJ (US tax procedure) Use I0 (A/P Sales Tax, exempt) for tax-free invoices
F110 “Pmnt method T should not be considered” Vendor LFB1.ZWELS = CDIP — method T not in vendor master Use method D (ACH CCD) or C (Check) in F110 Parameter tab
F110 “doc.balance not zero” ~150 old IDES open items (2019–2022) summed with P2P invoices Use Free Selection tab to filter by BELNR, or use F-53 for manual payment