Problem solve Get help with specific problems with your technologies, process and projects.

Accessing unpassed field values in user exits

Here's an easy solution which reads contents of PXA area and assigns field values to field-symbols.

Quite often, you'll find yourself in the situation to access data within an user-exit function module. However,...

data might not be accessible as they are not passed in the customer-function module's interface. Here's an easy solution which reads contents of PXA area and assigns field values to field-symbols.

If addition "local copy" is removed (see coding), also write access is possible.


* Example: a customer-function is called from two SAP
programs:
 SAPLV60A and RKERV002. 

FUNCTION EXIT_SAPLKEDRCOPA_001.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"       IMPORTING
*"             VALUE(I_OPERATING_CONCERN) LIKE  TKEB-ERKRS
*"             VALUE(I_DERIVATION_DATE)IKE  SY-DATUM
*"             VALUE(I_STEP_ID) LIKE  TKEDRS-STEPID
*"             VALUE(I_COPA_ITEM)
*"             VALUE(I_GLOBAL) LIKE  KEDRCOPA STRUCTURE  KEDRCOPA
*"       EXPORTING
*"             REFERENCE(E_COPA_ITEM)
*"             REFERENCE(E_GLOBAL)
*"             REFERENCE(E_EXIT_IS_ACTIVE)
*"             REFERENCE(E_FAILED)
*"       EXCEPTIONS
*"              DERIVATION_FAILED
*"----------------------------------------------------------------------


INCLUDE ZXKKEU11 .


ENDFUNCTION.

* In this include, we want to fill the function module's export paramter E_COPA_ITEM. 
This equals I_COPA_ITEM, but field KTGRD or KUNRG have to be changed.
E.g. field KTGRD is present in main program SAPLV60A, but not yet 
written to database and not passed by the module's interface.

* The include ZXKKEU11 reads:
*----------------------------------------------------------------------*
*   INCLUDE ZXKKEU11                                                   *
*----------------------------------------------------------------------*

data: item_1201 like ce01201.          
data: begin of pxa occurs 0,
        head type char5,
        type type char4,
        prog like help_info-program,
        rest(35) type c,
      end of pxa.

data: l_assign_ok type char1.

field-symbols: 
 
   type ktgrd.
field-symbols: 
  
    type kunnr.
data: ffield type char30 value 'SAPLV60A'.

clear l_assign_ok.

case i_operating_concern.
  when '1201'.
    e_exit_is_active = 'X'.            
    item_1201 = i_copa_item.

    case i_step_id.
      when 'KTGR'.

        call 'SAPCORE' id 'ID' 
             field 'PROGRAMS'
                id 'TABLE' field pxa-*sys*.

* Check if this routine is called out of SAPLV60A
        read table pxa with key prog = ffield.
        if sy-subrc eq 0.
          concatenate '(' ffield ')VBRK-KTGRD'  into ffield.
          assign local copy of (ffield) to 
   
    .
          if sy-subrc = 0.
            l_assign_ok = 'X'.
          endif.
        endif.
* Check if this routine is called out of RKERV002.
        ffield = 'RKERV002'.
        read table pxa with key prog = ffield.
        if sy-subrc eq 0.
          concatenate '(' ffield ')VBRK-KTGRD'  into ffield.
          assign local copy of (ffield) to 
    
     .
          if sy-subrc = 0.
            l_assign_ok = 'X'.
          endif.
        endif.

        if l_assign_ok = 'X'.
          item_1201-ktgrd = 
     
      .
        endif.
        e_copa_item = item_1201.
        if 
      
        is assigned.
          unassign 
       
        .
        endif.

      when 'KURG'.

        call 'SAPCORE' id 'ID' field 'PROGRAMS'
                        id 'TABLE' field pxa-*sys*.

* Check if this routine is called out of SAPLV60A
        read table pxa with key prog = ffield.
        if sy-subrc eq 0.
          concatenate '(' ffield ')KURGV-KUNNR'  into ffield.
          assign local copy of (ffield) to 
        
         .
          if sy-subrc = 0.
            l_assign_ok = 'X'.
          endif.
        endif.
* Check if this routine is called out of RKERV002.
        ffield = 'RKERV002'.
        read table pxa with key prog = ffield.
        if sy-subrc eq 0.
          concatenate '(' ffield ')KURGV-KUNNR'  into ffield.
          assign local copy of (ffield) to 
         
          .
          if sy-subrc = 0.
            l_assign_ok = 'X'.
          endif.
        endif.

        if l_assign_ok = 'X'.
          item_1201-kunrg = 
          
           .
        endif.
        e_copa_item = item_1201.

      when 'RURG'.
        call 'SAPCORE' id 'ID' field 'PROGRAMS'
                        id 'TABLE' field pxa-*sys*.

* Check if this routine is called out of SAPLV60A
        read table pxa with key prog = ffield.
        if sy-subrc eq 0.
          concatenate '(' ffield ')KURGV-KUNNR'  into ffield.
          assign local copy of (ffield) to 
           
            .
          if sy-subrc = 0.
            l_assign_ok = 'X'.
          endif.
        endif.
* Check if this routine is called out of RKERV002.
        ffield = 'RKERV002'.
        read table pxa with key prog = ffield.
        if sy-subrc eq 0.
          concatenate '(' ffield ')KURGV-KUNNR'  into ffield.
          assign local copy of (ffield) to 
            
             .
          if sy-subrc = 0.
            l_assign_ok = 'X'.
          endif.
        endif.

        if l_assign_ok = 'X'.
          item_1201-kunrg = 
             
              .
        endif.
        e_copa_item = item_1201.

    endcase.

endcase.

             
            
           
          
         
        
       
      
     
    
   
  
 
This was last published in September 2001

Dig Deeper on SAP Basis administration and NetWeaver administration

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close