Skip to Content
0
Former Member
Apr 01, 2009 at 08:21 AM

G/L Account in Sales Order

25 Views

Hi experts,

How to modify the query below:

DECLARE @string1 VARCHAR(30)

DECLARE @string2 VARCHAR(30)

IF (SELECT T0.[ItmsGrpCod] FROM OITM T0 WHERE T0.[ItemCode] = $[$38.1.0]) = '103'

SELECT '611000-11-001'

IF (SELECT T0.[ItmsGrpCod] FROM OITM T0 WHERE T0.[ItemCode] = $[$38.1.0]) = '102'

SELECT '611020-01-001'

ELSE SELECT @string1='(' + T0.ShortName + ', ' + SUBSTRING($[$38.U_Grade.0],LEN($[$38.U_Grade.0])-3,3)

FROM OASC T0 WHERE T0.Name =

(SELECT T1.ItmsGrpNam FROM OITB T1, OITM T2 WHERE

T1.ItmsGrpCod = T2.ItmsGrpCod AND

T2.ItemCode = $[$38.1.0])

select @string2=@string1 + T3.U_SGrp + ')' FROM OITM T3 WHERE T3.ItemCode = $[$38.1.0]

SELECT T4.FormatCode FROM OACT T4 WHERE RIGHT(T4.AcctName,11) = @string2 and LEFT(T4.FormatCode,2) = 61

The query above is for WhsCode 01. Whenever the WhsCode in RDR1 = 01, the G/L Account column will grab the corresponding account which starts with 61...

But I want the G/L Account column to grab the account which starts with 62... whenever the WhsCode in RDR1 = 'INDENT'

example:611020-01-001 will change to 621020-01-001