‎2007 Apr 09 9:42 AM
Dear all,
Hereafter my selection screen:
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-204.
PARAMETERS : p_flag TYPE flag DEFAULT 'X',
p_plant LIKE zmm13jpn-mag_emetteur DEFAULT 'C300' OBLIGATORY,
p_store LIKE t001l-lgort DEFAULT 'C301' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK bl1.
********************************************
Now, I'm using the following Select and FM to limit possible value in p_store field
**********************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_store.
SELECT werks lgort lgobe INTO TABLE i_lgort FROM t001l
WHERE werks = p_plant.
READ TABLE i_lgort WITH KEY lgort = p_store.
w_sloc_desc = i_lgort-lgobe.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
**************************************
The thing is that proceeding that way, since I need p_plant DEFAULT 'C300', the routine keep the value even though I overwrite it manually.
*********************************:
Question:
Is there any way to have p_plant set by DEFAULT with 'C300' for instance, but in case I change it, being able to read the new value before the
'AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_store.'
In order to be able to pass this new value while performing the
'SELECT werks lgort lgobe INTO TABLE i_lgort FROM t001l
WHERE werks = p_plant.' ?
Regards.
‎2007 Apr 09 9:45 AM
Hi Nozome,
It is very confusing, can you explain it in other words.
To read the screen field's values, you can use the FM DYNP_VALUES_READ, but if you explain you requirement, we can see if a simpler altenative exists.
Regards,
Ravi
‎2007 Apr 09 9:45 AM
Hi Nozome,
It is very confusing, can you explain it in other words.
To read the screen field's values, you can use the FM DYNP_VALUES_READ, but if you explain you requirement, we can see if a simpler altenative exists.
Regards,
Ravi
‎2007 Apr 09 10:07 AM
Hi Ravi,
Thanks a lot for the FM.
THe requirement would be as follow:
Two fields in the selection screen:
t001l-werks
t001l-lgort
The fields werks and lgort would have default values and be obligatory but:
when werks value is changed by user at the selection screen, lgort would be cleared, and its possible values would be conditioned by the new value entered in werks.
Regards.
‎2007 Apr 09 10:13 AM
Hi,
In your case, u will not be able to press F4 for LGORT if it is cleared as it is an obligatory field.
Instead, what u can do is dont make LGORT mandatory.
Check it on AT SELECTION-SCREEN event and if it is initial, thenu can give the error msg.
In this case, depending on the Plant values, u will be able to fill the default values for LGORT.
Hope it helps.
Regards,
Himanshu
‎2007 Apr 26 4:14 AM
Hi Ravi,
Thanks for the FM.
I finally succeed in using combination of DYNP_VALUES_READ and F4IF_INT_TABLE_VALUE_REQUEST after having declared the dynprofield in this last one in CAPITAL (ex: 'P_STORE' instead of 'p_store' (parameters: P_STORE like ....)) otherwise it did not work.
Thanks again.
‎2007 Apr 09 9:47 AM
Hi,
Try this below query,if you wish to overwrite p_plant,
SELECT werks lgort lgobe INTO TABLE i_lgort FROM t001l
WHERE werks = p_plant and p_plant NE 'C300'.
‎2007 Apr 09 9:47 AM
Hi,
'AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_store.'
In order to be able to pass this new value while performing the
if p_plant is initial.
p_plant = c_300.
endif.
SELECT werks lgort lgobe INTO TABLE i_lgort FROM t001l
WHERE werks = p_plant.
Best regards,
Prashant
‎2007 Apr 09 9:49 AM
Hi.,,
Execute this sample code... This is of the same requirement !!
<b>tables:mara,makt,mseg.
parameters: p_bukrs type t001-bukrs,
p_butxt type t001-butxt,
p_ort01 type t001-ort01,
p_land1 type t001-land1.
data: dynfields type table of dynpread with header line.
data: return type table of ddshretval with header line.
at selection-screen on value-request for p_bukrs.
call function 'F4IF_FIELD_VALUE_REQUEST'
exporting
tabname = 'T001'
fieldname = 'BUKRS'
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = 'P_BUKRS'
tables
return_tab = return
exceptions
field_not_found = 1
no_help_for_field = 2
inconsistent_help = 3
no_values_found = 4
others = 5.
refresh dynfields.
read table return with key fieldname = 'P_BUKRS'.
Add it back to the dynpro.
dynfields-fieldname = return-retfield.
dynfields-fieldvalue = return-fieldval.
append dynfields.
Get the company code from db and add to dynpro
data: xt001 type t001.
clear xt001.
select single * into xt001
from t001
where bukrs = return-fieldval.
dynfields-fieldname = 'P_BUTXT'.
dynfields-fieldvalue = xt001-butxt.
append dynfields.
dynfields-fieldname = 'P_ORT01'.
dynfields-fieldvalue = xt001-ort01.
append dynfields.
dynfields-fieldname = 'P_LAND1'.
dynfields-fieldvalue = xt001-land1.
append dynfields.
Update the dynpro values.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-cprog
dynumb = sy-dynnr
tables
dynpfields = dynfields
exceptions
others = 8.
</b>
reward if it helps u..
sai ramesh
‎2007 Apr 09 10:04 AM
Hi Nozome,
You are correct. You are getting the old value because 'AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_store. is not getting tiggered.
You will get the changed value only when the above event will trigger.
Hope you understand the problem.
Regards,
Tanmay
‎2007 Apr 09 10:18 AM
Hi Tanmay,
In fact as soon as I click on the match code related to p_store, then I have the 'AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_store logic triggered.
but the select that is part of the logic does not take new value of preceeding p_plant field in case I've manually changed it from the selection screen:
SELECT werks lgort lgobe INTO TABLE i_lgort FROM t001l
WHERE werks = p_plant.
It keeps the default value of the field.
I've tried MOVE p_plant TO werks but does not work.
Any idea?
Regards.
‎2007 Apr 09 10:35 AM
Hi,
----
Tables Declaration
----
tables : vbap. " Sales Document: Item Data
----
Constant Declaration *
----
CONSTANTS:
C_X TYPE C VALUE 'X'. " Translate to Uppercase
----
Variable Declaration *
----
Variable for Table index
data v_sytabix like sy-tabix.
Variable for Program name
data L_NAME LIKE SYST-REPID.
----
Ranges Declaration *
----
Range for getting values form selection screen
DATA: BEGIN OF range1 OCCURS 0,
SIGN(1),
OPTION(2),
LOW LIKE vbap-vbeln,
high like vbap-vbeln,
END OF range1.
----
Structure Declaration *
----
----
Internal table Declaration *
----
Internal table for Report output
data: begin of i_vbap occurs 0,
vbeln like vbap-vbeln, " Sales Document
posnr like vbap-posnr, " Sales Document item
end of i_vbap.
Internal table for output to the F4 help
data: begin of I_DISPLAY occurs 0,
vbeln like vbap-vbeln, " Sales Document
posnr like vbap-posnr, " Sales Document item
end of I_DISPLAY.
Internal table for return value form function module
DATA: BEGIN OF I_RETURNVAL OCCURS 0.
INCLUDE STRUCTURE DDSHRETVAL. " Interface Structure Search
DATA: END OF I_RETURNVAL.
Internal table for F4 help field heading
DATA: I_FIELDTAB LIKE DFIES OCCURS 0 WITH HEADER LINE.
Internal table for getting screen values from selection screen
data L_SCR_FIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.
----
Field-Symbols *
----
----
Selection-screen *
----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME title text-001.
select-options:
S_VBELN for vbap-vbeln no intervals,
S_POSNR for vbap-posnr no intervals.
SELECTION-SCREEN end OF BLOCK B1.
----
AT SELECTION-SCREEN ON VALUE-REQUEST *
----
at selection-screen on value-request for s_posnr-low.
clear: L_SCR_FIELDS, I_FIELDTAB, i_display, I_RETURNVAL.
refresh: L_SCR_FIELDS, I_FIELDTAB, i_display, I_RETURNVAL.
L_NAME = SYST-REPID.
MOVE 'S_VBELN-LOW' TO L_SCR_FIELDS-FIELDNAME.
APPEND L_SCR_FIELDS.
Call the Function module DYNP_VALUES_READ to get the values form
selection screen
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = L_NAME
DYNUMB = SYST-DYNNR
TRANSLATE_TO_UPPER = C_X " X
TABLES
DYNPFIELDS = L_SCR_FIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
INVALID_PARAMETER = 7
UNDEFIND_ERROR = 8
DOUBLE_CONVERSION = 9
STEPL_NOT_FOUND = 10
OTHERS = 11
.
IF SY-SUBRC eq 0.
LOOP AT L_SCR_FIELDS.
range1-sign = 'I'.
range1-option = 'EQ'.
range1-low = L_SCR_FIELDS-FIELDVALUE.
range1-high = space.
append range1.
ENDLOOP.
ENDIF.
F4 help Field headings
I_FIELDTAB-TABNAME = 'I_DISPLAY'.
I_FIELDTAB-FIELDNAME = 'VBELN'.
I_FIELDTAB-POSITION = '1'.
I_FIELDTAB-OUTPUTLEN = '10'.
I_FIELDTAB-INTTYPE = 'C'.
I_FIELDTAB-INTLEN = '10'.
APPEND I_FIELDTAB.
I_FIELDTAB-FIELDNAME = 'POSNR'.
I_FIELDTAB-POSITION = '2'.
I_FIELDTAB-OFFSET = '10'.
I_FIELDTAB-OUTPUTLEN = '6'.
I_FIELDTAB-INTTYPE = 'N'.
I_FIELDTAB-INTLEN = '6'.
APPEND I_FIELDTAB.
Retrieve sales document, Sales document item from table Sales
Document: Item Data(VBAP).
Primary keys used for selection: VBELN
select vbeln posnr from vbap
into table i_display
where vbeln in range1.
Call the function module F4IF_INT_TABLE_VALUE_REQUEST for F4 values
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'POSNR'
WINDOW_TITLE = 'Line Item'
VALUE_ORG = 'S'
MULTIPLE_CHOICE = C_X " (for muliple selection)
TABLES
VALUE_TAB = I_DISPLAY
FIELD_TAB = I_FIELDTAB
RETURN_TAB = I_RETURNVAL
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
Star for For single values
READ TABLE I_RETURNVAL INDEX 1.
S_POSNR-LOW = I_RETURNVAL-FIELDVAL.
End for the single values
Start For multiple selection
loop at i_returnval.
s_posnr-sign = 'I'.
s_posnr-option = 'EQ'.
s_posnr-low = I_RETURNVAL-FIELDVAL.
append s_posnr.
endloop.
sort s_posnr.
read table s_posnr index 1.
End for multiple selection
ENDIF.
----
Start-of-selection *
----
start-of-selection.
Retrieve sales document, Sales document item from table Sales
Document: Item Data(VBAP).
Primary keys used for selection: VBELN
select vbeln posnr from vbap
into table i_vbap
where vbeln in s_vbeln
and posnr in s_posnr.
if the above selection is successful continue the process else exit *
form the report
if sy-subrc ne 0.
message e002 with 'No data to display'.
endif.
----
End-of-selection *
----
end-of-selection.
if not i_vbap[] is initial.
loop at i_vbap.
write:/ i_vbap-vbeln, i_vbap-posnr.
endloop.
endif.