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: 

Tables in Subroutines

Former Member
0 Kudos

How to declare tables in Subroutines?

6 REPLIES 6

RoySayak
Active Participant
0 Kudos

just like u declare in other places..

data: begin of itab,

..........

.........

end of itab

Former Member
0 Kudos

You could only declare TABLES statement once in a program for a particular db table. You should declare in the TOP include.

If you want to you use a select statement in a subroutine and you dont want that this information is global you coud use this:

form.....

data: lw type vbak.

select single *

from vbak

into lw

where

.....

endform

Edited by: alejo arrighi on Dec 21, 2007 1:22 PM

Former Member
0 Kudos

Dear Krishna,

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.

Best Regards,

Rajesh.

Please reward points if found helpful.

Former Member
0 Kudos

Dear Krishna,

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.

Best Regards,

Rajesh.

Please reward points if found helpful.

Former Member
0 Kudos

hi

good

go through this link,this would help you to solve your problem.

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db982c35c111d1829f0000e829fbfe/content.htm

thanks

mrutyun^

Former Member
0 Kudos

Hi,

REport ztemp.

data : tb_konv LIKE konv OCCURS 0 WITH HEADER LINE.

select * from konv

into table tb_konv

up to 100 rows.

perform test tables tb_konv .

.

.

.

form test tables p_tb_konv structure konv.

data : wa_konv type konv .

read table p_tb_konv in to wa_konv with key kschl = 'ZOCD'.

if sy-subrc = 0 .

write p_tb_konv-kschl.

endif.

endform.

++++++++++++++++++++++++

We pass tables to subroutine with the concept TABLES ,STRUCTURE keywords to form definition.

Regds

Sivaparvathi

Please reward points if helpful...