In general, most of the time in SAP, we may need to convert the value of the String or Character field (say name, city, etc..) to UPPER case of to LOWER case.
We can achieve the functionality using the simple ABAP syntax provided by SAP.
Syntax:
Assuming the P_STR is a variable which is of type STRING or CHAR (C).
To Convert to UPPER case:
To convert value stored in the P_STR to UPPER case, we can use the below syntax.
TRANSLATE p_str TO UPPER CASE.
To Convert to LOWER case:
To convert value stored in the P_STR to LOWER case, we can use the below syntax.
TRANSLATE p_str TO UPPER CASE.
Program:
REPORT ZVTEST_PGM_1.
*--Parameter for User Input
PARAMETERS: p_str TYPE string.
*--Convert to Upper Case
TRANSLATE p_str TO UPPER CASE.
*--Print Value in Output
WRITE:/ 'Upper Case Value : ', p_str.
*--Convert to Lower Case
TRANSLATE p_str TO LOWER CASE.
*--Print Value in Output
WRITE:/ 'Lower Case Value : ', p_str.
================================
Save & Activate.
Enter the input string ("VENUgopal NanjaPPA") & execute (F8).
Thanks & Regards,
Venugopal M Nanjappa
Venugopal M Nanjappa
No comments:
Post a Comment