Wednesday 8 June 2011

Debugging CMOD user exit variables

This posting is about how to debug the CMOD code for user exit variables. These variables are used in BEX query development.






 Start transaction CMOD and select the required Project (ZGL_VAR in our case)

 
 Select the Function exit (double click)

 
Start the function in Test mode.
 

Enter the name of the variable in the field I_VNAM, (MCE0001)
Enter the returned  InfoObject type in the field I_IOBJNM, (0CALYEAR)
Enter the step in the field I_STEP, (1, Pre Popup)

Also enter I_VARTYP and I_PERIV. They are not used in this example, but required to enter.
After entering the data, click “Debugging”


DATA:  ld_fname(30TYPE c.

CASE i_step.
  
WHEN 0.
    
CONCATENATE 'Z_VAR_AUTHORITY_' i_vnam INTO ld_fname.
  
WHEN 1.
    
CONCATENATE 'Z_VAR_PRE_POPUP_' i_vnam INTO ld_fname.
  
WHEN 2.
    
CONCATENATE 'Z_VAR_POST_POPUP_' i_vnam INTO ld_fname.
  
WHEN 3.
    ld_fname = 
'Z_VAR_CHECK_VALIDITY'.ENDCASE.
 
TRY.
    
CALL FUNCTION ld_fname
      
EXPORTING
        i_vnam        = i_vnam
        i_vartyp      = i_vartyp
        i_iobjnm      = i_iobjnm
        i_s_cob_pro   = i_s_cob_pro
        i_s_rkb1d     = i_s_rkb1d
        i_periv       = i_periv
        i_t_var_range = i_t_var_range
        i_step        = i_step
      
IMPORTING
        e_t_range     = e_t_range
        e_meeht       = e_meeht
        e_mefac       = e_mefac
        e_waers       = e_waers
        e_whfac       = e_whfac
      
CHANGING
        c_s_customer  = c_s_customer
      
EXCEPTIONS
        cmod_error    = 
4
        
OTHERS        = 1.

  
CATCH cx_sy_dyn_call_illegal_func.ENDTRY.




In our case, the function that will be called is Z_VAR_PRE_POPUP_MCE0001





  DATA: l_s_range          TYPE rsr_s_rangesid.

  
DATA: lv_mnth(2)        TYPE n,
           lv_yr(
4)            TYPE n,
           lv_date            
TYPE sy-datum,
           lv_lstday          
TYPE sy-datum,
           lv_calmonth      
TYPE /bi0/oicalmonth.

  
CLEAR: l_s_range.

  l_s_range-
sign  = 'I'.
  l_s_range-opt   = 
'EQ'.

  lv_yr = sy-datum+
0(4) .
  l_s_range-low = lv_yr.
  
APPEND l_s_range TO e_t_range.


 The called Function Module contains above code.

 It will return the current year  in the e_t_range table.


 The result looks like the above.



1 comment:

  1. Can you please show the debugging for i_step = 2 in the same way.

    ReplyDelete