RavCOder
16th October 2019, 10:24
Hi,
I created this new thread becuase my problem is that I have duplicate values in my report.
I don't changed my session script (To see my script session I add link:http://www.baanboard.com/baanboard/showthread.php?t=72281)
How can I see different values?
Regards,
RavCoder

tmannais
17th October 2019, 09:56
Hi,
I created this new thread becuase my problem is that I have duplicate values in my report.
I don't changed my session script (To see my script session I add link:http://www.baanboard.com/baanboard/showthread.php?t=72281)
How can I see different values?
Regards,
RavCoder

Try changing values to your variables in before.layout of the layout you are having the duplicate values.

RavCOder
17th October 2019, 10:25
I didn't understand exactly how to put them, should I put in the fields section?

tmannais
17th October 2019, 11:05
I didn't understand exactly how to put them, should I put in the fields section?

Please specify your layout that has the duplicate values.
It maybe something like detail.1.
Then in your code, you do something like this.
detail.1:
before.layout:
| Assign new values for each record

RavCOder
17th October 2019, 11:08
Please specify your layout that has the duplicate values.
It maybe something like detail.1.
Then in your code, you do something like this.
detail.1:
before.layout:
| Assign new values for each record


How do I specify the layout? I'm sorry but I don't know exactly how to do it and I tried to look at the documentation but I can't find these things you're telling me.

tmannais
17th October 2019, 11:14
How do I specify the layout? I'm sorry but I don't know exactly how to do it and I tried to look at the documentation but I can't find these things you're telling me.

In your BW, select your report and select Specific then choose Layouts.
You will see all the layouts of that report.

RavCOder
17th October 2019, 11:19
Ok I found it, now to change value I have to do something like that:


|****************************** program section ********************************

detail.1:
before.layout:
if tdsls400.orno != " " then
tdsls400.orno = tdsls900.orno

|| put other fields like that?

tmannais
17th October 2019, 11:25
Ok I found it, now to change value I have to do something like that:


|****************************** program section ********************************

detail.1:
before.layout:
if tdsls400.orno != " " then
tdsls400.orno = tdsls900.orno

|| put other fields like that?




Yes.
Normally each time the detail layout is executed, the primary key(s) will change so you know it is a different record.
From that, you can use the data you have at the moment to query other values that you need to change then assign those values to the variables.
Or if you want to have some logic there then you can also do that here.

RavCOder
17th October 2019, 11:31
I have two error in my script :
ptdsls44000( 32): ERROR: Label 'detail.1' not expected within a section
ptdsls44000( 33): ERROR: Label 'before.layout' not expected within a section

tmannais
17th October 2019, 11:36
I have two error in my script :
ptdsls44000( 32): ERROR: Label 'detail.1' not expected within a section
ptdsls44000( 33): ERROR: Label 'before.layout' not expected within a section

Maybe your layout is not detail.1 or you put the code in a wrong place.
Another thing I just realized is that the root cause of duplicate values must actually come from its print session.
The print session might be sending these duplicate values to this report.
Try checking that point so that it is easier to fix by changing what the session is sending instead.

RavCOder
17th October 2019, 11:46
choice.cont.process:
on.choice:
execute(print.data)

choice.print.data:
on.choice:
detail.1:


if rprt_open() then
read.main.table()


sum_order()
sum_period()
insert_field_table()
detail.1:


rprt_close()
else
choice.again()
endif

This print my report, but I don't change nothing before and now I'm trying to insert before.layout in session script, but never changed.

tmannais
17th October 2019, 11:51
choice.cont.process:
on.choice:
execute(print.data)

choice.print.data:
on.choice:
detail.1:


if rprt_open() then
read.main.table()


sum_order()
sum_period()
insert_field_table()
detail.1:


rprt_close()
else
choice.again()
endif

This print my report, but I don't change nothing before and now I'm trying to insert before.layout in session script, but never changed.

Try putting some message() before rprt_send() to see if it is sending the same values twice.
And also please remove the detail.1 out of here because it belongs to report script.

RavCOder
17th October 2019, 12:14
I used message() before rprt_send:

message("error (%d)", tdsls400.orno)

then gave me this:
error(100000040)
and others same errors with different values.
I don't understand where is the problem in this print session.

tmannais
17th October 2019, 12:23
I used message() before rprt_send:

message("error (%d)", tdsls400.orno)

then gave me this:
error(100000040)
and others same errors with different values.
I don't understand where is the problem in this print session.

If the print session is sending correct values then you should go check your report script in its detail layout to see if it is getting different values each time it is executed.
Something like
detail.1:
before.layout:
message("error (%d)", tdsls400.orno)
It is either this place or in the layout that is causing this issue.
Note that your layout might not be detail.1. You should check in the report layout for the layout you are using.

RavCOder
17th October 2019, 12:37
Ok, I created a report script and put before.layout, when I executed my script I have for example error 10000040 then I have error 0 and execute a loop that never finish, so I don't now if I have duplicate value or not.

tmannais
17th October 2019, 12:58
Ok, I created a report script and put before.layout, when I executed my script I have for example error 10000040 then I have error 0 and execute a loop that never finish, so I don't now if I have duplicate value or not.

So that might be where the issue arises. Try checking why the data is not being sent to the report detail properly. There maybe something important missing between these two.
Once the detail gets correct data for each record then the report will print out the correct data.

RavCOder
17th October 2019, 13:31
Maybe is my function to insert field because when I debug my script session don't access into and stop iteration.
this is the function:

function insert_field_table(){
db.retry.point()
select tdsls900.*
from tdsls900 for update
where tdsls900.bpid = :tdsls400.ofbp
selectdo


selectempty
tdsls900.bpid = ""
tdsls900.nama = ""
tdsls900.item = ""
tdsls900.cuni = ""
tdsls900.odat = 0
tdsls900.orno = ""
tdsls900.qoor = 0
db.set.to.default(ttdsls900)



tdsls900.bpid = tdsls400.ofbp
tdsls900.nama = tccom100.nama
tdsls900.item = tdsls401.item
tdsls900.cuni = tdsls401.cups
tdsls900.odat = tdsls400.odat
tdsls900.orno = tdsls401.orno
tdsls900.qoor = tdsls401.qoor

db.insert(ttdsls900, db.retry)
commit.transaction()
endselect


}




if I comment the part of the select empty and execute script , gives me these error: -Fatal error :Error 100 (Duplicate value) on tdsls900121(Max retries (10) exceeded)
Can not continue in tdsls4400m000 in DLL : ottstp_stddll(__overloaded.commit.transaction)[commit.transaction]

tmannais
18th October 2019, 10:32
Maybe is my function to insert field because when I debug my script session don't access into and stop iteration.
this is the function:

function insert_field_table(){
db.retry.point()
select tdsls900.*
from tdsls900 for update
where tdsls900.bpid = :tdsls400.ofbp
selectdo


selectempty
tdsls900.bpid = ""
tdsls900.nama = ""
tdsls900.item = ""
tdsls900.cuni = ""
tdsls900.odat = 0
tdsls900.orno = ""
tdsls900.qoor = 0
db.set.to.default(ttdsls900)



tdsls900.bpid = tdsls400.ofbp
tdsls900.nama = tccom100.nama
tdsls900.item = tdsls401.item
tdsls900.cuni = tdsls401.cups
tdsls900.odat = tdsls400.odat
tdsls900.orno = tdsls401.orno
tdsls900.qoor = tdsls401.qoor

db.insert(ttdsls900, db.retry)
commit.transaction()
endselect


}




if I comment the part of the select empty and execute script , gives me these error: -Fatal error :Error 100 (Duplicate value) on tdsls900121(Max retries (10) exceeded)
Can not continue in tdsls4400m000 in DLL : ottstp_stddll(__overloaded.commit.transaction)[commit.transaction]

It might be because you are inserting a record where all of the primary keys are already existed in the database hence the duplicate value error. Check if the values you are putting in are not a duplicate.

RavCOder
18th October 2019, 12:53
I tried to see but still nothing, I always see duplicate values ​​repeated an N times

tmannais
18th October 2019, 13:28
I tried to see but still nothing, I always see duplicate values ​​repeated an N times

Try adding

as set with 1 rows

under where clause and see if the infinite loop stops.

RavCOder
18th October 2019, 13:36
I tried also that and I put db.insert() on top of selectempty, but nothing has changed.
Maybe I shouldn't make a loop? Because maybe I just read a value at random, but I don't know exactly how to do it