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: 

how to define itab from 2 tables ?

Former Member
0 Kudos

hi

i have 2 tables table A with 30 columns and tableB with 10 columns. I want to define an itab which will contain all the columns of table A and 2 columns from table B

How can i do that ????

thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Say table A contains 15 fields and table B contains 10 fields.

C need to have 15 from table A and 2 from table B.

create table c by including the structure of table A and declare explicitly 2 fields of table 2.

eg:data : begin of itab occurs 0.

include structure table A.

data : field1 type datatype,

field2 type datatype,

end of itab.

Hope this is clear.

Thanks and regards.

9 REPLIES 9

former_member181995
Active Contributor
0 Kudos

in data statement you have to define each field as you define in itab 1 itab2.

or

data: BEGIN OF it_final OCCURS 0.
include structure itab1.
include structure itab2.
data:END OF it_final.

Amit.

Edited by: Amit on Jun 23, 2008 4:54 PM

Former Member
0 Kudos
types: begin of ty_final,
          all columns of A,
          2 Columns of B,
         end of ty_final.

data: it_final type table of ty_final,
        wa_final type ty_final.

Regards

Kannaiah

Former Member
0 Kudos

Pl. see this example:

types: begin of ty_data,

a1 type mara, << Table A

a2 type lfa1, << Table B

end of ty_data.

data: i_tab type standard table of ty_data.

Regards,

Joy.

Former Member
0 Kudos

hiiiii

you can define as follows


DATA : BEGIN OF i_actual_temp OCCURS 0,

       comp_code LIKE zfi_actual_sum-comp_code,
       franchisee LIKE        uom LIKE zfi_actual_sum-uom.
 INCLUDE STRUCTURE fs_actual.

DATA :    END OF i_actual_temp.

<removed_by_moderator>

thx

twinkal

Edited by: twinkal patel on Jun 23, 2008 4:55 PM

Edited by: Julius Bussche on Jun 24, 2008 7:12 PM

former_member598013
Active Contributor
0 Kudos

Hi Ami,

Create one final table say it_final. it contains all the columns present in itabA and ItabB.


 Loop at ITABA.
   read table itabb with key <key value >.
   if sy-subrc = 0.
      it_final-<all> = itabA-<all values>
      append it_final.
      clear it_final.
   endloop.
Endloop.

&*************<removed_by_moderator>****************&

Edited by: Julius Bussche on Jun 24, 2008 7:12 PM

Former Member
0 Kudos

type: begin of ty1.

include structure tab1.

type: tab2col1 type tab2col1,

tab2col2 type tab2col2,

end of ty1.

data : dt1 type standard table of ty1.

Former Member
0 Kudos

hi,

data :

begin of itab occurs 0.

include structure mara. - first table structure

data : werks like marc-werks, - second table fields

pstat like marc-pstat

data end of itab.

<removed_by_moderator>

Warm Regards,

R Adarsh

Edited by: Julius Bussche on Jun 24, 2008 7:13 PM

Former Member
0 Kudos

Types : begin of struct_itab,

field1 type tableA-field1,

.

.

field30 type tableA-field30,

field1 type tableB-field1,

field2 type tableB-field2,

end of struct_itab.

Data : itab type standard table of struct_itab.

Former Member
0 Kudos

Hi,

Say table A contains 15 fields and table B contains 10 fields.

C need to have 15 from table A and 2 from table B.

create table c by including the structure of table A and declare explicitly 2 fields of table 2.

eg:data : begin of itab occurs 0.

include structure table A.

data : field1 type datatype,

field2 type datatype,

end of itab.

Hope this is clear.

Thanks and regards.