‎2008 Apr 15 7:29 AM
Hi....
Could you please give me more information about ranges and guide me how to use Ranges in the Program.
Thanks in Advance.
‎2008 Apr 15 7:35 AM
Hi Anuja
Plz have a look at the link
http://help.sap.com/saphelp_webas620/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/content.htm
regards
Avik
‎2008 Apr 15 7:41 AM
Hi,
Ranges concept is similar as slect-options.
But the main difference is ranges doesn't call selection screen.
to define ranges,
data: r_vbeln type range of vbeln.
now r_vbeln has the field sign, option, low and high.
Give the values and use this in teh select statement.
example,
********
r_vbeln-low = '1000'.
r_vbeln-high = '2000'.
append r_vbeln.
select * from vbak into table itab where vbeln in r_vbeln.
***********
Reward if it helpful.
Regards,
Bhanu
‎2008 Apr 15 7:45 AM
‎2008 Apr 15 9:12 AM
hii,,,
Ranges
Structure of ranges are similar to select-option.
To make selection without displaying on the selection screen. For this they are filled in initialisation.
For passing the values selected from one table to other table during selection. For this they are filled in select endselect loop.
If called program is using values from ranges, fill the ranges in calling program and pass it along with submit
How to Fill ranges RTAB.
RANGES RTAB FOR TABLE-FIELD.
If RTAB is to filled with range for values between.
INITIALIZATION.
RTAB-SIGN = 'I'
RTAB-LOW = variable/constant with lower value
RTAB-HIGH = variable/constant with higher value
RTAB-OPTION= 'BT'
APPEND RTAB.
If RTAB is to be filled with multiple values from table etc.
then in start of selection before the range is used for retrieval.
START-OF-SELECTION.
CLEAR RTAB.
RTAB-SIGN = 'I'.
RTAB-OPTION = 'EQ'.
select field into var1 from dbtable where .....
RTAB-LOW = var1.
APPEND R-TAB.
ENDSELECT.
The range will be used to retrieve further data for secondary list..
TABLES : LFA1,..........
RANGES : RTAB FOR LFA1-LIFNR.
GET LFA1.
WRITE : MARKFLD1 AS CHECKBOX, LFA-LIFNR, LFA1-NAME........
HIDE LFA1-LIFNR.
END-OF-SELECTION.
SET PF-STATUS 'BASE'.
SET TITLEBAR 'BAS'.
CLEAR LFA1-LIFNR.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'RFKK'.
IF LFA1-LIFNR IS INITIAL.
MESSAGE E024(ZA) WITH 'VENDOR LINE IS NOT SELECTED'.
ELSE
PERFORM ROUTRFKK.
ENDIF
WHEN
.
.
ENDCASE
...
...
FORM ROUTRFKK.
REFRESH RTAB.
MOVE 'I' TO RTAB-SIGN.
MOVE 'EQ' TO RTAB-OPTION.
FILL THE RANGE IN RTAB.
DO.
READ LINE SY-INDEX FIELD VALUE MARKFLD1.
IF SY-SUBRC NE 0.
EXIT.
ENDIF
CHECK MARKFLD1 NE SPACE.
MOVE LFA1-LIFNR TO RTAB-LOW.
APPEND RTAB.
MODIFY LINE SY-INDEX FIELD VALUE MARKFLD1 FROM SPACE.
ENDDO
SUBMIT ZARS0034 AND RETURN WITH KD-LIFNR IN RTAB.
ENDFORM.
Q.30 Do you prefer to use At PFnn or AT USER COMMAND? Why.
AT USER COMMAND.
Because AT PFnn only fires with key press of function key and not with for application tool bar or standard tool bars push buttons. i.e. selection of menu item or Icon Or push button.
pls reward if useful
regards,
rekha
‎2008 Apr 15 1:21 PM
Hi,
For ex:
If you want to populate the table names in ranges the following code :
Declare the ranges table and assign the values and append it.
RANGES : r_tab FOR dd03l-tabname.
CLEAR : r_tab, r_tab[].
r_tab-sign = 'I'.
r_tab-option = 'EQ'.
r_tab-low = 'KNA1'.
APPEND r_tab.
r_tab-low = 'KNB1'.
APPEND r_tab.
r_tab-low = 'KNBK'.
APPEND r_tab.
And retrieve the data based on the ranges table.
SELECT dd03l~tabname
dd03l~fieldname
dd03l~position
dd03l~keyflag
dd03l~rollname
dd04t~scrtext_s
dd04t~scrtext_m
dd04t~scrtext_l
FROM dd03l INNER JOIN dd04t
ON dd03lrollname = dd04trollname
INTO CORRESPONDING FIELDS OF TABLE t_fname
WHERE dd03l~tabname IN r_tab
AND ddlanguage EQ sy-langu.
I think you can understand now how it is populated.
Thanks
‎2008 Apr 15 2:18 PM
‎2008 Apr 16 1:08 AM
Hi Anuja,
You use the RANGES statement to create internal tables of the same type as selection tables.
RANGES <rangetab> FOR <f>.
This statement is simply a shortened form of the following statements:
DATA: BEGIN OF <rangetab> OCCURS 0,
sign(1) TYPE c,
option(2) TYPE c,
low LIKE <f>,
high LIKE <f>,
END OF <rangetab>.
Because the statement represents an obsolete form of defining internal tables with headers and headers should not to be used, you should use above variants of TYPES and DATA statements instead of RANGES.
Tables defined in this way have the same structure as selection tables, but they do not have the same functionality. They are not part of the selection screen: No corresponding input fields are generated and these tables cannot be used as a data interface in a program <prog> called using
SUBMIT <prog> WITH <rangetab> IN <table>.
However, you can use the above statements to create the table <table> in the calling program. The main function of these tables is to pass data to the actual selection tables without displaying the selection screen when executable programs are called.
The above tables are like actual selection tables in the WHERE clause of Open SQL statements and can be used in combination with the IN operator in logical expressions, but they are not linked to a database table. They:are not passed like selection criteria to logical databases cannot be used with the shortened form of selection tables in logical expressions
cannot be used like selection criteria in GET events
REPORT demo_sel_screen_tables_ranges.
RANGES s_carrid1 FOR spfli-carrid.
s_carrid1-sign = 'I'.
s_carrid1-option = 'EQ'.
s_carrid1-low = 'LH'.
APPEND s_carrid1.
SUBMIT demo_selection_screen_ldb_1 WITH carrid IN s_carrid1
VIA SELECTION-SCREEN AND RETURN.
REPORT demo_sel_screen_tables_ranges.
DATA: s_carrid2 TYPE RANGE OF spfli-carrid,
s_carrid2_wa LIKE LINE OF s_carrid2.
s_carrid2_wa-sign = 'I'.
s_carrid2_wa-option = 'EQ'.
s_carrid2_wa-low = 'AA'.
APPEND s_carrid2_wa TO s_carrid2.
SUBMIT demo_selection_screen_ldb_1 WITH carrid IN s_carrid2
VIA SELECTION-SCREEN AND RETURN.
A selection table S_CARRID is created with reference to column CARRID of database table SPFLI. Fields S_CARRID-LOW and S_CARRID-HIGH have the same type as CARRID. The work area of the internal table S_CARRID is filled and appended to the table. Program DEMO2 is called. If DEMO2 is linked to logical database F1S, its selections screen contains the fields of selection criterion CARRID from the logical database. These fields are filled with the contents of the internal table.
Hope its useful.Reward points if useful.
Thanks,
Surya Pydikondala.
‎2008 Apr 16 6:56 AM
Hi Anuja,
Please check this link .
http://www.abapguide.com/uncategorized/select-options-and-range/
Regards,
Muneesh Gitta.