SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Updating value of another field on the screen



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Sep 22, 2007 6:36 pm    Post subject: Updating value of another field on the screen Reply with quote

Code:
REPORT zvv.
TABLES tcurt.
DATA dyfields LIKE dynpread OCCURS 1 WITH HEADER LINE.
PARAMETERS: p_waers LIKE tcurt-waers, "Currency
p_ltext LIKE tcurt-ltext, "Long Text
p_ktext LIKE tcurt-ktext. "Short Text

*-----------------------------------------------------------------------
*--- Example of updating value of another field on the screen ----------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_waers.
  CLEAR: dyfields[], dyfields.
*--- select currency
  CALL FUNCTION 'HELP_VALUES_GET'
    EXPORTING
      fieldname    = 'WAERS'
      tabname      = 'TCURT'
    IMPORTING
      select_value = p_waers.
*--- get long text for the selected currency
  SELECT SINGLE ltext FROM tcurt
  INTO dyfields-fieldvalue
  WHERE spras = sy-langu
  AND waers = p_waers.
  IF sy-subrc <> 0.
    CLEAR dyfields-fieldvalue.
  ENDIF.
*--- update another field
  dyfields-fieldname = 'P_LTEXT'.
  APPEND dyfields.
  CALL FUNCTION 'DYNP_VALUES_UPDATE'
    EXPORTING
      dyname     = sy-cprog
      dynumb     = sy-dynnr
    TABLES
      dynpfields = dyfields.
*-----------------------------------------------------------------------

*--- Example of reading value of another field -------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ktext.
*--- read another field
  CLEAR: dyfields[], dyfields.
  dyfields-fieldname = 'P_WAERS'.
  APPEND dyfields.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname     = sy-cprog
      dynumb     = sy-dynnr
    TABLES
      dynpfields = dyfields.
  READ TABLE dyfields INDEX 1.
*--- get short text and update current field
  SELECT SINGLE ktext FROM tcurt
  INTO p_ktext
  WHERE spras EQ sy-langu
  AND waers EQ dyfields-fieldvalue.
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 195
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Tue Jul 31, 2012 3:56 pm    Post subject: Reply with quote

Детализация значения в тестовом поле

Code:
REPORT zvga_test.

PARAMETERS:   p_bwart TYPE t157d-bwart DEFAULT '322' OBLIGATORY.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text-020 FOR FIELD p_grund.
SELECTION-SCREEN POSITION 35.
PARAMETERS p_grund TYPE t157d-grund.
SELECTION-SCREEN COMMENT 41(20) text1.
SELECTION-SCREEN END OF LINE.



AT SELECTION-SCREEN OUTPUT.

  IF p_grund IS INITIAL AND NOT p_bwart IS INITIAL.
    SELECT SINGLE grund INTO p_grund
      FROM t157d
      WHERE bwart = p_bwart.
  ENDIF.

  IF NOT p_grund IS INITIAL.

    CLEAR text1.
    SELECT SINGLE grtxt INTO text1
      FROM t157e
      WHERE spras = sy-langu
        AND bwart = p_bwart
        AND grund = p_grund.

  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_grund.
*--- select currency
  CALL FUNCTION 'HELP_VALUES_GET'
    EXPORTING
      fieldname    = 'GRUND'
      tabname      = 'T157D'
    IMPORTING
      select_value = p_grund.

  CLEAR text1.
  SELECT SINGLE grtxt INTO text1
    FROM t157e
    WHERE spras = sy-langu
      AND bwart = p_bwart
      AND grund = p_grund.

  DATA: dynpread LIKE TABLE OF dynpread WITH HEADER LINE.
  CLEAR dynpread. REFRESH dynpread.
  dynpread-fieldname = 'P_GRUND'.
  dynpread-fieldvalue = p_grund.
  APPEND dynpread.
  dynpread-fieldname = 'TEXT1'.
  dynpread-fieldvalue = text1.
  APPEND dynpread.
  CALL FUNCTION 'DYNP_VALUES_UPDATE'
    EXPORTING
      dyname               = sy-cprog
      dynumb               = sy-dynnr
    TABLES
      dynpfields           = dynpread
    EXCEPTIONS
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      undefind_error       = 7
      OTHERS               = 8.

_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.