Report by Programming problems in WD17

Startbeitrag von Yogi Yang am 18.11.2014 07:39

Hello,

I am want to print the contents of the attached window to a report through programming as I am using WebService for accessing data on a remote server it is not possible to bind report to data source.

For this I tried as per Uncle Pete's Corner article: http://www.thenextage.com/wordpress/hand-coded-windev-reports/

But still no result. I keep getting infinite pages (when I return TRUE in Data Read Event) but if I return FALSE I get the message No Data To Print. What to do?

Finally how to repeat the content of the grid in the window in report? I am asking this as I cannot add a table control to the Report. How can I repeat a few controls as per contents in attached Window snapshot in Report's Body band?

Please help solve this.

TIA

Yogi Yang
[attachment 1246 2014-11-18_125632.jpg]

Antworten:

Hi Yogi,

This is possible but will ask you some cleverness and patience. This is always a little bit tricky the first time you try to make a report with a programmed source.

I do not have time to write a small how-to here, but I will simply point you to, yes, the documentation... sorry for that: http://doc.windev.com/en-US/?1011034

This page contains all the details you need (really), and there is a small project example. (Maybe it was available in WD17?) Take the time to read and experiment with a simple test case. Then once you will get the trick you will be able to implement it very quickly.

Quickly, in the "Data read event" you must return True when you want to print a line of data, and False end the report. Then in the "Filter event" you can discard a record or not. In the Report's Description, you can check the "Print report and do not display message" option in the HMI tab. This will print an empty report with no message. This can happen in some cases (no detail record, but main page must be printed any-way).

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 18.11.2014 21:40
Hi Yogi

I read what Uncle Pete's said on his page. Indeed this is how it can be done. However you can link to a querie and add aditional programming as well. I do that all the time and it works great

I made some reports with data form up to 6 files this way . Just sent parameters to the report and use the parameters to lookup stuff. It work like a charm.

You talk about a webservice. And because you use a webservice you cannot use files.

OK here goes

I guess you imported the data form the webservice otherwise you culd not have filles the table
In reports it work a bit the same. you can connect to the websevice the same way. or you can use the results from the webservice in the report. if they are global.

You could try adding the resuls of the webservice to an arry and use the arry to fill the table?

Just some of my thought onthis

Regards
Allard

von Allard - am 19.11.2014 00:52
@Alexandre,

Thanks for the link but I could not understand anything from there.

Yet I am trying hard to understand as to who to actually use this feature.

Thanks,

Yogi Yang

von Yogi Yang - am 21.11.2014 07:08
Hi Yogi,

As I said earlier it is verry similar then to programm a screen. Have you made reports by programming in the past without the data comming from a webservice?

If not then you are trying to solve several issues at one time, and that would mke things more complicated for you.

Ok a quitck and dirty way to create a report is to save the data of your screen to a file first . Then use the file to fillup the report. ( for the main table ) and use programming to get the values for
-customer
-date
-Salesnumber

Ok it is indeed possible to add a table to you report.:

Start a new report with the type of report:
Table ( prints tablerow for each data red)
link to en embeded querie made from file whare you saved your webservice data
Add as a a break Salesnumber

Ok then the report will be crated for you. In the break header you can add items like customer and date. In the page footer or end of document you can add the vat related fields

You have to add a parameter to the report to get the record of one salesnumber
in the opening of the report place a procedure with that parameter

Procedure rpt-reportname ( gnSalesnumber)
in the print butto on you screen add:
Ipreview()
Iprintreport(rpt-reportname, edt_salesnumber) edt salesnumber is the parameter you are going to sent

In the report go to discription and make a query embeded. Add a parameter to the querie a parameter for salesnumber. The querie is based on the file where you save your webservice data. (You use a querie so you are able to filter the data)

If you you do a print preview you will now see the data of the table. The other items not yet . IThe client name can have and id if you bind that field ( I f you onley have an ID in your querie)

So you have to do that by programming.

Do a Hreadseek() on your customer file with the ID that is in the querie. This code can be written in the report code.

Remais the vat related stuff if you added these values per row to the file as well then you can let the report do a summ on them

Well this is how it can be done. Maybe I made a little mistake, or missed something, for I write this without actually doing it but the moast parts are covert.

Hope this helps

Regards

Allard

von Allard - am 21.11.2014 09:49
Hi Yogi,

Almost all our "document" reports are based on this programming technique. As I said, the first one is a bit "hard" to get but once you understand this is very easy.

Please, take a look at the "Related examples" at the bottom of the help page. Open it and see how they do it. This might help you further.

Hope this helps and best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 21.11.2014 13:39
@Allard,

Thanks for the information. Currently I have managed to layout the report and in the case where we have to repeated controls I have Clones them and populated them with data. Of course this is a very length way but I have to complete the job so here is a small (non professional) sample of what I have coded

//Record previous controls position and calculate new controls locations
nControlPosXSr = {sControlNameSr}..X
nControlPosYSr = {sControlNameSr}..Y + {sControlNameSr}..Height
nControlPosXDescription = {sControlNameDescription}..X
nControlPosYDescription = {sControlNameDescription}..Y + {sControlNameDescription}..Height
nControlPosXQty = {sControlNameQty}..X
nControlPosYQty = {sControlNameQty}..Y + {sControlNameQty}..Height
nControlPosXRate = {sControlNameRate}..X
nControlPosYRate = {sControlNameRate}..Y + {sControlNameRate}..Height
nControlPosXAmount = {sControlNameAmount}..X
nControlPosYAmount = {sControlNameAmount}..Y + {sControlNameAmount}..Height

{sControlNameSr} = nControlCount
{sControlNameDescription} = sSbdItemName + (Length(NoSpace(sSbdDescription)) > 0 ? " - " + sSbdDescription ELSE "")
{sControlNameQty} = rSbdQty
{sControlNameRate} = NumToString(cySbdRate, "10.2f")
{sControlNameAmount} = NumToString(cySbdAmount, "10.2f")
//Enlarge Boday area as per number of controls
BODY..Height = {sControlNameAmount}..Y + {sControlNameAmount}..Height

Above code is in Data Read

I will try to understand as to how the programmable report is working once I complete this assignment on hand.

TIA

Yogi Yang

von Yogi Yang - am 21.11.2014 15:59
Hi Yogi

You are looking at this as way to big a problem .If you want something repeated in a windeow you use a table not a cloning of and edt control , well the same applies here.

Really look at my explination . It can be done in about half an hour or so . You have to look at it the windev way and use the tools that are availeble. Cloning controls is not the way to go in my honest opinion.

Just try to do the stepts I explained it is really not that difficult. try the steps and if something isnot working ask about that perticular step and I will try to give you a more detail explination.

regards

Allard

von Allard - am 21.11.2014 16:57
@Allard,

Thanks for your help.

I will start as per your guidance and as I proceed if I do run into any problems I will surely post here on this thread.

TIA

Yogi Yang

von Yogi Yang - am 24.11.2014 10:34
Ok,

No Problem If I can be of help I am glad to help.

regards Allard

von Allard - am 25.11.2014 15:03
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.