This scenario will comes in Data Migration project (SLT), where tables do not have primary keys. By using SE16 or SE16N tcodes, it will give short dump when trying to execute the non primary key tables. We can solve this issue by using the below two function modules in one report.
1). Initialize Dynamic Selection: Declare Permitted Tables - 'FREE_SELECTIONS_INIT'
2). Dialog for entering Dynamic Selection Conditions - 'FREE_SELECTIONS_DIALOG'
These FMs will provide SE16 or SE16n functionality.
Step 1: Create one executable report and one screen. In screen place one input field for enter table name and place sub screen area for display dynamic selection screen like SE16 or SE16N.
Step 2: Call standard program subscreen area for above subscreen area like below.
In PBO: CALL SUBSCREEN dynamic_selection_subscreen INCLUDING 'SAPLSSEL' '1105'.
In PAI: CALL SUBSCREEN dynamic_selection_subscreen.
3). after enter the table name in input field, have the ENTER function code and call two function modules inside this function code to display dynamic selection screen like SE16 or SE16N tcode.
Import the user entered selection values and write select statement by using it in where clause. Pass it to ALV FM.