2010 Jan 28 10:28 AM
Hello guys , could you give any advice of how to split a string every 132 chars or every <enter> key , i need to save every part in a field of internal table .
thank you.
2010 Jan 28 10:45 AM
hi guys , your ideas are great , however i need to split or every 132 OR every <ENTER> key and then create a register in the internal table for every part that i get. How do i find the <ENTER> key in the string in old fashion languages it was something with the ascii
kumar,
you dont know how many characters the string is then how can you use that ????
Regards
sas
2010 Jan 28 10:31 AM
2010 Jan 28 10:36 AM
yes the problem is that i dont know , how many parts im going to get . in split you need specify the variables to save the parts.
2010 Jan 28 10:36 AM
Its pretty simple..
Declare ITAB .
DATA: BEIGN OF ITAB OCCURS 1 ,
str(132) ,
end of itab.
check the length using strlen ( string ).
Now string is 1340 characters....
A = 1340 / 132 = 10 times....
B = 1340 - 132 * a= 8 charcaters...
C = 1340- B = 1332.
DATA: A TYPE I ,
DO A TIMES.
D = 132 + D.
ITAB-STR = STRING+D(132).
APPEND ITAB.
ENDDO.
ITAB-STR = STRING +C(b).
APPEND ITAB.
Is that ok???
Regards
sas
2010 Jan 28 10:37 AM
Hi Jose,
Use offset or function code.
For example i have used offset in time to dispaly as : :
MOVE sy-uzeit TO l_time.
CONCATENATE l_time+0(2) l_time+2(2) l_time+4(2) INTO l_time SEPARATED BY ':'.Manas M.
Edited by: Kumar Manas Mishra on Jan 28, 2010 11:39 AM
2010 Jan 28 10:45 AM
kumar,
you dont know how many characters the string is then how can you use that ????
Regards
sas
2010 Jan 28 10:43 AM
Hello,
You can make use of the FM: RKD_WORD_WRAP or FORMAT_TEXTLINES to split the string at 132 characters.
BR,
Suhas
2010 Jan 28 10:44 AM
Hello,
Use the FM TR_SPLIT_TEXT and specify the length at which it has to split to the parameter IV_LEN as 132. The export internal table will hold the splitted text
Vikranth
2010 Jan 28 10:45 AM
hi guys , your ideas are great , however i need to split or every 132 OR every <ENTER> key and then create a register in the internal table for every part that i get. How do i find the <ENTER> key in the string in old fashion languages it was something with the ascii
2010 Jan 28 10:51 AM
Hi José,
To separate a string at enter you can use this way:
data: c_new value cl_abap_char_utilities=>newline.
split v_string at c_new into table itab.
Also can you elobarate what do you mean by creating register.
Regards,
Swarna Munukoti
2010 Jan 28 10:58 AM
this is exactly what i want , one more thing how is the structure of ITAB my table has 4 columns
Edited by: José M. Sánchez on Jan 28, 2010 6:30 AM
2010 Jan 28 11:12 AM
Hi,
You can declare itab as follows:
data: itab type table of string.
Is this what you are asking for?
But iam still confused with your statement:
my table has 4 columns Regards,
Swarna Munukoti
2010 Jan 28 12:52 PM
if you have 4 and one string is having 4 enters only...
then you may use
SPLIT STRING AT NEWLINE INTO ITAB-A ITAB-A ITAB-C ITAB-D.
Sas
2010 Jan 28 12:21 PM
This logic will help
len = strlen( lv_string ).
lv_pos = ceil( len / 132 ). "Holds no of fields you will get based on this you can create the itab dynamically also.
lv_off1 = 0.
lv_off2 = 132.
do lv_pos times.
wa-line = lv_string+lv_off1(lv_off2).
lv_off1 = lv_off1 + lv_off2.
append wa to itab.
clear wa.
enddo.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |