‎2009 Nov 06 12:33 PM
Hi
i have two listboxes and i use only one interanal table to populate data to those listboxes
for first listbox i need 1 to 10.
and second listbox i need one to ten
but it gives first listbox have one to ten.
and second listbox have 1 to 10.
i declared internal table with two fields
num
num1
itab-num have 1 to 10 .
itab-num1 have one to ten.
in debugging it shows correct but it displays in screen reversly
thanks
Surendra Reddy
‎2009 Nov 09 2:47 AM
Hi
See example below - VRM_SET_VALUES is called twice, once for each listbox.
Jonathan
p.s. Note - I've reposted this in two "chunks" because the "code" tags didn't work when the program was over a few lines long... sigh.
report zsdn_jc_listbox_from_array.
type-pools:
vrm.
types::
begin of gtys_data,
num type numc2,
num1 type text15,
end of gtys_data.
data:
gt_data type table of gtys_data.
parameters:
p_list1 type numc2 as listbox visible length 15,
p_list2 type numc2 as listbox visible length 15.
initialization.
perform gt_data_fill.
perform listbox_fill.
start-of-selection.
format reset.
write: / 'Listbox 1 - you chose:', p_list1.
write: / 'Listbox 2 - you chose:', p_list2.
*&---------------------------------------------------------------------*
*& Form gt_data_fill
*&---------------------------------------------------------------------*
form gt_data_fill.
*
* Fill the array with 1 - 10 and "one" - "ten"
*
data:
ls_data type gtys_data,
l_numc2 type numc2.
do 10 times.
clear: ls_data.
add 1 to l_numc2.
*
* The number version
*
ls_data-num = l_numc2.
*
* The word version
*
case l_numc2.
when 1. ls_data-num1 = 'One'.
when 2. ls_data-num1 = 'Two'.
when 3. ls_data-num1 = 'Three'.
when 4. ls_data-num1 = 'Four'.
when 5. ls_data-num1 = 'Five'.
when 6. ls_data-num1 = 'Six'.
when 7. ls_data-num1 = 'Seven'.
when 8. ls_data-num1 = 'Eight'.
when 9. ls_data-num1 = 'Nine'.
when 10. ls_data-num1 = 'Ten'.
endcase.
append ls_data to gt_data.
enddo.
endform. "gt_data_fill
+... to be continued in next post...+
‎2009 Nov 09 2:47 AM
Hi
See example below - VRM_SET_VALUES is called twice, once for each listbox.
Jonathan
p.s. Note - I've reposted this in two "chunks" because the "code" tags didn't work when the program was over a few lines long... sigh.
report zsdn_jc_listbox_from_array.
type-pools:
vrm.
types::
begin of gtys_data,
num type numc2,
num1 type text15,
end of gtys_data.
data:
gt_data type table of gtys_data.
parameters:
p_list1 type numc2 as listbox visible length 15,
p_list2 type numc2 as listbox visible length 15.
initialization.
perform gt_data_fill.
perform listbox_fill.
start-of-selection.
format reset.
write: / 'Listbox 1 - you chose:', p_list1.
write: / 'Listbox 2 - you chose:', p_list2.
*&---------------------------------------------------------------------*
*& Form gt_data_fill
*&---------------------------------------------------------------------*
form gt_data_fill.
*
* Fill the array with 1 - 10 and "one" - "ten"
*
data:
ls_data type gtys_data,
l_numc2 type numc2.
do 10 times.
clear: ls_data.
add 1 to l_numc2.
*
* The number version
*
ls_data-num = l_numc2.
*
* The word version
*
case l_numc2.
when 1. ls_data-num1 = 'One'.
when 2. ls_data-num1 = 'Two'.
when 3. ls_data-num1 = 'Three'.
when 4. ls_data-num1 = 'Four'.
when 5. ls_data-num1 = 'Five'.
when 6. ls_data-num1 = 'Six'.
when 7. ls_data-num1 = 'Seven'.
when 8. ls_data-num1 = 'Eight'.
when 9. ls_data-num1 = 'Nine'.
when 10. ls_data-num1 = 'Ten'.
endcase.
append ls_data to gt_data.
enddo.
endform. "gt_data_fill
+... to be continued in next post...+
‎2009 Nov 09 3:20 AM
and code part 2...
Jonathan
*&---------------------------------------------------------------------*
*& Form listbox_fill
*&---------------------------------------------------------------------*
form listbox_fill.
*
* Use GT_DATA to fill the two listboxes
*
data:
ls_data type gtys_data,
l_id_1 type vrm_id,
l_id_2 type vrm_id,
l_value type vrm_value,
lt_value_1 type vrm_values,
lt_value_2 type vrm_values.
*
* Listbox field names:
*
l_id_1 = 'P_LIST1'. "name of variable in screen
l_id_2 = 'P_LIST2'. "name of variable in screen
loop at gt_data into ls_data.
l_value-key = ls_data-num.
*
* The numeric version - add to lt_value_1 array
*
write: ls_data-num to l_value-text left-justified.
append l_value to lt_value_1.
*
* The numeric version - add to lt_value_2 array
*
l_value-text = ls_data-num1.
append l_value to lt_value_2.
endloop.
*
* Set the two listbox values in memory
*
call function 'VRM_SET_VALUES'
exporting
id = l_id_1
values = lt_value_1.
call function 'VRM_SET_VALUES'
exporting
id = l_id_2
values = lt_value_2.
*
* And provide some defaults
*
p_list1 = '04'.
p_list2 = '02'.
endform. "listbox_fill
‎2009 Nov 09 5:35 AM