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

File name

Former Member
0 Likes
994

Hi gurus,

I have a condition where I need to do some action based on the file name, for example if there id "SP" in the file name then its meant for Sold to party and if there is " SH" somewhere in the file name then it is meant ship to party.... and then based on this I have to perform some routines, for example if v_name = " SP" then perform v_sp else v_sh,

so can you please tell me how to acheive this thing, my file name is in v_name

7 REPLIES 7
Read only

Former Member
0 Likes
909

Try:

IF v_name CS 'SP'.
  PERFORM v_sp.
ELSEIF v_name CS 'SH'.
  PERFORM v_sh.
ENDIF.

You could have solved this very easily yourself by simply putting your cursor on an IF statement and pressing F1.

Rob

Message was edited by:

Rob Burbank

Read only

Former Member
0 Likes
909

Hi ,

Try this way...


IF v_name CS 'SP'.
PERFORM v_sp.
ELSEIF v_name CS 'SH'.
PERFORM v_sa.
ENDIF.

Message was edited by:

Perez C

Message was edited by:

Perez C

Read only

Former Member
0 Likes
909

If V_name CS 'SP'

  • Do actions for Sold-to-party

ELSEIF V_NAME CS 'SH'

  • Do actions for Ship-to-party

ENDIF.

Regards

Nishant

Read only

0 Likes
909

Oops sorry Nishant you just beat me haha.

Read only

che_eky
Active Contributor
0 Likes
909

Use the contains string CS statement:

IF v_name CS 'SH'.

  • do ship to party logic

ELSE IF v_name CS 'SP'.

  • do Sold to party logic

ENDOF.

Read only

naimesh_patel
Active Contributor
0 Likes
909

Try this code:

REPORT  ZTEST_NP.

data: v_name(200) type c value 'SH_1000.txt'.

search v_name for 'SH'.
if sy-subrc = 0.
* call Peform for SH
endif.

search v_name for 'SP'.
if sy-subrc = 0.
* call Peform for SP - Sold to party
endif.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
909

Pass the complete file name to FM SPLIT_FILENAME .

You will have value in PURE_FILENAME ( FM Export parameter).

now compare with

if pure_filename+0(2) 'SH'.

write the logic

elseif pure_filename+0(2) 'SH'.

write the logic

elseif pure_filename+0(2) 'SH'

write the logic

endif.

Thanks

Seshu