SELECT LN.BUSINESS_UNIT
, LN.INVOICE
, LN.LINE_SEQ_NUM
, LN.NOTES_SEQ_NUM
, LN.NOTE_TYPE
, STD_NOTE.TEXT254
, LN.STD_NOTE_CD
FROM PS_STD_NOTE STD_NOTE
, PS_BI_LINE_NOTE LN
, PS_BI_HDR HDR
WHERE LN.STD_NOTE_FLAG = 'Y'
AND LN.INTERNAL_FLAG = 'N'
AND LN.TEXT254 = ' '
AND HDR.BUSINESS_UNIT = LN.BUSINESS_UNIT
AND HDR.INVOICE = LN.INVOICE
AND LN.STD_NOTE_CD = STD_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'
|