Thursday, July 19, 2012

Select Option in ABAP

 

For any ABAP Report or an executable giving the selection criterion is important. Presenting the user with selection screen is very easy using Select-Options and Parameters in SAP ABAP.
The basic for of Select-Options in SAP ABAP is as follows.

Select-options: s_vbeln for vbak-vbeln.

In the above statement s_vbeln is defined as an internal table. And it has the following fields.

‘SIGN:’, s_vbeln-sign,
‘OPTION:’, s_vbeln-option,
‘LOW:’, s_vbeln-low,
‘HIGH:’, s_vbeln-high.

__________________________________________________________

Valid data types of f include all elementary ABAP types except data type f. You cannot use data type f, references, or aggregate types.
We will explore Select Options with the help of a small program shown below.

__________________________________________________________

REPORT ZEX_SELECTOPTIONS.
Tables: VBAK,
VBAP.
Data: int_vbak type vbak occurs 0 with header line.
Select-options: s_vbeln for vbak-vbeln.
Select * INTO int_VBAK from VBAK where
VBELN in s_vbeln.
APPEND int_VBAK.
CLEAR int_VBAK.
ENDSELECT.
Loop at s_vbeln.
WRITE: / ‘SIGN:’, s_vbeln-sign,
‘OPTION:’, s_vbeln-option,
‘LOW:’, s_vbeln-low,
‘HIGH:’, s_vbeln-high.
Endloop.
loop at int_vbak.
Write:/ int_vbak-vbeln, int_vbak-AUART.
endloop.

_______________________________________________________

Once the above program is executed, then the user is presented with a selection screen as shown below.
Sales Order No. ___________| to ___________ >>
Basically here you can enter the Sales Order Number as follows.
1) Single Entry
2) Range
3) Selected Sales Order Numbers
In case the user enters only a single Sales Order number then only one order gets selected and the output of the code,

Loop at s_vbeln.
WRITE: / ‘SIGN:’, s_vbeln-sign,
‘OPTION:’, s_vbeln-option,
‘LOW:’, s_vbeln-low,
‘HIGH:’, s_vbeln-high.
Endloop.

is as Follows

SIGN: I OPTION: EQ LOW: 4969 HIGH:
_________________________________________

In case the user enters a range from 4969 to 4977 then the output of the above code is

SIGN: I OPTION: BT LOW: 4969 HIGH: 4977
_______________________________________________

In case the user enters only selected values as 4969, 4970, 4971, 4972 the the output will be as follows.

SIGN: I OPTION: EQ LOW: 4969 HIGH:
SIGN: I OPTION: EQ LOW: 4970 HIGH:
SIGN: I OPTION: EQ LOW: 4971 HIGH:
SIGN: I OPTION: EQ LOW: 4972 HIGH:
SIGN: I OPTION: EQ LOW: 4973 HIGH:
______________________________________________

Note: The output shown above is for the internal table of select options. The result of the selected Sales Order will be different. You can run the code given above and see the output

No comments:

Post a Comment