danielva
4th September 2015, 11:44
Hello,
I want to write the Parameter from a Query into the report.
In my example
tdpur041.suno.f
should be printet in the Report.
How can i handle this?

mark_h
4th September 2015, 15:33
There is no way I know of to do this. Wait a while and maybe someone else has a solution.

RedBatz
4th September 2015, 16:18
Hi,

declare the parameter as a report input field and put the field in the report layout.

Also declare the parameter as external on the session script.

bhushanchanda
4th September 2015, 17:39
Hi,

As Mark said, AFAIK, there is no way to get the from and to values on the query from in your report. Neither declaring it as input field nor declaring it in the report script will work.

The solution I got is to get the user inputs in before.program of report script using a hidden tools function called - input.string()

e.g.

declaration:

extern domain tcdate date.f,date.t
extern domain tcpono id,yearno,monthno,dayno,hours,minutes,seconds
extern domain tcmcs.str30 date.f.s,date.t.s

#pragma used dll ottdllinputstr

before.program:
|* Take From Date and store as string
input.string("Please Enter in this format :- mm/dd/yyyy","From Date",
50,
50,
date.f.s)
|* Take To Date and store as string
input.string("Please Enter in this format :- mm/dd/yyyy","To Date",
50,
50,
date.t.s)

|* Convert String to date
string.scan(date.f.s,"%d/%d/%d",monthno,dayno,yearno)
date.f = date.to.utc (yearno,monthno,dayno,0,0,0)
string.scan(date.t.s,"%d/%d/%d",monthno,dayno,yearno)
date.t = date.to.utc (yearno,monthno,dayno,23,59,59)

Now, you can use/print the date ranges on your report layout.

In your main query write any simple select e.g.

select tcibd001.item
from tcibd001
as set with 1 rows

Rest of the things, you will do in your report script i.e. the main query logics and selections.

danielva
8th September 2015, 11:42
Thanks for the replies!
@RedBatz
This solution doesn't work. If I declare it as external Domain I get compilation Errors.

@bhushanchanda
Clever idea but if I want to ask for anything else than the date (like the number of the Supplier) this solution doesen't apply.

Thanks for your posts, I hope somebody else has a better solution :)

bhushanchanda
8th September 2015, 11:48
Hi,

The solution I gave can be applied to get any data. You can take supplier code as well. Its just that, you can't provide zoom option. (Considering no alternatives, this one serves fine as a user can copy and paste the code from masters)

Not sure if you are on the latest version, in case if you are, there is a concept of programming dialog. So, in your report script, you can create a complete form/dialog to let user enter their selection and use it for your reporting.

mark_h
8th September 2015, 15:15
The only other solution is to just create a new session. There is only so much you can do in a query and the report.

RedBatz
8th September 2015, 18:34
Hi,

my apologies, I didn't have enough attention it was a SQL Query.

Regards

JaapJD
10th September 2015, 10:52
If you look at the bic_info of ottadv3280 (the object that executes the query), you see some variables: field.input.from and field.input.to. I tried to import those in the report script, but that didn't help. Then I thought that it could be an array and imported those in the report script. And yes, that does work:

declaration:
string field.from(20)
string field.to(20)

before.program:
get.indexed.var(parent, "field.input.from", field.from, 1)
get.indexed.var(parent, "field.input.to", field.to, 1)

Now the field.from and field.to contain the values of the given range values and you can print those on the report.

Notes:
1. If you have multiple ranges, I don't know what the order is in the array.
2. This uses some internals of the LN tools. It may not be compatible in future versions.

mark_h
10th September 2015, 16:53
That is a great hack - hope it works for original poster.

danielva
11th September 2015, 10:02
If you look at the bic_info of ottadv3280 (the object that executes the query), you see some variables: field.input.from and field.input.to. I tried to import those in the report script, but that didn't help. Then I thought that it could be an array and imported those in the report script. And yes, that does work:

declaration:
string field.from(20)
string field.to(20)

before.program:
get.indexed.var(parent, "field.input.from", field.from, 1)
get.indexed.var(parent, "field.input.to", field.to, 1)

Now the field.from and field.to contain the values of the given range values and you can print those on the report.

Notes:
1. If you have multiple ranges, I don't know what the order is in the array.
2. This uses some internals of the LN tools. It may not be compatible in future versions.

Thank you very much, exactly the solution i was looking for. Works great!!! :)

If you have multiple ranges you can take the next element from the Array


declaration:
string field.from(30)
string field.to(30)
string field.from2(30)
string field.to2(30)
before.program:
get.indexed.var(parent, "field.input.from", field.from, 1)
get.indexed.var(parent, "field.input.to", field.to, 1)
get.indexed.var(parent, "field.input.from", field.from2, 2)
get.indexed.var(parent, "field.input.to", field.to2, 2)