Access values outside the SAP customer exit

When implementing a customer exit (i.e. field, user etc) have you ever wanted to be able to read additional field values available in the main SAP program but not available in your exit. Now with the use of field-symbols you can have access to any field available in the main SAP program. The code below demonstrates how this is done within a field exit on BSTNR which can be tested using transaction ME21. Information on creating field exits can be found here.

FUNCTION field_exit_bstnr.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(INPUT)
*"  EXPORTING
*"     REFERENCE(OUTPUT)
*"----------------------------------------------------------------------
* create field symbol
  FIELD-SYMBOLS: <status>.
* Assign value of variable from calling prog to field symbol
  ASSIGN ('(SAPMM06E)RM06E-BSART') TO <status>.
* Display value retrieved in message
* Note: Messages of type i and w are not allowed
  IF sy-subrc = 0.
    MESSAGE e003(zr) WITH <status> 'kkk'.
  ENDIF.
ENDFUNCTION.

Related Articles

ABAP Enhancements - Modify SAP standard code using the SAP enhancement transaction CMOD
SAP BADI enhancement implementation (Business Add-In)
Changing SAP Data Element documentation (F1 help text)
Changing SAP Data Element field text
Find SAP BADI triggered from a SAP transaction, also find tcode from BADI name
SAP User Exits to Add functionality to the PBO and PAI of SAP HR infotypes
Adding fields to SAP standard Infotype
SAP User exist enhancements
SAP Field Exits implementation to update global dictionary field details
SAP filter BADI allows multiple implementations to be active
SAP migrated BADI using enhancement point implementation
Modifying Standard SAP System and help Menu options
Modifying Standard SAP System and help Menu options
SAP mutiple use BADI and enhancement spot implementation (Business Add-In)
SAP User exits to allow developers to enhance standard SAP functionality without modifiy SAP code