01-12-2006 6:34 PM
Hi All,
I have a program, in which, apart from other parameters and select-options, i have <b>two parameters</b>, one for <b>Month</b> and another for <b>year</b> (both have drop-down list boxes)
Now, when I run the program, select the values from the drop-down lists for both month and year, make other selections and try create a variant, though the variant is created, it is not holding the value in parameter.
why is it so? Even, i checked the properties that are displayed while creating a variant. The checkboxes for selection-value for these two parameters are <b>greyed out...</b>
can anyone help...
Regards,
Raj
01-12-2006 6:51 PM
Not sure what the problem is. This program is working fine for me. I run the program, make selections from the listbox, then save variant. Then when I pull the variant, the values are coming into the parameter fields.
report zrich_0003 .
type-pools: vrm.
data: ivrm_values type vrm_values.
data: xvrm_values like line of ivrm_values.
data: name type vrm_id.
parameters: p_month as listbox visible length 10.
parameters: p_year as listbox visible length 4.
at selection-screen output.
name = 'P_MONTH'.
refresh ivrm_values.
xvrm_values-key = '1'.
xvrm_values-text = 'January'.
append xvrm_values to ivrm_values.
xvrm_values-key = '2'.
xvrm_values-text = 'February'.
append xvrm_values to ivrm_values.
xvrm_values-key = '2'.
xvrm_values-text = 'March'.
append xvrm_values to ivrm_values.
call function 'VRM_SET_VALUES'
exporting
id = name
values = ivrm_values.
name = 'P_YEAR'.
refresh ivrm_values.
xvrm_values-key = '2001'.
xvrm_values-text = '2001'.
append xvrm_values to ivrm_values.
xvrm_values-key = '2002'.
xvrm_values-text = '2002'.
append xvrm_values to ivrm_values.
xvrm_values-key = '2003'.
xvrm_values-text = '2003'.
append xvrm_values to ivrm_values.
call function 'VRM_SET_VALUES'
exporting
id = name
values = ivrm_values.
Regards,
Rich Heilman
01-12-2006 6:51 PM
Not sure what the problem is. This program is working fine for me. I run the program, make selections from the listbox, then save variant. Then when I pull the variant, the values are coming into the parameter fields.
report zrich_0003 .
type-pools: vrm.
data: ivrm_values type vrm_values.
data: xvrm_values like line of ivrm_values.
data: name type vrm_id.
parameters: p_month as listbox visible length 10.
parameters: p_year as listbox visible length 4.
at selection-screen output.
name = 'P_MONTH'.
refresh ivrm_values.
xvrm_values-key = '1'.
xvrm_values-text = 'January'.
append xvrm_values to ivrm_values.
xvrm_values-key = '2'.
xvrm_values-text = 'February'.
append xvrm_values to ivrm_values.
xvrm_values-key = '2'.
xvrm_values-text = 'March'.
append xvrm_values to ivrm_values.
call function 'VRM_SET_VALUES'
exporting
id = name
values = ivrm_values.
name = 'P_YEAR'.
refresh ivrm_values.
xvrm_values-key = '2001'.
xvrm_values-text = '2001'.
append xvrm_values to ivrm_values.
xvrm_values-key = '2002'.
xvrm_values-text = '2002'.
append xvrm_values to ivrm_values.
xvrm_values-key = '2003'.
xvrm_values-text = '2003'.
append xvrm_values to ivrm_values.
call function 'VRM_SET_VALUES'
exporting
id = name
values = ivrm_values.
Regards,
Rich Heilman
01-12-2006 6:52 PM
Hi,
It is working fine for me. Can you please elobarate the problem.
Send your code .
Lanka
01-12-2006 6:54 PM
Hi Raj,
Send your selection screen code to me at our company's id.
Srinivas
01-12-2006 6:57 PM
Please check the variant attributes, may be the check box for protect field is checked. if it is checked then uncheck and save the variant.
01-12-2006 7:37 PM
Hi All,
In the properties that are displayed at the time we create a variant, the protected checkbox is greyed out for both these two parameters(automatically).
But, how to enable these checkboxes? Maybe this is the reason for not able to hold selected list-box value in parameter.
Regards,
Raj
Here is the relevant code of my program:
REPORT Z10HRR400_UNION_BILLING_TEMP NO STANDARD PAGE HEADING
MESSAGE-ID ZHR
LINE-SIZE 222
LINE-COUNT 50.
----
TYPE-POOL DECLARATIONS
----
TYPE-POOLS :VRM.
----
AT SELECTION-SCREEN
----
Selection Screen for Type of Record Retrived
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-202.
PARAMETERS:P_REC1 RADIOBUTTON group RB1 DEFAULT 'X', "Excess Rec
P_REC2 RADIOBUTTON group RB1. "Excusal Records
SELECTION-SCREEN END OF BLOCK B2.
Selection Screen for Clock Number,Union code,Area,Month,Year,Date
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-263.
SELECT-OPTIONS:S_BNAME FOR PA0001-PERNR, "Personnel Number
S_UNPOS FOR PA9004-Z_UNION_CODE. "Union code
PARAMETERS: P_LOCAL LIKE PA9004-Z_UNION_LOCAL
AS LISTBOX VISIBLE LENGTH 10 OBLIGATORY.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(16) TEXT-215 .
SELECTION-SCREEN POSITION 33.
PARAMETERS:P_DATUM LIKE SY-DATUM. "Week Ending Date
SELECTION-SCREEN COMMENT 44(20) TEXT-214.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(10) TEXT-213 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(10) TEXT-210 .
SELECTION-SCREEN POSITION 33.
PARAMETERS:P_MONTH LIKE T247-LTX AS LISTBOX VISIBLE LENGTH 14.
"Current Month
SELECTION-SCREEN COMMENT 51(6) TEXT-211.
PARAMETERS:P_YEAR LIKE VVIS_SOPTI-SYEAR AS LISTBOX VISIBLE LENGTH 10.
"Current Year
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(10) TEXT-213 .
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS:S_DATE FOR SY-DATUM. "Date
SELECTION-SCREEN END OF BLOCK B1.
Selection Screen For E-Mail
SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-204.
SELECT-OPTIONS:S_EMAIL FOR ADR6-SMTP_ADDR NO INTERVALS.
SELECTION-SCREEN END OF BLOCK B4.
----
AT SELECTION-SCREEN OUTPUT
----
AT SELECTION-SCREEN OUTPUT.
Get Drop down list for Local Union,Month and Year
PERFORM LIST_BOX.
*&----
*
*& Form LIST_BOX
*&----
*
Populate Drop down List for Selection Screen Parameter P_MONTH
*----
FORM LIST_BOX .
Declare WA and variables
DATA : WA_LIST TYPE VRM_VALUES WITH HEADER LINE, " Work Area for
" Dropdown ListBox
L_YEAR(4), " Local Variable for Year
L_MONTH(2), " Local Variable for Month
L_MONTH_NAME(20). " Local Variable for Month Name
clear: p_month,
p_year.
Drop down List for 'Union Local' Field
CLEAR I_LIST[].
Move Field Name to Variable
W_NAME = 'P_LOCAL'.
Populate Local Union Values to Internal table
WA_LIST-TEXT = 'CHESHIRE'.
WA_LIST-KEY = 'CHESHIRE'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'E.HARTFORD'.
WA_LIST-KEY = 'E.HARTFORD'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'MIDDLETOWN'.
WA_LIST-KEY = 'MIDDLETOWN'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
FM to opulate Drop down Listbox values for 'Local Union'
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = W_NAME
VALUES = I_LIST
EXCEPTIONS
ID_ILLEGAL_NAME = 1.
IF SY-SUBRC <> 0.
MESSAGE E200 WITH 'Wrong Parameter Name'.
ENDIF.
Drop down List for 'Month' Field
Get Current Month Number
L_MONTH = SY-DATUM+4(2).
CLEAR I_LIST[].
Populate Names of month into Internal table
W_NAME = 'P_MONTH'.
WA_LIST-TEXT = 'January'.
WA_LIST-KEY = '01'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'February'.
WA_LIST-KEY = '02'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'March'.
WA_LIST-KEY = '03'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'April'.
WA_LIST-KEY = '04'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'May'.
WA_LIST-KEY = '05'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'June'.
WA_LIST-KEY = '06'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'July'.
WA_LIST-KEY = '07'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'August'.
WA_LIST-KEY = '08'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'September'.
WA_LIST-KEY = '09'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'October'.
WA_LIST-KEY = '10'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'November'.
WA_LIST-KEY = '11'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'December'.
WA_LIST-KEY = '12'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
sort i_list by key.
FM to opulate Drop down Listbox values for 'Month'
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = W_NAME
VALUES = I_LIST
EXCEPTIONS
ID_ILLEGAL_NAME = 1.
IF SY-SUBRC <> 0.
MESSAGE E200 WITH 'Wrong Parameter Name'.
ENDIF.
Dropdown Values for 'Year' field
CLEAR :I_LIST[],W_NAME.
Populate Years into Internal table
W_NAME = 'P_YEAR'.
L_YEAR = 2004.
Populate values for year from 2005 to 2050
DO 59 TIMES.
L_YEAR = L_YEAR + 1.
WA_LIST-TEXT = L_YEAR.
WA_LIST-KEY = L_YEAR.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
IF L_YEAR = 2060.
EXIT.
ENDIF.
ENDDO.
FM to Populate Drop down Listbox values for 'Year'
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = W_NAME
VALUES = I_LIST
EXCEPTIONS
ID_ILLEGAL_NAME = 1.
IF SY-SUBRC <> 0.
MESSAGE E200 WITH 'Wrong Parameter Name'.
ENDIF.
ENDFORM. " LIST_BOX
Message was edited by: Rajasekhar Dinavahi
01-12-2006 8:13 PM
Declare like this
P_MONTH AS LISTBOX VISIBLE LENGTH 14.
P_YEAR AS LISTBOX VISIBLE LENGTH 4.
01-12-2006 8:22 PM
01-12-2006 8:25 PM
01-12-2006 8:32 PM
Hi Rich,
The issue is that the code for filling the list box is in AT SELECTION-SCREEN OUTPUT. It should be in the AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_month/p_year/p_local.
Raj,
I mailed you the modified code, see if it works and close the post once you find it working. Since we work for the same company, please don't reward me. I just wanted to share the solution here with the forum.
Srinivas
01-12-2006 8:34 PM
01-12-2006 8:42 PM
True, but isn't it wrong to have list values given in the AT SELECTION-SCREEN OUTPUT event? This event is triggered several times while the user is performing various things on the selection screen. The logically correct place for such a thing is AT SELECTION-SCREEN ON VALUE-REQUEST FOR event.
Srinivas
01-12-2006 8:50 PM
Really, if the values are always static, shouldn't we put it in the INITIALIZATION event. Then we know that it is always done once.
report zrich_0005 .
type-pools: vrm.
parameters: p_bname type usr01-bname as listbox visible length 20.
<b>initialization.
perform build_user_drop_down_list.</b>
start-of-selection.
write:/ p_bname.
************************************************************************
* build user_drop_down_list
************************************************************************
form build_user_drop_down_list.
data: name type vrm_id,
list type vrm_values,
value like line of list.
data: iusr01 type usr01 occurs 0 with header line.
clear list. refresh list.
name = 'P_BNAME'.
select * into corresponding fields of table iusr01
from usr01.
sort iusr01 ascending by bname.
loop at iusr01.
clear value.
value-key = iusr01-bname.
value-text = iusr01-bname.
append value to list.
endloop.
* Set the values
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
endform.
Regards,
Rich Heilman
01-12-2006 8:56 PM
That I agree, but not the AT SELECTION-SCREEN OUTPUT event.
In this case it is true, but let us say in another situation where you want to fill these only if the user wants the values from an internal table, then you should do it in AT SELECTION-SCREEN ON VALUE-REQUEST. Doing it in INITIALIZATION will unnecessarily add processing and memory consumption if the user never want to go through the drop down list.
01-12-2006 9:05 PM
Just one step further, Srinivas. If you execute the below code, it goes thru that event before even throwing the selection screen. And will pass thru it evertime the user hits enter. So doing it in the INITIALIZATION event may be the best way for static listboxes.
report zrich_0003.
type-pools: vrm.
parameters: p_bname type usr01-bname as listbox visible length 20.
<b>at selection-screen on value-request for p_bname.</b>
perform build_user_drop_down_list.
start-of-selection.
write:/ p_bname.
************************************************************************
* build user_drop_down_list
************************************************************************
form build_user_drop_down_list.
data: name type vrm_id,
list type vrm_values,
value like line of list.
data: iusr01 type usr01 occurs 0 with header line.
clear list. refresh list.
name = 'P_BNAME'.
select * into corresponding fields of table iusr01
from usr01.
sort iusr01 ascending by bname.
loop at iusr01.
clear value.
value-key = iusr01-bname.
value-text = iusr01-bname.
append value to list.
endloop.
* Set the values
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
endform.
Regards,
Rich Heilman
01-12-2006 9:15 PM
and one more step further...
This is specific to listboxes where the execution goes through value-request event even before the selection screen comes up similar to the intialization event. But if you remove the 'as listbox visible length 20' extension, then it will not go through the 'value-request' event unless the user requests for the values.
Listbox has to be ready with values before the selection screen is presented, that is why that is getting executed like 'initialization' event.
01-12-2006 8:39 PM
Hi Rich/Srini,
Rich is right in saying that it can be in AT SELECTION-SCREEN OUTPUT
(Though, ideally it should be AT SELECTION-SCREEN ON VALUE REQUEST.....)
I will comment the clearing of parameters and try execute it tomorrow, once am in office.
Will keep you guys informed...
Thanks & Regards,
Raj
01-12-2006 8:40 PM
Hi,
I made some changes in your code... Please check this.
Rich,
You are right. It is because of the Clear Statement.
----
TYPE-POOL DECLARATIONS
----
TYPE-POOLS :VRM.
----
AT SELECTION-SCREEN
----
Selection Screen for Clock Number,Union code,Area,Month,Year,Date
PARAMETERS: P_LOCAL(10)
AS LISTBOX VISIBLE LENGTH 10 OBLIGATORY.
PARAMETERS:P_MONTH LIKE T247-LTX AS LISTBOX VISIBLE LENGTH 14.
"Current Month
PARAMETERS:P_YEAR LIKE VVIS_SOPTI-SYEAR AS LISTBOX VISIBLE LENGTH 10.
"Current Year
----
AT SELECTION-SCREEN OUTPUT
----
AT SELECTION-SCREEN OUTPUT.
Get Drop down list for Local Union,Month and Year
PERFORM LIST_BOX.
*&----
*
*& Form LIST_BOX
*&----
*
Populate Drop down List for Selection Screen Parameter P_MONTH
*----
FORM LIST_BOX .
Declare WA and variables
DATA : I_LIST TYPE VRM_VALUES, " Work Area for
" Dropdown ListBox
WA_LIST like line of i_list, " Work Area for
" Dropdown ListBox
w_name type VRM_ID,
L_YEAR(4), " Local Variable for Year
L_MONTH(2), " Local Variable for Month
L_MONTH_NAME(20). " Local Variable for Month Name
Drop down List for 'Union Local' Field
CLEAR I_LIST[].
Move Field Name to Variable
W_NAME = 'P_LOCAL'.
Populate Local Union Values to Internal table
WA_LIST-TEXT = 'CHESHIRE'.
WA_LIST-KEY = 'CHESHIRE'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'E.HARTFORD'.
WA_LIST-KEY = 'E.HARTFORD'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'MIDDLETOWN'.
WA_LIST-KEY = 'MIDDLETOWN'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
FM to opulate Drop down Listbox values for 'Local Union'
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = W_NAME
VALUES = I_LIST
EXCEPTIONS
ID_ILLEGAL_NAME = 1.
IF SY-SUBRC <> 0.
MESSAGE E200 WITH 'Wrong Parameter Name'.
ENDIF.
Drop down List for 'Month' Field
Get Current Month Number
L_MONTH = SY-DATUM+4(2).
CLEAR I_LIST[].
Populate Names of month into Internal table
W_NAME = 'P_MONTH'.
WA_LIST-TEXT = 'January'.
WA_LIST-KEY = '01'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'February'.
WA_LIST-KEY = '02'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'March'.
WA_LIST-KEY = '03'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'April'.
WA_LIST-KEY = '04'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'May'.
WA_LIST-KEY = '05'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'June'.
WA_LIST-KEY = '06'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'July'.
WA_LIST-KEY = '07'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'August'.
WA_LIST-KEY = '08'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'September'.
WA_LIST-KEY = '09'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'October'.
WA_LIST-KEY = '10'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'November'.
WA_LIST-KEY = '11'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
WA_LIST-TEXT = 'December'.
WA_LIST-KEY = '12'.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
sort i_list by key.
FM to opulate Drop down Listbox values for 'Month'
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = W_NAME
VALUES = I_LIST
EXCEPTIONS
ID_ILLEGAL_NAME = 1.
IF SY-SUBRC <> 0.
MESSAGE E200 WITH 'Wrong Parameter Name'.
ENDIF.
Dropdown Values for 'Year' field
CLEAR :I_LIST[],W_NAME.
Populate Years into Internal table
W_NAME = 'P_YEAR'.
L_YEAR = 2004.
Populate values for year from 2005 to 2050
DO 59 TIMES.
L_YEAR = L_YEAR + 1.
WA_LIST-TEXT = L_YEAR.
WA_LIST-KEY = L_YEAR.
APPEND WA_LIST TO I_LIST.
CLEAR WA_LIST.
IF L_YEAR = 2060.
EXIT.
ENDIF.
ENDDO.
FM to Populate Drop down Listbox values for 'Year'
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = W_NAME
VALUES = I_LIST
EXCEPTIONS
ID_ILLEGAL_NAME = 1.
IF SY-SUBRC <> 0.
MESSAGE E200 WITH 'Wrong Parameter Name'.
ENDIF.
ENDFORM. " LIST_BOX
Message was edited by: Govindarajan Seenivasan
01-13-2006 9:02 AM
Hi Rich/Srini,
I removed that clear statement which Rich had suggested. Now, the problem is solved.
Regards,
Raj