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

reading the screen field value

Former Member
0 Likes
1,479

hi,gurus

i need a help from u ,my require ment is i need to read the screen field value and populate into the another field automatically .if i click f4 on that field.

please give me the reply

yours

sunil

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
915

Have a search through SDN for examples of the use of functions DYNP_VALUES_READ (to get field values during F4) and DYNP_VALUES_UPDATE (to write back to any fields on the screen during F4)... I've included a sample program below... type a value in the first field and press F4, and that field value plus some text will be returned in the second field.

Jonathan


report zlocal_jc_dynp_read_update.

parameters:
  p_field(10)           type c obligatory,  "field with F4
  p_desc(40)            type c lower case.

at selection-screen output.
  perform lock_p_desc_field.

at selection-screen on value-request for p_field.
  perform f4_field.

*&---------------------------------------------------------------------*
*&      Form  f4_field
*&---------------------------------------------------------------------*
form f4_field.
*
*" Quick demo custom pick list...
*
  data:
    l_desc             like p_desc,
    l_dyname           like d020s-prog,
    l_dynumb           like d020s-dnum,
    ls_dynpfields      like dynpread,
    lt_dynpfields      like dynpread occurs 10.

  l_dynumb = sy-dynnr.
  l_dyname = sy-repid.
*
*" Read screen value of P_FIELD
*
  ls_dynpfields-fieldname  = 'P_FIELD'.
  append ls_dynpfields to lt_dynpfields.

  call function 'DYNP_VALUES_READ'
    exporting
      dyname     = l_dyname
      dynumb     = l_dynumb
    tables
      dynpfields = lt_dynpfields
    exceptions
      others     = 1.

  check sy-subrc is initial.

*" See what user typed in P_FIELD:
  read table lt_dynpfields into ls_dynpfields
    with key fieldname = 'P_FIELD'.
*
*" normally you would then build your own search list
*" based on value of P_FIELD and call F4IF_INT_TABLE_VALUE_REQUEST
*" but this is just a demo of writing back to the screen...
*" so just put the value from p_field into P_DESC plus some text...
*
  concatenate 'This is a description for' ls_dynpfields-fieldvalue
    into l_desc separated by space.

*" Pop a variable value back into screen
  clear: ls_dynpfields.
  ls_dynpfields-fieldname  = 'P_DESC'.
  ls_dynpfields-fieldvalue = l_desc.
  append ls_dynpfields to lt_dynpfields.

  call function 'DYNP_VALUES_UPDATE'
    exporting
      dyname     = l_dyname
      dynumb     = l_dynumb
    tables
      dynpfields = lt_dynpfields
    exceptions
      others     = 0.

endform.                                                    "f4_field

*&---------------------------------------------------------------------*
*&      Form  lock_p_desc_field
*&---------------------------------------------------------------------*
form lock_p_desc_field.
*" Make P_DESC into a display field
  loop at screen.
    if screen-name = 'P_DESC'.
      screen-input = '0'.
      modify screen.
      exit.
    endif.
  endloop.
endform.                    "lock_p_desc_field

1 REPLY 1
Read only

Former Member
0 Likes
916

Have a search through SDN for examples of the use of functions DYNP_VALUES_READ (to get field values during F4) and DYNP_VALUES_UPDATE (to write back to any fields on the screen during F4)... I've included a sample program below... type a value in the first field and press F4, and that field value plus some text will be returned in the second field.

Jonathan


report zlocal_jc_dynp_read_update.

parameters:
  p_field(10)           type c obligatory,  "field with F4
  p_desc(40)            type c lower case.

at selection-screen output.
  perform lock_p_desc_field.

at selection-screen on value-request for p_field.
  perform f4_field.

*&---------------------------------------------------------------------*
*&      Form  f4_field
*&---------------------------------------------------------------------*
form f4_field.
*
*" Quick demo custom pick list...
*
  data:
    l_desc             like p_desc,
    l_dyname           like d020s-prog,
    l_dynumb           like d020s-dnum,
    ls_dynpfields      like dynpread,
    lt_dynpfields      like dynpread occurs 10.

  l_dynumb = sy-dynnr.
  l_dyname = sy-repid.
*
*" Read screen value of P_FIELD
*
  ls_dynpfields-fieldname  = 'P_FIELD'.
  append ls_dynpfields to lt_dynpfields.

  call function 'DYNP_VALUES_READ'
    exporting
      dyname     = l_dyname
      dynumb     = l_dynumb
    tables
      dynpfields = lt_dynpfields
    exceptions
      others     = 1.

  check sy-subrc is initial.

*" See what user typed in P_FIELD:
  read table lt_dynpfields into ls_dynpfields
    with key fieldname = 'P_FIELD'.
*
*" normally you would then build your own search list
*" based on value of P_FIELD and call F4IF_INT_TABLE_VALUE_REQUEST
*" but this is just a demo of writing back to the screen...
*" so just put the value from p_field into P_DESC plus some text...
*
  concatenate 'This is a description for' ls_dynpfields-fieldvalue
    into l_desc separated by space.

*" Pop a variable value back into screen
  clear: ls_dynpfields.
  ls_dynpfields-fieldname  = 'P_DESC'.
  ls_dynpfields-fieldvalue = l_desc.
  append ls_dynpfields to lt_dynpfields.

  call function 'DYNP_VALUES_UPDATE'
    exporting
      dyname     = l_dyname
      dynumb     = l_dynumb
    tables
      dynpfields = lt_dynpfields
    exceptions
      others     = 0.

endform.                                                    "f4_field

*&---------------------------------------------------------------------*
*&      Form  lock_p_desc_field
*&---------------------------------------------------------------------*
form lock_p_desc_field.
*" Make P_DESC into a display field
  loop at screen.
    if screen-name = 'P_DESC'.
      screen-input = '0'.
      modify screen.
      exit.
    endif.
  endloop.
endform.                    "lock_p_desc_field