Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limiting the size of a string variable 1

Status
Not open for further replies.

martinjt

Technical User
Aug 1, 2008
34
US
Using CR vers 9.2.2.693

I have the following formula:

WhilePrintingRecords;
StringVar last3actscom;
last3actscom := last3actscom+"|"+ {V_ACTIONS_MM.ACTCOMM}

The problem is that the field {V_ACTIONS_MM.ACTCOMM} can be very many characters long which would make the string variable over the limit of 65,534 characters.

How do I limit this variable so it will only do while the length is allowable? By the time it gets that long I don't need the data so ok to stop the loop at that limit. But how is this done? I'm imagining something like this somewhere in the formula:

while length(last3actscom)<65534 do last3actscom

but no matter where I put it, I keep getting the processing error: a string can at most be 35534 characters long.

Any help on this would be greatly appreciated. Thanks.
 
Hi,
Where have you placed that formula? In other words where is the concatenation taking place - with a large character field, it would not take many iterations to exceed the max length.

Try placing a limiting test like this:
Code:
WhilePrintingRecords;
StringVar last3actscom;
If  length(last3actscom)<65534 
Then
last3actscom :=  last3actscom+"|"+ {V_ACTIONS_MM.ACTCOMM}
Else
last3actscom := last3actscom


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks. It is in the details section and is the accumulation formula for a string that is then parsed based on the placement of the "|" into sections in the group footer. The formula is reset in the header.

I tried your formula and encountered the same error message.
 
Try:

WhilePrintingRecords;
StringVar last3actscom;
If length(last3actscom+"|"+{V_ACTIONS_MM.ACTCOMM})<65534
Then
last3actscom := last3actscom+"|"+ {V_ACTIONS_MM.ACTCOMM}
Else
last3actscom := last3actscom

-LB
 
Hi,
Nice catch LB, the test should be of the concatenated value not the existing one.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Unfortunately that doesn't work either. I have even tested for an individual record to see if somehow one of them was over the character limit and that wasn't the case. I'm studying the while do loop and will keep trying. Thanks anyways you two!
 
Hi,
When and where does the error appear? Does it show a line or line number?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Run-time error. It shows the 1st iteration or encounter of the field {V_ACTIONS_MM.ACTCOMM} for the first record on the report. I've used different eval times, I've used a bare bones report, while do loops ..nothing. I'm beginning to think it is a bug. The data appears ok.
 
Please show the exact formulas you are using for resetting, accumulating, and displaying and identify in what report sections you are placing them. Also identify the exact error message. Can the field ever be null?

-LB
 
//reset_actcomment
WhilePrintingRecords;
StringVar last3actscom :=""

//This is in group header #1. Group is based on record ID #. There are null (none) or multiple comment rows per record ID.


//accum_actcomment
WhilePrintingRecords;
StringVar last3actscom;
If length(last3actscom+"|"+{V_ACTIONS_MM.ACTCOMM})<65534
Then
last3actscom := last3actscom+"|"+ {V_ACTIONS_MM.ACTCOMM}
Else
last3actscom := last3actscom

//This is in the details section.


//show_actcomment
WhilePrintingRecords;
StringVar last3actscom;
If Len(last3actscom) <> 0 Then
Right((last3actscom),(Len(last3actscom)-1))
Else
last3actscom

//This is in group #1 footer. It is then parsed into 3 comment fields. The data is sorted in descending date order so that the last 3 comments per record are listed in a flat file.

Once you click on ok after the error message, it takes you to the accum_actcomment formula formula editor.

The exact error message is:
! A string can at most be 65534 characters long.

This same formula structure is used for other, shorter stringed fields such as the date of the action, type of action, etc. Just the comment field causes this trouble as it is lengthy.

But just so you know, no comment field for any record has more than 2,886 characters. The total number of characters for that field for the entire report is 155,892 and the add'l "|" probably adds another 1000 chars on top of that.
 
Not sure if this will do it, but try:

//accum_actcomment
WhilePrintingRecords;
StringVar last3actscom;
If not isnull({V_ACTIONS_MM.ACTCOMM}) and
length(last3actscom+"|"+{V_ACTIONS_MM.ACTCOMM})<65534 Then
last3actscom := last3actscom+"|"+ {V_ACTIONS_MM.ACTCOMM}Else
last3actscom := last3actscom

-LB
 
I will. Thanks! I have to come back to this next week as I have other commitments. Will let you know.
 
Thanks lbass! This is working well. The report got further complicated and needed additional grouping. Once I placed the accum formula in the right spot I got the desired result.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top