Go on link..

link us with ...

Monday, January 3, 2011

Dynamic Parameter in Selection Screen

n the last post Dynamic Parameter Texts in Selection Screen (which was so many weeks ago), we discussed how we can change the selection screen parameter by changing the values of some selection screen specific variables. Greets Enno suggested to use the FM SELECTION_TEXTS_MODIFY to handle the selection screen parameters more easily and in standard way.

Some of the readers also left comment on the previous post about the use of this trick. One scenario I came in my mind: Certain Parameter Texts based on the Radio button selection. E.g. We have some radio buttons like Sales Order, Credit Memo, Debit Memo and so on. Based on this radiobutton selection, we want to display the Date's parameter text.

This code snippet will realize this scenario using the FM SELECTION_TEXTS_MODIFY.
Code Snippet to show dynamic parameter text


*&---------------------------------------------------------------------*
*& Report ZTEST_NP_HELPER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZTEST_NP_HELPER.

*----------------------------------------------------------------------*
* Selection Screen Class definition
*----------------------------------------------------------------------*
class lcl_selscr DEFINITION.

PUBLIC SECTION.
class-DATA:
f_date_Text type char30.

CLASS-METHODS:
set_text
IMPORTING
if_name type char8
if_type type char1
if_text type char30,

change_screen.

PRIVATE SECTION.
class-DATA:
t_text type STANDARD TABLE OF RSSELTEXTS.

ENDCLASS. "lcl_selscr DEFINITION

*.... Selection Screen
SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE aaa.
PARAMETERS: p_so RADIOBUTTON GROUP rd1 DEFAULT 'X' USER-COMMAND USR1,
p_cre RADIOBUTTON GROUP rd1,
p_deb RADIOBUTTON GROUP rd1.
PARAMETERS: p_date type datum.
SELECTION-SCREEN: end of BLOCK blk1.

*.... Initialization
INITIALIZATION.
aaa = 'Select an option to continue'.

*.... At Selection-Screen Output
at SELECTION-SCREEN OUTPUT.
* text for Radiobuttons
lcl_selscr=>set_text( if_name = 'P_SO' if_type = 'P' if_TEXT = 'Sales Order' ).
lcl_selscr=>set_text( if_NAME = 'P_CRE' if_type = 'P' if_text = 'Credit memo' ).
lcl_selscr=>set_text( if_NAME = 'P_DEB' if_type = 'P' if_TEXT = 'Debit memo' ).

* determine the text for the P_DATE
CASE 'X'.
WHEN p_so. lcl_selscr=>f_date_text = 'Sales Order Entry Date'.
WHEN p_cre. lcl_selscr=>f_date_text = 'Credit Memo Entry Date'.
WHEN p_deb. lcl_selscr=>f_date_text = 'Debit Memo Entry Date'.
ENDCASE.
lcl_selscr=>set_text( if_name = 'P_DATE' if_type = 'P' if_TEXT = lcl_selscr=>f_date_text ).

* Change the Selection Screen
lcl_selscr=>change_screen( ).

*.... Start of selection
START-OF-SELECTION.
WRITE: 'Date Text', lcl_selscr=>f_date_text.

*----------------------------------------------------------------------*
* Selection Screen Class definition
*----------------------------------------------------------------------*
CLASS lcl_selscr IMPLEMENTATION.

METHOD set_text.
data: la_text LIKE LINE OF t_Text.

la_text-name = if_name.
la_text-KIND = if_type.
la_text-text = if_text.
APPEND la_text to t_text.

ENDMETHOD. "set_text

METHOD change_screen.
CALL FUNCTION 'SELECTION_TEXTS_MODIFY'
EXPORTING
PROGRAM = sy-cprog
TABLES
SELTEXTS = t_text.
ENDMETHOD. "change_screen

ENDCLASS. "lcl_selscr IMPLEMENTATION


2. Selection Screen Parameter Text by coding


Sometimes, we need to dispaly the Dynamic Parameter Text for the parameters in the selection screen.

We can use %_parameter_%_APP_%-TEXT to have the parameter text from the coding.

Code Snippet to show dynamic parameter text
  
*---------------------------------------------------------------------
* Shows how to give the selection screen parameter name by
* using coding
*---------------------------------------------------------------------
REPORT ZTEST_NP_TMP.
*
DATA: w_carrid TYPE sflight-carrid.
*
** Selection Screen
SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE aaa.
SELECT-OPTIONS: s_carrid FOR w_carrid.
SELECTION-SCREEN: END OF BLOCK blk1.
*
INITIALIZATION.
* Description for the parameter
if sy-uname = 'TEST'.
%_s_carrid_%_app_%-text = 'Carrier ID'.
else.
%_s_carrid_%_app_%-text = 'Flight ID'.
endif.


Without the code, we would see the selection screen like this:



And with the code, selection screen would be like this:


We can use this trik:
* Dyanmic Parameter text
* While Sharing the example code

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)