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!

a question about string arry and split

Status
Not open for further replies.

juku

IS-IT--Management
Jul 26, 2012
2
CH
Hi together

I have a database field (varchar2) with "n" entry's ( like "00340383920026147139/ 00340383920026147146/ 00340383920026147153/ 00340383920026157153")
The delimiter is "/ "
and the formula is
stringvar array x := split({mydatabase.field},"/ ");
stringvar z := "";
numbervar y;
for y:=1 to ubound(x) do(
z := z+ "" + x[y]+chr(13);
);
z;
That give me back
00340383920026147139
00340383920026147146
00340383920026147153
00340383920026157153

when i try the get it back as a barcode like code39, i get back the following
"00340383920026147139
00340383920026147146
00340383920026147153
00340383920026157153"
it's a long string with line breaks
but i need something like
00340383920026147139
00340383920026147146
00340383920026147153
00340383920026157153
with out line breaks

any idea to realize that with crystal 2008 ?

Thanks in advance

 
Then I am confused why you are adding in a chr(13) (line break) into the string?!?
 
Hi juku

The reason this is happening is because the result of your formula is still a single field with multiple values, but instead of being sparated by a slash they are separated by a carriage return.

The way to achieve this would be to use a table that has at least as many rows as the maximum number of values you would encounter, and extract the nth value from the string based on the nth record number. Place thie following formula in the detail section:

If RecordNumber <= Ubound(Split({table.field}, '/'))
Then Trim(Split({table.field}, '/')[RecordNumber])

To limit the rows returned to the number of items in the field, use thise Group Selection formula:

RecordNumber <= UBound(Split({table.field}, '/'))

This would give you a separate detail line line for each number, and therefore the bar codes would also be separated.



Hope this helps.

Cheers
Pete.
 
thanks pmax9999

I put it in the detail section of the crystal report .

Now i get something like this
(on the left hand side the is the string array and on right side is the new formular)
the first detail has the entry's (123456, 455612, 7898797)
and get back

00340383920026147139 00340383920026147139
00340383920026147146
00340383920026147153
00340383920026157153

the second detail
00340383920026180139 00340383920026180146
00340383920026180146
00340383920026180153
00340383920026180153

it means the first detail give me back only the first entry from the database field
and the second detail give me back the second entry from the database field

any idea whats the problem ?

thanks in advance
Juergen
 
whileprintingrecords;
stringvar array x := split({yourfield},"/ ");
numbervar i := i + 1;
if i <= ubound(x) then
x

This will return one element per row.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top