SELECT HDR_NOTE.BUSINESS_UNIT
, HDR_NOTE.INVOICE
, HDR_NOTE.NOTES_SEQ_NUM
, HDR_NOTE.NOTE_TYPE
, STD_NOTE.TEXT254
, HDR_NOTE.STD_NOTE_CD
FROM PS_STD_NOTE STD_NOTE
, PS_BI_HDR_NOTE HDR_NOTE
, PS_BI_HDR HDR
WHERE HDR_NOTE.STD_NOTE_FLAG = 'Y'
AND HDR_NOTE.INTERNAL_FLAG = 'N'
AND HDR_NOTE.TEXT254 = ' '
AND HDR.BUSINESS_UNIT = HDR_NOTE.BUSINESS_UNIT
AND HDR.INVOICE = HDR_NOTE.INVOICE
AND HDR_NOTE.STD_NOTE_CD = STD_NOTE.STD_NOTE_CD
AND HDR_NOTE.STD_NOTE_CD NOT IN (SELECT C.STD_NOTE_CD FROM PS_BI_CU_SNT_EC_VW C
WHERE C.BUSINESS_UNIT = HDR_NOTE.BUSINESS_UNIT
AND C.INVOICE = HDR_NOTE.INVOICE
AND C.NOTE_TYPE = HDR_NOTE.NOTE_TYPE
AND C.STD_NOTE_CD = HDR_NOTE.STD_NOTE_CD)
AND STD_NOTE.SETID =
(SELECT SETID FROM PS_SET_CNTRL_REC
WHERE SETCNTRLVALUE = HDR.BUSINESS_UNIT
AND RECNAME = 'STD_NOTE')
AND STD_NOTE.EFFDT =
(SELECT MAX(EFFDT) FROM PS_STD_NOTE
WHERE SETID = STD_NOTE.SETID
AND STD_NOTE_CD = STD_NOTE.STD_NOTE_CD
AND ((EFFDT <= %currentdatein and HDR.INVOICE_DT IS NULL)
or (EFFDT <= HDR.INVOICE_DT and HDR.INVOICE_DT IS NOT NULL)))
AND STD_NOTE.EFF_STATUS = 'A'
|