Is there a way to do this. I tried num-entries but i couldn't get it to work.
I want to detect in my report if one of my varables have multiple values adn if they do i want to concatenate them onto the previous field.
We are missing a little information...
How are the multiple values delimited?
Did you specify the delimiter when trying num-entries?
What didn't work?
Possibly a sample of what it looks like with multiple values?
yeah my bad i posted this right before i left work yesterday i was in quite a hurry. But here's my problem, i think im going about it the wrong way. I'll explain it and see if you guys could help me out a little.
OK there's these two tables I'm using for a work order report.
one is Called 3C's (keeping it generic) it has values like 1Cause 2Complain 3Correction.
and another table where it stores the comments.
FOR EACH FDCBCPP WHERE FDCBCPP.CBVENB = FDBMCPP.BMVENB NO-LOCK.
FOR EACH FDGYREP WHERE FDGYREP.GYPHNB = FDCBCPP.CBPHNB
And FDGYREP.GYUASU = FDCBCPP.CBUASU No-Lock:
/* This is going through all the Cause and so on and the comments for each one*/
/* This Adds What 3c the comment is from */
CASE FDCBCPP.CBE0CE:
WHEN "1COMPL" THEN
ASSIGN Var3c = "Complaint".
WHEN "2CAUSE" THEN
ASSIGN Var3c = "Cause".
WHEN "3CORR" THEN
ASSIGN Var3c = "Correction".
END CASE. /* case FDCBCPP.CBE0CE */
IF rep-warrantyaudit.WarrantyClaim3C = "" THEN
rep-WarrantyAudit.WarrantyClaim3C = "".
ELSE
rep-WarrantyAudit.WarrantyClaim3C =
rep-WarrantyAudit.WarrantyClaim3C + "~n".
/* Creates the string for the comment then adds on to it for each warranty claim number */
rep-WarrantyAudit.WarrantyClaim3C =
rep-WarrantyAudit.WarrantyClaim3C + " " + Var3c + " " +
FDGYREP.GYBTNA + "~n".
END. /* end FDGYREP */
END.
For each of our FDCBCPP.CBE0CE they have comments of cause complain and correction. Well some of them have two comments and some have one.
this prints out in report builder like this.
cause comment
complain comment
complain comment (what ever was cut off from the last complain comment)
correction comment
and what i was looking to do was if there are multiple comments for that field to do this
cause comment + other comment if multiple
complain comment + other comment if multiple
correction comment + other comment if multiple
Just at a glance, it looks to me like you need to initialize the string outside the comment loop and then add the comments to the end of it.
here's what i did to fix it
FOR EACH FDCBCPP /* Warranty Claim Reason / WHERE FDCBCPP.CBVENB = FDBMCPP.BMVENB /Waranty claim number*/ NO-LOCK.
CASE FDCBCPP.CBE0CE:
WHEN "1COMPL" THEN
ASSIGN Var3c = "Complaint".
WHEN "2CAUSE" THEN
ASSIGN Var3c = "Cause".
WHEN "3CORR" THEN
ASSIGN Var3c = "Correction".
END CASE. /* case FDCBCPP.CBE0CE*/
FOR EACH FDGYREP WHERE FDGYREP.GYPHNB = FDCBCPP.CBPHNB AND
FDGYREP.GYUASU = FDCBCPP.CBUASU BREAK BY FDGYREP.GYPINB.
WarrantyClaim3C = WarrantyClaim3C + " " + FDGYREP.GYBTNA.
IF LAST(FDGYREP.GYPINB) THEN
DO:
ASSIGN rep-WarrantyAudit.WarrantyClaim3C = rep-WarrantyAudit.WarrantyClaim3C + "~n" + Var3c + " " + WarrantyClaim3c.
WarrantyClaim3C = "".
END.
END.
END.
Thanks for the help you guys
A couple more comments for the future:
When posting code, it is handy to use and (without the spaces) around the code to preserve indention for readability, e.g.,
Also, I always get a little nervous when I see a case without an otherwise.
And, you don't really need the last of since you could just put the finish logic below the loop where you are collecting the comments.
Oh thanks i kept trying "" and and i couldnt figure it out. THanks for telling me its pre.
Also yeah i know i didnt use an otherwise only reason i didn't was because there's only 3 diff type of fields in that record, but i will keep that in mind.
So without the last of it should still work? i was having some crazy problems with it. Our enrich DB's structure i hate it haha. But yeah Tom thanks for the advice.
What I was suggesting is that you have an outer loop where you do the case statement an initialize the variable and then an inner loop where you accumulate the comments. After you fall out of the inner loop, then you have the category variable and the comment variable and you can compose your message. No need for last of because when you fall out of the loop you know you are done. And, for robustness, this also makes it easy to blank out the place where you are composing the comments before the inner loop and then to test after the loop whether there is anything there and do what you want if it turns out the comments are blank.
yeah that would have made more sense, it was a long day haha and im in my early days of progress and been working on this warranty auditing system for quite some time now. A little more than i would have liked haha.
It's just something i will probably learn in due time. I mean i learned the basics of progress in about under a week. I never even heard of progress until i got this job 4 months ago right out of college. So 19 years old doing progress and 20 now, i got many years ahead of me to learn :).
Once again thanks for your advice, its people like you who i believe help me become a better developer over the time.
Well, thanks. Glad to be of help.