Application Development 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: 

Global Variable assignment operation not working (Works with local variable)

vapor_anomaly
Explorer
0 Kudos

Hi,

We have a global variable with name wa_pb_file_recxyab of type ty_pb_file_recxya.

data: wa_pb_file_recxyab     TYPE ty_pb_file_recxya.

Inside one of my subroutines, when i try the below, nothing gets assigned to wa_pb_file_recxyab

wa_pb_file_recxyab+0(4) = 'test'.

But when i declare a local variable right before the line and try, it works

data: lwa_pb_file_recxyab type ty_pb_file_recxya.
lwa_pb_file_recxyab+0(4) = 'test'.

What am i missing. Please help.

Structure of TY_PB_FILE_REC03A is

 TYPES :  BEGIN OF ty_pb_file_recxya.
            INCLUDE STRUCTURE zst_ab_charges.
            TYPES: item_data(21) TYPE c.
            INCLUDE STRUCTURE zst_ab_charges_b.
            TYPES: premise       TYPE eanl-vstelle,
            ext_ui        TYPE euitrans-ext_ui,
          END OF ty_pb_file_rec03a.<br>

Thanks,

Joshua.

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

I guess that "it works" means that debug after the line doesn't show the change.

  1. Either you didn't activate your program,
  2. or you didn't restart the program after compiling,
  3. or the global variable is shadowed by attribute (class/interface/alias) with same name, etc.

Sometimes, we developers don't see obvious errors. Just ask a fellow developer of yours to have a second look at it.

4 REPLIES 4

Sandra_Rossi
Active Contributor

I guess that "it works" means that debug after the line doesn't show the change.

  1. Either you didn't activate your program,
  2. or you didn't restart the program after compiling,
  3. or the global variable is shadowed by attribute (class/interface/alias) with same name, etc.

Sometimes, we developers don't see obvious errors. Just ask a fellow developer of yours to have a second look at it.

Thanks Sandra.

Your point 3 is the reason.

I discovered that the programmer has added a loop further down the line, within same subroutine, with a dynamic data field with same name!

Once i corrected it, it worked.

loop at itab....into data(wa_pb_file_recxyab)...
......

Thanks,

Joshua.

0 Kudos

Thanks for the feedback!

raymond_giuseppi
Active Contributor
0 Kudos

Activate the code that contains the "global variable" (whether it's a class attribute, a top include, or anything else).

Try again to generate your program/class (or double-click on the field name in the method/role source, if it is indeed a global variable, its definition should be displayed).