G/L account transactions
Journal lines for one G/L account in a period, with debit, credit and reference.
Tool
SELECT T0.TransId, T0.RefDate, T0.TransType, T0.BaseRef, T1.Account, T2.AcctName, T1.Debit, T1.Credit, T1.LineMemo FROM OJDT T0 INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId INNER JOIN OACT T2 ON T1.Account = T2.AcctCode WHERE T1.Account = '[%0]' AND T0.RefDate BETWEEN '[%1]' AND '[%2]' ORDER BY T0.RefDate, T0.TransId
SELECT T0."TransId", T0."RefDate", T0."TransType", T0."BaseRef", T1."Account", T2."AcctName", T1."Debit", T1."Credit", T1."LineMemo" FROM OJDT T0 INNER JOIN JDT1 T1 ON T0."TransId" = T1."TransId" INNER JOIN OACT T2 ON T1."Account" = T2."AcctCode" WHERE T1."Account" = '[%0]' AND T0."RefDate" BETWEEN '[%1]' AND '[%2]' ORDER BY T0."RefDate", T0."TransId"
What this query answers
An auditor asks why the bank or a clearing account has a strange balance, and the accountant needs every journal line that hit that account in a date range. Each line shows the source transaction type and reference so it can be traced back to the document.
Sample output
Illustrative demo values. Your columns are the same; the numbers come from your company.
| TransId | RefDate | TransType | BaseRef | Account | AcctName | Debit | Credit | LineMemo |
|---|---|---|---|---|---|---|---|---|
| 20311 | 2026-10-01 | 24 | 1201 | 112100 | Bank - Main Account | 5250 | 0 | Incoming Payment - C20000 |
| 20330 | 2026-10-05 | 46 | 870 | 112100 | Bank - Main Account | 0 | 12600 | Outgoing Payment - V10000 |
| 20345 | 2026-10-08 | 30 | 20345 | 112100 | Bank - Main Account | 0 | 35 | Bank charges October |
SQL Server vs SAP HANA
The three parameters keep their quotes ('[%0]' for the account, '[%1]' and '[%2]' for dates). On HANA the account code comparison is case-sensitive, which matters only if your account codes contain letters.
Common errors and fixes
- No rows returned for an account that clearly has postings: With account segmentation, JDT1.Account stores the internal code (for example _SYS00000000012), not the code you see. Filter on T2.FormatCode = '[%0]' instead of T1.Account.
- TransType shows numbers instead of names: TransType is the object type: 13 = A/R invoice, 14 = A/R credit note, 18 = A/P invoice, 24 = incoming payment, 46 = outgoing payment, 30 = manual journal entry. Add a CASE expression if you need text.
- Opening balance is missing: The query lists movements only. Sum Debit - Credit for RefDate before '[%1]' to get the opening balance of the account.
Need this report built into SAP Business One?
A saved query answers the question once. We build Crystal Reports and Power BI dashboards for SAP Business One on SQL Server and HANA, and you own the files. Or hire a SAP Business One developer for the whole job, fixed price per phase.
Related queries
Table reference: OJDT table (Journal Entry (header)) · JDT1 table (Journal Entry Lines) · OACT table (G/L Accounts (chart of accounts))
Three steps, no signup
Copy the right version
Use the SQL Server tab for MS SQL databases and the HANA tab for SAP B1 on HANA.
Open Query Generator
In SAP Business One go to Tools → Queries → Query Generator, paste and click Execute.
Save and share
Click Save, pick a category and give the query a name. Your team can run it from Query Manager.
Questions about this tool
How do I run the g/l account transactions query in SAP Business One?
Copy the version that matches your database, open Tools → Queries → Query Generator, paste it in the SQL box and click Execute. Save it to reuse it later.
Which tables does this query use?
It reads OJDT, JDT1, OACT from the standard SAP Business One schema. No user-defined fields are needed.
What should I enter when the selection window opens?
This query uses parameters: [%0] = account code, [%1] = from date, [%2] = to date. SAP B1 shows a selection window for each one when you run it.
Can this be turned into a dashboard or alert?
Yes. We turn queries into Crystal reports, Excel reports that refresh themselves, SAP B1 alerts or WhatsApp messages for managers.
Built for SAP Business One teams
Need this inside SAP Business One?
We build add-ons, reports and integrations for SAP B1 on SQL Server and HANA. Tell us what you need and get a fixed price, usually within 24 hours.
