cancel
Showing results for 
Search instead for 
Did you mean: 

Purchase order Approval

Former Member
0 Kudos
58

Hi Experts,

I have an approval for sales orders orders where a Sales order for a Business partner belonging to a certain division( this is UDF in OCRD) are approved by a certain manager.

The approval for sales order works fine, but now I want the same manager that approved the sales order to approve a purchase order raised from the sales order where the purchase order is created from the Procurement Confirmation wizard.

Below is a query I used for the sales order approval:

DECLARE @Type as varchar(5)

DECLARE @BP as varchar(20)

set @Type =  (select $[ORDR.Doctype])

set @BP = (SELECT OCRD.U_Division   

FROM         OCRD

WHERE

OCRD.CardCode = $[ORDR.CardCode])

IF @Type = 'I' and (@BP = 1)

BEGIN

                SELECT 'TRUE'

END

I am using this query for my PO approval but is not working:

DECLARE @Type as varchar(5)

DECLARE @BP as varchar(20)

DECLARE @SODOC as varchar (20)

set @Type =  (select $[OPOR.Doctype])

set @BP = (SELECT OCRD.U_Division   

FROM         OCRD  INNER JOIN ORDR ON OCRD.CARDCODE = ORDR.CARDCODE

                              INNER JOIN RDR1 ON ORDR.DOCENTRY = RDR1.DOCENTRY INNER JOIN POR1 ON RDR1.DOCENTRY = POR1.BaseEntry

WHERE

OCRD.CardCode = $[ORDR.CardCode])

RDR1.DOCENTRY = POR1.BaseEntry

IF @Type = 'I' and (@BP = 1)  and ISNULL($[$38.43.0],0) = '17'

                SELECT 'TRUE'  ELSE SELECT 'FALSE'

Please help.

Aubrey

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Aubrey,

Please close your thread if the issue solved. Could you elaborate how did you find the solution?

Thanks,

Gordon

former_member184718
Active Contributor
0 Kudos

Hi Aubrey,

Try interchanging the DocEntry and BaseEntry fields of tables, RDR1 & POR1 like,

INNER JOIN POR1 ON RDR1.BaseEntry = POR1.DocEntry

WHERE OCRD.CardCode = $[ORDR.CardCode]) and

RDR1.BaseEntry = POR1.DocEntry

Thanks.

Hari

Former Member
0 Kudos

Hi Harikumar,

It still doesn't work.

Please help.

Aubrey

former_member184718
Active Contributor
0 Kudos

Hi,

In your code, IF @Type = 'I' and (@BP = 1)  and ISNULL($[$38.43.0],0) = '17'

the use of ISNULL function is incorrect. You are replacing all the NULL values with '0' and then why you are comparing with the value '17' ?

But the ISNULL function won't return any value.

Pls check.

Thanks.

Hari

Former Member
0 Kudos

Hi Hari,

Thanks, I solved the issue.

Regards,

Aubrey