In SAP ABAP if you wish to concatenate 2 or 3 strings together then you can use the following function module.
STRING_CONCATENATE_3
The above mentioned function module excepts 3 strings and concatenates them into 1. Please see the example given below.REPORT ZEX_STRINGCON .
parameters: p_str1(100),
p_str2(100),
p_str3(100).
Data: d_str(500).
CALL FUNCTION 'STRING_CONCATENATE_3'
EXPORTING
STRING1 = p_str1
STRING2 = p_str2
STRING3 = p_str3
IMPORTING
STRING = d_str
EXCEPTIONS
TOO_SMALL = 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.
Write: d_str.
If the input is as follows.parameters: p_str1(100),
p_str2(100),
p_str3(100).
Data: d_str(500).
CALL FUNCTION 'STRING_CONCATENATE_3'
EXPORTING
STRING1 = p_str1
STRING2 = p_str2
STRING3 = p_str3
IMPORTING
STRING = d_str
EXCEPTIONS
TOO_SMALL = 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.
Write: d_str.
p_str1 = 'This'
p_str2 = 'Is'
p_str3 = 'ABAP'
The output would be as follows.
String Concatenate
THISISABAP
THISISABAP
No comments:
Post a Comment