‎2010 Mar 12 1:42 AM
Hi Experts,
My internal table contains a field of length 255 characters.
I have a string variable. I need to populate the internal table from the string variable.
How should I code for this.
Thanks,
Sangeeta.
‎2010 Mar 12 2:14 AM
Hi Sangeetha,
<li>Try this way.
Thanks
Venkat.O
REPORT ztest_notepad.
DATA: BEGIN OF it_file OCCURS 0,
data TYPE c LENGTH 255,
END OF it_file.
DATA str TYPE string.
DATA g_len TYPE i.
DATA g_off TYPE i.
DATA g_loops TYPE i.
CONCATENATE
'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890x'
'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890y'
'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890z'
'12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789m'
INTO str SEPARATED BY space.
g_len = STRLEN( str ).
g_loops = g_len / 255.
g_off = 1.
DO g_loops TIMES.
IF g_loops NE sy-index.
IF sy-index EQ 1.
it_file-data = str+0(255).
ELSE.
it_file-data = str+g_off(255).
ENDIF.
APPEND it_file.
CLEAR it_file.
g_off = sy-index * 255.
ELSE.
g_len = g_len - g_off.
it_file-data = str+g_off(g_len).
APPEND it_file.
CLEAR it_file.
ENDIF.
ENDDO.
LOOP AT it_file.
WRITE:/ it_file-data.
ENDLOOP.
‎2010 Mar 12 2:14 AM
Hi Sangeetha,
<li>Try this way.
Thanks
Venkat.O
REPORT ztest_notepad.
DATA: BEGIN OF it_file OCCURS 0,
data TYPE c LENGTH 255,
END OF it_file.
DATA str TYPE string.
DATA g_len TYPE i.
DATA g_off TYPE i.
DATA g_loops TYPE i.
CONCATENATE
'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890x'
'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890y'
'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890z'
'12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789m'
INTO str SEPARATED BY space.
g_len = STRLEN( str ).
g_loops = g_len / 255.
g_off = 1.
DO g_loops TIMES.
IF g_loops NE sy-index.
IF sy-index EQ 1.
it_file-data = str+0(255).
ELSE.
it_file-data = str+g_off(255).
ENDIF.
APPEND it_file.
CLEAR it_file.
g_off = sy-index * 255.
ELSE.
g_len = g_len - g_off.
it_file-data = str+g_off(g_len).
APPEND it_file.
CLEAR it_file.
ENDIF.
ENDDO.
LOOP AT it_file.
WRITE:/ it_file-data.
ENDLOOP.
‎2010 Mar 12 3:28 AM
This will solve your problem..
DATA VAR VALUE '/' .
split text1 at VAR into table it_text. " chops the string at '/' and puts sequentially in table it_text(field shud b char)OR USE FM..
DATA: BEGIN OF TABLE OCCURS 10 ,
STR(100),
END OF TABLE.
DATA WA LIKE LINE OF TABLE.
CALL FUNCTION 'IQAPI_WORD_WRAP'
EXPORTING
TEXTLINE = 'sumit12sddadsadasd3456789'
* DELIMITER = ' '
OUTPUTLEN = 5 " this is the length of each peice --> give 255 in your case
* IMPORTING
* OUT_LINE1 =
* OUT_LINE2 =
* OUT_LINE3 =
TABLES
OUT_LINES = TABLE
* EXCEPTIONS
* OUTPUTLEN_TOO_LARGE = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.Regards,
Sumit Nene
‎2010 Mar 12 4:58 AM
Hi,
Concatenate all the fields you need move into the file seperated by space or comma into your string,
and then populate the string into your internal table.
Thanks,
sudheer