Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Process on value-request: filling dynpro before Enter

Former Member
0 Likes
5,056

Hello,

I have a problem with a dynpro:

I fill in a value into field "zmepo_badi_9000-ateil" with the help of:

PROCESS ON VALUE-REQUEST.
   FIELD zmepo_badi_9000-ateil
         MODULE suchhilfe_ateil. (the complete dynpro implementation see below: "
Module  SUCHHILFE_ATEIL  INPUT")

I get a value into the field zmepo_badi_9000-ateil (F4 help with FB 'F4IF_INT_TABLE_VALUE_REQUEST')  immediatly!! That works.

But in "MODULE suchhilfe_ateil" I also want to fill in a value into field zmepo_badi_9000-z_zielpreis (bold text below).

That works only after pushing ENTER (I think that`s PAI). But I would like that the value of zmepo_badi_9000-z_zielpreis appears immediatly (similar to zmepo_badi_9000-ateil). Is that possible? I hope anybody can help me. Thank you.


*----------------------------------------------------------------------*
***INCLUDE LZMEPOBADIEXI02 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  SUCHHILFE_ATEIL  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE suchhilfe_ateil INPUT.
   DATA: ls_ekko TYPE ekko,
         lv_netwr_eur(16)               TYPE p DECIMALS 2.

   CLEAR ls_ekko.
   TYPES: BEGIN OF t_ateil,
           ateil   TYPE zco_pc4a-ateil,
           pspnr   TYPE zco_pc4a-pspnr,
           kstar   TYPE zco_pc4a-kstar,
           menge   TYPE zco_pc4a-menge,
           wertz   TYPE zco_pc4a-wertz,
           ktext   TYPE zco_pc4a_text-ktext,
           ltext   TYPE zco_pc4a_text-ltext,
           waers   TYPE zco_pc4a-waers,
           END OF t_ateil.
   DATA: ateil TYPE zco_pc4a-ateil.
   CLEAR ateil.
   DATA: it_return    TYPE ddshretval OCCURS 10.
   DATA: it_return2    TYPE ddshretval OCCURS 10.

   DATA: ls_return    TYPE ddshretval.
   DATA: ls_ateil TYPE t_ateil,
         it_ateil TYPE STANDARD TABLE OF t_ateil.
   DATA: BEGIN OF dynpfields OCCURS 0. "Hilfsstruktur zum auslesen des akt.
           INCLUDE STRUCTURE dynpread. "Feldwertes vom Dynpro bei >F4<
   DATA: END OF   dynpfields.

   REFRESH it_ateilREFRESH it_return. CLEAR ls_return.

******************************************************
* --> Selektion der A-Teile anhand des PSP-Elements
******************************************************
   SELECT * FROM zco_pc4a INTO CORRESPONDING FIELDS OF ls_ateil
     WHERE pspnr = zmepo_badi_9000-z_pspnr.
     APPEND ls_ateil TO it_ateil.
   ENDSELECT.


   CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
     EXPORTING
*   DDIC_STRUCTURE         = ' '
     retfield               = 'ATEIL'
*   PVALKEY                = ' '
*    dynpprog               = sy-repid
*    dynpnr                 = sy-dynnr
*   DYNPROFIELD            = ' '
*    window_title           = text-001
*   VALUE                  = ' '
     value_org              = 'S'
*   MULTIPLE_CHOICE        = ' '
*   DISPLAY                = ' '
*   CALLBACK_PROGRAM       = ' '
*   CALLBACK_FORM          = ' '
*   CALLBACK_METHOD        =
*   MARK_TAB               =
* IMPORTING
*   USER_RESET             =
     TABLES
       value_tab            = it_ateil
       return_tab           = it_return
*   DYNPFLD_MAPPING        =
* EXCEPTIONS
*   PARAMETER_ERROR        = 1
*   NO_VALUES_FOUND        = 2
*   OTHERS                 = 3
.

   LOOP AT it_return  INTO ls_return.
     zmepo_badi_9000-ateil   = ls_return-fieldval.
     zmepo_badi_9000-z_kstar = ls_ateil-kstar.
     zmepo_badi_9000-z_wertz = ls_ateil-wertz.
     IF ls_ateil-wertz IS NOT INITIAL.
       IF zmepo_badi_9000-z_zielpreis IS INITIAL.

         IF  ls_ateil-waers NE 'EUR' AND ls_ateil-waers IS NOT INITIAL .
           SELECT SINGLE * FROM ekko INTO ls_ekko WHERE ebeln = zmepo_badi_9000-z_ebeln.
*             WAE umrechnen in EUR
           CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
             EXPORTING
               date             = ls_ekko-bedat
               foreign_amount   = '23' "ls_ekko-wertz
               foreign_currency = ls_ekko-waers
               local_currency   = 'EUR'
               rate             = ls_ekko-wkurs
             IMPORTING
               local_amount     = lv_netwr_eur
             EXCEPTIONS
               no_rate_found    = 1
               overflow         = 2
               no_factors_found = 3
               no_spread_found  = 4
               derived_2_times  = 5
               OTHERS           = 6.
           if sy-subrc = 0.
             zmepo_badi_9000-z_wertz = lv_netwr_eur.
            zmepo_badi_9000-z_zielpreis = zmepo_badi_9000-z_wertz.
             modify SCREEN.
           endif.
         ENDIF.
        ENDIF.
     ENDIF.

     EXIT.
   ENDLOOP.
  ENDMODULE.                 " SUCHHILFE_ATEIL  INPUT


PROCESS BEFORE OUTPUT.

   MODULE event_pbo.

   MODULE screen_9000.

PROCESS AFTER INPUT.

   FIELD zmepo_badi_9000-z_zielpreis
     MODULE daten_pruefen_9000_zp ON REQUEST.

   FIELD zmepo_badi_9000-z_bestang
     MODULE daten_pruefen_9000_ba ON REQUEST.

   FIELD zmepo_badi_9000-z_altpreis
     MODULE daten_pruefen_9000_ap ON REQUEST.
*  MODULE zielpreis.

   MODULE event_pai.


PROCESS ON VALUE-REQUEST.
   FIELD zmepo_badi_9000-ateil
         MODULE suchhilfe_ateil.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,075

Hello, thank you it works with

CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'

     EXPORTING

       functioncode           = '/00'

     EXCEPTIONS

       function_not_supported = 1.

But I have another problem:

I select data with:

   SELECT * FROM zco_pc4a INTO CORRESPONDING FIELDS OF ls_ateil
     WHERE pspnr = zmepo_badi_9000-z_pspnr.
     APPEND ls_ateil TO it_ateil.
   ENDSELECT.

With F4IF_INT_TABLE_VALUE_REQUEST I get the value of ATEIL back (selection of an internal table).

That works. But I want to have to get back more than one field  of F4IF_INT_TABLE_VALUE_REQUEST.

At the moment I get the value of ATEIL, but I also want to get the value of  KSTAR.

Can you please tell me how to get the value of KSTAR.

Thank you very much.




8 REPLIES 8
Read only

Arun_Prabhu_K
Active Contributor
0 Likes
3,075

Hello Kevin.

Refer this thread http://scn.sap.com/thread/3224916.

Regards.

Read only

Former Member
3,075

Hi Kevin,

Please try the function module 'DYNP_VALUES_UPDATE'. See the sample code below.

TYPES:
BEGIN OF l_x_names,
 
uname TYPE uname,
END OF l_x_names.

DATA:
l_i_names TYPE STANDARD TABLE OF l_x_names INITIAL SIZE 0,
l_wa_names TYPE l_x_names,
l_i_field_tab TYPE STANDARD TABLE OF dfies INITIAL SIZE 0,
l_i_return_tab TYPE STANDARD TABLE OF ddshretval INITIAL SIZE 0,
l_wa_return_tab TYPE ddshretval,
l_i_dynpfld_mapping TYPE STANDARD TABLE OF dselc INITIAL SIZE 0.

l_wa_names-uname = 'TEST1'.
APPEND l_wa_names TO l_i_names.
l_wa_names-uname = 'TEST2'.
APPEND l_wa_names TO l_i_names.
l_wa_names-uname = 'TEST3'.
APPEND l_wa_names TO l_i_names.
l_wa_names-uname = 'TEST4'.
APPEND l_wa_names TO l_i_names.


CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
 
EXPORTING
   
retfield        = 'UNAME'
   
dynpprog        = sy-repid
   
dynpnr          = sy-dynnr
   
dynprofield     = p_retfield
   
value_org       = 'S'
 
TABLES
   
value_tab       = l_i_names
   
field_tab       = l_i_field_tab
   
return_tab      = l_i_return_tab
   
dynpfld_mapping = l_i_dynpfld_mapping
 
EXCEPTIONS
   
parameter_error = 1
   
no_values_found = 2
   
OTHERS          = 3.
IF sy-subrc = 0.
 
READ TABLE l_i_return_tab INTO l_wa_return_tab INDEX 1.
 
p_name = l_wa_return_tab-fieldval.
ELSE.
 
MESSAGE e001(00) WITH 'Error while displaying F4 help'.
ENDIF.

DATA: l_i_dynpfields  TYPE STANDARD TABLE OF dynpread INITIAL SIZE 0,
     
l_wa_dynpfields TYPE dynpread.
IF p_name = 'TEST1'.
 
l_wa_dynpfields-fieldname = 'P_CTRY'.
 
l_wa_dynpfields-fieldvalue = 'IN'.
 
APPEND l_wa_dynpfields TO l_i_dynpfields.
ELSE.
 
l_wa_dynpfields-fieldname = 'P_CTRY'.
 
CLEAR l_wa_dynpfields-fieldvalue.
 
APPEND l_wa_dynpfields TO l_i_dynpfields.
ENDIF.

CALL FUNCTION 'DYNP_VALUES_UPDATE'
 
EXPORTING
   
dyname               = sy-repid
   
dynumb               = sy-dynnr
 
TABLES
   
dynpfields           = l_i_dynpfields
 
EXCEPTIONS
   
invalid_abapworkarea = 1
   
invalid_dynprofield  = 2
   
invalid_dynproname   = 3
   
invalid_dynpronummer = 4
   
invalid_request      = 5
   
no_fielddescription  = 6
   
undefind_error       = 7
   
OTHERS               = 8.
IF sy-subrc <> 0.
 
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
         
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Thanks and Regards,

Abyson Joseph

Applexus Technologies.

Read only

Former Member
0 Likes
3,075

Hi Kevin,

Another shortcut way is to simulate the 'Enter'. Without reading or updating screen values, you can simulate and enter pressed to trigger the PAI automatically...easy money

CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'

     EXPORTING

       functioncode           = '/00'

     EXCEPTIONS

       function_not_supported = 1.

Thanks and Regards,

Abyson Joseph

Read only

Former Member
0 Likes
3,075

HI,

Use DYNP_VALUES_READ function module for Particular field.

This will resolve your issue.

check this sample program.

parameters: p_vbeln type vbak-vbeln,

             p_posnr type vbap-posnr.

at selection-screen on value-request for p_posnr.

   data: begin of help_item occurs 0,

           posnr type vbap-posnr,

           matnr type vbap-matnr,

           arktx type vbap-arktx,

         end of help_item.

   data: dynfields type table of dynpread with header line.

   dynfields-fieldname = 'P_VBELN'.

   append dynfields.

   call function 'DYNP_VALUES_READ'

        exporting

             dyname               = sy-cprog

             dynumb               = sy-dynnr

             translate_to_upper   = 'X'

        tables

             dynpfields           = dynfields

        exceptions

             invalid_abapworkarea = 1

             invalid_dynprofield  = 2

             invalid_dynproname   = 3

             invalid_dynpronummer = 4

             invalid_request      = 5

             no_fielddescription  = 6

             invalid_parameter    = 7

             undefind_error       = 8

             double_conversion    = 9

             stepl_not_found      = 10

             others               = 11.

   read table dynfields with key fieldname = 'P_VBELN'.

   p_vbeln = dynfields-fieldvalue.

   call function 'CONVERSION_EXIT_ALPHA_INPUT'

        exporting

             input  = p_vbeln

        importing

             output = p_vbeln.

   select posnr matnr arktx into table help_item

                  from vbap

                       where vbeln = p_vbeln.

   call function 'F4IF_INT_TABLE_VALUE_REQUEST'

        exporting

             retfield    = 'POSNR'

             dynprofield = 'P_POSNR'

             dynpprog    = sy-cprog

             dynpnr      = sy-dynnr

             value_org   = 'S'

        tables

             value_tab   = help_item.

Regards,

Ravi Pratap Singh

Message was edited by: Ravi Singh

Read only

sandeep_ramesh88
Explorer
0 Likes
3,075

Hi Kevin,

The return table in the FM "F4IF_INT_TABLE_VALUE_REQUEST" will solve your problem.

Thank You.

Read only

Former Member
0 Likes
3,076

Hello, thank you it works with

CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'

     EXPORTING

       functioncode           = '/00'

     EXCEPTIONS

       function_not_supported = 1.

But I have another problem:

I select data with:

   SELECT * FROM zco_pc4a INTO CORRESPONDING FIELDS OF ls_ateil
     WHERE pspnr = zmepo_badi_9000-z_pspnr.
     APPEND ls_ateil TO it_ateil.
   ENDSELECT.

With F4IF_INT_TABLE_VALUE_REQUEST I get the value of ATEIL back (selection of an internal table).

That works. But I want to have to get back more than one field  of F4IF_INT_TABLE_VALUE_REQUEST.

At the moment I get the value of ATEIL, but I also want to get the value of  KSTAR.

Can you please tell me how to get the value of KSTAR.

Thank you very much.




Read only

0 Likes
3,075

I found the solution:

In FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
I have to use

    callback_form          = 'F4CALLBACK'.


I have implemented the Form:


FORM f4callback
      TABLES   record_tab STRUCTURE seahlpres
      CHANGING shlp TYPE shlp_descr
               callcontrol LIKE ddshf4ctrl.
    DATA: interface LIKE LINE OF shlp-interface.
    CLEAR interface.
*  INTERFACE-VALTABNAME = 'ZMEPO_BADI_9000'.
*  INTERFACE-VALFIELD = 'Z_KSTAR'.
    interface-shlpfield = 'F0003'.
    interface-valtabname = space.
    interface-valfield = '~'.
*   MODIFY shlp-interface FROM interface
*          TRANSPORTING valtabname valfield
*          WHERE shlpfield = 'F0003'.
    APPEND interface TO shlp-interface.
  ENDFORM.                    "F4CALLBACK

Read only

0 Likes
3,075

Using search tool you could have found my similar answer in How can I restrict the entries found in a selection screen?

Regards,

Raymond