Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Access the variables declared using generate subroutine pool

soumya_jose3
Active Contributor
0 Likes
502

Hi,

I am decalring variables dynamically at run-time using generate subroutine pool.

Is there any way I can access the declared variables globally??.

CLEAR: g_s_repcode.

REFRESH: g_t_repcode.

g_s_repcode-line = text-035.

APPEND g_s_repcode TO g_t_repcode.

g_s_repcode-line = FORM dyn_var.

APPEND g_s_repcode TO g_t_repcode.

IF p_stat[] IS NOT INITIAL.

g_text = 'lv_stat'.

PERFORM dynamic_var_decl USING p_stat.

ENDIF.

g_s_repcode-line = ENDFORM.

APPEND g_s_repcode TO g_t_repcode.

GENERATE SUBROUTINE POOL g_t_repcode NAME g_prog

MESSAGE g_msg.

IF sy-subrc NE 0.

WRITE:/ text-040.

ELSE.

PERFORM dynamic_var IN PROGRAM (g_prog).

ENDIF.

FORM dyn_var_decl USING p_par.

DATA: l_count TYPE string,

l_var TYPE string.

LOOP AT p_stat.

CLEAR: l_count, l_var, g_s_repcode.

l_count = sy-tabix.

CONCATENATE g_text l_count INTO l_var.

CONCATENATE text-037 l_var text-038 text-039 INTO g_s_repcode

SEPARATED BY space.

APPEND g_s_repcode TO g_t_repcode.

ENDLOOP.

ENDFORM. " DYNAMIC_VAR_DECL

the perform 'dynamic_var' created two variables lv_stat1 and lv_stat2. But these variables are accessible only in the form dyn_var. Is there any way I can access the variables created outside that form???

Thanks & Regards,

Soumya.

1 REPLY 1
Read only

soumya_jose3
Active Contributor
0 Likes
464

Any solution?