Generally we move with the listbox that when we select a list item in a listbox we want the other input field to be populated.
here,
we can also do the same with two inputfields,
The POV (PROCESS ON VALUE-REQUEST) is the major event in use here....
where we want one inputfield to be populated on entering a value in another.
the example is here for material and material description.
Starting with creating a program in SE80 with top include and creating a transaction for it as a module pool program....
Create a screen here i have taken as (100)
Take materail number from the program field as (FS_MATERIAL-MATNR)
and material description as from the program here for me (FS_MATERIAL-MAKTX).
now, in the top include the declarations go this way...
*&---------------------------------------------------------------------*
*& Include YH1316_INPUT_VALUES_TOP
*& Module Pool YH1316_INPUT_VALUES
*&
*&---------------------------------------------------------------------*
PROGRAM yh1316_input_values.
tables makt.
TYPES :
BEGIN OF material,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx ,
END OF material.
DATA
: fs_material TYPE material.
DATA :
t_material LIKE
STANDARD
TABLE OF fs_material.
DATA
OK_CODE TYPE SY-UCOMM.
w_matnr(18) type n.
the main program contains all the modules and the include....
the main program is...
*&---------------------------------------------------------------------*
*& Module Pool YH1316_INPUT_VALUES
*&---------------------------------------------------------------------*
INCLUDE YH1316_INPUT_VALUES_TOP . " global Data
* INCLUDE YH1316_INPUT_VALUES_O01 . " PBO-Modules
* INCLUDE YH1316_INPUT_VALUES_I01 . " PAI-Modules
* INCLUDE YH1316_INPUT_VALUES_F01 . " FORM-Routines
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_0100 output.
SET PF-STATUS 'STATUS'.
endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module FILL_DESCRIPTION INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module fill_description input.
call function 'F4IF_FIELD_VALUE_REQUEST'
exporting
tabname = 'MAKT'
fieldname = 'MATNR'
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = 'MATNR'
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 = 'FS_MATERIAL-MATNR'.
* Add it back to the dynpro.
dynfields-fieldname = return-retfield.
dynfields-fieldvalue = return-fieldval.
append dynfields.
w_matnr = return-fieldval.
select matnr
maktx from makt
into table t_material
where matnr = w_matnr
and spras = 'EN'.
if sy-subrc = 0.
loop at t_material into fs_material.
move fs_material-maktx to fs_material-maktx.
endloop.
endif.
dynfields-fieldname = 'FS_MATERIAL-MAKTX'.
dynfields-fieldvalue = fs_material-maktx.
append dynfields.
* UPDATE THE DYNPRO VALUES.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-cprog
dynumb = sy-dynnr
tables
dynpfields = dynfields
exceptions
others = 8.
endmodule. " FILL_DESCRIPTION INPUT
screen layout code...................
process before output.
module status_0100.
process after input.
MODULE USER_COMMAND_0100 . (program BACK FUNCTION)
process on value-request.
field fs_material-matnr module fill_description.
The output is seen as... on selecting the value material description is obtained.....