cancel
Showing results for 
Search instead for 
Did you mean: 

How to Right Align the output of amount with currency?

Former Member
0 Kudos

Hi,

I have the following SQL query, which basically is the duplication of the SAP standard Item List. The only difference is, the stock on hand is only for Warehouse 01.

In the output, I manage to display eg: AUD 1321.00. However, it is aligned to the center. Is there a way that I can make it right align like the standard report? Appreciate your help.

SELECT T0.[ItemCode], T0.[ItemName], (select T100.OnHand from OITW T100 where T100.ItemCode=T0.ItemCode and T100.WhsCode='01') as 'InStock',T0.[CodeBars], T1.[ItmsGrpNam], T2.[FirmName], T0.[InvntryUom],

('AUD'+ replicate(' ',16-len(T0.[LstEvlPric])) + Convert (char(18),(cast ((round(T0.[LstEvlPric], 2)) as decimal(16,2)))) ) as 'Last Eval Price', (T0.[LastPurCur]+ replicate(' ',16-len(T0.[LastPurPrc])) + Convert (char(18),(cast ((round(T0.[LastPurPrc], 2)) as decimal(16,2)))) ) as 'Last Pur. Price',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=1 and T200.ItemCode=T0.ItemCode) as 'L 1',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=2 and T200.ItemCode=T0.ItemCode) as 'L 2',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=3 and T200.ItemCode=T0.ItemCode) as 'L 3',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=4 and T200.ItemCode=T0.ItemCode) as 'L 4',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=5 and T200.ItemCode=T0.ItemCode) as 'L 5',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=6 and T200.ItemCode=T0.ItemCode) as 'Price List 6',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=7 and T200.ItemCode=T0.ItemCode) as 'Price List 7',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=8 and T200.ItemCode=T0.ItemCode) as 'Price List 8',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=9 and T200.ItemCode=T0.ItemCode) as 'Price List 9',

(SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200 INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=10 and T200.ItemCode=T0.ItemCode) as 'Price List 10'

FROM OITM T0 INNER JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN OMRC T2 ON T0.FirmCode = T2.FirmCode

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Your query is quite impressive. However, the requirement for right alignment is not available in anyway by just changing your query. Only additional report tools such as Crystal Report can produce the result you need. What you can do is using any fix length font like Courier New, that will ensure you have good looking report.

Thanks,

Gordon

Former Member
0 Kudos

Thanks.

But, does that mean the the right alignment in SAP Item list was done through UI?

Another question is:

Normally, in an SAP query, when click Ctrl + left click the mouse at the bottom, I can see the total.

However, with the query that I have created, it seems to cut off the first number. Eg: The total should be AUD 231,123.00, but it is showing me AUD 31,123.

Can you see how I can fix that?

Former Member
0 Kudos

I believe SAP reports are all hard coded to take advantage of the system functions. They are not just a simple query.

As for the cut off of the first number, try to change your number of space to 17-len(T200.Price) since your total digits are 16.