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 can use simpler code?

Former Member
0 Likes
696

How can use simpler code for checking a particular value in a string?

FIND 'C' IN fg_result ."FOR PAYMENT METHODS "CPRS"
IF sy-subrc NE 0. FIND 'P' IN fg_result.ENDIF.
IF sy-subrc NE 0. FIND 'R' IN fg_result.ENDIF.
IF sy-subrc NE 0. FIND 'S' IN fg_result.ENDIF.
IF SY-SUBRC = 0.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
666

Hello.

Try like this:

IF fg_result <b>CA 'CPRS'.</b>

Process...

Endif.

Vasanth

5 REPLIES 5
Read only

Former Member
0 Likes
666

hi,

Use Case ... Endcase statement instead of if endif ..

Regards,

Santosh

Read only

Former Member
0 Likes
667

Hello.

Try like this:

IF fg_result <b>CA 'CPRS'.</b>

Process...

Endif.

Vasanth

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
666

You might want to use CHECK statement.



find 'C' in fg_result ."FOR PAYMENT METHODS "CPRS"
check sy-subrc <> 0.
find 'P' in fg_result.
check sy-subrc <> 0.
find 'R' in fg_result.
check sy-subrc <> 0.
find 'S' in fg_result.
check sy-subrc <> 0.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
666

Hi,

try this:

DATA: TEST(12) VALUE 'YYYCPRSCCC'.

*

IF TEST CA 'CPRS'.

WRITE: / 'YES'.

ELSE.

WRITE: / 'NO'.

ENDIF.

Regards, Dieter

Read only

Former Member
0 Likes
666

Dear Shashank,

DATA: GV_SRCH(1) TYPE C.

CASE GV_SRCH.

WHEN 'C'.

FIND 'C' IN fg_result.

WHEN 'P'.

FIND 'P' IN fg_result

WHEN 'R'.

FIND 'R' IN fg_result

WHEN 'S'.

FIND 'S' IN fg_result

ENDCASE.

Regards,

Abir

************************************

  • Don't forget to award Points *