2007 Jun 26 11:52 AM
Hi Experts,
I have a requirement to select data for different condition types from a condition table. For that, I have to write a select statement in such a way that I can pass the selected condition types in the where condition of the select query. The way we write in SQL. E.g. select * from t_city where city in (delhi, kol,mum,chennai).
But we don't write like that in ABAP. So how to build the range table for a select statement. I want to build a range table for condition types.How to go about writing the following query in ABAP:
select * from condition_table where condition_records in(cond_type1, cond_type2).
If I want to fulfill the range table using a macro because of reusability how to go about it?
Thanks and Regards,
Sangeeta.
2007 Jun 26 11:59 AM
HI,
SEE THIS CODIN THIS MIGHT SATISFY YOUR REQUIREMENT
SELECT-OPTIONS : s_matnr FOR mara-matnr.
TYPES : BEGIN OF ty_mara,
matnr TYPE matnr,
mtart TYPE mtart,
END OF ty_mara.
TYPES : BEGIN OF TY_MARC,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
END OF TY_MARC.
TYPES : tt_mara TYPE STANDARD TABLE OF ty_mara,
TT_MARC TYPE STANDARD TABLE OF TY_MARC.
DATA : it_mara TYPE tt_mara WITH HEADER LINE,
IT_MARC TYPE TT_MARC WITH HEADER LINE.
SELECT matnr
mtart
FROM mara
INTO TABLE it_mara
WHERE matnr IN s_matnr.
IF IT_MARA IS NOT INITIAL.
SELECT MATNR
WERKS
FROM MARC
INTO TABLE IT_MARC
FOR ALL ENTRIES IN IT_MARA
WHERE MATNR EQ IT_MARA-MATNR.
Hi Experts,
I have a requirement to select data for different condition types from a condition table. For that, I have to write a select statement in such a way that I can pass the selected condition types in the where condition of the select query. The way we write in SQL. E.g. select * from t_city where city in (delhi, kol,mum,chennai).
But we don't write like that in ABAP. So how to build the range table for a select statement. I want to build a range table for condition types.How to go about writing the following query in ABAP:
select * from condition_table where condition_records in(cond_type1, cond_type2).
If I want to fulfill the range table using a macro because of reusability how to go about it?
Thanks and Regards,
Sangeeta.
2007 Jun 26 11:55 AM
Hi,
Check the coding.
This is not in accordance to condition types but would give you a fairly good idea about how to build ranges.
RANGES:R_LAND FOR IFLO-TPLNR.
SELECT-OPTIONS:S_LAND FOR KNA1-LAND1 NO INTERVALS .
LOOP AT S_LAND.
R_LAND-SIGN = 'I'.
R_LAND-OPTION = 'CP'.
R_LAND-LOW = s_land-low..
APPEND R_LAND.
clear r_land.
ENDLOOP.
Regards,
Suruchi Mahajan
2007 Jun 26 11:59 AM
Hi,
U can give range of values inside open and closed brackets within ' '.
or U can build one range table like Ranges : S_matnr ...
Regards,
Nandha
2007 Jun 26 11:59 AM
HI,
SEE THIS CODIN THIS MIGHT SATISFY YOUR REQUIREMENT
SELECT-OPTIONS : s_matnr FOR mara-matnr.
TYPES : BEGIN OF ty_mara,
matnr TYPE matnr,
mtart TYPE mtart,
END OF ty_mara.
TYPES : BEGIN OF TY_MARC,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
END OF TY_MARC.
TYPES : tt_mara TYPE STANDARD TABLE OF ty_mara,
TT_MARC TYPE STANDARD TABLE OF TY_MARC.
DATA : it_mara TYPE tt_mara WITH HEADER LINE,
IT_MARC TYPE TT_MARC WITH HEADER LINE.
SELECT matnr
mtart
FROM mara
INTO TABLE it_mara
WHERE matnr IN s_matnr.
IF IT_MARA IS NOT INITIAL.
SELECT MATNR
WERKS
FROM MARC
INTO TABLE IT_MARC
FOR ALL ENTRIES IN IT_MARA
WHERE MATNR EQ IT_MARA-MATNR.
2007 Jun 26 12:00 PM
HI.
REPORT YARRANGE.
TABLES YTXLFA1.
RANGES: VENDOR FOR YTXFLA1-LIFNR.
- - - -
- - - --
- - - -
SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB
WHERE LIFNR IN VENDOR.
Here with RANGES user has to design an internal table with fields -
SIGN,OPTION,LOW and HIGH EXPLICITLY.
Rewards all helpfull answers.
Regards.
Jay
2007 Jun 26 12:01 PM
RANGES r_vbtyp FOR vbfa-vbtyp_n.
INITIALIZATION.
Include the list of document categories for document check
CLEAR r_vbtyp.
REFRESH r_vbtyp.
r_vbtyp-low = 'K'.
r_vbtyp-option = 'EQ'.
r_vbtyp-sign = 'I'.
APPEND r_vbtyp.
r_vbtyp-low = 'O'.
r_vbtyp-option = 'EQ'.
r_vbtyp-sign = 'I'.
APPEND r_vbtyp.
r_vbtyp-low = 'S'.
r_vbtyp-option = 'EQ'.
r_vbtyp-sign = 'I'.
APPEND r_vbtyp.
Etc....
SELECT vbeln posnv vbelv posnn vbtyp_n vbtyp_v fplnr fpltr FROM vbfa
INTO TABLE t_vbfa_r
FOR ALL ENTRIES IN t_alv1
WHERE vbelv = t_alv1-vbeln AND
<b>NOT vbtyp_n IN r_vbtyp.</b>
2007 Jun 26 12:06 PM
Sangeeta,
U can use SQL as you have mentioned like :
select * from t_city where city in ( 'delhi', 'kol','mum','chennai' )
But using a range is preferrable here because u can add another city
straight in range rather than disturbing the sql stmt .
u can define a range
Range : ra_city like city .
loop,.,
ra_city-f1 = 'delhi'.
append ra_city .
clear ra_city .
endloop.
~ Laxmi
Reward all helpful answers
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |