Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic Selection Options

Former Member
0 Likes
703

Hi Guru's,

The requirement is something like this:

1. The user enters the technical name of the table.

2. The users enter a number of selection options to

fetch the data from the table user enters. The

number of selections options need to be dynamic.

Can you please let me know, which way I need to go in order to get this report done.

Any suggestions greatly appreciated.

Regards,

GPK.

5 REPLIES 5
Read only

Former Member
0 Likes
666

You should look at the code of SE16 transaction, it does exactly the same.

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

Laxmana_Appana_
Active Contributor
0 Likes
666

Hi Praveen,

check this code , this program display the output in ALV for the entered table name (any), also fetchs the records based on the entered number of rows on the selection screen. you can give where condition also, based on where condition it will bring the rows from the table.

REPORT y_test LINE-SIZE 250 .

TYPE-POOLS: slis. " ALV Global Types

DATA: BEGIN OF ty_work ,

buffer(30000),

END OF ty_work.

DATA : work LIKE ty_work OCCURS 0 WITH HEADER LINE,

ws_rec LIKE sy-tabix,

ws_repname LIKE tbprogref-progname,

ws_tabname LIKE dd03l-tabname,

i_fields LIKE dd03l OCCURS 0 WITH HEADER LINE,

ws_flag(1) TYPE c.

FIELD-SYMBOLS <d>.

ASSIGN COMPONENT 0 OF STRUCTURE work TO <d>.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.

PARAMETERS : p_mandt LIKE t000-mandt,

p_rows LIKE rseumod-tbmaxsel DEFAULT 100.

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN: FUNCTION KEY 1.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

PARAMETERS : p_tab LIKE dd03l-tabname OBLIGATORY MEMORY ID dtb,

p_opt LIKE rfc_db_opt-text.

SELECTION-SCREEN END OF BLOCK b1.

FIELD-SYMBOLS :

<lt_data> TYPE table. " Data to display

DATA:

lp_table TYPE REF TO data,

ls_layout TYPE slis_layout_alv.

FIELD-SYMBOLS: <wa> TYPE ANY, <comp> TYPE ANY.

ASSIGN work TO <wa> CASTING TYPE (p_tab).

  • Create internal table

CREATE DATA lp_table TYPE STANDARD TABLE OF (p_tab)

WITH NON-UNIQUE DEFAULT KEY.

ASSIGN lp_table->* TO <lt_data>.

START-OF-SELECTION.

TRANSLATE p_opt TO UPPER CASE. "#EC SYNTCHAR

  • Read data

SELECT * FROM (p_tab)

CLIENT SPECIFIED

INTO CORRESPONDING FIELDS OF TABLE <lt_data>

UP TO p_rows ROWS

WHERE mandt = p_mandt

AND (p_opt)

ORDER BY PRIMARY KEY.

DESCRIBE TABLE <lt_data> LINES ws_rec.

ls_layout-zebra = 'X'.

ls_layout-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_structure_name = p_tab

is_layout = ls_layout

TABLES

t_outtab = <lt_data>.

Regards

Appana

*reward points for useful answers

Read only

0 Likes
666

Hi,

Thank you for your valuable suggestions.

Currently, I am doing exactly as you had stated. But the user wants to see it something like this:

1. For the selection options, he wants to see three box's.

a. Technical Name of the field selection.

b. Box 2 and 3 are for lower and higher limits.

2. He should be in a position to ADD new selection i.e (more than one selection options dynamically with a click of a button)

3. Eg:

Table: VBAP

Selection Options:

VBELN 100 to 200

Click the button to add another selection option

POSNR = 10 to 20

Hope it makes sense.

Regards,

GPK.

Read only

0 Likes
666

Hi,

In that case create a ADD button in the application toolbar , whenever user press this button after entering the table name in selection screen ,dispaly all table fields using FM : ISB_TABLE_READ_FIELDS (or directly read fields from table DD03L) in ALV list with five columns

1.checkbox

2.fieldname

3.from value

4.to value

5.AND/OR option

then user will select the required fields with checkboxces and range in 'from' and 'to' columns and also he can select 'And/Or' options . based on his selection generate where condition and pass to the select statement.

Regards

Appana

Read only

0 Likes
666

Hi Appana,

Thank you for your valuable suggestion. I will try this logic.

If you have a pseudo kind off, it would be great.

Regards,

GPK.