SAP ABAP Function Module to Wrap Long Text ( split text ) - Sap 4 All

Latest

Please enter your email and get the updates in your inbox.

Sunday 24 April 2016

SAP ABAP Function Module to Wrap Long Text ( split text )

The following function module can be used to wrap long text (Split Text) in ABAP.

SAP ABAP Function Module to Wrap Text
RKD_WORD_WRAP
Find the code below to test the above Function Module.

Import Parameters:

TEXTLINE
DELIMITER
OUTPUTLEN

OutPut Parameters:

OUT_LINE1
OUT_LINE2
OUT_LINE3

Sample Code:
REPORT ZTEST_WORDWRAP.
Data: d_text(110),
d_text1(110),
d_text2(110),
d_text3(110),
d_text4(110),
d_oline1(110),
d_oline2(110),
d_oline3(110).
 
Data: Begin of int_text occurs 0,
o_lines(100),
End of int_text.
 
Move: 'THIS IS LONG TEXT DESCRIPTION WHICH NEEDS TO BE WRAPPED' to d_text1,
'IN TO SEVERAL LINES AS IT IS TOOL LONG FOR ONE LINE.' to d_text2.
 
Concatenate d_text1 d_text2 INTO d_text. 
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
TEXTLINE = d_text
DELIMITER = ' '
OUTPUTLEN = 35
IMPORTING
OUT_LINE1 = d_oline1
OUT_LINE2 = d_oline2
OUT_LINE3 = d_oline3
TABLES
OUT_LINES = int_text
EXCEPTIONS
OUTPUTLEN_TOO_LARGE = 1
OTHERS = 2.
 
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
loop at int_text.
write: int_text-o_lines.
endloop

No comments:

Post a Comment