Solved - Dynamic Selection Screen - SAP Community
Solved - Dynamic Selection Screen - SAP Community
m
m
Products and Technology Groups Partners Topics Events What's New Get Started
u
ni
t
y
SAP Community Groups Interest Groups Application Development Discussions
dynamic selection screen
Option
Go to solution
Former Member
2006 Oct 23 10:39 AM
0 Kudos 435
hi!
i need to show this table on the selection screen and next each line add checkbox.
is it possible to do it?
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 1/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
regards
yifat
Reply
1 ACCEPTED SOLUTION
FredericGirod
Active Contributor
2006 Oct 23 10:41 AM
0 Kudos
168
Hi,
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 2/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
REPORT Z_TEST_FG_0071 .
TYPE-POOLS: rsds.
* Macros
DEFINE table_error.
message e398(00) with 'Table' p_table &1.
END-OF-DEFINITION.
DEFINE fixed_val.
is_fdiff-fieldname = is_dfies-fieldname.
is_fdiff-fixed_val = &1.
is_fdiff-no_input = 'X'.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 3/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
* Selection screen
SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME.
PARAMETERS: p_table TYPE tabname OBLIGATORY
MEMORY ID dtb
MATCHCODE OBJECT dd_dbtb_16.
SELECTION-SCREEN: BEGIN OF LINE,
PUSHBUTTON 33(20) selopt USER-COMMAND sel,
COMMENT 55(15) selcnt,
END OF LINE.
SELECTION-SCREEN: SKIP.
PARAMETERS: p_rows TYPE i.
SELECTION-SCREEN: END OF BLOCK b01,
SKIP,
BEGIN OF BLOCK b02 WITH FRAME.
PARAMETERS: p_displ TYPE c AS CHECKBOX.
SELECTION-SCREEN: END OF BLOCK b02.
* Initialization
INITIALIZATION.
MOVE '@4G@ Filter records' TO selopt.
* PBO
AT SELECTION-SCREEN OUTPUT.
IF w_active IS INITIAL.
CLEAR: selcnt.
ELSE.
WRITE w_active TO selcnt LEFT-JUSTIFIED.
ENDIF.
* PAI
AT SELECTION-SCREEN.
IF p_table NE is_x030l-tabname.
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = p_table
IMPORTING
x030l_wa = is_x030l
TABLES
dfies_tab = it_dfies
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 4/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
EXCEPTIONS
OTHERS = 1.
IF is_x030l IS INITIAL.
table_error 'does not exist or is not active'.
ELSEIF is_x030l-tabtype NE 'T'.
table_error 'is not selectable'.
ELSEIF is_x030l-align NE 0.
table_error 'has alignment - cannot continue'.
ENDIF.
CLEAR: w_selid.
ENDIF.
IF sy-ucomm = 'SEL'.
IF w_selid IS INITIAL.
* Init free selection dialog
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 5/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
expressions = it_expr
IMPORTING
selection_id = w_selid
expressions = it_expr
TABLES
tables_tab = it_tables
EXCEPTIONS
OTHERS = 1.
ENDIF.
* Start of processing
START-OF-SELECTION.
PERFORM f_select_table.
PERFORM f_display_table.
*-------------------------------------------------------------
* FORM f_create_table
*-------------------------------------------------------------
FORM f_create_table USING in_tabname.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 6/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 7/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
IF sy-subrc = 0.
ASSIGN it_modif->* TO <ntab>.
ELSE.
WRITE: 'Error creating internal table'.
STOP.
ENDIF.
ENDFORM.
*-------------------------------------------------------------
* FORM f_select_table
*-------------------------------------------------------------
FORM f_select_table.
IF w_active = 0.
SELECT * FROM (p_table)
INTO CORRESPONDING FIELDS OF TABLE <itab>
UP TO p_rows ROWS.
ELSE.
* Selection with parameters
CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
EXPORTING
field_ranges = it_ranges
IMPORTING
where_clauses = it_where.
READ TABLE it_where INTO is_where WITH KEY tablename = p_t
IF sy-dbcnt = 0.
WRITE: 'No record selected'.
STOP.
ENDIF.
ENDFORM.
*-------------------------------------------------------------
* FORM f_display_table
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 8/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
*-------------------------------------------------------------
FORM f_display_table.
DATA: l_answer TYPE c,
l_eflag TYPE c.
CLEAR: w_okcode.
REFRESH: <ntab>.
* Display table contents
CALL FUNCTION 'STC1_FULLSCREEN_TABLE_CONTROL'
EXPORTING
header = p_table
tabname = p_table
display_only = p_displ
endless = 'X'
no_button = space
IMPORTING
okcode = w_okcode
TABLES
nametab = it_dfies
table = <itab>
fielddif = it_fdiff
modif_table = <ntab>
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
IF p_displ IS INITIAL AND w_okcode = 'SAVE'.
* Confirm update
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = p_table
text_question = 'Do you want to update
default_button = '2'
display_cancel_button = ' '
IMPORTING
answer = l_answer
EXCEPTIONS
OTHERS = 1.
IF l_answer = '1'.
* Apply modifications
IF NOT <ntab>[] IS INITIAL.
PERFORM f_add_system USING space.
MODIFY (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 9/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
l_eflag = 'X'.
ENDIF.
ENDIF.
* Apply deletions
IF l_eflag IS INITIAL.
REFRESH: <ntab>.
CALL FUNCTION 'STC1_GET_DATA'
TABLES
deleted_data = <ntab>
EXCEPTIONS
OTHERS = 1.
IF NOT <ntab>[] IS INITIAL.
DELETE (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
ROLLBACK WORK.
l_eflag = 'X'.
ENDIF.
ENDIF.
ENDIF.
* Apply creations
IF l_eflag IS INITIAL.
REFRESH: <ntab>.
CALL FUNCTION 'STC1_GET_DATA'
TABLES
new_data = <ntab>
EXCEPTIONS
OTHERS = 1.
IF NOT <ntab>[] IS INITIAL.
PERFORM f_add_system USING 'X'.
INSERT (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
ROLLBACK WORK.
l_eflag = 'X'.
ENDIF.
ENDIF.
ENDIF.
IF l_eflag IS INITIAL.
COMMIT WORK.
MESSAGE s261(53).
ELSE.
MESSAGE s075(3i).
PERFORM f_select_table.
ENDIF.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 10/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
349
ENDIF.
350
* Display table again
351
PERFORM f_display_table.
352
ENDIF.
353
ENDIF.
354
355
ENDFORM.
356
357
358
*-------------------------------------------------------------
359
* FORM f_add_system
360
*-------------------------------------------------------------
361
FORM f_add_system USING new TYPE c.
362
363
FIELD-SYMBOLS: <irec> TYPE ANY,
364
<upd> TYPE ANY.
365
366
LOOP AT it_fdiff INTO is_fdiff.
367
READ TABLE it_dfies INTO is_dfies
368
WITH KEY fieldname = is_fdiff-fieldname.
369
LOOP AT <ntab> ASSIGNING <irec>.
370
ASSIGN COMPONENT is_fdiff-fieldname OF STRUCTURE <irec>
371
IF is_dfies-datatype = 'CLNT'.
372
<upd> = sy-mandt.
373
ELSE.
374
CASE is_dfies-rollname.
375
WHEN 'AENAM'.
376
<upd> = sy-uname.
377
WHEN 'AEDAT' OR 'LAEDA'.
378
<upd> = sy-datum.
379
WHEN 'AETIM'.
380
<upd> = sy-uzeit.
381
WHEN OTHERS.
382
ENDCASE.
383
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 11/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
Fred
Reply
1 REPLY
FredericGirod
Active Contributor
2006 Oct 23 10:41 AM
0 Kudos
169
Hi,
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 12/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
REPORT Z_TEST_FG_0071 .
TYPE-POOLS: rsds.
* Macros
DEFINE table_error.
message e398(00) with 'Table' p_table &1.
END-OF-DEFINITION.
DEFINE fixed_val.
is_fdiff-fieldname = is_dfies-fieldname.
is_fdiff-fixed_val = &1.
is_fdiff-no_input = 'X'.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 13/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
* Selection screen
SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME.
PARAMETERS: p_table TYPE tabname OBLIGATORY
MEMORY ID dtb
MATCHCODE OBJECT dd_dbtb_16.
SELECTION-SCREEN: BEGIN OF LINE,
PUSHBUTTON 33(20) selopt USER-COMMAND sel,
COMMENT 55(15) selcnt,
END OF LINE.
SELECTION-SCREEN: SKIP.
PARAMETERS: p_rows TYPE i.
SELECTION-SCREEN: END OF BLOCK b01,
SKIP,
BEGIN OF BLOCK b02 WITH FRAME.
PARAMETERS: p_displ TYPE c AS CHECKBOX.
SELECTION-SCREEN: END OF BLOCK b02.
* Initialization
INITIALIZATION.
MOVE '@4G@ Filter records' TO selopt.
* PBO
AT SELECTION-SCREEN OUTPUT.
IF w_active IS INITIAL.
CLEAR: selcnt.
ELSE.
WRITE w_active TO selcnt LEFT-JUSTIFIED.
ENDIF.
* PAI
AT SELECTION-SCREEN.
IF p_table NE is_x030l-tabname.
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = p_table
IMPORTING
x030l_wa = is_x030l
TABLES
dfies_tab = it_dfies
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 14/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
EXCEPTIONS
OTHERS = 1.
IF is_x030l IS INITIAL.
table_error 'does not exist or is not active'.
ELSEIF is_x030l-tabtype NE 'T'.
table_error 'is not selectable'.
ELSEIF is_x030l-align NE 0.
table_error 'has alignment - cannot continue'.
ENDIF.
CLEAR: w_selid.
ENDIF.
IF sy-ucomm = 'SEL'.
IF w_selid IS INITIAL.
* Init free selection dialog
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 15/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
expressions = it_expr
IMPORTING
selection_id = w_selid
expressions = it_expr
TABLES
tables_tab = it_tables
EXCEPTIONS
OTHERS = 1.
ENDIF.
* Start of processing
START-OF-SELECTION.
PERFORM f_select_table.
PERFORM f_display_table.
*-------------------------------------------------------------
* FORM f_create_table
*-------------------------------------------------------------
FORM f_create_table USING in_tabname.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 16/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 17/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
IF sy-subrc = 0.
ASSIGN it_modif->* TO <ntab>.
ELSE.
WRITE: 'Error creating internal table'.
STOP.
ENDIF.
ENDFORM.
*-------------------------------------------------------------
* FORM f_select_table
*-------------------------------------------------------------
FORM f_select_table.
IF w_active = 0.
SELECT * FROM (p_table)
INTO CORRESPONDING FIELDS OF TABLE <itab>
UP TO p_rows ROWS.
ELSE.
* Selection with parameters
CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
EXPORTING
field_ranges = it_ranges
IMPORTING
where_clauses = it_where.
READ TABLE it_where INTO is_where WITH KEY tablename = p_t
IF sy-dbcnt = 0.
WRITE: 'No record selected'.
STOP.
ENDIF.
ENDFORM.
*-------------------------------------------------------------
* FORM f_display_table
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 18/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
*-------------------------------------------------------------
FORM f_display_table.
DATA: l_answer TYPE c,
l_eflag TYPE c.
CLEAR: w_okcode.
REFRESH: <ntab>.
* Display table contents
CALL FUNCTION 'STC1_FULLSCREEN_TABLE_CONTROL'
EXPORTING
header = p_table
tabname = p_table
display_only = p_displ
endless = 'X'
no_button = space
IMPORTING
okcode = w_okcode
TABLES
nametab = it_dfies
table = <itab>
fielddif = it_fdiff
modif_table = <ntab>
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
IF p_displ IS INITIAL AND w_okcode = 'SAVE'.
* Confirm update
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = p_table
text_question = 'Do you want to update
default_button = '2'
display_cancel_button = ' '
IMPORTING
answer = l_answer
EXCEPTIONS
OTHERS = 1.
IF l_answer = '1'.
* Apply modifications
IF NOT <ntab>[] IS INITIAL.
PERFORM f_add_system USING space.
MODIFY (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 19/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
l_eflag = 'X'.
ENDIF.
ENDIF.
* Apply deletions
IF l_eflag IS INITIAL.
REFRESH: <ntab>.
CALL FUNCTION 'STC1_GET_DATA'
TABLES
deleted_data = <ntab>
EXCEPTIONS
OTHERS = 1.
IF NOT <ntab>[] IS INITIAL.
DELETE (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
ROLLBACK WORK.
l_eflag = 'X'.
ENDIF.
ENDIF.
ENDIF.
* Apply creations
IF l_eflag IS INITIAL.
REFRESH: <ntab>.
CALL FUNCTION 'STC1_GET_DATA'
TABLES
new_data = <ntab>
EXCEPTIONS
OTHERS = 1.
IF NOT <ntab>[] IS INITIAL.
PERFORM f_add_system USING 'X'.
INSERT (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
ROLLBACK WORK.
l_eflag = 'X'.
ENDIF.
ENDIF.
ENDIF.
IF l_eflag IS INITIAL.
COMMIT WORK.
MESSAGE s261(53).
ELSE.
MESSAGE s075(3i).
PERFORM f_select_table.
ENDIF.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 20/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
349
ENDIF.
350
* Display table again
351
PERFORM f_display_table.
352
ENDIF.
353
ENDIF.
354
355
ENDFORM.
356
357
358
*-------------------------------------------------------------
359
* FORM f_add_system
360
*-------------------------------------------------------------
361
FORM f_add_system USING new TYPE c.
362
363
FIELD-SYMBOLS: <irec> TYPE ANY,
364
<upd> TYPE ANY.
365
366
LOOP AT it_fdiff INTO is_fdiff.
367
READ TABLE it_dfies INTO is_dfies
368
WITH KEY fieldname = is_fdiff-fieldname.
369
LOOP AT <ntab> ASSIGNING <irec>.
370
ASSIGN COMPONENT is_fdiff-fieldname OF STRUCTURE <irec>
371
IF is_dfies-datatype = 'CLNT'.
372
<upd> = sy-mandt.
373
ELSE.
374
CASE is_dfies-rollname.
375
WHEN 'AENAM'.
376
<upd> = sy-uname.
377
WHEN 'AEDAT' OR 'LAEDA'.
378
<upd> = sy-datum.
379
WHEN 'AETIM'.
380
<upd> = sy-uzeit.
381
WHEN OTHERS.
382
ENDCASE.
383
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM.
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 21/22
09/02/2025 12:03 Solved: dynamic selection screen - SAP Community
Fred
Reply
Trademark Support
Cookie Preferences
Follow
https://community.sap.com/t5/application-development-discussions/dynamic-selection-screen/m-p/1677795 22/22