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

tables statement in procedure.

Former Member
0 Likes
1,139

hi experts:

today i get a program:

report ytest_table1.

tables:proj.

form frm_f1.

proj-pspnr = '12345678'.

endform.

report ytest_table.

form frm_f.

   tables:proj.

  if proj is initial.

  endif.  "breakpoint1

  clear proj-pspnr.

  if proj is initial.

  endif.  "breakpoint2

endform.

start-of-selection.

  perform frm_f1 in program ytest_table1.

  perform frm_f.

write: 1. "breakpoint3

when i run ytest_table and found:

the value is 12345678 when break1

the value is initial when break2

the value is 12345678 when break3

break 1 and break 2 i can understand that is a table work area,

but why break 3 is still 12345678?

hi experts:

today i get a program:

report ytest_table1.

tables:proj.

form frm_f1.

proj-pspnr = '12345678'.

endform.

report ytest_table.

form frm_f.

   tables:proj.

  if proj is initial.

  endif.  "breakpoint1

  clear proj-pspnr.

  if proj is initial.

  endif.  "breakpoint2

endform.

start-of-selection.

  perform frm_f1 in program ytest_table1.

  perform frm_f.

write: 1. "breakpoint3

when i run ytest_table and found:

the value is 12345678 when break1

the value is initial when break2

the value is 12345678 when break3

break 1 and break 2 i can understand that is a table work area,

but why break 3 is still 12345678?

9 REPLIES 9
Read only

Former Member
0 Likes
1,114

Hi,

please read the follwing note from the keyword help for TABLES:

Table work areas declared with TABLES can be declared in subroutines and function modules. However, this is not recommended. A table work area declared in a procedure is not local but belongs to the context of a framework program. The table work area can be viewed starting from the declaration in the framework program and lives as long as the framework program. In contrast to normal program-global data, the content of the table work areas declared in subroutines and function modules is stored temporarily when these subroutines and function modules are called. Value assignments that were made during runtime of the procedure are preserved until the procedure is completed. When exiting the procedure, the table work areas are filled with the contents that they contained when the procedure was called. Table work areas declared in procedures behave like global data to which the statement LOCAL is applied in the procedure.

Regards,

Klaus

Read only

0 Likes
1,114

hi Klaus,

   i already reading sap f1 for tables,  and also know its not recommed in procedure.

but for break 1, it get the global value.

and for break 2 it clear the global value.

and for break 3 it still is 12345678.

for the form frm_f.

if the proj is local , it should not  get the global value for break 1 and if the proj is global,it should not get the value for break 3 because it already clear.

Read only

0 Likes
1,114

Hi,

... A table work area declared in a procedure is not local ... When exiting the procedure, the table work areas are filled with the contents that they contained when the procedure was called. ...

I think this means, that TABLES is always a global definition and the value gets reset to th value at call when leaving the form. That would perfectly describe the behaviour you posted.

Table work areas declared with TABLES can be declared in subroutines and function modules. However, this is not recommended.

But you shouldn't do that anyway.

Regards,

Klaus

Read only

Former Member
0 Likes
1,114

hi hua,

in form frm_f, u have declared table proj so it becomes local declaration for the program ytest_table.

So once it comes out of this fm, proj-pspnr will have the values from ytest_table1

Read only

0 Likes
1,114

but in form frm_f, it get the global value 12345678

Read only

0 Likes
1,114

in form_f, u have declared table proj so it becomes local declaration so outside this form proj-pspnr will consider the declaration from report ytest_table1.

All Local y declared variables have exisance within same orm they have no existence outside this form.

But in ur case, outside form form_f, it has already taken declaration from report ytest_table1 and hence the value 12345678 for proj-pspnr will remain at break3.

Read only

0 Likes
1,114

hi Sachin,

    im not clear for this :

in form_f the proj is local or global?

if local ,it shouldnt get the global  value, and if global , it should clear the global value.

Read only

0 Likes
1,114

hi

declaring with tables dosent clear the work area, it is just the declaration.

While in case of "data: lv_matnr type matnr" means a delcaration with clearing data.

Thanks,

Sachin

Read only

0 Likes
1,114

hi

   there is a statement clear proj-pspnr between break 1 and break 2.