SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Read/Populate Selection Screen Parameters Dynamically



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Tue Sep 04, 2007 5:23 pm    Post subject: Read/Populate Selection Screen Parameters Dynamically Reply with quote

Applies to:
SAP 4.6c
Summary
The main purpose of this article is to focus on dynamic read and dynamic population of selection screen
parameter values.

Author(s):Rahul Kavuri

Company: Intelligroup Asia Pvt. Ltd.

Created on:October 26, 2006

Selection Screen Scenario Requirement
Here we are going to simulate a stock market scenario for a better understanding. The selection screen
contains the
. Stock Exchange Name
. Stock Name
. Stock Code and
. Last Traded Price on the exchange asthe parameters.
Our requirement is to fill the STOCK CODE and LAST TRADED PRICE based on the STOCK NAME
selected which may have been entered either manually or selected using F4 Help.
Process
Based on the exchange selected using the drop down we are going to modify the values which are going to
be displayed when the user presses F4 by dynamically reading the value selected in the Drop Down menu.
When the user selects one of the stock from the pop up window of F4 request the corresponding Stock Code
and the last traded price are loaded fromthe table ZEXCH into the parameters Stock Name and Stock
Code and finally updated on the selection screen dynamically.
The process can be summarized into 3 steps
1. Read the value selected in the drop down
2. Displaying the pop up window when the user uses F4 help
3. Populate the values in the parameters

Code for Selection Screen
Code:
*&---------------------------------------------------------------------*
*& REPORT Z_SDN_SEL *
*&---------------------------------------------------------------------*
REPORT Z_SDN_SEL .
************************************************************************
* TYPE POOLS DECL'ON *
************************************************************************
TYPE-POOLS : VRM.

************************************************************************
* TABLES *
************************************************************************
TABLES: ZBANKCODE,
ZUSERDATA,
ZUSERDETAILS,
ZSELORD,
ZBUYORD,
ZEXCH,
SSCRFIELDS.
************************************************************************
* DATA DECLARATIONS AND VARIABLES *
************************************************************************
DATA : V TYPE VRM_VALUES.
DATA : DROPDOWN LIKE LINE OF V.
* VARS FOR DYNAMIC SCREEN POPULATION
DATA: PROGNAME TYPE SY-REPID,
DYNNUM TYPE SY-DYNNR,
DYNPRO_VALUES TYPE TABLE OF DYNPREAD,
FIELD_VALUE LIKE LINE OF DYNPRO_VALUES.
DATA: RETURN TYPE TABLE OF DDSHRETVAL WITH HEADER LINE.
DATA: DYNFIELDS TYPE TABLE OF DYNPREAD WITH HEADER LINE.
* VARS FOR SELECTION-SCREEN POPULATION
DATA: T_CODE LIKE ZEXCH-STOCK.
DATA: T_CURRPR LIKE ZEXCH-CURRPR.
DATA: T_CHAR(10).
************************************************************************
* INTERNAL TABLES *
************************************************************************
DATA: BEGIN OF TEMP_ITAB OCCURS 0,
ST_CODE LIKE ZEXCH-STOCK,
ST_NAME LIKE ZEXCH-ST_NAME,
CURRPR LIKE ZEXCH-CURRPR,
END OF TEMP_ITAB.
************************************************************************
* SELECTION-SCREEN *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
SELECTION-SCREEN COMMENT 1(10) TEXT-R01 FOR FIELD BUY.
PARAMETERS: BUY RADIOBUTTON GROUP G1.
SELECTION-SCREEN POSITION 16.
SELECTION-SCREEN COMMENT 16(10) TEXT-R02 FOR FIELD SELL.
PARAMETERS: SELL RADIOBUTTON GROUP G1.
SELECTION-SCREEN END OF LINE.
PARAMETERS: EXCH(3) TYPE C AS LISTBOX VISIBLE LENGTH 10,
* EXCHANGE CHECKBOX
ST_NAME LIKE ZEXCH-ST_NAME ,
* STOCK NAME FROM EXCHANGE
ST_CODE LIKE ZEXCH-STOCK,
* STOCK ID FROM EXCHANGE
CURRPR LIKE ZEXCH-CURRPR ,
* LAST TRADED PRICE
LIMPR LIKE ZBUYORD-LIMPR,
* PRICE AT WHICH USER WANTS TO BUY
QTY LIKE ZBUYORD-QTY.
* QUANTITY THE USER WANTS TO BUY
SELECTION-SCREEN END OF BLOCK B1.
INITIALIZATION.
 * VARS FOR DYNAMIC SCREEN POPULATION
PROGNAME = SY-REPID.
DYNNUM = SY-DYNNR.
* VARS FOR POPULATION OF DROPDOWN
DROPDOWN-KEY = '1'.
DROPDOWN-TEXT = 'BSE'.
APPEND DROPDOWN TO V.
DROPDOWN-KEY = '2'.
DROPDOWN-TEXT = 'NSE'.
APPEND DROPDOWN TO V.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'EXCH'
VALUES = V
EXCEPTIONS
ID_ILLEGAL_NAME = 1
OTHERS = 2.

Read the value in the drop down
AT SELECTION-SCREEN ON VALUE-REQUEST FOR ST_NAME.
CLEAR: FIELD_VALUE, DYNPRO_VALUES.
REFRESH DYNPRO_VALUES.
FIELD_VALUE-FIELDNAME = 'EXCH'.
APPEND FIELD_VALUE TO DYNPRO_VALUES.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TRANSLATE_TO_UPPER = 'X'
TABLES
DYNPFIELDS = DYNPRO_VALUES.
READ TABLE DYNPRO_VALUES INDEX 1 INTO FIELD_VALUE.
IF FIELD_VALUE-FIELDVALUE IS NOT INITIAL.
IF SY-SUBRC = 0 AND FIELD_VALUE-FIELDVALUE = 1.
FIELD_VALUE-FIELDVALUE = 'BSE'.
ELSEIF SY-SUBRC = 0 AND FIELD_VALUE-FIELDVALUE = 2.
FIELD_VALUE-FIELDVALUE = 'NSE'.
ENDIF.

Display the pop up window when the user uses F4 help

Code:
SELECT STOCK ST_NAME
CURRPR
FROM
ZEXCH
INTO TABLE TEMP_ITAB
WHERE EXCH = FIELD_VALUE-FIELDVALUE.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'ST_NAME'
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'ST_NAME'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = TEMP_ITAB
RETURN_TAB = RETURN.


Populate the values in the selection screen parameters dynamically
Code:
SELECT STOCK CURRPR
FROM ZEXCH
INTO (T_CODE, T_CURRPR)
WHERE ST_NAME = RETURN-FIELDVAL.
ENDSELECT.

CLEAR DYNPRO_VALUES[].
FIELD_VALUE-FIELDNAME = 'ST_NAME'.
FIELD_VALUE-FIELDVALUE = RETURN-FIELDVAL.
APPEND FIELD_VALUE TO DYNPRO_VALUES .
FIELD_VALUE-FIELDNAME = 'ST_CODE'.
FIELD_VALUE-FIELDVALUE = T_CODE.
APPEND FIELD_VALUE TO DYNPRO_VALUES .
FIELD_VALUE-FIELDNAME = 'CURRPR'.
FIELD_VALUE-FIELDVALUE = T_CURRPR.
APPEND FIELD_VALUE TO DYNPRO_VALUES .
* UPDATE THE DYNPRO VALUES.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = DYNPRO_VALUES.
ENDIF.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.