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

Any Function Module or Program Exist ?

Former Member
0 Likes
573

Hi Gurus,

Can anyone please let me know is there any FM or any program for the below kind of requirement ?

Let us say I have a Text ( change dynamically ) with 150 charecters length. However It is split into 3 parts of each 50.

I would like to have only the complete words in each part.

Example - My text is " Approximately 72.4% from a total of 1,226.7 million shares outstanding are in free float "

It should be as " Approximately 72.4% from a total of 1,226.7 million " in Part1

and " shares outstanding are in free float " in part2.

but currently it is happening as " " Approximately 72.4% from a total of 1,226.7 mil " in part1

and " lion shares outstanding are in free float " in part2.

Kindly suggest me how to handle this situation.

Kind regards,

Varun

3 REPLIES 3
Read only

Former Member
0 Likes
527

Hi

I don't know if there's a fm, but you can try something like this:

 DATA text(150).

DATA: part1(50), part2(50).

DATA: offset TYPE i.

text = 'Approximately 72.4% from a total of 1,226.7 million shares outstanding are in free float'.

PERFORM set_part USING part1 0.
PERFORM set_part USING part2 offset.

WRITE: part1, / part2.

FORM set_part  USING    p_part p_offset TYPE i.
  DATA: last_char(1).
  DATA: l_offset TYPE i.
  DATA: pos      TYPE i.

  l_offset = p_offset + 50.
  last_char = text+l_offset(1).

  WHILE last_char <> space.
    l_offset = l_offset - 1.
    last_char = text+l_offset(1).
  ENDWHILE.

  pos = l_offset - p_offset.

  p_part = text+p_offset(pos).
  offset = p_offset + pos.

  WHILE p_part(1) = space.
    p_part = p_part+1.
  ENDWHILE.

ENDFORM.                    " SET_PART

Max

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
527

What is the FM you're using? Did you try the FM 'RKD_WORD_WRAP' ?

Output of the text you've provided(splitting into blocks of 50 chars) will be

Approximately 72.4% from a total of 1,226.7

million shares outstanding are in free float

Read only

Former Member
0 Likes
527

I used - CRM_MESSAGE_TEXT_SPLIT and it solved the purpose. Thanks - Varun