Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

String validation

Former Member
0 Kudos

hello all,

i am extracting file name from file path but i want to add some validation on filename

i.e filename should be in "CITI2010072101" format.

how to validate i/p string.

format is like citi date '01'(any code from 00 to 09)

4 REPLIES 4

syed_ibrahim5
Active Participant
0 Kudos

hi,

use the function module PC_SPLIT_COMPLETE_FILENAME to seperate the filename from path and concatenate as per your requirements...

with regards,

syed

0 Kudos

my file name is 14 ch ar long, the function you proposed is support only12 (filename)char .

but i already got filename i just want to validate format as per above mention.

MarcinPciak
Active Contributor
0 Kudos

This message was moderated.

0 Kudos
DATA: v_filename TYPE fileintern VALUE 'CITI2010072101',
      v_date TYPE datum.

IF v_filename+0(4) = `CITI`.
  v_date = v_filename+4(8).
  CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
    EXPORTING
      date                      = v_date
    EXCEPTIONS
      plausibility_check_failed = 1
      OTHERS                    = 2.
  IF sy-subrc = 0.
    IF v_filename+12(2) GE '01' OR v_filename+12(2) LE '09'.
      WRITE: / 'File Name is correct'.
    ELSE.
      WRITE: / `Error in filename. Sequence is incorrect` .
    ENDIF.
  ELSE.
    WRITE: / `Error in filename. Date is incorrect` .
  ENDIF.

ELSE.
  WRITE: / `Error in filename. Prefix not mainted as CITI` .
ENDIF.

BR,

Suhas