‎2009 Feb 18 9:08 AM
hello frnds
can you send me any sample code for setting/defaulting the values in selection screen.
I have parameter matnr on my selection screen, now the reqyirement is that parameter for Plant and Stock is also to be added in selection screen and when the user enters MATNTR then othr two values(plant & stock) shld be displayed according the MATNR selected.
In which event shld i code?
can you send me any related sample code for it.
-anjali
‎2009 Feb 18 9:17 AM
Hi,
U have to write code for both plant and stock at selction-screen on value request for plant and stock
create F4 help for both plant and stock..
U have to use the FM DYNP_VALUES_READ
DATA :lit_df TYPE STANDARD TABLE OF dynpread
INITIAL SIZE 0 WITH HEADER LINE.
RANGES : lr_tknum FOR zbatchpck_header-tknum.
lit_df-fieldname = 'S_MATNR-LOW'.
APPEND lit_df.
lit_df-fieldname = 'S_MATNR-HIGH'.
APPEND lit_df.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-cprog
dynumb = '1000'
TABLES
dynpfields = lit_df
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.
READ TABLE lit_df INDEX 1.
lr_matnr-low = lit_df-fieldvalue.
READ TABLE lit_df INDEX 2.
lr_matnr-high = lit_df-fieldvalue
lr_matnr-sign = 'I'.
IF lr_matnr-high IS INITIAL.
lr_matnr-option = 'EQ'.
ELSE.
lr_matnr-option = 'BT'.
ENDIF.
APPEND lr_matnr-.
REFRESH : git_disphlp1.
SELECT palnt
stock FROM dbtable INTO TABLE git_disphlp1
WHERE tknum IN lr_matnr-.
IF lr_matnr--low IS NOT INITIAL OR lr_matnr-high IS INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'WERKS' " for plant
dynpprog = sy-cprog
dynpnr = '1000'
dynprofield = 'S_WERKS-LOW'
window_title = 'Load No'
value_org = 'S'
TABLES
value_tab = git_disphlp1
return_tab = git_ret1
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0. "#EC *
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSEIF lr_matnr-high IS NOT INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'WERKS'
dynpprog = sy-cprog
dynpnr = '1000'
dynprofield = 'S_WERKS-HIGH'
window_title = 'Load No'
value_org = 'S'
TABLES
value_tab = git_disphlp1
return_tab = git_ret1
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0. "#EC *
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
Hope this helps...
Regards,
Nagaraj
‎2009 Feb 18 9:10 AM
‎2009 Feb 18 9:10 AM
Hi,
In INITIALIZATION event select stock and plant based on entered MATNR and pass that values into respective parameter.
Regards,
prashant
‎2009 Feb 18 9:14 AM
AT selection-screen on p_Matnr.
Select Plant and Stock from <table>
where Matnr = p_matnr.
‎2009 Feb 18 9:16 AM
** Data declarations
TYPE-POOLS: SLIS.
DATA: DESCRIPTOR TYPE REF TO CL_ABAP_STRUCTDESCR.
DATA: FLDDESCR TYPE DDFIELDS,
WA_FLDDESCR LIKE LINE OF FLDDESCR.
**--- Return table to handle selected field in F4 help ---**
DATA: IT_RETURN LIKE DDSHRETVAL OCCURS 0 WITH HEADER LINE.
TYPES: BEGIN OF TY_HELP,
FIELDNAME TYPE FIELDNAME,
END OF TY_HELP.
DATA: IT_HELP TYPE TABLE OF TY_HELP,
WA_HELP TYPE TY_HELP.
DATA: V_DBTABLE_TEMP TYPE DD02L-TABNAME.
DATA: V_INDEX_NEW TYPE I,
V_INDEX TYPE I VALUE 1.
DATA: IT_FIELDCATALOG1 TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCATLOG1 LIKE LINE OF IT_FIELDCATALOG1.
DATA GD_REPID TYPE SY-REPID.
DATA: DYNFIELDS TYPE TABLE OF DYNPREAD WITH HEADER LINE.
**Selection Screen declarations
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP.
PARAMETERS: P_TABLE LIKE DD02L-TABNAME OBLIGATORY,
P_FIELD LIKE WA_FLDDESCR-FIELDNAME.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK B1." with text text-001.
AT SELECTION-SCREEN ON P_TABLE.
IF NOT P_TABLE IS INITIAL.
SELECT SINGLE TABNAME
FROM DD02L
INTO V_DBTABLE_TEMP
WHERE TABNAME EQ P_TABLE.
IF SY-SUBRC EQ 0.
REFRESH FLDDESCR.
DESCRIPTOR ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_NAME( P_TABLE ).
FLDDESCR = DESCRIPTOR->GET_DDIC_FIELD_LIST( ).
ELSE.
MESSAGE E001 WITH P_TABLE.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON P_FIELD.
IF NOT FLDDESCR IS INITIAL AND P_FIELD IS NOT INITIAL.
READ TABLE FLDDESCR INTO WA_FLDDESCR WITH KEY FIELDNAME = P_FIELD.
IF SY-SUBRC <> 0.
MESSAGE I000 WITH P_FIELD.
STOP.
ENDIF.
ENDIF.
**The list of fields displayed
*AT SELECTION-SCREEN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FIELD.
REFRESH IT_HELP.
DYNFIELDS-FIELDNAME = 'P_TABLE'.
APPEND DYNFIELDS.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TRANSLATE_TO_UPPER = 'X'
TABLES
DYNPFIELDS = DYNFIELDS
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.
READ TABLE DYNFIELDS WITH KEY FIELDNAME = 'P_TABLE'.
P_TABLE = DYNFIELDS-FIELDVALUE.
DESCRIPTOR ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_NAME( P_TABLE ).
FLDDESCR = DESCRIPTOR->GET_DDIC_FIELD_LIST( ).
LOOP AT FLDDESCR INTO WA_FLDDESCR.
WA_HELP-FIELDNAME = WA_FLDDESCR-FIELDNAME.
APPEND WA_HELP TO IT_HELP.
CLEAR WA_HELP.
ENDLOOP.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'FIELDNAME'
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
VALUE_ORG = 'S'
CALLBACK_PROGRAM = SY-CPROG
TABLES
VALUE_TAB = IT_HELP
RETURN_TAB = IT_RETURN
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2.
IF SY-SUBRC EQ 0.
LOOP AT IT_RETURN.
CLEAR P_FIELD.
P_FIELD = IT_RETURN-FIELDVAL.
ENDLOOP.
ENDIF. The key in your requirement lies in the usage of the function module DYNP_VALUES_READ which will help you read the MATNR value entered in the selection screen immediatly after going to the other selection screen.
Hope this helps,
Murthy.
‎2009 Feb 18 9:17 AM
Hi,
U have to write code for both plant and stock at selction-screen on value request for plant and stock
create F4 help for both plant and stock..
U have to use the FM DYNP_VALUES_READ
DATA :lit_df TYPE STANDARD TABLE OF dynpread
INITIAL SIZE 0 WITH HEADER LINE.
RANGES : lr_tknum FOR zbatchpck_header-tknum.
lit_df-fieldname = 'S_MATNR-LOW'.
APPEND lit_df.
lit_df-fieldname = 'S_MATNR-HIGH'.
APPEND lit_df.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-cprog
dynumb = '1000'
TABLES
dynpfields = lit_df
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.
READ TABLE lit_df INDEX 1.
lr_matnr-low = lit_df-fieldvalue.
READ TABLE lit_df INDEX 2.
lr_matnr-high = lit_df-fieldvalue
lr_matnr-sign = 'I'.
IF lr_matnr-high IS INITIAL.
lr_matnr-option = 'EQ'.
ELSE.
lr_matnr-option = 'BT'.
ENDIF.
APPEND lr_matnr-.
REFRESH : git_disphlp1.
SELECT palnt
stock FROM dbtable INTO TABLE git_disphlp1
WHERE tknum IN lr_matnr-.
IF lr_matnr--low IS NOT INITIAL OR lr_matnr-high IS INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'WERKS' " for plant
dynpprog = sy-cprog
dynpnr = '1000'
dynprofield = 'S_WERKS-LOW'
window_title = 'Load No'
value_org = 'S'
TABLES
value_tab = git_disphlp1
return_tab = git_ret1
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0. "#EC *
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSEIF lr_matnr-high IS NOT INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'WERKS'
dynpprog = sy-cprog
dynpnr = '1000'
dynprofield = 'S_WERKS-HIGH'
window_title = 'Load No'
value_org = 'S'
TABLES
value_tab = git_disphlp1
return_tab = git_ret1
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0. "#EC *
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
Hope this helps...
Regards,
Nagaraj
‎2009 Feb 18 9:24 AM
do in INITIALIZATION event
*selection screen
parameters: p_matnr like mara-matnr,
p_werks like marc-werks,
p_stock like mard-INSME "whicever stock u want
initialization
select single werks from marc into p_werks where matnr = p_matnr.
select single INSME from mard into p_stock where matnr = p_matnr.
thanks,