pjohns
7th October 2002, 14:45
I want to select a report based on the current baan company that the user is logged in to and I'm having trouble knowing how to create the program script behing my choice button.

My logic is:-
if in company 501 then use AA report
if in company 502 use BB report
if in company 503 use CC report
else display message "Non valid company......"

I am using the get.compnr function which is attributed to the variable 'comp'.

I'm presuming that I need to use the CASE function.

Regards

PJ

P.S. Please go easy on any expalnations as I'm new to programming.

BIGFATDAVE
7th October 2002, 14:58
Try using brp.open, brp.ready, brp.close within "if" statement
as in
if <compno> = 100 then
pointer = brp.open(report1...)
else
if <compno) = 101 then
pointer = brp.open(report2...)...etc

then, to release record to sort
brp.ready(pointer)

and to close report
brp.close(pointer)

the exact syntax can be seen in the prog. manual.

Any questions, plz. feel free to e-mail me,

Cheers,
BIGFATDAVE

mark_h
7th October 2002, 15:41
Or you can set the reports up by report group. Report group 1 could have company 501 reports, report group 2 could have company 502 reports, etc. Then in the before.program section you can set your report group.



before.program:
on case get.compnr()
case 501:
reportgrp = 1
break
case 502:
reportgrp = 2
break
......
endcase

pjohns
7th October 2002, 16:43
Thanks for your replies.

I've tried the CASE route. Below is an extract from my script. The script compiles okay but when running the session and pressing my option button the case "default" is always returned. This happens when running in all valid companies. (501, 502, 503 anf 509) Can you guys see anything obviously wrong with this?



choice.user.2:
on.choice:

comp = get.compnr()
long ret
long company
domain tcmcs.s256 url

#pragma used dll ottdllbw

on case company

Case 1:
comp = 501
url = "http://teenet/SSG/docs/Singular_NCDR_Report_final.rpt "
ret = app_start(url, "", "", "", "")
break

Case 2:
comp = 502
url = "http://teenet/SSG/docs/Singular_NCDR_Report_final_502.rpt "
ret = app_start(url, "", "", "", "")
break

Case 3:
comp = 503
url = "http://teenet/SSG/docs/Singular_NCDR_Report_final_503.rpt "
ret = app_start(url, "", "", "", "")
break

Case 4:
comp = 509
url = "http://teenet/SSG/docs/Singular_NCDR_Report_final_509.rpt "
ret = app_start(url, "", "", "", "")
break

default:
Message ("Baan NCDR's not valid is this company")

endcase



Thanks

PJ

mark_h
7th October 2002, 16:51
Well your case statement is for comp and yet you set company = get.compnr(). So you need to get them to use the same variable.

Try this:


choice.user.2:
on.choice:
long ret
long company
company = get.compnr()
....
on case company
.....



Mark

pjohns
7th October 2002, 20:21
Mark,

Thanks for coming back to me. After I sat and read your first reply, properly this time, I realised what I needed to do.

It all works fine now.

Thanks

PJ