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
540

hi ,

i want to give validation for two input files.as if i load any file between these two it should load it .But if i load the file other than this than it must give error as not a valid load file.

I am trying to do it with this code but it is getting done.

pls help me out.

IF ( P_FILE CP 'Balances_DMTHMPLAN' ) OR

( P_FILECP 'Balances_VMTHMPLAN' ).

IF SY-SUBRC <> 0.

MESSAGE E000 WITH TEXT-013 . ENDIF.

ENDIF.

You have 2 options.


IF ( P_FILE CS 'Balances_DMTHMPLAN' )
OR  ( P_FILE CS 'Balances_VMTHMPLAN' ).
*>>> Do Something
ELSE.
  MESSAGE E000 WITH TEXT-013 .
ENDIF.


  SEARCH  P_FILE for 'Balances_DMTHMPLAN'.
  if sy-subrc NE 0.
    SEARCH  P_FILECP for 'Balances_VMTHMPLAN'.
    if sy-subrc NE 0.
      MESSAGE E000 WITH TEXT-013 .
    else.
*    Do something
    endif.
  else.
*    Do something
    endif.

Edited by: Paul Chapman on May 14, 2008 6:47 AM

3 REPLIES 3
Read only

Former Member
0 Likes
499

You have 2 options.


IF ( P_FILE CS 'Balances_DMTHMPLAN' )
OR  ( P_FILE CS 'Balances_VMTHMPLAN' ).
*>>> Do Something
ELSE.
  MESSAGE E000 WITH TEXT-013 .
ENDIF.


  SEARCH  P_FILE for 'Balances_DMTHMPLAN'.
  if sy-subrc NE 0.
    SEARCH  P_FILECP for 'Balances_VMTHMPLAN'.
    if sy-subrc NE 0.
      MESSAGE E000 WITH TEXT-013 .
    else.
*    Do something
    endif.
  else.
*    Do something
    endif.

Edited by: Paul Chapman on May 14, 2008 6:47 AM

Read only

Former Member
0 Likes
499

i think you are checking the reverse condition....you should throw the error if the if statement fails....and i feel there is no need to check sy-subrc after if statement

IF ( p_file CP 'Balances_DMTHMPLAN' ) OR

( p_file CP 'Balances_VMTHMPLAN' ).

*<do your processing here>

else.

MESSAGE e000 WITH text-013 .

ENDIF.

Read only

Sm1tje
Active Contributor
0 Likes
499

IF ( P_FILE CP 'Balances_DMTHMPLAN' ) OR

( P_FILECP 'Balances_VMTHMPLAN' ).

IF SY-SUBRC 0. "NO NEED FOR THIS.

MESSAGE E000 WITH TEXT-013 . ENDIF.

ENDIF.

What does your p_file look like because the expression looks ok, but remember case sensitive!!!