Hi,
I have written a program in which it outputs customer account details to a text file, so I can then create a crystal report from it. The problem I am having, is that some of the data within the text file seems to be duplicated. I,e.
"14","North & South Yorkshire","T291","","NG30 9BF","UNIT 1","WOODLAND CLOSE","HIGHAM"
"14","North & South Yorkshire","T291","","NG30 9BF","UNIT 1","WOODLAND CLOSE","HIGHAM"
"14","North & South Yorkshire","T291","","NG30 9BF","UNIT 1","WOODLAND CLOSE","HIGHAM"
"14","North & South Yorkshire","T291","","NG30 9BF","UNIT 1","WOODLAND CLOSE","HIGHAM"
This would get displayed when I only want it to be displayed once. Could it have something to do with the way im outputting the data in my program? The current way I am doing it is: -
FOR EACH ttdeliveryarea:
EXPORT STREAM details DELIMITER ","
ttdeliveryarea.delivery_code
ttdeliveryarea.delivery_description
vch-sl_code
IF AVAILABLE oa_customer THEN oa_customer.NAME ELSE ""
ipch_postcode
sl_branch_address1
sl_branch_address2
sl_branch_address3.
Anyhelp would be much appreciated, I'm pretty sure this is quite an easy problem to fix but have a deadline to meet which is why I'm stuck.
Thanks.
Hi,
The code you posted (although limited) seems fine. It seems that you are looping through a temp-table (ttdeliveryarea)... are you sure the temp-table does not have duplicate records in it to start with?
Stupid question I know but one that needs to be asked.
Philip
Hi,
Thank you for your reply,
Ive checked my temp table in definitions and everything seems ok. Im quite new to prgress so apologise if this sounds like a stupid question. The table is set as follows:
DEFINE TEMP-TABLE ttDeliveryArea LIKE delivery_area.
/
DEFINE VARIABLE vch_trimAddress AS CHARACTER NO-UNDO.
DEFINE VARIABLE vin_CheckCount AS INTEGER NO-UNDO INITIAL 0.
DEFINE VARIABLE vin_CheckDigit AS INTEGER NO-UNDO INITIAL 0.
DEFINE VARIABLE vch_PostArea AS CHARACTER NO-UNDO INITIAL "".
DEFINE TEMP-TABLE tt_deliveryArea NO-UNDO
FIELD delivery_code LIKE delivery_area.delivery_code
FIELD delivery_Description LIKE delivery_area.delivery_description
FIELD coll_comp_number LIKE coll_comp_header.coll_comp_number
FIELD coll_comp_line_no LIKE coll_comp_detail.coll_comp_line_no
FIELD collection_date LIKE coll_comp_header.collection_date
INDEX IND_deliveryArea IS PRIMARY UNIQUE
coll_comp_number
coll_comp_line_no.
Is there something I can do within there to stop it duplicationg the data?
Thanks
Hiya,
Your temp-table definitions look fine as well... how do you populate the temp-table with data though? There could be a problem there... post the code or something similar and we'll have a look...
Philip
Actually, on second thought I noticed that you have...
DEFINE TEMP-TABLE ttDeliveryArea LIKE delivery_area.
as well as...
DEFINE TEMP-TABLE tt_deliveryArea NO-UNDO
FIELD delivery_code LIKE delivery_area.delivery_code
FIELD delivery_Description LIKE delivery_area.delivery_description
FIELD coll_comp_number LIKE coll_comp_header.coll_comp_number
FIELD coll_comp_line_no LIKE coll_comp_detail.coll_comp_line_no
FIELD collection_date LIKE coll_comp_header.collection_date
INDEX IND_deliveryArea IS PRIMARY UNIQUE
coll_comp_number
coll_comp_line_no.
I'm assuming that you don't have both in the same program as that will throw a compile error. On a side note, you might not need the second DEFINE TEMP-TABLE statement mentioned above if you are using the first one. The first one encompass all the fields automatically by saying LIKE delivery_area.
The second temp-table is unfortunatly being used by another procedure within the program, otherwise I would just dismiss it. Its proving to be a bigger pain than I thought as it generates a 350page report instead of a 130pages which it is supposed to do.
Sorry, im probably not giving you a great deal in order for you to help me, ive tried quite a few things but seems to be giving out the same output. Is there anything I could put within the temp-table to stop the repetition?
Hi Kevin,
It is very difficult to tell you what the problem is without knowing how you populate your temp-table(s) with data as the problem will most likely be there rather than anywhere else. If you could post some more code that would be usefull...
One thing you can do to see where your problem is, is to add a unique index on the temp-table on a field or combination of fields that you know must be unique. This should then throw some errors when you run it and hopefully point you in the right direction. If it doesn't, then the error is likely to be in the way that you output the data to file rather than populating the tt with data.
Once again, if you can post some more complete code then we'll have another stab at it...
Hope this helps
Philip
You could specify a unique index in the temp-table, but if you do and the current code is populating it with multiple records, that will just get you a run-time error. What you really need is to add a check at the point where records are created to see if the record is already there.
Thanks for your reply, much appreciated. I have attached the program itself, I've began to think that maybe I've got a section trapped in a loop and that maybe why its repeating the data. If you could please have a quick look at the program and see if any obvious mistakes have been made, id be very much obliged.
Thanks.
I had a quick look at the code and one thing that stands out is the EMPTY TEMP-TABLE ttdeliveryarea statement. Are you sure this is in the right block?
Maybe it should move to just inside the main FOR EACH block OR just inside the IF vlo-found = FALSE THEN... block
Have a look.... give it a go.... and let me know.
HTH Philip
Yeah putting EMPTY TEMP-TABLE ttdeliveryarea within the vlo block worked perfectly thanks Phil. Cheers for your help, was driving me abit crazy. So Im guessing the problem that I was having, was that I was emptying the temp table before it went and actually outputted the data within the block. Is that right?
Thanks again.
No worries Kevin! An easy mistake to make... just glad I could help!
Yeah, the reason you got the duplicate records is because you were not emptying the temp table in the right place which meant that duplicate data was being created and in return caused duplicate output!
Regards,
Phil
Hi again Phil,
Sorry to be a pain, but just one more question. As I try and display a report from the screen menu, the screen flashes every couple of seconds as if its in a loop. The code I added to the program was: -
IF VALID-HANDLE( hdlPrint ) THEN RUN CloseProcedure IN hdlPrint NO-ERROR.
RUN prog_senatordb/senator_routines/print.w PERSIST SET hdlPrint NO-ERROR
( "reports\DeliveryAreaAccounts.RPT",
"",
"" ).
Any help would be great.
Thanks,
Kev
Hiya,
I'm not exactly sure what print.w does... I assume it brings up a print window so that you can print the data you exported earlier. If this is the case then you might not want to do that inside any of the FOR EACH blocks as this could cause the screen flashing that you currently experience.
I would recommend adding an OUTPUT CLOSE. statement after the main FOR EACH block and then after that I would add the code you mentioned before...
IF VALID-HANDLE( hdlPrint ) THEN RUN CloseProcedure IN hdlPrint NO-ERROR.
RUN prog_senatordb/senator_routines/print.w PERSIST SET hdlPrint NO-ERROR
( "reports\DeliveryAreaAccounts.RPT",
"",
"" ).
Once again, I don't know if this would work as I don't know what print.w does but it seems a likely cause of your problem.
HTH
Philip
Hi Phil,
That worked great, again, thank you for your help.
Kev