cancel
Showing results for 
Search instead for 
Did you mean: 

Using Field Tab in matchcode F4IF_INT_TABLE_VALUE_REQUEST

Gonza_90
Explorer
0 Kudos
100

Hi all, I have a problem using the F4IF_INT_TABLE_VALUE_REQUEST function.
What happens is that when I run the routine that consumes the F4IF_INT_TABLE_VALUE_REQUEST function, it shows me the data I need, but with incorrect header titles, for example: F0001, F0002, F0003. For this reason, I am creating a fieldtab with the titles of the headers that I want to show, but when I run the program with the fieldtab, it returns the MANDT data repeated in all the fields.
Could you help me by telling me if I am missing something? Thank you very much!

 

TYPES:
    BEGIN OF ty_module,
      Mandt       TYPE Mandt,
      Row	      TYPE INT4,
      Process     TYPE ZBI_BEN_S01H-PROCESS,
    END OF ty_module.
	
DATA: it_module       TYPE STANDARD TABLE OF ty_module,
it_ret_values   TYPE STANDARD TABLE OF ddshretval.

FORM SHOW_F4_MODULE.

  DATA: wa_fcat   TYPE DFIES,
        it_fcmod  TYPE STANDARD TABLE OF DFIES.

  REFRESH: it_ret_values.

  IF it_module IS INITIAL.
    ObjBenMto->GetModule(
      IMPORTING
        rtdat = it_module ).
  ENDIF.

  CLEAR wa_fcat.
  wa_fcat-tabname   = 'IT_MODULE'.
  wa_fcat-fieldname = 'MANDT'.
  wa_fcat-intlen    = 5.
  wa_fcat-outputlen = 10.
  APPEND wa_fcat TO it_fcmod.

  CLEAR wa_fcat.
  wa_fcat-tabname   = 'IT_MODULE'.
  wa_fcat-fieldname = 'ROW'.
  wa_fcat-intlen    = 5.
  wa_fcat-outputlen = 10.
  APPEND wa_fcat TO it_fcmod.

  CLEAR wa_fcat.
  wa_fcat-tabname   = 'IT_MODULE'.
  wa_fcat-fieldname = 'PROCESS'.
  wa_fcat-intlen    = 50.
  wa_fcat-outputlen = 50.
  APPEND wa_fcat TO it_fcmod.

  IF sy-subrc = 0.
    
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        retfield        = 'PROCESS'
        window_title    = 'Process'
        value_org       = 'S'
      TABLES
        value_tab       = it_module
        field_tab       = it_fcmod
        return_tab      = it_ret_values
      EXCEPTIONS
        parameter_error = 1
        no_values_found = 2
        OTHERS          = 3.

    IF sy-subrc = 0.
      READ TABLE it_ret_values ASSIGNING <fs_rval> INDEX 1.
      IF sy-subrc = 0.
        p_mod   = <fs_rval>-fieldval.
        gv_mod  = <fs_rval>-fieldval.
      ENDIF.
    ENDIF.
  ENDIF.

ENDFORM.

 

the table I get at the end is similar to this one:

MANDTROWPROCESS
200200200
200200200
View Entire Topic
Sandra_Rossi
Active Contributor
0 Kudos

It's because of the DFIES-OFFSET field which you have left zero, so all your fields take the value at offset 0 which is '200'.

It's complex to calculate the offsets yourself.

It's easier to use the callback subroutine, e.g. here to change CARRID header to 'The airline company':

PARAMETERS p_carr TYPE sflight-carrid.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_carr.
  SELECT *
    FROM sflight
    UP TO 10 ROWS
    INTO TABLE @DATA(flights).
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING  retfield         = 'CARRID'
               dynpprog         = sy-repid
               dynpnr           = sy-dynnr
               dynprofield      = 'P_CARR'
               value_org        = 'S'
               callback_program = sy-repid
               callback_form    = 'F4CALLBACK'
    TABLES     value_tab        = flights
    EXCEPTIONS parameter_error  = 1
               no_values_found  = 2
               OTHERS           = 3.
FORM f4callback TABLES   record_tab  STRUCTURE seahlpres
                CHANGING shlp        TYPE shlp_descr
                         callcontrol LIKE ddshf4ctrl.
  LOOP AT VALUE ddfields( ( lfieldname = 'CARRID' reptext = 'The airline company' ) ) REFERENCE INTO DATA(new_ddfield).
    DATA(ddfield) = REF #( shlp-fielddescr[ lfieldname = new_ddfield->lfieldname ] OPTIONAL ).
    ddfield->reptext   = new_ddfield->reptext.
    ddfield->scrtext_s = ''.
    ddfield->scrtext_m = ''.
    ddfield->scrtext_l = ''.
  ENDLOOP.
ENDFORM.