‎2006 Sep 26 11:09 AM
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
‎2006 Sep 26 11:13 AM
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.
‎2006 Sep 26 11:14 AM
Hi Zastawny,
Just Clear the variables r_FRGKZ_line and r_EBAKZ_line before assigning any values to them. That might help.
Regards,
Saurabh
‎2006 Sep 26 11:18 AM
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.
‎2006 Sep 26 11:18 AM
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.
‎2006 Sep 26 11:21 AM
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