Events on ABAP fields

If you are looking for a way to catch events when user insert a value on some fields in ABAP you can do it very easy usgin PROCESS ON VALUE-REQUEST.

For this example I going to work with VA42 T-CODE, in this transaction we have added some custom fields, please check image below:

custom fields

For this example  I need to change values from search help of  "Dias Facturar" field depends of user selection on "Tipo" field,

Step 1. Add search help to "Tipo" field.

Go to SE38 and put program name, in my case its: MV45AFZZ and looking for 8309 dynpro.

We put these code lines after PROCESS AFTER INPUT:

PROCESS ON VALUE-REQUEST.

FIELD VBAK-ZZTIPO_FACT MODULE F_TIPO_FACTURACION.

FIELD VBAK-ZZDIA_FAC MODULE  F_DIA_FACTURACION.

Now we need to crete modules for these rutines:

f_tipo_facturacion:

I have crated a search help, in this case I only assing this search help to this field:

Module f_dia_facturacion.

This is the interesting part, here I will catch values selected on the search help of  "Tipo", when  user select a value on search help on the previous function module, We will have values selected on t_return table returing for F4IF_FIELD_VALUE_REQUEST, thus we will evaluate this value and depends of value selected we will decided what we need to show on second field or what any other action we need to do, for example show a message or select information from database, in this case, I will fill the search help of "Dias facturar" with diferent values depends of selection on previous field. Please check:

If user opens the search help of "Tipo" they will see these options:

Well, now when user select anyone we will have this value on t_return table, nex step its evaluate this value when user do clic on "Dias facturar":

MODULE f_dia_facturacion.

  TYPES:   BEGIN OF ty_dia,
           dia     TYPE zsded_dia_fact,
           periodo TYPE zztipo_desc,
           END OF ty_dia.

  DATA: it_valu    TYPE STANDARD TABLE OF dselc,
        t_dia      TYPE STANDARD TABLE OF ty_dia,
        l_dia      TYPE ty_dia,
        number_day TYPE n LENGTH 2,
        l_return   TYPE ddshretval,
        cl_util    TYPE REF TO cls_utils.

  CREATE OBJECT cl_util.

  READ TABLE t_return INTO l_return INDEX 1.



  CASE l_return-fieldval.
    WHEN '1' .
      CLEAR: t_dia.
      l_dia-dia    = '0'.
      l_dia-periodo = 'Diario'.
      APPEND l_dia TO t_dia.

    WHEN '2'.
      CLEAR: t_dia.
      number_day = 1.

      DO 7 TIMES.

        l_dia-dia    = number_day.
        l_dia-periodo = cl_util->get_day_name( number_day = number_day  ).
        APPEND l_dia TO t_dia.
        number_day = number_day + 1.
      ENDDO.
    WHEN '3'.
      CLEAR: t_dia.
      number_day = 1.
      DO 28 TIMES.
        l_dia-dia    = number_day.
        l_dia-periodo = 'Día'.
        APPEND l_dia TO t_dia.
        number_day = number_day + 1.
      ENDDO.
*    WHEN OTHERS.
  ENDCASE.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = 'DIA'
      dynpprog        = sy-repid
      dynpnr          = sy-dynnr
      dynprofield     = 'VBAK-ZZDIA_FAC'
      value_org       = 'S'
      display         = 'F'
    TABLES
      value_tab       = t_dia
      dynpfld_mapping = it_valu
    EXCEPTIONS
      parameter_error = 1.

ENDMODULE.

As you can see, depends on value selected we fill table t_dias and shows like on seatch help of  "Dia facturar".

I done this more elaborated but in theory the only thing you need to catch ehe event its puting these lines after PROCESS AFTER INPUT

PROCESS ON VALUE-REQUEST.

FIELD VBAK-ZZTIPO_FACT MODULE F_TIPO_FACTURACION.

FIELD VBAK-ZZDIA_FAC MODULE  F_DIA_FACTURACION.

FIELD VBAK-ZZFACTURISTA MODULE f_usuario.

enjoy it.

Rob.

Leave a Reply

Your email address will not be published. Required fields are marked *

Go up