2008 May 29 7:26 AM
Hi,
I have a string with fields each of length 40, I need to split it at the mutilples of 40 and put in an internal table , i.e.
field1(40),
field2(40),
field3(40)
v_str = (field1 field2 field3 .. ).
thanks
points will rewarded
2008 May 29 7:28 AM
DATA: s1 TYPE string,
s2 TYPE string,
s3 TYPE string,
it_tab TYPE TABLE OF string,
text = ` ur text `.
SPLIT text AT ',' INTO: s1 s2 s3,
TABLE it_tab.
Regards,
Jagadish
2008 May 29 7:29 AM
Hi,
try this
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
itab TYPE TABLE OF string,
text TYPE string.
text = `What,a,drag,it,is,getting,old`.
SPLIT text AT ',' INTO: str1 str2 str3,
TABLE itab.
Regards,
Raja
2008 May 29 7:29 AM
do.
move string+offset(40) to lv_field.
offset = offset + 40.
enddo.
Within DO ENDDO also check if offset + length does not exceed the total length of the field, else you will get a short dump.
2008 May 29 7:39 AM
HI Micky,
Thanks for the answer.
1. iam uploading the data . looping at the internal table(upload data) and putting tht in a string .Now the data tht iam uploading is each of length 40 . when iam puting tht in a string each field is separated by space i.e next field is starting at 41 and so on .
2. Now again i need to remove these spaces and put in an internal table .
this is my requirement ..
thanks .
2008 May 29 7:48 AM
v_len = STRLEN( gs_string ).
If not v_len is initial.
IF v_len GT '40'.
wa_tab-field1 = gs_string+0(40).
SHIFT gs_string LEFT BY 40PLACES.
wa_tab-field2 = gs_string+0(40).
* Similary do for all the fields.
ENDIF.
ENDIF.
Regards
Kannaiah
2008 May 29 8:13 AM
hi wajid
try to give offset while splitting.
or after getting the strings into unternal table again split them acording to space..
split str1 at space into str2 str3 str4..
table itab.
try it
regards
sachhi.
2008 May 29 7:48 AM
hi,
first condense the string.
like
fld = u r text.
condense fld.
and then split as u requitred.
like
split var5 at ',' into var 6 var 7 var 8.