RavCOder
9th August 2019, 17:11
Hi,

I declared this function in program section in a script ( General library):


function sum.quantity(){
select tdsls400.item, tccom100.bpid
from tdsls400, tccom100

selectdo

db.set.to.default(ttdsls400)
db.set.to.default(ttccom100)

(select sum(tdsls400.qoor)
where tdsls400.item > 0)

endselect

}

In the declaration I put tables (tdsls400,tdsls401,tccom100 and tdsls900)
My objctive is to sum quantity for each article selected by id (business partner), and insert the result in field created in other table (tdsls900).

Regards,

---RavCoder----

bdittmar
9th August 2019, 23:19
Hello,

this requirement can be solved with the LN purchise/sales statistics.

Purchised/Sold quantity by business partner and item per period or item per period a.s.o.
(tdpst and tdsst)

Or is there any other reason to do it with an own developed session ?

Regards

RavCOder
26th August 2019, 10:42
Hi ,
I want create a new script that sum quantities ordered for article and customer.
But I don't idea how to create this.
Sorry but I read the documentation and I don't know how to develop in this.

Regards,
RavCoder

mark_h
26th August 2019, 14:30
I would check into what Bernd recommended. Search the board.

In the meantime in 4c4 I would user something like this.

function sum.quantity(){
select tdsls400.item, tccom100.bpid
from tdsls400, tccom100
where ......whatever filter you have and the link between 2 tables...
group by select tdsls400.item, tccom100.bpid | My guess you would have multiples
selectdo

select sum(a.qoor):sum.qoor | Declare sum.qoor as same domain as tdsls400.qoor
from tdsls400 a, tccom100 b
where a.item = :tdsls400.item
and link tdsls400 and tccom100 using the aliases
and b.bpid = :tccom100.bpid
selectdo
endselect

| Send to report or go write the sum.qoor into another table.

endselect

}


You might have to work some bugs out of it depending on needs, but this is the basics I would do in 4c4. But I would search this forum for purchase or sales statistics to see what comes up.

bdittmar
26th August 2019, 15:39
Hello,
table tdsls400 is sales header, the item is stored in tdsls401.

Regards

RavCOder
26th August 2019, 16:13
I created this session but don't show me datas from both tables (tdsls400 and tdsls401).
My objective is read these tables in a new session , then created a script (maybe?) to sum quantity ordered for item and customer e memorize in another table ( that I have created yet).
But this session should be a print report that show me a summary of data who I have created before ( they aren't tdsls400 and tdsls401).
Regards,
RavCoder

RavCOder
26th August 2019, 17:21
Do you write your code into a script right?

mark_h
26th August 2019, 20:56
Yes - my code would go into a 4gl script to load the table. Then I would typically have display and report sessions for the data.