Deknor
2nd October 2015, 04:47
Hi all,

May i ask something about my code?

This is example of my code. My code didn't give the error.

The problem:
1)But the data which is print for issue quantity become 0,no value. Only the receipt quantities print out.
2) The data print out more than 1. The data becomes double.

|****************************** function section ******************************
functions:
function read.main.table()
{
long i,i2,x
domain tcqiv1 v.quan
domain tctrns.date qty.date, qty2.date

|utc.to.date(date.f,yy,mm,dd,hh,nn,ss)
|date.f = date.to.utc(yy,mm,dd,0,0,0)

|utc.to.date(date.t,yy,mm,dd,hh,nn,ss)
|date.t = date.to.utc(yy,mm,dd,23,59,59)

for i = 1 to 30 || initialize transaction date

utc.add(date.f,0,0,+(i-1),0,0,0,date.title(i))
i2 = i

if date.title(i) >= date.t then
i = 30
endif
endfor

|read files
select whwmd400.*,tcibd100.*,whinp100.*
from whwmd400,tcibd100,whinp100
where whwmd400._index1 inrange {:item.f} and {:item.t}
and whinp100.item refers to tcibd100
and tcibd100.item refers to whwmd400
|order by whwmd400.item |add item group
order by whwmd400._index1

|set.mem(QtyReceipt,0)
selectdo
qty2.date= 0
select whinp100.*
from whinp100
where whinp100._index2 = {:tcibd100.item}
and whinp100.kotr = tckotr.receipt
order by whinp100._index2

selectdo
qty2.date = whinp100.date

for i = 1 to 30
if qty2.date = date.title(i) then
QtyReceipt(i) = QtyReceipt(i) + whinp100.qana
endif
endfor
endselect

|Planned Qty Issue
|selectdo
qty.date = 0
select whinp100.*
from whinp100
where whinp100._index2 = {:tcibd100.item}
and whinp100.kotr = tckotr.requirement
order by whinp100._index2

selectdo
qty.date = whinp100.date

for i = 1 to 30
if qty.date = date.title(i) then
QtyIssue(i) = QtyIssue(i) + whinp100.qana
endif
endfor
endselect

rprt_send()
endselect
}


The attachment is a example of my results:

Your kindness I'm very appreciate,:)

mark_h
2nd October 2015, 20:19
Keep in mind I do not know these tables and I am assuming LN based off your profile. Below is how I would approach it in 4C4.

First thing I would do is pull whinp100 from the outer query.

select whwmd400.*,tcibd100.*
from whwmd400,tcibd100
where whwmd400._index1 inrange {:item.f} and {:item.t}
and tcibd100.item refers to whwmd400
order by whwmd400._index1

Then make sure the above is not returning more than one record - you might so maybe take those .* off. Since the only field below to be used is really tcbdi100.item - maybe group on it.

Then I would step thru debugging it to make sure that qty.date = date.title(i) actually happens and a value is inserted.

Bottom line my code based off what I read would look like this:

select tcibd100.item
from whwmd400,tcibd100
where whwmd400._index1 inrange {:item.f} and {:item.t}
and tcibd100.item refers to whwmd400
group by tcibd100
selectdo
qty2.date= 0
select whinp100.*
from whinp100
where whinp100._index2 = {:tcibd100.item}
and whinp100.kotr = tckotr.receipt
order by whinp100._index2

selectdo
qty2.date = whinp100.date

for i = 1 to 30
if qty2.date = date.title(i) then
QtyReceipt(i) = QtyReceipt(i) + whinp100.qana
endif
endfor
endselect

|Planned Qty Issue
|selectdo
qty.date = 0
select whinp100.*
from whinp100
where whinp100._index2 = {:tcibd100.item}
and whinp100.kotr = tckotr.requirement
order by whinp100._index2

selectdo
qty.date = whinp100.date

for i = 1 to 30
if qty.date = date.title(i) then
QtyIssue(i) = QtyIssue(i) + whinp100.qana
endif
endfor
endselect

rprt_send()
endselect
}

smusba
11th October 2015, 13:17
in the Planned Qty Issue use the 'alias' field name like
select whinp100.koor:koor,whinp100.item:item

We should use alias when we are repeating the script for the second time bcos the field name get confused to retrieve

Deknor
15th October 2015, 11:48
in the Planned Qty Issue use the 'alias' field name like
select whinp100.koor:koor,whinp100.item:item

We should use alias when we are repeating the script for the second time bcos the field name get confused to retrieve


hai smusba,

I already use alias to replace my variable into my code. But the result still the same. Issue quantities still not print.