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

how to find a string into another string

Former Member
0 Likes
934

Hi,

I'm trying to give a validation on the input file name which is given below.I dont want to hard code the path.when i'm giving F4 help it should pick only

' C.028 Project Plan balances_DMTHMPLAN ' file .if the file having different name is picked than it should give an error.

I'm trying to do this via this code.

Can anyone help me out.

IF P_FILE NP ' C.028 Project Plan balances_DMTHMPLAN' .

IF SY-FDPOS = 1.

MESSAGE E000 WITH TEXT-001 .

ENDIF.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
826

Use CS keyword and check.

Means contains string

7 REPLIES 7
Read only

Former Member
0 Likes
827

Use CS keyword and check.

Means contains string

Read only

Former Member
0 Likes
826

Hi,

SEARCH f FOR g.

regards

Nicole

Read only

Former Member
0 Likes
826

hi,

do this way ..


IF P_FILE NS ' C.028 Project Plan balances_DMTHMPLAN' .
   MESSAGE E000 WITH TEXT-001 .
ENDIF. 

Read only

Former Member
0 Likes
826

Hi Dheeraj,

You can try using CS (Contains String) or CP (Contains Pattern ). But be specific , as it is case-sensitive.

Try using :

IF P_FILE CS ' C.028 Project Plan balances_DMTHMPLAN' .

or

IF P_FILE CP ' C.028 Project Plan balances_DMTHMPLAN' .

Choose the kind of syntax as per your requirement.

Hope this is helpful to you. If you need further information, revert

back.

Reward all the helpful answers.

Regards

Nagaraj T

Read only

Former Member
0 Likes
826

HI,

use find keyword.


FIND 'C.028 Project Plan balances_DMTHMPLAN' in file.
IF subrc <> 0.
  MESSAGE e000(zmsg_tab) with 'error'.
ENDIF.

rgds,

bharat.

Read only

Former Member
0 Likes
826

Hi,

You can use this code with little bit modifications as of ur requirements.

PARAMETERS: P_FILE TYPE RLGRAP-FILENAME.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_FILE.

IF P_FILE NE 'C.028 Project Plan balances_DMTHMPLAN'.

MESSAGE i000(Z50871MSG) WITH 'error' .

ENDIF.

Regards

Sandeep Reddy

Read only

Former Member
0 Likes
826

Thanks a lot