‎2011 Mar 08 5:12 PM
Hello Together,
I'm searching for a solution of the following problem:
I need in the 'AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file_d'
part the content of a select-option variable (named 's_shiftd').
This should happen in a normal report. p_file_d is declared as a parameter (char 128).
The select-option variable 's_shiftd' is declared in the same (entry) dynpro as a num 10 type.
I need the latest content of 's_shiftd' when F4 was pressed for parameter p_file_d.
How can I get this content.
The function "DYNP_VALUES_READ" gives only the content of the fields 's_shiftd-low' and 's_shiftd-high'.
But I need every input made by the user in the ranges table behind 's_shiftd'.
Thanks for your support!
Jens.
‎2011 Mar 09 6:50 AM
Hi,
Try this
first
-
**F4 help to fetch Accounting Document Number
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_belnr-low.
lv_string = 'S_BELNR-LOW'.
**Fatch the Accounting No. List from database table
PERFORM select_belnr USING lv_string
CHANGING i_bkpf.
**Show F4 list
PERFORM f4_belnr_list USING lv_string
CHANGING s_belnr-low.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_belnr-high.
lv_string = 'S_BELNR-HIGH'.
**Fatch the Accounting No. List from database table
PERFORM select_belnr USING lv_string
CHANGING i_bkpf.
**Show F4 list
PERFORM f4_belnr_list USING lv_string
CHANGING s_belnr-high.
FORM select_belnr USING lv_string TYPE dfies-fieldname
CHANGING p_i_bkpf TYPE t_bkpf.
RANGES: s_belnr1 FOR bkpf-belnr.
CLEAR: p_i_bkpf.
CLEAR s_belnr1[].
**Fetch the values entered by user on selection screen
PERFORM read_selection_screen USING lv_string.
**Read the value
READ TABLE dynfields WITH KEY fieldname = lv_string.
IF sy-subrc = 0
AND dynfields-fieldvalue IS NOT INITIAL.
s_belnr1-low = dynfields-fieldvalue.
s_belnr1-sign = 'I'.
s_belnr1-option ='CP'.
APPEND s_belnr1.
ENDIF.
**Fetch the data from database table
SELECT belnr
FROM bkpf
INTO TABLE p_i_bkpf
WHERE bukrs GE space
AND belnr IN s_belnr1
AND gjahr GE space
AND blart EQ 'AB'.
**Remove Duplicate Records
SORT p_i_bkpf BY belnr.
DELETE ADJACENT DUPLICATES FROM p_i_bkpf.
ENDFORM. " SELECT_BELNR
FORM f4_belnr_list USING p_retfield
CHANGING p_belnr.
CLEAR: ret_tab.
**Call F4 Help Value-request
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = p_retfield
value_org = 'S'
TABLES
value_tab = i_bkpf
return_tab = ret_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
**Read the Value selected by user
READ TABLE ret_tab INTO w_ret_tab INDEX 1.
IF sy-subrc = 0.
p_belnr = w_ret_tab-fieldval.
ENDIF.
CLEAR: i_bkpf,
ret_tab.
ENDFORM. " F4_BELNR_LIST
FORM read_selection_screen USING p_dynfields TYPE dfies-fieldname.
CLEAR: dynfields.
REFRESH : dynfields.
**Append field name
dynfields-fieldname = p_dynfields.
APPEND dynfields.
**Fetch the field Values
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
TABLES
dynpfields = dynfields.
ENDFORM. " READ_SELECTION_SCREEN
DECLARATION PART
TYPES: BEGIN OF ty_bkpf,
belnr TYPE bkpf-belnr,
END OF ty_bkpf.
TYPES: t_bkpf TYPE TABLE OF ty_bkpf.
Data: i_bkpf TYPE t_bkpf.
DATA: dynfields TYPE TABLE OF dynpread WITH HEADER LINE.
DATA: ret_tab TYPE STANDARD TABLE OF ddshretval,
w_ret_tab TYPE ddshretval.
Try the aboe code hope this will work for you.
thanks
lalit
‎2011 Mar 08 7:38 PM
No sure if I completely understand the request, but you could simply loop at your select-option field to get the low value for each:
tables: pa0000.
SELECTION-SCREEN begin of BLOCK b0.
SELECT-OPTIONS: s_selopt for pa0000-pernr.
SELECTION-SCREEN end of BLOCK b0.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_selopt-low.
perform get_value.
START-OF-SELECTION.
end-of-SELECTION.
&----
*& Form GET_VALUE
&----
text
----
--> p1 text
<-- p2 text
----
form GET_VALUE .
loop at s_selopt.
*validate s_selopt-low
endloop.
endform. " GET_VALUE
Warren
Edited by: Warren Clements on Mar 8, 2011 8:39 PM
‎2011 Mar 08 8:21 PM
Halo Jens,
When you declare a select option in the selection screen . In the background an internal table is created( range for that select option ) .
This internal table will have structure fields like LOW HIGH SIGN OPTION
So your select option s_shiftd will be an internal table structure like above.
LOW represents the from value
HIGH represents the to value
SIGN represents whether it is I(Inclusive) or E(Exclusive)
OPTION represents the comparison operator (Like EQ,NE,etc )
Regards
Arshad
‎2011 Mar 09 6:50 AM
Hi,
Try this
first
-
**F4 help to fetch Accounting Document Number
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_belnr-low.
lv_string = 'S_BELNR-LOW'.
**Fatch the Accounting No. List from database table
PERFORM select_belnr USING lv_string
CHANGING i_bkpf.
**Show F4 list
PERFORM f4_belnr_list USING lv_string
CHANGING s_belnr-low.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_belnr-high.
lv_string = 'S_BELNR-HIGH'.
**Fatch the Accounting No. List from database table
PERFORM select_belnr USING lv_string
CHANGING i_bkpf.
**Show F4 list
PERFORM f4_belnr_list USING lv_string
CHANGING s_belnr-high.
FORM select_belnr USING lv_string TYPE dfies-fieldname
CHANGING p_i_bkpf TYPE t_bkpf.
RANGES: s_belnr1 FOR bkpf-belnr.
CLEAR: p_i_bkpf.
CLEAR s_belnr1[].
**Fetch the values entered by user on selection screen
PERFORM read_selection_screen USING lv_string.
**Read the value
READ TABLE dynfields WITH KEY fieldname = lv_string.
IF sy-subrc = 0
AND dynfields-fieldvalue IS NOT INITIAL.
s_belnr1-low = dynfields-fieldvalue.
s_belnr1-sign = 'I'.
s_belnr1-option ='CP'.
APPEND s_belnr1.
ENDIF.
**Fetch the data from database table
SELECT belnr
FROM bkpf
INTO TABLE p_i_bkpf
WHERE bukrs GE space
AND belnr IN s_belnr1
AND gjahr GE space
AND blart EQ 'AB'.
**Remove Duplicate Records
SORT p_i_bkpf BY belnr.
DELETE ADJACENT DUPLICATES FROM p_i_bkpf.
ENDFORM. " SELECT_BELNR
FORM f4_belnr_list USING p_retfield
CHANGING p_belnr.
CLEAR: ret_tab.
**Call F4 Help Value-request
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = p_retfield
value_org = 'S'
TABLES
value_tab = i_bkpf
return_tab = ret_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
**Read the Value selected by user
READ TABLE ret_tab INTO w_ret_tab INDEX 1.
IF sy-subrc = 0.
p_belnr = w_ret_tab-fieldval.
ENDIF.
CLEAR: i_bkpf,
ret_tab.
ENDFORM. " F4_BELNR_LIST
FORM read_selection_screen USING p_dynfields TYPE dfies-fieldname.
CLEAR: dynfields.
REFRESH : dynfields.
**Append field name
dynfields-fieldname = p_dynfields.
APPEND dynfields.
**Fetch the field Values
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
TABLES
dynpfields = dynfields.
ENDFORM. " READ_SELECTION_SCREEN
DECLARATION PART
TYPES: BEGIN OF ty_bkpf,
belnr TYPE bkpf-belnr,
END OF ty_bkpf.
TYPES: t_bkpf TYPE TABLE OF ty_bkpf.
Data: i_bkpf TYPE t_bkpf.
DATA: dynfields TYPE TABLE OF dynpread WITH HEADER LINE.
DATA: ret_tab TYPE STANDARD TABLE OF ddshretval,
w_ret_tab TYPE ddshretval.
Try the aboe code hope this will work for you.
thanks
lalit
‎2011 Mar 09 8:04 AM
Hello Together,
Thanks for your answers. I think I have to add some infomation.
The question is more, how can I access the latest content in the ranges table behind s_shiftd.
If the user only fills the dynpro fields s_shiftd-low or/and s_shiftd-high in the screen and then presses F4 of parameter p_file_d, there won't be any entry in the range table of s_shiftd (handling the event 'AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file_d').
I find all entries - entered by the user - in the ranges table, when the user presses Enter before using the F4 of the other parameter p_file_d. Also if the user enters the values by the select-option extra window (pressing the button right from the select-option fields) everything is fine.
There is a workaround to use DYNP_VALUES_READ and add the values entered in the screen fields into the ranges table manually.
But I'm searching for a more elegant way to get the latest content entered in the select-option in all possible situations.
Hoping this would describe the situation a bit better.
Thanks
Jens.
‎2011 Mar 10 4:42 AM
Hi Jens,
I think there is nothing wrong in using the Function Module.
Thanks,
Rathish