10-15-2008 2:18 PM
Hi everybody,
ive created a table in my data-dictionary which i want to use in an sql-statement combined with "where sparte IN myselectiontable", but this doesnt work for me.
ive created this structure in the datadic for my selectiontable and a corresponding tabletype.
SIGN char(1)
OPTION char(2)
LOW z_sparte
HIGH z_sparte
low and high are the same type es the databasefield i want to use the selectiontable on.
later on the table based on this structure is filled by me with the following data, because i want to get only the lines of my database where "sparte" is equal to "J" or "S".
SIGN OPTION LOW HIGH
I EQ J
I EQ S
but no matter what the content of my selectiontable is, its just being ignored, i alwys get the same result.
thanks for your help.
10-15-2008 2:21 PM
I think you need to put your values into the LOW column rather than the HIGH column.
10-15-2008 2:27 PM
sorry this is a formatting problem, the values are in the LOW-field, the HIGH-field is empty
10-15-2008 2:31 PM
Post your selection code.
edit. I have a feeling you defined your own SELECT-OPTIONS structure and you are using that instead of the standard SAP SELECT-OPTIONS structure.
10-15-2008 2:34 PM
hi, youre talking about my sql-statement?
SELECT sparte FROM zebit_hcr_btabn into CORRESPONDING FIELDS OF TABLE sparten
WHERE termtdat BETWEEN from AND to AND prod = o_produkt AND
action = 'B' OR action = 'Z' AND sparte IN o_sparten_sichtbar.
with o_sparten_sichtbar being my selection table with the structure above.
10-15-2008 2:35 PM
Do what Thomas suggested and see what happens.
Or:
RANGES: ra_sparte FOR zebit_hcr_btabn-sparte.
ra_sparte will have the same fields as you defined in your own structure.
Edited by: Maen Anachronos on Oct 15, 2008 3:36 PM
10-15-2008 2:41 PM
i defined it manually in the source of my class-attributes, it didn't change anything. in the debugger the table seems to be correctly filled.
edit: the ranges command is not allowed in the definition of my class.
im trying to use this in a BSP, i have serveral dynamicly generated checkboxes. i want to generate a selection-table out of them so i can do a selection on the database based on the checkbox-data.
Edited by: dsp on Oct 15, 2008 3:45 PM
Edited by: dsp on Oct 15, 2008 3:50 PM
10-15-2008 2:53 PM
> the ranges command is not allowed in the definition of my class.
Correct, because it uses implicit header lines. Try my suggestion
> DATA: ... TYPE RANGE OF ...
10-15-2008 2:31 PM
why don't you define the selection range like this:
DATA: r_sparte TYPE RANGE OF z_sparte.
Thomas
10-15-2008 2:51 PM
Make sure you APPEND the tablw with correct values and put your values in LOW. If you are selecting a range of data to be selected then use LOW + HIGH.
-Aman
10-15-2008 2:55 PM
the generation of the selectiontable, "sel_sparten_sichtbar" being the selectiontable in this case
some looping....
clear wa_o_sparten_sichtbar.
wa_o_sparten_sichtbar-sign = 'I'.
wa_o_sparten_sichtbar-option = 'EQ'.
wa_o_sparten_sichtbar-low = wa_i_sparten_sichtbar-sparte.
APPEND wa_o_sparten_sichtbar TO sel_sparten_sichtbar.
endloop.
thomas: tried it out, it didn't change anything.
10-15-2008 3:14 PM
Can you have a look at this code.
REPORT ztest3.
DATA: BEGIN OF sel OCCURS 10,
sign(1) TYPE c,
option(2) TYPE c,
low TYPE s_carr_id,
high TYPE s_carr_id,
END OF sel.
DATA: lt TYPE TABLE OF spfli.
sel-sign = 'I'. sel-option = 'EQ'. sel-low = 'LH'. APPEND sel.
sel-sign = 'I'. sel-option = 'EQ'. sel-low = 'AA'. APPEND sel.
BREAK-POINT.
SELECT * FROM spfli INTO TABLE lt WHERE carrid IN sel.
BREAK-POINT.
-Aman
10-15-2008 3:18 PM
i everybody,
i solved the problem, the reason for this was the sql-statement. the "<field> IN <selectiontable>" has to be right after the "WHERE" in the select, or it wont work like it should. this now works fine for me:
SELECT abrstatus sparte prod COUNT(*) AS summe FROM zebit_hcr_btabn INTO CORRESPONDING FIELDS
OF TABLE int_overview_sparte WHERE sparte in o_sparten_sichtbar and termtdat BETWEEN from AND to AND prod = o_produkt AND action = 'B' OR action = 'Z' GROUP BY abrstatus sparte prod ORDER BY abrstatus ASCENDING.
thanks everybody for your help.
10-15-2008 3:24 PM
Well done!
But i'm still wondering as i haven't seen that happen before that you need to put it right after the WHERE. Is it possible that the result was affected by:
action = 'B' OR action = 'Z' AND sparte IN o_sparten_sichtbar.
And that it would have worked if you used:
( action = 'B' OR action = 'Z' ) AND sparte IN o_sparten_sichtbar.
Just being curious.
10-15-2008 4:15 PM
10-16-2008 7:21 AM