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

how to create dynamic selection screen

Former Member
0 Likes
1,962

Dear All,

My requirement is to get a dynamic selection screen for the table same as SE16

The only difference is, upon execute the output has to be downloaded to an excel file instead of list that gets created by SE16

Kind regards,

Sujith

10 REPLIES 10
Read only

Former Member
0 Likes
1,250

hi,

please refer

here is the code of creating dynamic selection screen:

************************************************************************
TABLES: kna1.
************************************************************************
* Internal Tables                                                      *
************************************************************************
DATA: i_filetable TYPE filetable.
************************************************************************
* Screen Parameters                                                    *
************************************************************************
* Begin - Block 1
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: r_local RADIOBUTTON GROUP rad1 USER-COMMAND flg, "Local
            r_server RADIOBUTTON GROUP rad1 DEFAULT 'X'.     "Server
* Begin - Block 2
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETER: p_local  LIKE rlgrap-filename DEFAULT 'C:\' OBLIGATORY.
PARAMETER: p_server LIKE rlgrap-filename DEFAULT '/default' OBLIGATORY.
* End - Block 2
SELECTION-SCREEN END OF BLOCK b2.
* Begin - Block 3
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr, "Customer Number 1
                s_land1 FOR kna1-land1. "Country Key
* End - Block 3
SELECTION-SCREEN END OF BLOCK b3.
* End - Block 1
SELECTION-SCREEN END OF BLOCK b1.
************************************************************************
* At Selection Screen OUTPUT                                           *
************************************************************************
AT SELECTION-SCREEN OUTPUT.
* Check what radiobutton is selected
* Local
  IF r_local = 'X'.
    LOOP AT SCREEN.
      IF "screen-name = 'P_LOCAL'. " OR
         screen-name = '%_P_LOCAL_%_APP_%-TEXT'.
        screen-invisible = '0'.
        screen-input = '1'.
        MODIFY SCREEN.
      ELSEIF screen-name = 'P_SERVER'. " OR
             screen-name = '%_P_SERVER_%_APP_%-TEXT'.
        screen-invisible = '1'.
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
* Server
  ELSE.
    LOOP AT SCREEN.
      IF screen-name = 'P_SERVER' OR
         screen-name = '%_P_SERVER_%_APP_%-TEXT'.
        screen-invisible = '0'.
        screen-input = '0'.
        MODIFY SCREEN.
      ELSEIF screen-name = 'P_LOCAL' OR
             screen-name = '%_P_LOCAL_%_APP_%-TEXT' OR
             screen-name = '%_S_KUNNR_%_APP_%-TEXT' OR
             screen-name = '%_S_KUNNR_%_APP_%-OPTI_PUSH' OR
             screen-name = 'S_KUNNR-LOW' OR
             screen-name = '%_S_KUNNR_%_APP_%-TO_TEXT' OR
             screen-name = 'S_KUNNR-HIGH' OR
             screen-name = '%_S_KUNNR_%_APP_%-VALU_PUSH'.             .
        screen-invisible = '1'.
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.
************************************************************************
* At Selection Screen ON VALUE REQUEST                                 *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_local.
  PERFORM filename_local CHANGING p_local.
************************************************************************
START-OF-SELECTION.
************************************************************************
************************************************************************
* Forms                                                                *
************************************************************************
*&---------------------------------------------------------------------*
*&      Form  filename_local
*&---------------------------------------------------------------------*
*&
FORM filename_local CHANGING p_file TYPE rlgrap-filename.
  DATA: vl_rc           TYPE i,
        vl_action       TYPE i.
* Open the File Open Dialog
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      file_filter             = ''
      initial_directory       = 'C:\'
    CHANGING
      file_table              = i_filetable
      rc                      = vl_rc
      user_action             = vl_action
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0 OR vl_rc < 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    IF vl_action EQ cl_gui_frontend_services=>action_ok.
      CLEAR p_file.
      READ TABLE i_filetable INDEX 1 INTO p_file.
    ENDIF.
  ENDIF.
ENDFORM.                               " filename_local

regards

rahul

Edited by: RAHUL SHARMA on Feb 3, 2009 11:08 AM

Read only

0 Likes
1,250

Dear Rahul,

My requement is similar to SE16

The only difference is upon execute, instead of list the data should be downloaded to a file

Kind regards,

Sujith

Read only

0 Likes
1,250

Hi,

Search in the Wiki section with the text dynamic selection screen. You will find many examples.

regards,

Advait

Read only

0 Likes
1,250

Hi

Is my understanding rite

u have ZSE16 , from which u will provide a table name and want to control the fields for selection

and on execute want to download to excel

Cheers

Lavanya

Read only

0 Likes
1,250

Dear Lavanya,

You are right!!! that is what i need

Kind Regards,

Sujith

Read only

0 Likes
1,250

Hi Sujith

Create ZSE16 a report program with selection screen where u can input table name

and on selection of table name call SE16 and let the selection of fields remain as SE16 provides

Settings->Feilds for selection. on execute the data which is prepared for list output display can be downloaded using GUI_DOWNLOAD. Incase you dont want to control fields selection as present in SE16 then a z table needs to be created which will hold the fields which needs to be visible or not

Let me know incase of any further clarifications

Cheers

Lavanya

Read only

0 Likes
1,250

Hi Lavanya,

Upon execute, list should NOT be created instead data should be downloaded to an excel file.

How to capture the list in our z-program with out having the list to be created?

Kind regards,

Sujith

Read only

0 Likes
1,250

Hi Sujith,

Following is the sample code to call the selection screen dynamically hope this helps you ...

parameters :

a type i.

selection-screen begin of screen 100.

parameters :

b type i.

selection-screen end of screen 100.

at selection-screen.

call selection-screen 100.

Read only

0 Likes
1,250

on pressing F8,

call the function gui_download and dont use write statements, list will not be created...

Read only

Former Member
0 Likes
1,250

hi,

first create parameter for table name....

then call se16 like this...

SET PARAMETER ID 'DTB' FIELD p_table.

CALL TRANSACTION 'SE16'.

then it wil goes to se16 with table..

then execute the table

then goto menu EDIT-> Download->it wil ask u to to select file formate..

select file formate ,path

Then click on genarate

File downloaded

Try this....