Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

selection-screen

Former Member
0 Likes
547

If I choose a value by pressing f4 in a field in selection-screen I have to get the vales even into the next 2 fields (Ex: If I select a material by pressing f4 then I should get the related values like plant and storage location in the next 2 fiedls) How I can get it?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
518

<b>Run the below code to get the result u required</b>

If I choose a value by pressing f4 in a field in selection-screen I have to get the vales even into the next 2 fields

report zabc.

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.

break-point.

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.

start-of-selection.

5 REPLIES 5
Read only

Former Member
0 Likes
518

You have to use the function module:

DYNP_VALUES_UPDATE. Check the documentation for more details.

regards,

Ravi

Read only

Former Member
0 Likes
518

Hi,

U can Use the FM "DYNP_VALUES_READ" to read the Values that u have Entered. Just Read the Value and Based on that value build the further Help.

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

Read only

Former Member
0 Likes
519

<b>Run the below code to get the result u required</b>

If I choose a value by pressing f4 in a field in selection-screen I have to get the vales even into the next 2 fields

report zabc.

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.

break-point.

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.

start-of-selection.

Read only

rahulkavuri
Active Contributor
0 Likes
518

i have a code sample for the exact requirement for which I myself am the author

here i am dynamically populating 2 screen values based on F4 help

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a07a330f-126c-2910-c684-d2a45f0f...

award points if found helpful

Read only

Former Member
0 Likes
518

HI,

check this...

<b>

TABLES: mara, makt.

DATA mat LIKE mara-matnr.

DATA: BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

END OF itab.

DATA : BEGIN OF btab OCCURS 0,

maktx LIKE makt-maktx,

END OF btab.

DATA mak LIKE makt-maktx.

DATA : return LIKE ddshretval OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF dynpfields OCCURS 3.

INCLUDE STRUCTURE dynpread.

DATA: END OF dynpfields.

PARAMETERS: p_matnr LIKE mara-matnr,

p_maktx LIKE makt-maktx.

INITIALIZATION.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.

REFRESH itab.

SELECT matnr FROM mara INTO TABLE itab.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'MATNR '

dynprofield = 'P_MATNR '

dynpprog = sy-repid

dynpnr = sy-dynnr

value_org = 'S'

TABLES

value_tab = itab

return_tab = return.

mat = return-fieldval.

UNPACK mat TO mat.

SELECT SINGLE maktx FROM makt INTO mak WHERE matnr = mat AND spras =

sy-langu.

p_matnr = return-fieldval.

REFRESH return.

CLEAR return.

MOVE 'P_MAKTX' TO dynpfields-fieldname.

MOVE mak TO dynpfields-fieldvalue.

APPEND dynpfields.

CALL FUNCTION 'DYNP_VALUES_UPDATE'

EXPORTING

dyname = 'SY-REPID'

dynumb = '1000'

TABLES

dynpfields = dynpfields.

REFRESH return.

CLEAR return.</b>

Regards

SAB