2015 Jul 24 3:57 PM
2015 Jul 24 4:46 PM
Thanks for sharing.
My take on this is essentially to search backwards from the maximum line length for the first space and chop off that number of characters then print them. Keep going until the string is empty:
Start-Of-Selection.
*
Constants c_Max_Len Type i Value 50.
*
Data: l_Str Type String,
l_Trimmed Type String,
l_Pos Type i,
l_Len Type i.
*
l_Str = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed'.
l_Str = l_Str && ' do eiusmod tempor incididunt ut labore et dolore magna'.
l_Str = l_Str && ' aliqua. Ut enim ad minim veniam, quis nostrud exercitation'.
l_Str = l_Str && ' ullamco laboris nisi ut aliquip ex ea commodo consequat.'.
l_Str = l_Str && ' Duis aute irure dolor in reprehenderit in voluptate velit'.
l_Str = l_Str && ' esse cillum dolore eu fugiat nulla pariatur. Excepteur sint'.
l_Str = l_Str && ' occaecat cupidatat non proident, sunt in culpa qui officia'.
l_Str = l_Str && ' deserunt mollit anim id est laborum.'.
*
While l_Str Is Not Initial.
Clear l_Trimmed.
l_Len = StrLen( l_Str ).
If l_Len <= c_Max_Len.
l_Trimmed = l_Str.
l_Str = ''.
Else.
l_Pos = Find( Val = l_Str
Regex = ' [^ ]*$'
Off = 0
Len = c_Max_Len ).
If l_Pos = -1.
l_Pos = c_Max_Len.
EndIf.
l_Trimmed = SubString( Val = l_Str
Off = 0
Len = l_Pos ).
l_Pos = l_Pos + 1.
l_Str = SubString( Val = l_Str
Off = l_Pos ).
EndIf.
l_Len = StrLen( l_Trimmed ).
Write :/ l_Trimmed, l_Len.
EndWhile.
2015 Jul 24 5:00 PM
It would be great if you convert this to the document with some screenshots showing inputs and expected output.
Thanks for sharing.
Regards,
Naimesh Patel
2015 Jul 24 5:38 PM
I agree - this should not be posted as discussion. Add more explanation (especially business scenario when this could be needed) and re-post it as a document. See this document for more info. Also the title is barely readable, please don't put the whole text there.