Go to SE37
Enter Name <>
Press Create Button
Enter Import & Export Variables as Type String
Enter Exceptions as NOT_VALID
TOO_LONG
TOO_SMALL
Create Source Code as Follows
FUNCTION NN_TEXT_CONVERT_PROPER.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(STRING1)
*" EXPORTING
*" REFERENCE(STRING)
*" EXCEPTIONS
*" NOT_VALID
*" TOO_LONG
*" TOO_SMALL
*"----------------------------------------------------------------------
*
DATA :
IT_TXTS TYPE TABLE OF STRING, "Tabel for data storing
WA_TXTS(100) TYPE C, "Getting each words
CP_TEXT TYPE STRING, "Copying text
NN_TEXT TYPE STRING. "Result text
*
CP_TEXT = STRING1.
SPLIT CP_TEXT AT SPACE INTO: TABLE IT_TXTS.
*
*break itnr.
LOOP AT IT_TXTS INTO WA_TXTS.
PERFORM CHANGE_CASE USING WA_TXTS.
CONCATENATE NN_TEXT WA_TXTS INTO NN_TEXT SEPARATED BY SPACE.
ENDLOOP.
CONDENSE NN_TEXT.
*
CASE SY-SUBRC.
WHEN 0.
STRING = NN_TEXT.
EXIT.
WHEN 2.
RAISE NOT_VALID.
WHEN 3.
RAISE TOO_LONG.
WHEN 4.
RAISE TOO_SMALL.
ENDCASE.
*
ENDFUNCTION.
In the Perform part add code as follows (include LZPROPERTOP)
FUNCTION-POOL ZPROPER. "MESSAGE-ID ..
*&---------------------------------------------------------------------*
*& Form CHANGE_CASE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_TXTS text
*----------------------------------------------------------------------*
FORM CHANGE_CASE USING P_WA_TXTS.
*
DATA : P_DEM.
P_DEM = '&'.
*
CALL FUNCTION 'STRING_UPPER_LOWER_CASE'
EXPORTING
DELIMITER = P_DEM
STRING1 = P_WA_TXTS
IMPORTING
STRING = P_WA_TXTS
EXCEPTIONS
NOT_VALID = 1
TOO_LONG = 2
TOO_SMALL = 3
OTHERS = 4.
*
ENDFORM. " CHANGE_CASE
No comments:
Post a Comment