pjohns
14th February 2003, 17:59
Where a report session program script is filtering data is there any way to override this in the report script?
We have a customised field in the sales order line table that marks each line with a priority. In the program script, for which we have no source, this field is set to 'blank' unless tdsls041.opri = emergency. I now want to have all priority statuses shown on my report but without the program source I cannot change the logic in the script. Is there any way to retrieve this data via the report script?
I think not, but I thought I'd ask.
Thanks
PJ
wizard
14th February 2003, 18:14
If I have understood well you want to override the value of the field the program script send to the report.
I think it is possible to select again that field in the before.layout of the section where the field is showed. If the field is printed on more sections then you can use a variable, to be initialized for every SLS order line, defined in the report script to which to assign the value.
Ciao
pjohns
14th February 2003, 18:58
Hi Wizard,
I had already tried what you suggested, I created a variable to return this data but I never got any values returned.
I even created a simple variable with a string domain and hard coded what this variable should return (pri.stat = "Normal" in before.layout of report script) but still not data returned??
Regards
PJ
mark_h
14th February 2003, 19:43
Could you post the script? That may help someone see the problem. Since we do not own source we also do things like this in the report script - along with filtering, sorting, etc. Did you run through the report in debug mode to make see where the value was getting reset? When you hardcoded the value which section did you use with the before.layout.
Mark
tools123
14th February 2003, 21:38
Make sure the field in question is in the report input fields.
If not check if it could have been assigneda variable name.
My last option would be to read the table again in the report for
each of the desired layouts after the current output is laid out.
Also, Check if the layouts are set to print for a particular
condition in maintain layouts.
Good luck.
nick_rogers
14th February 2003, 22:04
I would not declare the var in the report input fields as this indicates the var is comming from the program script.
I would then declare the var in the report script as EXTERN.
I would then lookup the value of the var in the after.receive.data section, as you want to determine the value as soon as possible, that is if each orderline is sent as a record to the report, if not then lookup the value in the before.layout event of the before.field.tdsls041.pono.
When looking up the value of the var make sure you have the select tdsls041 in a function with the table tdsls041 declared in the function to make it local, that way the select will not mix up the data/pointers of the tdsls041 data already selected (sent to the report).
after.receive.data:
The actions defined in this session are executed when the report writer has received a record. In this section you can for example read or modify a variable.
tools123
14th February 2003, 23:31
I was referring to the new customized field in the table:
=========================
"We have a customised field in the sales order line table that marks each line with a priority. In the program script, for which we have no source, this field is set to 'blank' unless tdsls041.opri = emergency"
=======================
My approach would be to check if the field or the variable it is
assigned to in the program script is currently available in the report.(to make sure it is not being used just to filter in the PS
and never sent to the report explicitly)
In that context, I would check to see if the field is available
with values in the report and then you can program based on that.
pjohns
17th February 2003, 12:27
Thanks for all your replies and help.
I declared my new variable as EXTERN and created a function to select the data.
I've managed to get my new report variable to print data but it still only prints the order line priority where tdsls041.opri = 'Emergency' It's ignoring all other priorities??
I have attached a copy of the program and report script to show you what's going on.
The report details are:-
variable = pri.stat
order line priority = tdsls041.opri
layout = detail 5
Any further help you can give will be appreciated.
Thank you
PJ
(Novice Scripter!)
RobertB
17th February 2003, 16:39
You most probably need to declare your table as local to the function in order not to reset the table pointer - try something like this :
....
| Call your function...............
order.priority(tdsls041.orno, tdsls041.pono)
....
function order.priority(domain tcorno i.orno, domain tcpono i.pono)
{
table ttdsls041
pri.stat = ""
select tdsls041.orno, tdsls041.pono, tdsls041.opri
from tdsls041
where tdsls041.orno = :i.orno
and tdsls041.pono = :i.pono
selectdo
pri.stat = tdsls041.opri
endselect
}HTH
mark_h
17th February 2003, 18:15
Well from looking at the scripts it looks like the session does a select tdsls041.*. With that the customized field tdsls041.opri should have been selected. Then all you should have had to do was add tdsls041.opri to the report fields and add it to the layout. I did this with tisfc001 and the print production order priority report. I take it this did not work?
From what you have posted here are the changes I would make:
detail.5:
before.layout:
order.priority()
function order.priority()
{
pri.stat = ""
select tdsls041.opri:pri.stat
from tdsls041
where tdsls041.orno = :tdsls041.orno and tdsls041.pono = :tdsls041.pono
selectdo
endselect
}
This assumes that detail.5 is always printed for each detail order line. You may want to check for print conditions on this layout. Last but not least from looking on our system I do not see where tdsls041.orno and tdsls041.pono are passed to the report(I checked session tdsls4402m000 and report tdsls440201000) - have you included them on your report fields? My system has tdsls045.orno and pono as input fields - check this. Run your report in debug mode and step through it to find out where it is really failing.
Good Luck!
Mark
pjohns
17th February 2003, 18:44
Thanks Mark and Robert,
I've combined your suggestions and it appears to be working, subject to further testing.
I used Robert's code example and as directed by Mark found that tdsls041.orno/pono were not included as report fields.
Just one more question, using Robert's code, what does the extra syntax between the () do when calling a function?
Hopefully the nut has been cracked!
Thanks for all your help.
Regards
PJ
RobertB
18th February 2003, 08:52
Hi,what does the extra syntax between the () do when calling a function?This is where you pass non-global variables to your function.
Unfortunately, I was a little hasty in my reply, so the actual variables passed in the example are global:rolleyes: . It might therefore have been better in this instance to write something like: | Declare some variables outside of the function....
domain tcorno this.orno
domain tcpono this.pono
| Call your function with the variables...............
this.orno = tdsls041.orno
this.pono = tdsls041.pono
order.priority(this.orno, this.pono)
....This way, you can be completely sure that the local set of table references inside the function don't "step on the toes" of the global set outside of the function, and hence don't reset the tdsls041 record pointer to some record other than that one actually being processed by the report script. You set up the function to accept a number of (in this case 2) variables ("function arguments") of the correct type, and pass them accordingly.
Mark's code probably works 100% in this example (and he's a real pro ;), so he knows OK?) - but that wouldn't always be the case. It's a good idea to get into the habit of coding defensively to "stop leaks" - and the above example could even be rewritten to pass a return value to indicate success/failure in searching, as well as the opri field as a third argument - but let's not get carried away....
Mark's also right about the tdsls045 table - I didn't check this either...
Have fun!