‎2007 Aug 27 9:35 PM
hi,
i have a table suppose ZTABLE, which has three fields such as (program name), (variant) and (Description).i have to develop a program which will automatically create that much radiobutton with the entry of the ZTABLE, beside the radiobuton it will automatically populate the description of the program.suppose there are 20 program names in the table then when i execut ethe code it will automatically create 20 radiobutton with the description beside.Suppose after 1 month the table entries get 40 then it will create 40 radiobutton.when i choose a radiobuton it will execute the code with the following variant.
can anyone help me out to populate the selection screen.pleaseeeeeeeeeeeeeeeeee.i know it is possible with table control but i have very less ides about it.
thank you.
‎2007 Aug 28 11:12 AM
Hello,
I am not yet clear with the need of the radio button,but in table control if you enable the selection lines > a tab will come for each line--> u can click on a TAB(commonly known as "sel" Button/TAB) and execute the program
In the code you can identify for which line the SEL button has been clicked and you can do a call transaction or other means to run the program..it serves the same purpose i guess....
If you still want the radio button , you can go to the scree number containing the control table -> double click on it -> go to screen Layout and on the left side ->5th button in the left column "Radio Button" -> click it and drag and drop onto the control table -> it will come in a different colour on the table control...double click on it and assign function code and name
Then you can program the control table to do the work for you
Please see the following link to learn more on table controls
These are general help and not help specific to the radio button problem...
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/content.htm
1)What a table control is?
2)Table controls offer users the functions
3)Table Controls on the Screen
4)Table Controls in the Flow Logic
5)Table Controls in ABAP Programs
6)Table Controls: Examples with Scrolling
7)Table Controls: Examples with Modifications
Appendix: The Step Loop Technique
For more examples...in SAP itself
Run t-code : ABAPDOCU
go to BC ABAP Programming -> ABAP USER DIALOGS ->SCreens -> Complex screen elements ->
1) table control with scrolling (REPORT demo_dynpro_tabcont_loop.)
2) Table control with modifications(REPORT demo_dynpro_tabcont_loop_at.)
Hope it was useful
Reward if helpful
Regards
Byju
‎2007 Aug 28 1:18 PM
Here's a program to do what you want
Forget Table controls . Use ALV. Once you've got a "generalized:"class as shown in this program you can use it for almost anything and can generate new programs very quickly indeed.
Took me 3 mins to code this as I already had the class.
I've populated the table with the 1st 200 Z* entries but you could do this via a selection such as a parmeter or standard select options.
You can decide what to put in the internal table in form POPULATE_DYNAMIC_ITAB.
You need to define your output structure as follows.
Don't change the name s_elements but put your structure between the begin and end of the s_elements types.
The CLASS will do the rest.
TYPES: BEGIN OF s_elements,
name TYPE trdirt-name,
variant TYPE varid-variant,
text type trdirt-text,
status(5) type c,
END OF s_elements.
DATA: t_elements TYPE TABLE OF s_elements, "refers to our ITAB
Create a screen with a custom container on it called CCONTAINER1. (Not a spelling error. Call it CCONTAINER1).
Now run this code (optionally you can create a status SE41 to get SAP standard toolbar on top of your screen and screen title).
When you double click a row / cell you'll get the program name and variant back.
(There's a break-point in the code).
Modify this to do what you want.
Program ZZSDNTEST.
INCLUDE ZZJIMBOXX_INCL. * <================== shown below
TABLES : trdirt,
varid.
TYPES: BEGIN OF s_elements,
name TYPE trdirt-name,
variant TYPE varid-variant,
text type trdirt-text,
status(5) type c,
END OF s_elements.
DATA: t_elements TYPE TABLE OF s_elements, "refers to our ITAB
my_line TYPE s_elements.
START-OF-SELECTION.
CALL SCREEN 100.
END-OF-SELECTION.
MODULE status_0100 OUTPUT.
CREATE OBJECT z_object EXPORTING z_object = z_object.
CALL METHOD z_object->build_dynamic_structures
EXPORTING
my_line = my_line
calling_program = sy-repid
IMPORTING
dy_table = dy_table
CHANGING
it_fldcat = it_fldcat.
Here before displaying you can change the field catalog to
adjust your own names
Method call just uses the names in the table structure.
col_name 1 'Program' '20'.
col_name 2 'Variant' '20'.
col_name 3 'Description ' '30'.
PERFORM populate_dynamic_itab.
CALL METHOD z_object->display_grid
EXPORTING
g_outtab = <dyn_table>
g_fldcat = it_fldcat
CHANGING
it_fldcat = it_fldcat
gt_outtab = <dyn_table>.
SET PF-STATUS '0001'.
SET TITLEBAR '000'.
ENDMODULE.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'RETURN'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
FORM populate_dynamic_itab.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
SELECT avariant bname b~text
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
UP TO 200 rows
FROM ( varid as a
inner join trdirt as b
ON areport eq bname )
WHERE a~report like 'Z%'
AND b~sprsl eq sy-langu.
Populate Dynamic table and save a copy
create 2nd Dyn table to hold original data (optional)
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <orig_table>.
CREATE DATA dy_line LIKE LINE OF <orig_table>.
ASSIGN dy_line->* TO <dyn_wa>.
<orig_table> = <dyn_table>.
ENDFORM.
FORM DATA_CHANGED
USING
changed_tab
inserted_tab
deleted_tab
modified_cells_tab.
ENDFORM.
FORM process.
Orig table is in dynamic table <orig_table>
ALV GRID changed table is in <dyn_table>.
Loop AT <orig_table> INTO <dyn_wa>.
Do what you want
end
ENDLOOP.
ENDFORM.
FORM refresh.
CALL METHOD z_object->refresh_grid.
ENDFORM.
form dubbelklik using
e_row type LVC_S_ROW
e_column type LVC_S_col
es_row_no type lvc_s_roid.
field-symbols: <row_nr> type any.
assign e_row to <row_nr>.
break-point 1.
READ TABLE <dyn_table> index <row_nr> into my_line.
my_line-status = 'C-PRG'.
here submit your program
program is in my_line-name
variant is in my_line-variant.
modify <dyn_table> from my_line index <row_nr>.
SET TITLEBAR '001'.
i_gridtitle = 'ALV display change title here'.
CALL METHOD z_object->change_title
EXPORTING i_gridtitle = i_gridtitle.
PERFORM refresh.
call method z_object->set_cursor
EXPORTING column_id = e_column
row_no = es_row_no.
Here's the INCLUDE
Generic ALV class etc for use as INCLUDE Jimbo 2007.
DEFINE col_name.
READ TABLE it_fldcat INTO wa_it_fldcat INDEX &1.
wa_it_fldcat-coltext = &2.
wa_it_fldcat-outputlen = &3.
modify it_fldcat from wa_it_fldcat index &1.
END-OF-DEFINITION.
DEFINE toolbar_funcs.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_TYPE.
MOVE &1 TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE &2 TO ls_toolbar-icon.
MOVE &3 TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
END-OF-DEFINITION.
INCLUDE <icon>.
FIELD-SYMBOLS :
<fs1> TYPE STANDARD TABLE,
<fs0> TYPE STANDARD TABLE,
<dyn_table> TYPE STANDARD TABLE,
<orig_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY.
CLASS zcl_alv_test DEFINITION DEFERRED.
DATA:
z_object TYPE REF TO zcl_alv_test, "Instantiate our class
it_fldcat TYPE lvc_t_fcat,
i_gridtitle TYPE lvc_title,
wa_it_fldcat TYPE lvc_s_fcat,
new_table TYPE REF TO DATA,
dy_table TYPE REF TO DATA,
inserted_tab TYPE lvc_t_moce,
deleted_tab TYPE LVC_T_MOCE,
changed_tab TYPE REF TO DATA,
is_layout TYPE LVC_S_LAYO,
modified_cells_tab TYPE LVC_T_MODI,
dy_line TYPE REF TO DATA.
CLASS zcl_alv_test DEFINITION.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING
z_object TYPE REF TO zcl_alv_test,
display_grid
IMPORTING
g_outtab TYPE STANDARD TABLE
g_fldcat TYPE lvc_t_fcat
CHANGING
it_fldcat TYPE lvc_t_fcat
GT_OUTTAB TYPE STANDARD TABLE,
change_title
IMPORTING
i_gridtitle TYPE lvc_title,
refresh_grid,
set_cursor
IMPORTING
column_id TYPE lvc_s_col
row_no TYPE lvc_s_roid,
build_dynamic_structures
IMPORTING
my_line TYPE ANY
calling_program TYPE sy-repid
EXPORTING
dy_table TYPE REF TO DATA
CHANGING
it_fldcat TYPE lvc_t_fcat .
PRIVATE SECTION.
*
Attributes
*
DATA:
lr_rtti_struc TYPE REF TO cl_abap_structdescr,
zog LIKE LINE OF lr_rtti_struc->components,
zogt LIKE table of zog,
struct_grid_lset TYPE lvc_s_layo,
e_row TYPE lvc_s_row,
e1_row TYPE i,
e_value TYPE c,
e1_col TYPE i,
e_column TYPE lvc_s_col,
es_rowid TYPE lvc_s_roid,
es_row_id TYPE LVC_S_ROW,
es_col_id TYPE LVC_S_COL,
es_row_no TYPE lvc_s_roid,
grid_container1 TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid,
ls_layout TYPE kkblo_layout,
lt_fieldcat_wa TYPE kkblo_fieldcat,
gt_outtab TYPE REF TO DATA,
l_mode TYPE raw4,
celltab TYPE lvc_t_styl,
wa_celltab TYPE lvc_s_styl,
lt_fieldcat TYPE kkblo_t_fieldcat,
l_tabname TYPE slis_tabname,
ls_toolbar TYPE stb_button,
caller TYPE sy-repid,
g_outtab1 TYPE REF TO DATA,
g_fldcat1 TYPE REF TO DATA.
*
Event Receivers - These methods are entered
when the specified event occurs
*
EVENTS: before_user_command.
METHODS:
on_user_command
FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm
sender,
on_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive,
on_dubbelklik
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no,
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed,
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING
e_modified
et_good_cells,
*
Rest of the methods
*
process,
dubbelklik
IMPORTING
e_row TYPE lvc_s_row
e_column TYPE lvc_s_col
es_row_no TYPE lvc_s_roid,
return_structure
IMPORTING
my_line TYPE ANY,
create_dynamic_fcat
EXPORTING
it_fldcat TYPE lvc_t_fcat,
create_dynamic_table
IMPORTING
it_fldcat TYPE lvc_t_fcat
EXPORTING
dy_table TYPE REF TO DATA,
download_to_excel,
refresh.
ENDCLASS. "zcl_alv_test DEFINITION
*
Implementation definition
*
CLASS zcl_alv_test IMPLEMENTATION.
*
Constructor
create our reference / instance to cl_gui_alv_grid
*
METHOD constructor.
CREATE OBJECT grid_container1
EXPORTING
container_name = 'CCONTAINER1'.
CREATE OBJECT grid1
EXPORTING
i_parent = grid_container1.
*
Set event handlers
*
SET HANDLER z_object->on_user_command for grid1.
SET HANDLER z_object->on_toolbar for grid1.
SET HANDLER Z_OBJECT->handle_data_changed FOR grid1.
SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDMETHOD. "constructor
*
Rest of the methods
*
METHOD on_dubbelklik.
CALL METHOD me->dubbelklik
EXPORTING
e_row = e_row
e_column = e_column
es_row_no = es_row_no.
ENDMETHOD. "on_dubbelklik
*
METHOD set_cursor.
CALL METHOD grid1->set_current_cell_via_id
EXPORTING
is_column_id = column_id
is_row_no = row_no.
ENDMETHOD.
METHOD handle_data_changed.
break-point 1.
call method grid1->get_current_cell
IMPORTING
e_row = e1_row
e_value = e_value
e_col = e1_col
es_row_id = es_row_id
es_col_id = es_col_id
es_row_no = es_row_no.
changed_tab = er_data_changed->mp_mod_rows.
inserted_tab = er_data_changed->mt_inserted_rows.
deleted_tab = er_data_changed->mt_deleted_rows.
modified_cells_tab = er_data_changed->mt_mod_cells.
PERFORM data_changed IN PROGRAM (caller) IF FOUND
USING changed_tab
inserted_tab
deleted_tab
modified_cells_tab.
ENDMETHOD. "handle_data_changed
METHOD handle_data_changed_finished.
ENDMETHOD. "handle_data_changed_finished
METHOD return_structure.
lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( my_line ).
zogt[] = lr_rtti_struc->components.
ENDMETHOD. "return_structure
METHOD create_dynamic_fcat.
LOOP AT zogt INTO zog.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = zog-name .
wa_it_fldcat-dataTYPE = zog-TYPE_kind.
wa_it_fldcat-intTYPE = zog-TYPE_kind.
wa_it_fldcat-intlen = zog-length.
wa_it_fldcat-decimals = zog-decimals.
wa_it_fldcat-coltext = zog-name.
wa_it_fldcat-lowercase = 'X'.
case sy-tabix.
When 2.
wa_it_fldcat-edit = 'X'.
When 4.
wa_it_fldcat-edit = 'X'.
when 6.
wa_it_fldcat-edit = 'X'.
when others.
wa_it_fldcat-edit = ' '.
endcase.
APPEND wa_it_fldcat TO it_fldcat .
ENDLOOP.
ENDMETHOD. "create_dynamic_fcat
METHOD download_to_excel.
assign g_outtab1->* to <fs0>.
assign g_fldcat1->* to <fs1>.
CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
EXPORTING
it_fieldcat_lvc = <fs1>
is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
IMPORTING
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
CLEAR lt_fieldcat_wa-tech_complete.
IF lt_fieldcat_wa-tabname IS initial.
lt_fieldcat_wa-tabname = '1'.
MODIFY lt_fieldcat FROM lt_fieldcat_wa.
ENDIF.
l_tabname = lt_fieldcat_wa-tabname.
ENDLOOP.
CALL FUNCTION 'ALV_XXL_CALL'
EXPORTING
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
TABLES
it_outtab = <fs0>
EXCEPTIONS
fatal_error = 1
no_display_possible = 2
others = 3.
IF sy-subrc <> 0.
message id sy-msgid TYPE 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMETHOD. "download_to_excel
METHOD change_title.
CALL METHOD grid1->set_gridtitle
EXPORTING
i_gridtitle = i_gridtitle.
ENDMETHOD. "CHANGE_TITLE
METHOD create_dynamic_table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = dy_table.
ENDMETHOD. "create_dynamic_table
METHOD build_dynamic_structures.
caller = calling_program.
CALL METHOD me->return_structure
EXPORTING
my_line = my_line.
CALL METHOD me->create_dynamic_fcat
IMPORTING
it_fldcat = it_fldcat.
CALL METHOD me->create_dynamic_table
EXPORTING
it_fldcat = it_fldcat
IMPORTING
dy_table = dy_table.
ENDMETHOD. "build_dynamic_structures
METHOD display_grid.
GET REFERENCE OF g_outtab INTO g_outtab1.
GET REFERENCE OF g_fldcat INTO g_fldcat1.
struct_grid_lset-grid_title = 'ALV generic class'.
struct_grid_lset-zebra = 'X '.
struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
struct_grid_lset-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_ready_for_input "sets WHOLE GRID editable in one step
EXPORTING
i_ready_for_input = '1'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = struct_grid_lset
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = it_fldcat.
ENDMETHOD. "display_grid
METHOD on_user_command.
CASE e_ucomm.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'EXCEL'.
CALL METHOD me->download_to_excel.
WHEN 'SAVE'.
WHEN 'PROC'.
CALL METHOD me->process.
WHEN 'REFR'.
CALL METHOD me->refresh.
ENDCASE.
ENDMETHOD. "on_user_command
METHOD on_toolbar.
customize this section with your own Buttons
When a button is pressed method ON_USER_COMMAND is entered
toolbar_funcs 'EXIT' icon_system_end 'Click2exit'.
toolbar_funcs 'SAVE' icon_system_save 'Savedata'.
toolbar_funcs 'EDIT' icon_toggle_display_change 'Edit data'.
toolbar_funcs 'PROC' icon_businav_process 'Process'.
toolbar_funcs 'EXCEL' icon_xxl 'Excel'.
toolbar_funcs 'REFR' icon_refresh 'Refresh'.
ENDMETHOD. "on_toolbar
METHOD refresh_grid.
CALL METHOD cl_gui_cfw=>flush.
CALL METHOD grid1->refresh_table_display.
ENDMETHOD. "refresh_grid
METHOD refresh.
PERFORM refresh IN PROGRAM (caller) IF FOUND.
ENDMETHOD. "refresh
METHOD process.
PERFORM process IN PROGRAM (caller) IF FOUND.
ENDMETHOD. "process
METHOD dubbelklik.
perform dubbelklik IN PROGRAM (caller) IF FOUND
USING e_row
e_column
es_row_no.
ENDMETHOD. "dubbelklik
ENDCLASS. "zcl_alv_test IMPLEMENTATION
endform.