Hi, you can validate the field in PAI itself before converting the string as below:
CASE sy-ucomm.
WHEN 'ENTE'.
IF strlen( inp ) > 10.
MESSAGE 'Enter only 10 characters' TYPE 'S' DISPLAY LIKE 'E'.
exit.
ENDIF.
CONCATENATE inp+0(3) inp+4(3) inp+7(2) inp+9(2) INTO inp1
SEPARATED BY '-'.
inp = inp1.
ENDCASE.
where inp is the screen field name. you can similarly put check for special characters.