quarta-feira, 13 de novembro de 2019

F4IF_INT_TABLE_VALUE_REQUEST - Retorno de mais de um valor - ADENDO com CALLBACK METHOD

Copiado do SAP SDN

https://answers.sap.com/questions/5445798/f4ifinttablevaluerequest---return-more-than-1-fiel.html

PARAMETERS:
  a TYPE char10,
  b TYPE char10,
  c TYPE char10.


DATA:
  BEGIN OF tab OCCURS 0,
    field1 TYPE char10,
    field2 TYPE char10,
    field3 TYPE char10,
  END OF tab,
  wa LIKE LINE OF tab,
  DYNPFLD_MAPPING TYPE STANDARD TABLE OF DSELC,
  dyn_wa TYPE DSELC,
  lt_return TYPE TABLE OF DDSHRETVAL,
  lwa_return TYPE ddshretval.

INITIALIZATION.
  wa-field1 = 'aaaaa'.
  wa-field2 = 'bbbbb'.
  wa-field3 = 'ccccc'.
  APPEND wa to tab.

  wa-field1 = 'aaaaa'.
  wa-field2 = 'bbccc'.
  wa-field3 = 'ddddd'.
  APPEND wa to tab.

  wa-field1 = 'aaaab'.
  wa-field2 = 'bbccc'.
  wa-field3 = 'eeeee'.
  APPEND wa to tab.

AT SELECTION-SCREEN on VALUE-REQUEST FOR a.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*     DDIC_STRUCTURE         = ' '
      retfield               = 'FIELD1'
*     PVALKEY                = ' '
      DYNPPROG               = sy-cprog
      DYNPNR                 = '1000'
      DYNPROFIELD            = 'A'
*     STEPL                  = 0
*     WINDOW_TITLE           = WINDOW_TITLE
*     VALUE                  = ' '
      VALUE_ORG              = 'S'
*     MULTIPLE_CHOICE        = ' '
*     DISPLAY                = ' '
     CALLBACK_PROGRAM       = sy-cprog
     CALLBACK_FORM          = 'CALLBACK_F4'
*     MARK_TAB               = MARK_TAB
*   IMPORTING
*     USER_RESET             = USER_RESET
    TABLES
      value_tab              = tab
*     FIELD_TAB              = FIELD_TAB
      RETURN_TAB             = lt_return
*      DYNPFLD_MAPPING        = 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.


form callback_f4 TABLES record_tab STRUCTURE seahlpres
            CHANGING shlp TYPE shlp_descr
                     callcontrol LIKE ddshf4ctrl.
  DATA:
    ls_intf     LIKE LINE OF shlp-interface,
  ls_prop     LIKE LINE OF shlp-fieldprop.
*Hide unwanted fields
  CLEAR: ls_prop-shlpselpos,
         ls_prop-shlplispos.
*  MODIFY shlp-fieldprop FROM ls_prop
*    TRANSPORTING shlpselpos shlplispos
*  WHERE ( fieldname NE 'F0001'  AND
*          fieldname NE 'F0002'  AND
*          fieldname NE 'F0003' ).
*  " Overwrite selectable fields on search help
  REFRESH: shlp-interface.
  ls_intf-shlpfield = 'F0001'.
  ls_intf-valfield  = 'A'.
  ls_intf-f4field   = 'X'.
  APPEND ls_intf TO shlp-interface.
  ls_intf-shlpfield = 'F0002'.
  ls_intf-valfield  = 'B'.
  ls_intf-f4field   = 'X'.
  APPEND ls_intf TO shlp-interface.
  ls_intf-shlpfield = 'F0003'.
  ls_intf-valfield  = 'C'.
  ls_intf-f4field   = 'X'.
  APPEND ls_intf TO shlp-interface.
ENDFORM.
============= CHAMADA POR CALLBACK METHOD
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        retfield        'BANKL'
       dynpprog        sy-repid
       dynpnr          '0100'
       dynprofield     'TELA1-COD_AGENCIA'
        value_org       'S'
        callback_method o_prog_local
      TABLES
        value_tab       lt_but0bk
*        field_tab       = lt_fields
        return_tab      lt_retval
      EXCEPTIONS
        parameter_error 1
        no_values_found 2
        OTHERS          3.
Declaração na classe local.
CLASS LCL_PROG_LOCAL DEFINITION.
  PUBLIC SECTION.
    INTERFACES if_f4callback_value_request.
    ALIASES f4_call_callback FOR if_f4callback_value_request~f4_call_callback.
IMPLEMENTAÇÃO DO MÉTODO.
CLASS lcl_PROG_LOCAL IMPLEMENTATION.

  METHOD f4_call_callback.

   BREAK-POINT.
    cs_shlp-interface VALUE #shlpfield 'F0001'
                     valfield  'TELA1-COD_AG'
                     f4field   'X' )
                     shlpfield 'F0002'
                     valfield  'TELA1-CONTA_COR'
                     f4field   'X' )  ).

  ENDMETHOD.


Nenhum comentário:

Postar um comentário