Batch information SQL query

Batch Query Execution Plan

Here’s a SQL query that returns batch information for item codes that have a stock level greater than zero. This is the first in a series of posts highlighting some useful SQL queries for SAP Business One. I usually find myself writing out the same queries time & time again, so I thought I’d share them with the world. Some will be simple, some will be complex, hopefully all will be useful!

To keep things simple, wherever possible, I will not be using any User Defined Fields that I have created as part of my day-to-day work. However, sometimes they can be handy so if I include one, I’ll explain the reasoning why.

SELECT 
     T0.[ItemCode],
     T0.[DistNumber],
     T0.[LotNumber],
     T0.[Notes],
     T1.[WhsCode],
     T1.[Quantity],
     T1.[CommitQty],
     T2.[Location],
     T0.[Status],
     T3.[SWW]
 FROM
     [dbo].[OBTN] T0
     LEFT OUTER JOIN [dbo].[OBTQ] T1 ON T0.[ItemCode] = T1.[ItemCode] AND T0.[SysNumber] = T1.[SysNumber] 
     INNER JOIN [dbo].[OBTW] T2 ON T0.[ItemCode] = T2.[ItemCode] AND T0.[SysNumber] = T2.[SysNumber] AND T1.[WhsCode] = T2.[WhsCode]
     INNER JOIN [dbo].[OITM] T3 ON T0.[ItemCode] = T3.[ItemCode]
 WHERE 
     T1.[Quantity] > 0

Columns returned:

  • Item Code
  • Batch Number
  • Batch Attribute 2
  • Notes
  • Warehouse Code
  • Quantity
  • Committed Quantity
  • Location
  • Status
  • Item Additional Identifier

By a strange quirk of fate I had cause to use this query moment after I had written the first draft of this post!

You can find this query, and more over at my GitHub page: https://github.com/roguelj/SAP-Business-One-SQL-Queries

There are more SAP Business One queries on my blog, and you can find them here directly.

Pink Sky

Just another dramatic photo of a pink sky…

A Pink Sky
Pink Sky

All images were captured using the Sony DSC100IV camera. See a few more of my attempts at photography here: https://roguelj.co.uk/tag/photography/

Crystal Report extra characters when exporting to PDF

Crystal Report Extra Characters

Crystal Report extra characters: This is a problem I have had several times. It happens on multiple workstations, and it has a habit of returning. After some investigation, it would appear that it returns after a Crystal upgrade.

The symptom:

Exporting a Crystal Report that uses the Calibri font to a Portable Document Format file (PDF) will add an extra ‘ti’ after any letter ‘t’. Oddly, if you copy & paste the word into notepad or another text editor, it is correct.

The cause:

In my previous experience the problem has been caused by a missing USP10.dll fileĀ  (Uniscribe Unicode Script Processor) in the following path:

C:\Program Files (x86)\Business Objects\BusinessObjects Enterprise 12.0\win32_x86

Either that, or it’s a different version. On my machine, the USP10.DLL file can be found in the following places, and I’ve included the MD5 of each for later reference:

d529d8f23f9c686a293203eb837b61ec

“C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\usp10.dll”

9255da3e4662edf10170e30e8b97c194

“C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win64_x64\usp10.dll”

85cea5cd92c4766ac54823011f6de43b

“C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\USP10.DLL”

1602a45f76281381dcfc88e25d889027

“C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\vwd\usp10.dll”

9870191d0f26bdaaf6d4550eee3a96ec

“C:\Program Files (x86)\Business Objects\BusinessObjects Enterprise 12.0\win32_x86\usp10.dll”

I had to use Process Explorer (a fantastic tool) to find out exactly which one was in use – in this instance it was at the following path:

C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\usp10.dll

It is version 1.626.7601.23259, which can be found in the details screen of the file:

Crystal Report Extra Characters : USP10.DLL d529d8f23f9c686a293203eb837b61ec
USP10.DLL d529d8f23f9c686a293203eb837b61ec

So I copied over the USP10.DLL from “C:\Program Files (x86)\Business Objects\BusinessObjects Enterprise 12.0\win32_x86\usp10.dll” to “C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\usp10.dll”, and the problem was resolved. For reference, the MD5 of the one that works isĀ 9870191d0f26bdaaf6d4550eee3a96ec, and the details are as follows (file version 1.422.3790.1830):

Crystal Report Extra Characters : USP10.DLL 9870191d0f26bdaaf6d4550eee3a96ec
UPS10.DLL: 9870191d0f26bdaaf6d4550eee3a96ec

I found the following page helpful during my investigations of this issue:

https://archive.sap.com/discussions/thread/1272660

Check out my other Crystal Report annoyances here:

https://roguelj.co.uk/tag/crystal-reports/