Skip to end of metadata
Go to start of metadata

Author: Jay Sadaram
Submitted: 11/07/2008
Description: In a SAP script I had some long text,which I was getting from Read_text function module. I had to split it and show in various lines. When the code was originally developed they were using the FM RKD_WORD_WRAP which splits to 3 lines Only, but my requirement was to have more than 10+ lines. So I developed a logic where with min changes you can adjust the number of characters to split to.. and kind of dynamic approach.

DATA: lv_len TYPE i,
      lv_z1 TYPE i,
      lv_z2 TYPE i,
      lv_z3 TYPE i,
      lv_z4 TYPE i,
      lv_z5 TYPE i,
      lv_z6 TYPE i,
      lv_z7 TYPE i,
      lv_last TYPE i,
      lv_offset(3) TYPE n.

lv_len = strlen( ztext ).
CLEAR: lv_offset.
lv_offset = lv_len / 7 .
lv_z1 = lv_offset.
lv_z2 = lv_z1 + 1.
lv_z3 = lv_z2 + lv_z1 + 1.
lv_z4 = lv_z3 + lv_z1 + 1.
lv_z5 = lv_z4 + lv_z1 + 1.
lv_z6 = lv_z5 + lv_z1 + 1.
lv_z7 = lv_z6 + lv_z1 + 1.
zoutline1 = ztext+0(lv_z1).
zoutline2 = ztext+lv_z2(lv_z1).
zoutline3 = ztext+lv_z3(lv_z1).
zoutline4 = ztext+lv_z4(lv_z1).
zoutline5 = ztext+lv_z5(lv_z1).
zoutline6 = ztext+lv_z6(lv_z1).
CHECK lv_len GT lv_z7.
lv_last = abs( lv_len - lv_z7 ).
zoutline7 = ztext+lv_z7(lv_last).