[Main]
dbuse(true)
initparam(printMode,reportId,s_id,tok_cd,seikyu_ymd)
deforgpage(blank)
defheadarea(hed)
defbodyarea(mei)
subroutine(SelectRecords)
loop(PrintNormal,@rs1,Key1,key2)
printreport($printMode,true,false)

#-------------------------------------------------
#  Key1�ݒ胋�[�`��
#-------------------------------------------------
[KeyInfo_key1]
keyvalue(@rs1.skbn,@rs1.tok_cd)
keybreakproc(GroupBegin_key1,GroupEnd_key1)

#-------------------------------------------------
#  Key1�J�n��
#-------------------------------------------------
[GroupBegin_key1]
deforgpage(blank)
#Import���邩�ǂ���,FormatNormal���邩�ǂ���
pageopen(true,true)
deforgpage(formats)
resetorg()


#�w�b�_����_�w�b�_�[
putcell(1,7,���i�R�[�h�F)
putcell(1,9,@rs1.hin_cd)
putcell(3,2,@rs1.hin_nm)


#-------------------------------------------------
#  Key1�I����
#-------------------------------------------------
[GroupEnd_key1]
#FormatNormal���邩�ǂ���
pageclose(false)

#putcell($_row,32,@rs1.row_B)

#-------------------------------------------------
#  Key2�ݒ胋�[�`��
#-------------------------------------------------
[KeyInfo_key2]
keyvalue(@rs1.skbn,@rs1.tok_cd,@rs1.row_page)
keybreakproc(GroupBegin_key2,GroupEnd_key2)

#-------------------------------------------------
#  Key2�J�n��
#-------------------------------------------------
[GroupBegin_key2]
#�P�ƂQ�y�[�W�ڂ̃w�b�_���E�o��
case($page1,@rs1.row_page,0,1,0)
case($page2,@rs1.row_page,0,0,1)
iterate(Type21,$page1)
iterate(Type22,$page2)


[Type21]

#���׍s�ꊇformat
formatspecialrow($_row,0,7,41)

[Type22]
#�w�b�_����_����
#formatspecialrow($_row,0,65,4)

#���׍s�ꊇformat
formatspecialrow($_row,0,7,40)

#-------------------------------------------------
#  Key2�I����
#-------------------------------------------------
[GroupEnd_key2]

#sum($f_biko,50)

sum($_row,-1)
putcell($_row,9,@rs1.now_stock)

#-------------------------------------------------
#  SQL���s
#-------------------------------------------------
[SelectRecords]
new($param)
addparam($param,$s_id)
addparam($param,$tok_cd)
addparam($param,$seikyu_ymd)

dbselect(SelectRecords,@rs1,$param)

#-------------------------------------------------
#  ���ו\������
#-------------------------------------------------
[PrintNormal]

case($type0,@rs1.sort,0,1,0)
case($type1,@rs1.sort,0,0,1)
iterate(Type0,$type0)
iterate(Type1,$type1)

[Type0]
putcell($_row,2,@rs1.syori_ymd)
putcell($_row,3,@rs1.den_no)
putcell($_row,4,@rs1.tor_nm)
putcell($_row,5,@rs1.tor_kbn)
putformula($_row,9,(R[1]C+((-R[1]C[-2])+(R[1]C[-1]))))

putline(,,,,,@rs1.tanka#,@rs1.nyuko_su#,@rs1.syuko_su#)



[Type1]
putcell($_row,2,@rs1.syori_ymd)
putcell($_row,3,@rs1.den_no)
putcell($_row,4,@rs1.tor_nm)
putcell($_row,5,@rs1.tor_kbn)
#putformula($_row,9,\x28R[1]Cx2b\x28\x28-R[1]C[-2]\x29x2b\x28R[1]C[-1]\x29\x29\x29)
putformula($_row,9,(R[1]C+((-R[1]C[-2])+(R[1]C[-1]))))

putline(,,,,,@rs1.tanka#,@rs1.nyuko_su#,@rs1.syuko_su#)