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

Accessing internal table of main program inside function module...

Former Member
0 Likes
697

I have function module say ZFUNC and main program say ZMAIN and internal table defined as IT_TAB inside ZMAIN but not passed as parameter to Function module ZFUNC.

If I want to access the field value of IT_TAB of main program ZMAIN inside ZFUNC during debugging then, I simply put <b>(ZMAIN)IT_TAB-amount</b> in ABAP debugger and then change it when the debugger is inside ZFUNC.

How can I write code to change the value of internal table of main program in function module ZFUNC instead of doing in debugger ? I guess I have to use some field symbols, but not sure. Please suggest.

Regards,

Rajesh.

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
601

Yes, you do need to use a field symbol. Say for example, you had a internal table called IMARC in your program and you want to access it later in a funciton module, you would do something like this.

  data: xmarc type marc.
  field-symbols: <imarc> type marc_upl_tt.

* Assign an internal table
  field = '(ZPROGRAM_NAME)IMARC[]'.
  assign (field) to <imarc>.

  loop at <imarc> into xmarc.
    write: / xmarc-matnr, xmarc-werks.
  endloop.

Regards,

Rich Heilman

Read only

0 Likes
601

The above solution will help me seeing the value but if I wanna change the value of (ZMAIN)I_TAB-amount inside function module how can I do that ?

Rajesh.

Read only

0 Likes
601

Well, since you use a field symbol, this will give you access to the internal table, You can then read the specific line that you want to change, and update is using a MODIFY statement.

Regards,

Rich Heilman