pegaga1979
16th January 2019, 06:46
Hi,

I have create query to print bom multilevel, but the data display is jump.
i wanted to display like this:
ItemA |1. | ItemB
ItemA |1. | ItemC
ItemA | 2. | ItemD
ItemA | 2. | ItemE
ItemA | 3. | ItemF
ItemA | 4. | ItemG
ItemA | 5.| ItemH
ItemA | 3. | ItemI

But resulted:
ItemA | | ItemB
ItemA | | ItemC
ItemA | | ItemE
ItemA | | ItemI

My script is as below:

declaration:

table ttibom010




detail.1:

after.layout:
select tibom010.*
from tibom010
where tibom010.mitm=:tibom010.sitm
selectdo
layout.again()
selectempty
endselect



Does anyone can help me how i can print the right report?
Your help is very much appreciated.
Thank you.

mark_h
16th January 2019, 16:11
Is there more to this script? I guess if what you posted works then you could just add some kind of sort to the tibom010 select.

pegaga1979
17th January 2019, 02:21
Hi Mark,

my main query as below:

select
tibom010.exdt, | Expiry Date
tcibd001.item, | Item
tcibd001.citg, | Item Group
tibom010.pono, | Position
tibom010.sitm, | Item
tibom010.qana, | Net Quantity
tibom010.cwar, | Warehouse
tibom010.indt | Effective Date
from
tcibd001, | Items - General
tibom010 | Bill of Material
where
tcibd001.item >= tcibd001.item.f and
tcibd001.item <= tcibd001.item.t and
tcibd001.citg >= tcibd001.citg.f and
tcibd001.citg <= tcibd001.citg.t and
tcibd001.item = tibom010.mitm


my report script:

declaration:

extern domain tcdate today
domain tcdate expdate
domain tcmcs.long no.of.days

long lng.ddta
long lng.dtim
long lng.cdat
long lng.ctim

table ttibom010
|extern domain tcbool print.lay

before.program:
today = utc.to.local (utc.num (), lng.ddta, lng.dtim)


detail.1:
before.layout:

expdate = utc.to.local (tibom010.exdt, lng.cdat, lng.ctim)
no.of.days = lng.cdat - lng.ddta

if no.of.days > 0 then
lattr.print = true

else lattr.print = false
endif



can u help me where i'm missing?

mark_h
17th January 2019, 17:04
Now I am really confused. The first post shows a layout again and the second post has nothing like that in the report script. So if I go off the second post my first question would be does that main query (assuming from session script) return all the records you are looking for?

bdittmar
17th January 2019, 17:31
[QUOTE=pegaga1979;211400]Hi,

I have create query to print bom multilevel, but the data display is jump.
i wanted to display like this:
ItemA |1. | ItemB
ItemA |1. | ItemC
ItemA | 2. | ItemD
ItemA | 2. | ItemE
ItemA | 3. | ItemF
ItemA | 4. | ItemG
ItemA | 5.| ItemH
ItemA | 3. | ItemI

In print BOM structure , this is the BOM Level, where the item is found (eg).
1 - sitm has own BOM
.2 - sitm at Level 2 has own BOM
..3 - component (sitm)
..3 - component (sitm)
..3 - component (sitm)
.2 - next sitm at BOM Level 2
.2
.2
1
.2
..3
..3
.2
1

This can't be realized with easy SQL.

The stucture in Report must be drilled down by BOM Level
On lower BOM Level, sitm become mitm.

Regards

pegaga1979
21st January 2019, 02:35
Now I am really confused. The first post shows a layout again and the second post has nothing like that in the report script. So if I go off the second post my first question would be does that main query (assuming from session script) return all the records you are looking for?

Hi Mark,
Apologize because missing the bottom script.
Below is the complete code.


declaration:

extern domain tcdate today
domain tcdate expdate
domain tcmcs.long no.of.days



long lng.ddta
long lng.dtim
long lng.cdat
long lng.ctim

table ttibom010
|extern domain tcbool print.lay



before.program:
today = utc.to.local (utc.num (), lng.ddta, lng.dtim)


detail.1:
before.layout:

expdate = utc.to.local (tibom010.exdt, lng.cdat, lng.ctim)
no.of.days = lng.cdat - lng.ddta

if no.of.days > 0 then
lattr.print = true

else lattr.print = false
endif



after.layout:
select tibom010.*
from tibom010
where tibom010.mitm=:tibom010.sitm
selectdo
layout.again()
selectempty
endselect

mark_h
21st January 2019, 14:59
This is the part that confuses me"

after.layout:
select tibom010.*
from tibom010
where tibom010.mitm=:tibom010.sitm
selectdo
layout.again()
selectempty
endselect

Everytime you hit this section of code you are going to get the first record for what ever is in subitem - assuming it is a make item. So each time you hit it only if the subitem is a make will you get the first item on the BOM. Then the when the subitem becomes a purchase part then you will go get the record the next record on the report. Since I am not sure exactly what you are trying to do I ca't really make suggestions. If you are trying to read an indented bom then I do not know of how to make this work without replicating everything in printing indented boms in the report.

pegaga1979
24th January 2019, 02:54
Hi Mark,

At this moment, I just want to all multilevel bom is printed in report. The dot (to identify the level) is my next stage of report design :)

mark_h
24th January 2019, 18:20
I am just not sure you can achieve this thru a report script. My BOM explosion programs are do a whole lot to decide what to pass to the report. It uses an array of item to determine where it is at in the Bill of materials. If you need something to print an indented bill there should already be some reports in LN. Then depending on what you want to do with the output you can modify those reports.

Han Brinkman
4th February 2019, 15:37
Since the 4GL language of baan doesn't support recursive programming you need a few arrays to do keep the status of the last line which you handled and come back after you handled the next level of the bom.
That is the way to make it work for all levels.
If that's to complex: you can use different functions to handle each level. However if you have to handle a lot of levels than you wil have to copy a lot of functions ;-)

vamsi_gujjula
4th February 2019, 20:59
Since the 4GL language of baan doesn't support recursive programming you need a few arrays to do keep the status of the last line which you handled and come back after you handled the next level of the bom.
That is the way to make it work for all levels.
If that's to complex: you can use different functions to handle each level. However if you have to handle a lot of levels than you wil have to copy a lot of functions ;-)

I think baan does allow recursion as long as the function doesn't have argument.

Han Brinkman
5th February 2019, 12:32
Vamsi, looks like you are correct, checked it with a little script.

hklett
6th February 2019, 22:18
Its also not allowed to have local variables.
So you have to handle this by global arrays.
With this restrictions the recursive call of functions doesnt help much.

avpatil
12th February 2019, 18:23
Looks like you want to print multilevel BOM but don't want to show items at intermediate level. If you are running this at one top level item at time, then it is very straight forward Take a standard Baan BOM report and just show the main item, current item and show item of current level. Levels are already being calculated by Baan. I think it should be fairly simple to do.