12-29-2009 6:19 AM
Hi Experts,
I Have a table ZMCTR1AM_CNSTNTS with two columns n its entries are as follows.
FIELDNM FIELD_VAL_
Panel Names
Field Group Names
Field Last Name
Field Suffix
Field First Name
Field Middle Initial
Field Nick Name
I have to separate entries in this table based on FIELD_NM = 'PANEL', FIELD_NM = 'FIELD GROUP' and FIELD_NM = 'FIELD' and put them in separate range table.
My range table declaration is as follows,
DATA: ra_panel TYPE RANGE OF JQTATTRIBUTE-PANEL,
ra_field_group TYPE RANGE OF JQTATTRIBUTE-FIELD_GROUP,
ra_field TYPE RANGE OF JQTATTRIBUTE-FIELD.
My select query which didnt work,
SELECT field_val
FROM ZMCTR1AM_CNSTNTS
INTO TABLE ra_panel
WHERE field_nm EQ 'PANEL'.
I havent worked on ranges and tried a lot of search. But didnt find any info. that i could use. Can someone tel me how do i go about doing it. I cannot use SELECT...ENDSELECT and WITH HEADER LINE as coding stds.
Thanks in advance.
Edited by: Herwin Wilmet Dsouza on Dec 29, 2009 7:20 AM
12-29-2009 7:18 AM
Hi Herwin,
I understood your query now. You are using the ranges in the first select statement to build the range to be used later. In that case, you might have to use something like this
DATA: ra_panel TYPE RANGE OF JQTATTRIBUTE-PANEL,
ra_field_group TYPE RANGE OF JQTATTRIBUTE-FIELD_GROUP,
ra_field TYPE RANGE OF JQTATTRIBUTE-FIELD.
data: begin of it_panel occurs 0, "internal table to hold the values
field_val like ZMCTR1AM_CNSTNTS-field_val,
end of it_panel.
data: wa_panel like it_panel. "work area
SELECT field_val
FROM ZMCTR1AM_CNSTNTS
INTO TABLE it_panel
WHERE field_nm EQ 'PANEL'.
loop at it_panel into wa_panel.
ra_panel-sign = 'I'.
ra_panel-option = 'EQ'.
ra_panel-low = wa_panel.
append ra_panel.
endloop.
"similarly build other ranges and use them
Vikranth
12-29-2009 6:36 AM
Hello,
I dont understand why do you need to use a Ranges table in a INTO clause of a select statement. Look like you have misunderstood the use of ranges. Ranges will have a SIGN, OPTION, HIGH and LOW fields and it makes no sense to use them in INTO clause.
You should be using a internal table of the type of the table and use it
data: itab type standard table of ZMCTR1AM_CNSTNTS.
SELECT field_val
FROM ZMCTR1AM_CNSTNTS
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE field_nm EQ 'PANEL'. " Add whatever conditions required
Vikranth
12-29-2009 6:59 AM
Hi vikranth,
I have to get not just the Panel details but also Field group and field details.. then In another select query in need to combne all of these to get record from another table.
I will be using it in the where slause later in another select query which is like this,
SELECT tech_adspec_id field value_fin
FROM JQTATTRIBUTE
INTO CORRESPONDING FIELDS OF TABLE t_names
WHERE panel IN ra_panel
AND field_group IN ra_field_group
AND field IN ra_field
AND tech_adspec_id EQ ls_adspec_id-tech_adspec_id.
But before that all the three ranges needs to have values from the constants table.
12-29-2009 6:37 AM
Hi,
Declare the range table as follows,
ranges: it_matnr FOR vbap-matnr.
Use this range table in the where clause and not in the into table .
Regards,
Abhijit G. Borkar
Edited by: Abhijit Borkar on Dec 29, 2009 7:38 AM
12-29-2009 6:45 AM
Hi,
Declare range like this, chose low and high as per requirement.
types:
begin of ty_range1,
sign type c length 1,
option type c length 2,
low type werks,
high type werks,
end of ty_range1.
data : lt_range type table of ty_range1,
wa_range1 type ty_range1.
You can take into a internal table and then pass it to range table's low if required and if you want to use it in where clause.
Regards
Mohinder
12-29-2009 6:47 AM
You can define range in two ways:
Internal table for Range(Obsolete way, this declares with header line)
RANGES: robs_matnr FOR mara-matnr.
Work area for that range
DATA: waobs_matnr LIKE LINE OF robs_matnr.
Internal table for range(New way)
DATA: rnew_matnr TYPE RANGE OF mara-matnr.
Work area for range
DATA: wanew_matnr LIKE LINE OF rnew_matnr.
DATA: i_matnr TYPE STANDARD TABLE OF mara-matnr.
To fill the range table
wanew_matnr-sign = 'I'. " Sign can be I-Including or E- Excluding
wanew_matnr-option = 'BT'." Option can be BT,EQ,GT,LT etc.
wanew_matnr-low = '000000000000000001'.
wanew_matnr-high = '000000000000000020'.
APPEND wanew_matnr TO rnew_matnr.
SELECT matnr FROM mara INTO TABLE i_matnr
WHERE matnr IN rnew_matnr.
12-29-2009 7:18 AM
Hi Herwin,
I understood your query now. You are using the ranges in the first select statement to build the range to be used later. In that case, you might have to use something like this
DATA: ra_panel TYPE RANGE OF JQTATTRIBUTE-PANEL,
ra_field_group TYPE RANGE OF JQTATTRIBUTE-FIELD_GROUP,
ra_field TYPE RANGE OF JQTATTRIBUTE-FIELD.
data: begin of it_panel occurs 0, "internal table to hold the values
field_val like ZMCTR1AM_CNSTNTS-field_val,
end of it_panel.
data: wa_panel like it_panel. "work area
SELECT field_val
FROM ZMCTR1AM_CNSTNTS
INTO TABLE it_panel
WHERE field_nm EQ 'PANEL'.
loop at it_panel into wa_panel.
ra_panel-sign = 'I'.
ra_panel-option = 'EQ'.
ra_panel-low = wa_panel.
append ra_panel.
endloop.
"similarly build other ranges and use them
Vikranth
12-29-2009 10:01 AM