batmush
18th January 2013, 23:02
Hi all,

I have a report based on tibom141001000 but in my report I want to suppress (not to print) the BOM line (sitm line) if alternative item exists for that sitm. So my script is like:

declaration:
table ttibom010
table ttiitm001
table ttiitm011

detail.1:
before.layout:

select tiitm011.*
from tiitm011
where tiitm011.item=:tibom010.sitm

selectdo
if tiitm011.aitm="" |this suppose to imitate having NULL
then lattr.print = true
else lattr.print = false
endif
endselect

** And then I have the lattr.print = true in "Output Expr." for "detail.1"

So it doesn't work and I think because tiitm011.aitm="" is not imitating having NULL or not alternatives for the specific sitm. I also tried the opposite way when setting lattr.print=false when tiitm011.aitm<>"" - same result.

Please help or give any hints. Thank you in advance.

bdittmar
19th January 2013, 11:44
Hello,

try with isspace

Or try :


select tiitm011.*
from tiitm011
where tiitm011._index1 inrange {:tibom010.sitm, ""}
and {:tibom010.sitm, "ZZZZZZZZZZZZZZZZ"}
|and not isspace(tiitm011.aitm)
as set with 1 rows
selectdo
lattr.print = false |don't print if record exists
selectempty
lattr.print = true |print, if no record exists
endselect




Regards

batmush
21st January 2013, 17:02
Bernd,

Thank you but is there a comment pipe in front of "and not isspace(tiitm011.aitm)"?

bdittmar
21st January 2013, 17:24
Bernd,

Thank you but is there a comment pipe in front of "and not isspace(tiitm011.aitm)"?

Hello,

yes, can be used as additional check for tiitm011.aitm is empty.
Without this line, the check is only, if alternative item for ...sitm exists.

Regards

batmush
21st January 2013, 18:19
Hi,

1. isspace is unknown command and not compiling
2. This is what I used but still not printing when no records

select tiitm011.*
from tiitm011
where tiitm011.item=:tibom010.sitm
as set with 1 rows
selectdo
lattr.print = false |don't print if record exists
selectempty
lattr.print = true |print, if no record exists
endselect

bdittmar
21st January 2013, 18:39
Hi,

1. isspace is unknown command and not compiling
2. This is what I used but still not printing when no records

select tiitm011.*
from tiitm011
where tiitm011.item=:tibom010.sitm
as set with 1 rows
selectdo
lattr.print = false |don't print if record exists
selectempty
lattr.print = true |print, if no record exists
endselect

Hello,

from progguide :

BaanERP Programmers Guide


isspace()

--------------------------------------------------------------------------------

Syntax
long isspace( string_expr )

Description
This tests whether the result of string_expr contains only spaces or is empty.

Return values
TRUE string is empty or contains only spaces
FALSE string is not empty and contains characters other than spaces

not isspace can't be used in where clause !

Regards

bdittmar
21st January 2013, 19:18
Hello,

in one of oure BIV system with alternative items this works :


select tiitm011.*
from tiitm011
where tiitm011._index1 inrange {:tibom010.sitm, ""}
and {:tibom010.sitm, "ZZZZZZZZZZZZZZZZ"}
as set with 1 rows
selectdo
aitm = "AA" |don't print if record exists, alt. item exists
selectempty
aitm = "NA" |print, if no record exists, no alt. item exists
endselect


See result in attachment.

AA ist printed when an alt. item exists (Alternative A)
NA ist printed when not (No Alternative)

Regards

batmush
21st January 2013, 19:57
I want to see it

batmush
21st January 2013, 20:58
And then what do you have in your "Output Expr." of that Detail?

batmush
21st January 2013, 21:15
Bernd,

where tiitm011._index1 inrange {:tibom010.sitm, ""}
and {:tibom010.sitm, "ZZZZZZZZZZZZZZZZ"}

how does it check if particular sitm has alternative item(s)?

Maybe I was not clear from the beginning - I want to print the sitm line only when this sitm doesn't have Alternative.

Anyway the code is not working for me - not printing all the lines now regardless if there is Alternative exists.

mark_h
21st January 2013, 23:07
** And then I have the lattr.print = true in "Output Expr." for "detail.1"


From reading thru this thread I think this would work, but first you have set your output expression for the layout to 1. Then add this code in the script:

detail.1:
before.layout:
select tiitm011.*
from tiitm011
where tiitm011._index1 = {:tibom010.sitm}
as set with 1 rows
selectdo
lattr.print = false |Skip if alt item exists.
selectempty
lattr.print = true |Print if no alt item exists.
endselect

mark_h
21st January 2013, 23:23
Oops forgot to add this is basically what Bernd posted. Just a little different and you have to change that output expression.

batmush
22nd January 2013, 05:13
Hi all,

Thanks to Gurus it works now!

This "first you have set your output expression for the layout to 1" did the job. I had lattr.print=true and it didn't work.

Thank you again

batmush
26th March 2013, 21:31
Hi again,

The issue still exists if the report has more than 1 page. How the code depends on page number? This is what I have so far:

declaration:
table ttibom010
table ttcmcs015
table ttiitm001
table ttiitm011

header.2:
before.layout:
select tiitm001.item, tiitm001.ctyp
from
tiitm001
where
tiitm001.item=:tibom010.mitm
selectdo

message(tiitm001.item)
select tcmcs015.*
from tcmcs015
where
tcmcs015.ctyp=:tiitm001.ctyp
selectdo
endselect
endselect

detail.1:
before.layout:
select tiitm001.cuni
from
tiitm001
where
tiitm001.item=:tibom010.sitm
selectdo
endselect

select tibom010.*
from
tibom010
where
tibom010.mitm=:tisfc001.mitm and
tibom010.sitm=:ticst001.sitm
order by tibom010._index2
selectdo
endselect

select tiitm011.*
from
tiitm011
where
tiitm011.item=:tibom010.sitm
selectdo
endselect

select tiitm011.*
from tiitm011
where tiitm011._index1 = {:tibom010.sitm}
as set with 1 rows
selectdo
lattr.print = false |Skip if alt item exists.
selectempty
lattr.print = true |Print if no alt item exists.
endselect


plus the "tiitm011.item = tibom010.sitm or tibom010.txta <> 0" in Detail Output Expr.

mark_h
26th March 2013, 22:01
Should not have anything to do with page number. I would set the output expression to 1 and see what happens - because the alternate item check should not print the expression if that is true. Then add the output expression back in as it was - see if there is a difference. You might have to debug it to check each step to see where the issue is.