code report not get result why

i have shipment report with return order in report :
this is shipment report with return order(all values in table sales shippment line table) as following:
doc no order no quantity
12 15 50
12 15 50-
11 20 30
19 21 50
20 32 25
20 32 -25
1-i want to show shipment report without return order as following:
doc no order no quantity
11 20 30
19 21 50
20 32 25
meaning i don’t want any document no returned because returned order must be negative value to cancelled order that make by wrong so that i don’t want to display returned document no in report.

this report based on sales shipment header and sales shipment line table how i write code to make this result .

i try to write this code but not result

on view-sections-highlight header of sales shipment header

Sales Shipment Header, Body (1) - OnPreSection()

SalesShipmentLine.SetRange(“Document No.”,“No.”);
If SalesShipmentLine.FindFirst then
If Not ShowNeg then
If ShowNeg then

but no result

the logic i want to write code with it is:

1-filter out those lines (and the origin) place a filter on quantity: >0
2-For those other lines (the positive ones), use another rec var to check if a similar line exist within the same document with the quantity = quantity *-1

please help me


You have to use group totaling based upon Doc. No.

the result what i need is

doc no order no quantity

11 20 30

19 21 50

why i use grouping what i need is display data without any document no have negative value and positive value

Put this code on Sales Shipment Line - OnAfterGetRecord()

If NOT ShowNeg then begin

SalesShipmentLine2.SETCURRENTKEY(“Document No.”,“Order No.”,“Line No.”);

SalesShipmentLine2.SETRANGE(“Document No.”,“Document No.”);

SalesShipmentLine2.SETRANGE(“Order No.”,“Order No.”);

SalesShipmentLine2.SETRANGE(Quantity,Quantity * -1);

If SalesShipmentLine2 .COUNT > 0 then


If Quantity < 0 then



Hope it will help you for your result.

thank you very much