2007 Nov 23 5:46 AM
I have a structure data like this:
<b>Consignment Fill-up Reference Nos.: 92001254, 98745521, 36955214 and 62258523</b>
Now my problem is I wanted to trim those numbers and and put it in my declared variables, example:
Data: var1, var2, var3, var4.
var1 = 92001254.
var2 = 98745521
var3 = 36955214
var4 = 62258523
any help will be greatly appreciated.
reward also for useful info
Thanks
2007 Nov 23 6:16 AM
small changes:
str1 = 'Consignment Fill-up Reference Nos.: 92001254, 98745521, 36955214 and 62258523'.
constants c_str(10) type c value '0123456789'.
length = strlen(str1).
do length times.
if str1(sy-index) ca c_str.
l_index1 = sy-index.
flag1 = 'X'.
endif.
if str1(sy-index) na c_str and flag1 EQ 'X'.
l_index2 = sy-index.
flag2 = 'X'
endif.
if flag1 EQ 'X' and flag2 EQ 'X'.
move str+l_index1(l_index2-l_index1) to itab-line.
append itab.
clear itab.
clear: flag1,flag2.
endif.
enddo.
reward if solved
2007 Nov 23 5:48 AM
Data: var1(8) type c, var2(8) type c, var3(8) type c, var4(8) type c.
or
Data: var1 type i, var2 type i, var3 type i, var4type i.
var1 = 92001254.
var2 = 98745521
var3 = 36955214
var4 = 62258523
2007 Nov 23 5:52 AM
Hi..
You have to specify the Data type and length while declaring the variables.
Eg:
Data: var1(10) type C,
var2(10) TYPE C,
var3(10) TYPE C,
var4(10) TYPE C.
var1 = '92001254'.
var2 = '98745521'.
var3 = '36955214'.
var4 = '62258523'.
REWARD IF HELPFUL.
2007 Nov 23 5:53 AM
Hi,
Do as follows
SPLIT field AT ',' INTO: str1 str2 str3.
now your structure seperates the values at , and stores in diff variables
Regards,
Siva chalasani.
<b>reward points if usefull</b>
2007 Nov 23 6:03 AM
2007 Nov 23 6:08 AM
Hi,
now you are splitting your field at ',' into separrete variables
when ever it finds a , then the next one will be placed in a new variable
so what i say is replace you 'and' in your field with comma and split at ,
so your [problem will be solved
Regards,
Siva chalasani.
<u><b>Reward points if usefull.</b></u>
2007 Nov 23 5:59 AM
I mean the whole data is like this:
<b>Consignment Fill-up Reference Nos.: 92001254, 98745521, 36955214 and 62258523</b>
now i want to get only the numbers and set it in the variables. I know what kind of data types but the problem is trimming those numbers
2007 Nov 23 6:05 AM
HI,
You can do one thing
you are saying your field is having ',' for seperation and for the last one 'AND' is there
now you can replace 'and' with ','.
and use the split command as given above.
Regards,
siva chalasani.
Reward points if usefull.
2007 Nov 23 6:09 AM
I understand what you are saying
if i may think the output maybe like this:
correct me if im wrong.
var1 = Consignment Fill-up Reference Nos.: 92001254
var2 = 98745521
var3 = 36955214
var4 = 62258523
2007 Nov 23 6:17 AM
Hi,
Yes you are correct
you can do one thing
if your out same always as you menctioned
then you wirte the code
or if it going to change frequently
my answere will not properly
what you can do is
you can use FIND keyword
and find at what position the ' : ' is there in the first string
then you can trim that value
using offset and length
find F1 help on find command you write the statement and trim according to your requirement
example:
FIND patt IN SECTION OFFSET off OF field.
Regards,
Siva chalasani.
<u><b>Reward points if usefull.</b></u>
2007 Nov 23 6:14 AM
try a logic something like below, i did not test it if it works:
str1 = 'Consignment Fill-up Reference Nos.: 92001254, 98745521, 36955214 and 62258523'.
constants c_str(10) type c value '0123456789'.
length = strlen(str1).
do length times.
if str1(sy-index) ca c_str.
l_index1 = sy-index.
flag1 = 'X'.
endif.
if str1(sy-index) na c_str and fl_flag1 EQ 'X'.
l_index2 = sy-index.
flag2 = 'X'
endif.
if flag1 EQ 'X' and flag2 EQ 'X'.
move str+l_index1(l_index2-l_index1) to itab-line.
append itab.
clear itab.
endif.
enddo.
now itab contains the numbers, u can easily assign to variables
2007 Nov 23 6:16 AM
small changes:
str1 = 'Consignment Fill-up Reference Nos.: 92001254, 98745521, 36955214 and 62258523'.
constants c_str(10) type c value '0123456789'.
length = strlen(str1).
do length times.
if str1(sy-index) ca c_str.
l_index1 = sy-index.
flag1 = 'X'.
endif.
if str1(sy-index) na c_str and flag1 EQ 'X'.
l_index2 = sy-index.
flag2 = 'X'
endif.
if flag1 EQ 'X' and flag2 EQ 'X'.
move str+l_index1(l_index2-l_index1) to itab-line.
append itab.
clear itab.
clear: flag1,flag2.
endif.
enddo.
reward if solved
2007 Nov 23 6:24 AM