Application Development and Automation 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: 
Read only

String validation

Former Member
0 Likes
740

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
Read only

syed_ibrahim5
Active Participant
0 Likes
705

hi,

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

with regards,

syed

Read only

0 Likes
705

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.

Read only

MarcinPciak
Active Contributor
0 Likes
705

This message was moderated.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
705
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