Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

STRLEN, Code

Former Member
0 Likes
793

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
708

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.

6 REPLIES 6
Read only

Former Member
0 Likes
708

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

Read only

0 Likes
708

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

Read only

0 Likes
708

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

Read only

Former Member
0 Likes
708

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

Read only

0 Likes
708

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

Read only

Former Member
0 Likes
709

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.