Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

F4IF_INT_TABLE_VALUE_REQUEST

Hi,

I want to do as follows.

I have 2 parameters on selection screen P1 and P2.

If i hit F4 on P1 it brings value list with 2 columns. I want to fill parameter P1 with C1 value and P2 with C2 value when i select any row in the list. I am just wondering to know how it can be done using the following FM.

F4IF_INT_TABLE_VALUE_REQUEST. I appreciate your response.

Thanks

Raj

Former Member
Former Member replied

Hi,

Check this code...

PARAMETES : p_werks type ...
PARAMETES : p_plnnr type ....
PARAMETES : p_plnal type....
 
 
AT SELECTION-SCREEN ON P_PLNNR.
 


  data:
    lg_condition    type string.

  data:
     lwa_ddshretval type ddshretval,
     lwa_dselc      type dselc,
     lwa_dynpread   type dynpread.
  data:
     li_f4_insp     type standard table of t_f4_insp,
     li_ddshretval  type standard table of ddshretval,
     li_dselc       type standard table of dselc,
     li_dynpread    type standard table of dynpread.


  lwa_dynpread-fieldname = 'P_WERKS'.
  append lwa_dynpread to li_dynpread.
  clear lwa_dynpread.
* Read Screen Field Values.
  call function 'DYNP_VALUES_READ'
    exporting
      dyname     = sy-repid
      dynumb     = sy-dynnr
    tables
      dynpfields = li_dynpread.

* Read the first record as only one record will be present
  read table li_dynpread into lwa_dynpread index 1.
  p_werks = lwa_dynpread-fieldvalue.

  if p_werks is initial.
    move 'PLNTY EQ ''Q''' to lg_condition.
  else.
    move 'WERKS EQ P_WERKS AND PLNTY EQ ''Q''' to lg_condition.
  endif.

* Fetch Data
  select werks
         plnnr
         plnal
         plnty
         ktext
    into table li_f4_insp
    from plko
    where (lg_condition).

  lwa_dselc-fldname = 'F0002'.
  lwa_dselc-dyfldname = 'PLNNR'.
  append lwa_dselc to li_dselc.
  clear lwa_dselc.
  lwa_dselc-fldname = 'F0003'.
  lwa_dselc-dyfldname = 'PLNAL'.
  append lwa_dselc to li_dselc.
  clear lwa_dselc.
* FM For F4 Help
  call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    exporting
      retfield        = 'PLNNR'
      dynpprog        = sy-cprog
      dynpnr          = sy-dynnr
      dynprofield     = 'PLNNR'
      value_org       = 'S'
    tables
      value_tab       = li_f4_insp
      return_tab      = li_ddshretval
      dynpfld_mapping = li_dselc
    exceptions
      parameter_error = 1
      no_values_found = 2
      others          = 3.

  if sy-subrc eq 0.
    refresh li_dynpread.
    read table li_ddshretval into lwa_ddshretval index 1.
    if sy-subrc eq 0.
      move lwa_ddshretval-fieldval to p_plnnr.
      lwa_dynpread-fieldname = 'P_PLNNR'.
      lwa_dynpread-fieldvalue = lwa_ddshretval-fieldval.
      append lwa_dynpread to li_dynpread.
      clear lwa_dynpread.
    endif.                             " IF sy-subrc EQ 0.
    read table li_ddshretval into lwa_ddshretval index 2.
    if sy-subrc eq 0.
      move lwa_ddshretval-fieldval to p_plnal.
      lwa_dynpread-fieldname = 'P_PLNAL'.
      lwa_dynpread-fieldvalue = lwa_ddshretval-fieldval.
      append lwa_dynpread to li_dynpread.
      clear lwa_dynpread.
    endif.                             " IF sy-subrc EQ 0.
  endif.                               " IF sy-subrc EQ 0.

* Set Screen Field Values.
  call function 'DYNP_VALUES_UPDATE'
    exporting
      dyname               = sy-repid
      dynumb               = sy-dynnr
    tables
      dynpfields           = li_dynpread
    exceptions
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      undefind_error       = 7
      others               = 8.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question