Wednesday 22 October 2014

FM : DYNP_VALUES_READ Use


The FM 'DYNP_VALUES_READ' can  be used in various scenarios to read the screen field values.
Here in the below post just a use case is provided, where the user provides a sales document number and based on this number the partner values like sold-to-party, ship-to-party, bill-to-party , payer and other partner function associated with the sales document are populated dynamically on the selection-screen field as a option of F4 functionality.

Step1.
----------------------------------------------------------------------------------------------------------
TYPES : BEGIN OF ty_kunnr,
               kunnr TYPE vbpa-kunnr,
               END OF ty_kunnr.

DATA : lt_kunnr   TYPE TABLE OF ty_kunnr,
              lt_dyn_fld TYPE TABLE OF dynpread,
              ls_dyn_fld TYPE dynpread,
              lv_vbeln   TYPE vbak-vbeln,
              lt_ret     TYPE TABLE OF ddshretval.

PARAMETERS :  p_vbeln TYPE vbak-vbeln DEFAULT '0000011762',
                               p_kunnr TYPE char10.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_kunnr.
REFRESH lt_dyn_fld.

ls_dyn_fld-fieldname = 'P_VBELN'.
APPEND ls_dyn_fld TO lt_dyn_fld.
CLEAR ls_dyn_fld.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname                               = sy-cprog
      dynumb                               = sy-dynnr
*     TRANSLATE_TO_UPPER                   = ' '
    TABLES
      dynpfields                           = lt_dyn_fld. " Reads the value of the P_vbeln field

  IF sy-subrc = 0.
   CLEAR ls_dyn_fld.
   READ TABLE lt_dyn_fld INTO ls_dyn_fld WITH KEY fieldname = 'P_VBELN'.
   IF ls_dyn_fld-fieldvalue IS NOT INITIAL.
     lv_vbeln = ls_dyn_fld-fieldvalue.
     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
       EXPORTING
         input         = lv_vbeln
      IMPORTING
         output        = lv_vbeln.
    ON CHANGE OF lv_vbeln.
     REFRESH lt_kunnr.
     SELECT kunnr FROM vbpa INTO TABLE lt_kunnr WHERE vbeln = lv_vbeln.
    ENDON.

       IF lt_kunnr IS NOT INITIAL.
         CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
*            DDIC_STRUCTURE         = ' '
            retfield               = 'KUNNR'
*            PVALKEY                = ' '
            dynpprog               = sy-cprog
            dynpnr                 = sy-dynnr
            dynprofield            = 'P_KUNNR'
*            STEPL                  = 0
*            WINDOW_TITLE           =
*            VALUE                  = ' '
            value_org              = 'S'
           TABLES
             value_tab              = lt_kunnr
*            FIELD_TAB              =
             return_tab             = lt_ret
*            DYNPFLD_MAPPING        =
         EXCEPTIONS
            parameter_error        = 1
            no_values_found        = 2
            OTHERS                 = 3.
         IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
       ENDIF.
   ENDIF.
  ENDIF.
-------------------------------------------------------------------------------------------------------------




































Step2.





















----------------------------------------------------------------------------------------------------

No comments:

Comments system

Disqus Shortname