10-16-2007 8:58 AM
Hi All,
Can I declare tables in the subroutine?
Since I am accessing table fields in the subroutine I need to declare them in subroutine.
Is it a bad practice or what?
Regards,
Shaily
10-16-2007 9:06 AM
Hi Shaily,
Yes u can definitely use tables in a subroutine.
The syntax goes like this :
PERFORM subroutine_name TABLES itab1 USING field1 changing field2.
In this the TABLES should always preceed the USING and CHANGING addition.
then in the definition of subroutine, the code goes like this :
FORM subroutine_name TABLES itab1 structure <Structure same as that of itab> USINg field1 CHANGING field2.
Hope it helps.
Regards,
Himanshu
10-16-2007 9:06 AM
variable declared with tables statement are always global , whether u declare it in the main prog or a subroutine.. they are always accessable globally.,..
so it is always recommended to declare tables in the main prog.
No rewards Plz..
10-16-2007 9:11 AM
Hi,
check the belowcode...
do like this
PERFORM send_file_as_email_attachment
TABLES t_mess_bod
t_mess_att
USING p_email
'Example .xls documnet attachment'
'PDF'
v_attachment_name
v_attachment_desc
p_sender
v_sender_type
CHANGING v_error
v_reciever.
Reward if helpful.
Regards,
Nagaraj
10-16-2007 9:15 AM
hi,,
all tables which u are using in a subrotine should be declared in program n not in subroutine as u r calling sub routines using perform statement using tables keyword u must call. if u dont declare them in main program u ll get an error stating dat tables ........... are not declared.
generally wat objects u require locally are declared in a sub routine using keyword LOCAL.
if useful reward some points.
with regards,
Suresh Aluri.
10-16-2007 9:48 AM
My subroutine is in a include , which is again in standard User exit(FM).
I cannot declare the tables in the FM global data as it is standard Program.
Should I use subroutine also within this Include is a doubt for me...
Only problem is I wanted if use the statement :
<b>Tables: mara,mard.</b>
I want to confirm if this is not a bad practice.
Shaily