‎2006 Sep 12 4:01 PM
hi all,
can anyone pls help me regarding this, my problem is, i have a table and it contains several lines i dont know how many, and then each line has a length of 132 characters. I want to do, if line1 is less than 132 i will get some characters to line2 to satisfy the 132 of the line1, the same as the remaining lines. Pls. do help me, i need this code.
thanx a lot,
jc
‎2006 Sep 12 4:13 PM
Please try and use the below logic.
*itab is the table where you have the lines.
itab1[] = itab[].
Loop at itab1.
lindx = sy-tabix - 1.
check lindx > 0.
read table itab index lindx.
lstr = itab-line.
llen = strlen ( lstr ).
if llen < 132.
lvar = 132 - llen.
write itab1-line(lvar) to lstr1.
concatenate lstr lstr1 into itab-line.
modify itab lindx.
write itab1-line+lvar(132) to lstr1.
itab1-line = lstr1
lnindx = lindx + 1.
modify itab1 index lnindx.
endif.
endloop.
‎2006 Sep 12 4:05 PM
data v_str type string.
loop at itab.
concatenate v_str itab-line into v_str.
endloop.
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
TEXTLINE = v_str
OUTPUTLEN = 132
TABLES
OUT_LINES = itab
EXCEPTIONS
OUTPUTLEN_TOO_LARGE = 1
OTHERS = 2.
Regards,
ravi
‎2006 Sep 12 4:22 PM
Alternatively, try this also:
loop at itab.
concatenate v_str itab-line into v_str.
endloop.
CALL FUNCTION 'CONVERT_STRING_TO_TABLE'
EXPORTING
I_STRING = v_str
I_TABLINE_LENGTH = 132
TABLES
ET_TABLE = itab
.
Regards,
Ravi
‎2006 Sep 12 6:16 PM
hi, ravi,
thanx for the function modules but i cant use them for there's an error coming when i run the fm's. first in rkd_word_wrap, ur textline is not valid to v_str.
in 'CONVERT_STRING_TO_TABLE'its the table that has a problem for when im making my internal tablt type 'table', this 'table' is an error for its a generic.
thanx, hope u can help me how to use this.
regards,
jc
‎2006 Sep 12 4:06 PM
Hi,
Did you mean "i will get some characters <b>from line2 of the internal table</b> to satisfy the 132 of the line1"??
Thanks,
Naren
‎2006 Sep 12 4:18 PM
hi all, thanx
for the reply, well im going to try this,
yes im going to use only 1 internal table which contains all the lines.
thanx,
jc
‎2006 Sep 12 4:13 PM
Please try and use the below logic.
*itab is the table where you have the lines.
itab1[] = itab[].
Loop at itab1.
lindx = sy-tabix - 1.
check lindx > 0.
read table itab index lindx.
lstr = itab-line.
llen = strlen ( lstr ).
if llen < 132.
lvar = 132 - llen.
write itab1-line(lvar) to lstr1.
concatenate lstr lstr1 into itab-line.
modify itab lindx.
write itab1-line+lvar(132) to lstr1.
itab1-line = lstr1
lnindx = lindx + 1.
modify itab1 index lnindx.
endif.
endloop.