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

compare two ranges

Former Member
0 Likes
4,371

hi all,

I am stuck at comparing two ranges. Basically I am validating a select-option field with a range. I am not clear how to do it. Can somebody help me in this regard?

thanks in advance.

7 REPLIES 7
Read only

Former Member
0 Likes
1,761

write down logic :

s_matnr is select-option.

r_matnr is range

loop at s_matnr.

read r_matnr

if sy-subrc ne 0.

endif.

endloop.

Read only

0 Likes
1,761

@ Seshu: Looping at s_matnr will not help... since we dont know how is s_matnr populated..

it can be populated in many ways... low , high, sign, option... there can be different combinations...

Read only

Former Member
0 Likes
1,761

hi,

chk this.

select options : s_matnr for mara-matnr.

Ranges : r_one for mara-matnr.
Data : wa_ran like line of r_one.
 
wa_ran-sign = 'I'.
wa_ran-option = 'EQ'.
wa_ran-low  = '0018'.
append wa_ran to r_one.

wa_ran-sign = 'I'.
wa_ran-option = 'EQ'.
wa_ran-low  = '0025'.
append wa_ran to r_one.

 
if s_matnr IN r_one.

*data avialble in range.

endif.

Regards

Reshma

Read only

Former Member
0 Likes
1,761

hi,

see this subroutine

&----


-

*& Form f_authchk_ekorg

&----


  • Authority check and Validation for Purchasing org

----


  • -->FP_S_EKORG Purchasing Org

  • <--FP_RA_EKORG Range for Purchasing Org

----


FORM f_authchk_ekorg USING fp_s_ekorg TYPE ty_ra_ekorg

CHANGING fp_ra_ekorg TYPE ty_ra_ekorg.

*Local constants

CONSTANTS : l_c_obj TYPE xuobject VALUE '1234',

l_c_ekorg TYPE char5 VALUE 'EKORG',

l_c_eq TYPE char2 VALUE 'EQ',

l_c_i TYPE char1 VALUE 'I'.

*Local types

TYPES: BEGIN OF l_ty_ekorg,

ekorg TYPE ekorg,

END OF l_ty_ekorg.

*Local range

DATA: l_ra_wa_ekorg LIKE LINE OF fp_ra_ekorg. "you need to declare like this

*Local internal table

DATA: l_it_ekorg TYPE STANDARD TABLE OF l_ty_ekorg.

*field symbols

FIELD-SYMBOLS : <l_fs_ekorg> TYPE l_ty_ekorg.

SELECT ekorg "Purchasing organisation

FROM t024e

INTO TABLE l_it_ekorg "this is define as local internal table see above

WHERE ekorg IN fp_s_ekorg.

IF sy-subrc <> 0.

MESSAGE e024. "Invalid Purchasing ORG.

ELSE.

*looping purchase org range for authority check

LOOP AT l_it_ekorg ASSIGNING <l_fs_ekorg>.

AUTHORITY-CHECK OBJECT l_c_obj

ID c_actvt FIELD c_03

ID l_c_ekorg FIELD <l_fs_ekorg>-ekorg.

IF sy-subrc = 0.

l_ra_wa_ekorg-sign = l_c_i.

l_ra_wa_ekorg-option = l_c_eq.

l_ra_wa_ekorg-low = <l_fs_ekorg>-ekorg.

APPEND l_ra_wa_ekorg TO fp_ra_ekorg.

CLEAR l_ra_wa_ekorg.

ENDIF.

ENDLOOP.

IF fp_ra_ekorg IS INITIAL.

MESSAGE e122. "No authorization for range of Purchase Org

ENDIF.

ENDIF.

ENDFORM. " f_authchk_ekorg

rewards if useful

regards,

nazeer

Read only

0 Likes
1,761

@ Nazeer: I have done in the same way but I dont think it is the standard solution for this problem.

@Reshma: The solution u gave is not working. This is first thing anyone would do.. but dats not working...

Read only

0 Likes
1,761

do not compare in operator dircetly in if condition...

Read only

former_member196280
Active Contributor
0 Likes
1,761

Try this...

select-options : s_matnr for mara-matnr.

Ranges : r_one for mara-matnr.

Data : wa_ran like line of r_one.

wa_ran-sign = 'I'.

wa_ran-option = 'EQ'.

wa_ran-low = '000000000000000018'.

append wa_ran to r_one.

wa_ran-sign = 'I'.

wa_ran-option = 'EQ'.

wa_ran-low = '000000000000000025'.

append wa_ran to r_one.

Loop at r_one.

IF NOT s_matnr IS initial.

IF r_one-option EQ 'EQ'.

IF s_matnr-low EQ r_one-low

OR s_matnr-high EQ r_one-low.

*data available in range.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

Reward points to all answers.

Regards,

SaiRam