SELECT-OPTIONS:
Select - options is the keyword which accepts single value, multiple single values, single range ,multiple ranges.
Syntax:
Select-options <Name of the select-options> for <variable name>.
eg:
Data V1 TYPE T001-BUKRS .
Select-options S_BUKRS for V1.
(the variable v1 must be decleared before the statement).
eg:
Data V TYPE KNA1-KUNNR.
Select-options S_KUNNR for V.
Syntax of Select-options in Select Query:
Select <field1> <field2>....... from <database table> Into Table <internal table> where <field> in <select-options> .
OBJECT:
Based on given company codes , display the company codes
, company names , and cities.
solution:
backend fetching:
PROGRAM:
*syntax of select options
Data V1 Type T001-Bukrs.
Select-options S_BUKRS for V1.
*syntax of work area.
Data : Begin of WA,
Bukrs Type T001-Bukrs,
Butxt Type T001-Butxt,
Ort01 Type T001-Ort01,
End of WA.
*syntax of internal table
Data IT Like Table of WA.
*select options syntax
Select Bukrs Butxt Ort01 from T001 Into Table IT Where Bukrs in S_BUKRS.
*Loop syntax
Loop At IT into WA.
WRITE : / WA-Bukrs,
WA-Butxt,
WA-Ort01.
ENDLOOP.
>> Save ,check ,activate and test the program then you will find new screen.
>>Provide the from value and to value eg 3000 to 4000
or provide multiple value eg like 3000, 3005.....
>> according to the given values the output is displayed.
PARAMETER:
Parameter is the keyword which accepts single value at run-time.
SYNTAX:
parameter <name of parameter> TYPE <data type>.
eg:
parameter P_BUKRS Type T001-BUKRS.
Syntax of parameter in select query:
Select <field1> <field2>........ from <database table>
Into Table <internal table> where <field> = <parameter>
NOTE:
WE USE WHERE<FIELD> IN <select option> in select options
we use where<field> = <parameter> .
OBJECT:
Based on the given company code , to display the company code, company name and city.
solution:
*parameter syntax
Parameter P_BUKRS Type T001-BUKRS.
*declaring work area and internal table
Data : Begin of WA,
Bukrs Type T001-Bukrs,
Butxt Type T001-Butxt,
Ort01 Type T001-Ort01,
End of WA.
*syntax of internal table
Data IT Like Table of WA.
*select options syntax
Select Bukrs Butxt Ort01 from T001 Into Table IT Where Bukrs = P_BUKRS.
*Loop syntax
Loop At IT into WA.
WRITE : / WA-Bukrs,
WA-Butxt,
WA-Ort01.
ENDLOOP.
>>save ,check, activate, test you will new screen as show in select options.
>> provide the value you will get corsponding output.
Difference between parameters and select options
PARAMETERS SELECT-OPTIONS
1. parameters is the keyword 1. select options is the key-
which accepts the single- -word which accepts the
value at run time. single value,multiple-single
value,single value,multiple
value.
2. without providing any input 2. without providing any
to the parameter we an not input to the select options
get output. we can get the entire
data of database.
Select - options is the keyword which accepts single value, multiple single values, single range ,multiple ranges.
Syntax:
Select-options <Name of the select-options> for <variable name>.
eg:
Data V1 TYPE T001-BUKRS .
Select-options S_BUKRS for V1.
(the variable v1 must be decleared before the statement).
Data V TYPE KNA1-KUNNR.
Select-options S_KUNNR for V.
Syntax of Select-options in Select Query:
Select <field1> <field2>....... from <database table> Into Table <internal table> where <field> in <select-options> .
OBJECT:
Based on given company codes , display the company codes
, company names , and cities.
solution:
backend fetching:
PROGRAM:
*syntax of select options
Data V1 Type T001-Bukrs.
Select-options S_BUKRS for V1.
*syntax of work area.
Data : Begin of WA,
Bukrs Type T001-Bukrs,
Butxt Type T001-Butxt,
Ort01 Type T001-Ort01,
End of WA.
*syntax of internal table
Data IT Like Table of WA.
*select options syntax
Select Bukrs Butxt Ort01 from T001 Into Table IT Where Bukrs in S_BUKRS.
*Loop syntax
Loop At IT into WA.
WRITE : / WA-Bukrs,
WA-Butxt,
WA-Ort01.
ENDLOOP.
>> Save ,check ,activate and test the program then you will find new screen.
>>Provide the from value and to value eg 3000 to 4000
or provide multiple value eg like 3000, 3005.....
>> according to the given values the output is displayed.
PARAMETER:
Parameter is the keyword which accepts single value at run-time.
SYNTAX:
parameter <name of parameter> TYPE <data type>.
eg:
parameter P_BUKRS Type T001-BUKRS.
Syntax of parameter in select query:
Select <field1> <field2>........ from <database table>
Into Table <internal table> where <field> = <parameter>
NOTE:
WE USE WHERE<FIELD> IN <select option> in select options
we use where<field> = <parameter> .
OBJECT:
Based on the given company code , to display the company code, company name and city.
solution:
*parameter syntax
Parameter P_BUKRS Type T001-BUKRS.
*declaring work area and internal table
Data : Begin of WA,
Bukrs Type T001-Bukrs,
Butxt Type T001-Butxt,
Ort01 Type T001-Ort01,
End of WA.
*syntax of internal table
Data IT Like Table of WA.
*select options syntax
Select Bukrs Butxt Ort01 from T001 Into Table IT Where Bukrs = P_BUKRS.
*Loop syntax
Loop At IT into WA.
WRITE : / WA-Bukrs,
WA-Butxt,
WA-Ort01.
ENDLOOP.
>>save ,check, activate, test you will new screen as show in select options.
>> provide the value you will get corsponding output.
Difference between parameters and select options
PARAMETERS SELECT-OPTIONS
1. parameters is the keyword 1. select options is the key-
which accepts the single- -word which accepts the
value at run time. single value,multiple-single
value,single value,multiple
value.
2. without providing any input 2. without providing any
to the parameter we an not input to the select options
get output. we can get the entire
data of database.






Comments
Post a Comment