select
	null as visesq,
	to_char(a.dat,'yyyy/mm/dd') dat,
	null as hvseq,
	null as iseq30,
	null as iseq31,
	a.iseq as iseq3111,
	a.vseq as cvseq,
	a.cuiseq as cuiseq3111,
	a.vlin,
	a.vlin as vlin3111,
	a.jan,
	a.ijan,
	c.gdjnm,
	c.gdjstnd,
	nvl(a.jpno, 0) as pno,
	a.cst,
	nvl(a.pno, 0)-nvl(a.jpno, 0) as tpno,
	a.cst as fcst,
	c.gdcls9,
	f.scls5 gdcls9nm,
	null as txt2,
	a.spktcd,
	'11' as tcls,
	null chgcdnm,
	null as idat,
	null as upchgnm,
	null as kflg,
	null as udat,
	:sdday as dat
from afm04 m04, afm90 f,afm08 e,afm08 d,afm02 c,afm05 b,afr3111 a
where a.ktktcd=:ktktcd
	and a.vseq=:cvseq
	and a.mcd=:mcd
	and a.dcls in ('1','2') and a.dcls1='1'
	and a.sts=' ' /*仕入入力できる発注は、確定済みのみ*/
	and a.spktcd=b.ktktcd(+)
	and a.ijan=c.ijan(+)
	and a.chgcd=d.chgcd(+)
	and a.upchg=e.chgcd(+)
	and f.cls(+)='6' and c.gdcls9=f.scls1(+)
	and a.mcd = m04.mcd(+)
	and nvl(a.pno, 0)-nvl(a.jpno, 0) > 0
order by a.vlin
