BaBernd
6th October 2016, 08:40
Hello to All,

I'm trying to query selected records out of a parent session from a print session for reporting. Are there special procedures or functions to identify these selected records and query them for printing?
I've a screenshot attached as example for such selected records.

Best Regards
Bernd

andreas.toepper
6th October 2016, 09:49
Can you look in one of the latest programmers guides? (Its available in KB 22924522 at inforxtreme.com.)

Check function do.parent.selection(..) and sel.use.parent.selection(..). Those are available from FP6 onwards (ES 8.6 and its portingset I think). I've been using those functions on our LN 10.2.1.


on.choice:
if sel.use.parent.selection("tseic400") then
do.parent.selection(handle.selection.from.parent)

else
read.main.table(cprj.f, cprj.t)
endif

(..)

function long handle.selection.from.parent()
{
long ret

ret =
read.main.table(tseic400.cprj, tseic400.cprj)

return(ret)
}


You also need to mark/set the group of the selection fields in your sessions mask as linked to a parent table. This is done in the DFE in the properties of the group.
In my example cprj.j and cprj.t are placed in one group on the form. In the properties of this form you must select "Selection Group" and specify the parent table in "Table of Parent Session". This will automatically insert a dummy field in the DFE on top of the field list: sel.use.tseic400

I thinks that's all (at least I can't remember anything else that's needs to be done).

BaBernd
6th October 2016, 11:32
Hello Andreas,

it seems to be less code. But now I get the error as shown in the attached pdf-file during compilation: "function: 'read.main.table' returns no value.

Here my full code: maybe I've copied something in a wrong manner?

|******************************************************************************
|* Main table tccom600 Aktivit›¼äten, Form Type 4
|******************************************************************************

|****************************** declaration section ***************************
declaration:
table ttccom600 |* Activities


extern domain tccom.acty acty.f fixed
extern domain tccom.acty acty.t fixed

|* Includes *******************************************************************

#include <bic_dam>

|****************************** group section **********************************

group.1:
init.group:
get.screen.defaults()

|****************************** choice section ********************************

choice.print.data:
on.choice:
rprt_open()
if sel.use.parent.selection("tccom600") then
do.parent.selection(handle.selection.from.parent)
else
read.main.table(acty.f, acty.t)
endif
rprt_close()

|****************************** field section *********************************

field.acty.f:
before.zoom:
tccom600.acty = acty.f

when.field.changes:
acty.t = acty.f

field.acty.t:
before.zoom:
tccom600.acty = acty.t

|****************************** function section ******************************

functions:

function long handle.selection.from.parent()
{
long ret
ret = read.main.table(tccom600.acty,tccom600.acty)
return(ret)
}

function read.main.table(domain tccom.acty i.acty.f, domain tccom.acty i.acty.t)
{
select tccom600.*
from tccom600
where tccom600._index1 inrange {:acty.f} and {:acty.t}
order by tccom600._index1
selectdo
rprt_send()
endselect
}


Best Regards Bernd

bhushanchanda
6th October 2016, 12:52
ret = read.main.table(tccom600.acty,tccom600.acty)
This is causing problem as the function read.main.table() doesn't have any return type and hence is void.

Either replace it with

read.main.table(tccom600.acty,tccom600.acty)

Or modify your function as -

function long read.main.table(domain tccom.acty i.acty.f, domain tccom.acty i.acty.t)
{
select tccom600.*
from tccom600
where tccom600._index1 inrange {:acty.f} and {:acty.t}
order by tccom600._index1
selectdo
rprt_send()
endselect

return(0)
}

andreas.toepper
6th October 2016, 13:35
Yes, read.main.table(..) needs to return a value.
I've had some german explanation in my code but removed it prior to posting. ;-)


function long handle.selection.from.parent()
{
long ret

ret =
read.main.table(tseic400.cprj, tseic400.cprj)

|Die von do.parent.selection() aufgerufene Funktion
|muss Null zurückgeben, sonst wird abgebrochen!
return(ret)
}
{

BaBernd
6th October 2016, 14:40
Hello Bhushan, Hello Andreas,

thanks for reply. Now I can compile that script.
But during testing I've found:
1.) with no selected records the print mask will pop up and I can insert a range of activity numbers.
2.) with selected records in the parent session, if they are consecutive or not consecutive, then no printing mask will pop up and no printing is possible.

Do I have to add special programming for the second case?
Best Regards Bernd

andreas.toepper
6th October 2016, 16:08
When there a additional fields (i.e. options) on the print session, LN will present a form with the options fields in the second case.
Maybe LN will try to start the default option, when there are no additional fields present. I never had that one.

But in your pdf I can see, that you have not defined printing as default option on the third mask of the session details (options and field are named "Schaltfläche Voreinstellungen" in the german tools version; on mask 3 in ttadv2100s000 "Sessions"). I usually select print.data as default option and deactivate "Save + Exit" in the standard commands ("Speichern+Ende").

BaBernd
6th October 2016, 16:36
Hello Andreas,

I don't know how it works, but I did as you mentioned! And now the print mask will start and the report runs fine.

Thanks a lot to you and Bhushan.

Best Regards Bernd