Skip to content

Instantly share code, notes, and snippets.

@kmlxn
Last active June 5, 2023 06:17
Show Gist options
  • Select an option

  • Save kmlxn/f157e1ec634cf71b82594a053c9b3e93 to your computer and use it in GitHub Desktop.

Select an option

Save kmlxn/f157e1ec634cf71b82594a053c9b3e93 to your computer and use it in GitHub Desktop.
SAP Business One Hana SQL query to retrieve items in stock, their serial numbers and item groups.

SAP Business One Hana SQL query to retrieve items in stock, their serial numbers and item groups.

select
TOSRI."InDate" AS "Kelish sanasi",
TOSRN."CostTotal" AS "Tannarx",
TOITB."ItmsGrpNam" AS "Kategoriya",
TOITM."ItemName" AS "Nom",
TOSRI."IntrSerial" AS "IMEI",
TOITM."U_Color" AS "Rang",
TOITM."U_Condition" AS "Holat"
from OSRI TOSRI
INNER JOIN OSRN TOSRN ON TOSRN."DistNumber" = TOSRI."IntrSerial"
INNER JOIN OITM TOITM ON TOSRI."ItemCode" = TOITM."ItemCode"
INNER JOIN OITB TOITB ON TOITB."ItmsGrpCod" = TOITM."ItmsGrpCod"
where TOSRN."Quantity" > TOSRN."QuantOut" and TOSRI."WhsCode" = '02'
ORDER BY TOSRI."InDate" DESC

SAP Business One Hana SQL get Invoice (OINV) sub total

T0.[DocTotal] + T0.[DiscSum] + T0.[DpmAmnt] - T0.[TotalExpns] - T0.[VatSum]

SAP Business One Crystal Reports Sum to text. Haven't tested.

select (RIGHT(SPLIT(TOTEXT(SUM({@LineTotalNoVAT})),",")[1],1))
CASE "1":
ProperCase(split(ToWords (Sum ({@LineTotalVAT}),0), " ")[1]) + " " + towords(tonumber(split(totext(Sum ({@LineTotalVAT})),",")[1]),0)[(InStr (ToWords (Sum ({@LineTotalVAT}),0), " ") + 1) To Length (ToWords (Sum ({@LineTotalVAT}),0))] + " доллар) " +Right("0"+ToText ((Round(Sum ({@LineTotalVAT}),2) - Int(Sum ({@LineTotalVAT}))) * 100, 0),2) + " цент США"
CASE "2","3","4":
ProperCase(split(ToWords (Sum ({@LineTotalVAT}),0), " ")[1]) + " " + towords(tonumber(split(totext(Sum ({@LineTotalVAT})),",")[1]),0)[(InStr (ToWords (Sum ({@LineTotalVAT}),0), " ") + 1) To Length (ToWords (Sum ({@LineTotalVAT}),0))] + " доллара) " +Right("0"+ToText ((Round(Sum ({@LineTotalVAT}),2) - Int(Sum ({@LineTotalVAT}))) * 100, 0),2) + " цент США"
DEFAULT: ProperCase(split(ToWords (Sum ({@LineTotalVAT}),0), " ")[1]) + " " + towords(tonumber(split(totext(Sum ({@LineTotalVAT})),",")[1]),0)[(InStr (ToWords (Sum ({@LineTotalVAT}),0), " ") + 1) To Length (ToWords (Sum ({@LineTotalVAT}),0))] + " долларов) " +Right("0"+ToText ((Round(Sum ({@LineTotalVAT}),2) - Int(Sum ({@LineTotalVAT}))) * 100, 0),2) + " цент США"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment