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

ranges question

Former Member
0 Likes
827

Hi, need help

I need to get information from table EBAN with a function.

I have two imput var:

STATUS_0 and STATUS_1.

Now in my FM i have ranges declaration:

  DATA: r_FRGKZ type range of eban-FRGKZ,
        r_FRGKZ_line like line of r_FRGKZ.

  DATA: r_EBAKZ type range of eban-EBAKZ,
        r_EBAKZ_line like line of r_EBAKZ.

  if STATUS_0 eq 'X'.
        r_FRGKZ_line-sign   = 'I'.
        r_FRGKZ_line-option = 'EQ'.
        r_FRGKZ_line-low    = '0'.
      append r_FRGKZ_line to r_FRGKZ.

        r_EBAKZ_line-sign   = 'I'.
        r_EBAKZ_line-option = 'EQ'.
        r_EBAKZ_line-low    = ' '.
      append r_EBAKZ_line to r_EBAKZ.
  endif.
  if STATUS_1 eq 'X'.
        r_FRGKZ_line-sign   = 'I'.
        r_FRGKZ_line-option = 'EQ'.
        r_FRGKZ_line-low    = 'Z'.
      append r_FRGKZ_line to r_FRGKZ.

        r_EBAKZ_line-sign   = 'I'.
        r_EBAKZ_line-option = 'EQ'.
        r_EBAKZ_line-low    = 'X'.
      append r_EBAKZ_line to r_EBAKZ.
  endif.

then i use select:

select * into TEBAN from EBAN
  where frgkz in r_frgkz
    and EBAKZ in r_EBAKZ.

Everything works fine if only STATUS_0 or STATUS_1 is set to 'X'. If both of them are 'X' then I don't get a good result

My question: how to make SAP use all conditions from line 1 and then all conditions from line 2.

Best regards

5 REPLIES 5
Read only

Former Member
0 Likes
751

You can do something like this :

if STATUS_1 eq 'X' and STATUS_0 eq 'X'.

r_FRGKZ_line-low = '0'.

r_FRGKZ_line-sign = 'I'.

r_FRGKZ_line-option = 'BT'.

r_FRGKZ_line-HIGH = 'Z'.

append r_FRGKZ_line to r_FRGKZ.

r_EBAKZ_line-sign = 'I'.

r_EBAKZ_line-option = 'BT'.

r_EBAKZ_line-low = ''.

r_EBAKZ_line-HIGH = 'X'.

append r_EBAKZ_line to r_EBAKZ.

endif.

select * into TEBAN from EBAN

where frgkz in r_frgkz

and EBAKZ in r_EBAKZ.

Read only

Former Member
0 Likes
751

Hi Zastawny,

Just Clear the variables r_FRGKZ_line and r_EBAKZ_line before assigning any values to them. That might help.

Regards,

Saurabh

Read only

former_member186741
Active Contributor
0 Likes
751

I can't see anything wrong.... what sort of bad result are you getting and under what circumstances?

Is TEBAN a table? maybe you should be coding

select * into <b>table</b> TEBAN from EBAN where frgkz in r_frgkz and EBAKZ in r_EBAKZ.

Read only

Former Member
0 Likes
751

Everything works fine if only STATUS_0 or STATUS_1 is set to 'X'. If both of them are 'X' then I don't get a good result

-->

What do you mean by good result ..can you please check and confirm that if you have data with both status_0 and status_1 as defined in the ranges.

Read only

Former Member
0 Likes
751

hi,

one info to you.

if RANGES field is empty,then all the records will come into the table. so first check your RANGES table whether its empty or not.

so change your code to,

 if STATUS_0 eq 'X'  AND
    STATUS_1 eq ''.    
*--Only 1st field is selected.
     select * into TEBAN from EBAN
             where EBAKZ in r_EBAKZ.
 ELSEIF STATUS_0 eq ''  AND
    STATUS_1 eq 'X'.    
*--only 2nd field is selected
     select * into TEBAN from EBAN
             where frgkz in r_frgkz.
 ELSEIF STATUS_0 eq 'X'  AND
    STATUS_1 eq 'X'.  
*--both fields are selected
      select * into TEBAN from EBAN
        where frgkz in r_frgkz
          and EBAKZ in r_EBAKZ.
 ENDIF.

test with this code.

Regards

srikanth