tracylee
27th September 2018, 06:36
Dear all,

I have issue on display report data. Please refer attached file for more details. First attached file (Report Layout Issue 1) is now current layout display. How can I show the report layout as second attached file (Report Layout(request like this)). My code as below. Please advise. Thanks.


|****************************** declaration section ***************************

declaration:

table ttccus025 | Cut List Calculation
table ttccom001 | Employee-General
table ttccus024 | Short Bar List
table ttcmcs052 | Projects


extern domain tcmcs.str60 title1, sect.olen.clle
extern domain tclbal bal
extern domain tcclle count.clle, max.clle, run.no
extern domain tccsle total.qty, totalqty
extern domain tcoqty gross.qty, short.qty, minus.qty, a.short.qty, test.qty

extern domain tcitem item.var(1) based
extern domain tcitem qty.var(1) based
extern domain tcitem bal.qty.var(1) based
extern domain tcitem finish.item, f.item, f.qty, f.bal.qty
long i, t, tot.num

before.program:
free.mem(item.var)
free.mem(qty.var)
free.mem(bal.qty.var)

i = 0
t = 1

header.1:
before.layout:
title1 = "TEST"

before.tccus025.sect.1:
before.layout:
totalqty = 0

detail.1:
before.layout:

select count(tccus025.clle):count.clle
from tccus025
where tccus025.sect = :tccus025.sect and tccus025.olen = :tccus025.olen and tccus025.clle = :tccus025.clle
selectdo
run.no = run.no + 1
endselect

|**** Max Long Bar ***********
select max(tccus025.clle):max.clle
from tccus025
where tccus025.sect = :tccus025.sect and tccus025.olen = :tccus025.olen and tccus025.ocut = tcyesno.no
|group by tccus025.clle
selectdo
selectempty
max.clle = 0
endselect

if count.clle = run.no then
bal = tccus025.lbal
else
bal = 0
endif


|**** Show Finish Goods ***********
short.qty = tccus025.csle

select tccus024.*
from tccus024
where tccus024.sect = :tccus025.sect and tccus024.lgth = :tccus025.slen
selectdo
gross.qty = tccus024.oqty
finish.item = tccus024.item

short.qty = short.qty - gross.qty


i = i + 1
alloc.mem(item.var, 47, i)
alloc.mem(qty.var, 47, i)
alloc.mem(bal.qty.var, 47, i)

item.var(1,i) = finish.item
qty.var(1,i) = str$(gross.qty)
bal.qty.var(1,i) = str$(short.qty)

endselect

after.layout:
calculate.total.quantity(tccus025.csle)


detail.2:
before.layout:
for tot.num = t to i

f.item = trim$(item.var(1,tot.num))
f.qty = qty.var(1,tot.num)
f.bal.qty = bal.qty.var(1,tot.num)

break
endfor

if (i = 0) or (i = t) then
i = 0
t = 1
free.mem(item.var)
free.mem(qty.var)
free.mem(bal.qty.var)
endif

after.layout:
if i <> 0 then

if i <> t then
t = t + 1
layout.again()
endif

endif

after.program:
free.mem(item.var)
free.mem(qty.var)
free.mem(bal.qty.var)

after.tccus025.clle.1:
after.layout:
run.no = 0

after.tccus025.sect.1:
before.layout:

total.qty = totalqty


Functions:

function calculate.total.quantity(domain tccsle t.qty)
{
totalqty = totalqty + t.qty
}

Ajesh
27th September 2018, 17:29
Do you want to get After Used Qty on the report? Simply use a field with quantity domain and assign the value f.qty - tccus025.csle

tracylee
28th September 2018, 04:09
Do you want to get After Used Qty on the report? Simply use a field with quantity domain and assign the value f.qty - tccus025.csle

Thanks for your reply. Yes, but the figure get wrongly. I also want to display the item code.

Eg:
finish good A need use 3 pcs short bar A and
finish good B need use 4 pcs short bar A.
1 pcs Long Bar only can cut 2pcs shor bar A.

I want display as below.
Material Mat.qty Qty short bar A finish good After used qty
Long Bar 1 pcs 2 pcs finish good A 1 pcs
Long Bar 1 pcs 2 pcs finish good A 0 pcs
finish good B 3 pcs
Long Bar 1 pcs 2 pcs finish good B 1 pcs
Long Bar 1 pcs 2 pcs finish good B 0 pcs

Please advise. Thanks.

Ajesh
28th September 2018, 14:40
Whatever value is being shown in Total Qty to be used - Short Bar Process Qty, You can display it in before.layout of the Report or use it directly in the Report Field

Also You want the Trimmed Item Code to be displayed? Its achievable if you use trim$