cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP Unit for local classes inside function group?

sh4il3sh
Participant
0 Likes
702

I have local class(LCL_CUT) created inside function group ZFG_BP.

method get_activity of class lcl_cut, tries to access global variables of ZFG_BP.

 

METHOD get_activity
 IF gv_act_id = 'YCUS'. "this gv_act_id is part of Fn Group ZFG_BP
   **logic to calculate*
 ENDIF.
ENDMETHOD.

 

 I need to write abap unit for method get_activity, but I don't know how would I set gv_act_id  = 'YCUS' for my unit test method call?

As of now gv_act_id = ' ', which makes sense because I am calling this method individually and there is no prior call/screen click to set gv_act_id value.

Accepted Solutions (1)

Accepted Solutions (1)

alex_frank
Product and Topic Expert
Product and Topic Expert

Hi sh4il3sh,

If you put the unit test class into the T99 include of the function group, like you should: https://help.sap.com/docs/abap-cloud/abap-development-tools-user-guide/where-to-write-abap-unit-test..., you can directly assign your needed value to the variable of the TOP include before calling your code under test in the unit test method.

BR,
Alex

Answers (0)