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: 

Internal Table

Former Member
0 Kudos
194

Hi All

I would like to create an internal table with a few fields. Can someone let me know how i should declare the DATA & write the steps for the below req.

The first few fields in the internal table i want to fill with values from another internal table which is filled with values from a function module output & for each value (i.e. for IT_FUNcMod-Fld1) i want to read a few fields from MARC & DRAD tables.

Eg:

Internal table - Function Module (Table name: IT_FUNcMod)

Fld1 Fld2 Fld3...

M1 89 37

M2 33 45

& so on

MARC Table

Fld1 Fld2 Fld3...

M1 B AB

M2 H UY

& so on

DRAD Table

Fld1 Fld2 Fld3...

xM1 1234 RT78

xM2 2354 TY89

& so on

Link between IT_FUNcMod & MARC => IT_FUNcMod-Fld1 EQ MARC-Fld1

Link between MARC & DRAD => MARC-matnr Like DRAD-Objky

Output:

(Fld1 & Fld2 from IT_FUNcMod, Fld3 & Fld4 from MARC table, Fld5 & Fld6 from DRAD)

New Internal Table (Table name: IT_NEW)

Fld1 Fld2 Fld3 Fld4 Fld5 Fld6

M1 89 B AB 1234 RT78

M2 33 H UY 2354 TY89

& so on

Vivek

1 ACCEPTED SOLUTION

Former Member
0 Kudos
146

Hope this is not Dynamic Interal Table.

Proceed Like this if it is not Dynamic Internal Table.

Declare Internal Tables for Each :

Itab for Function MOdule Data,

Itab for Mara Data,

Itab for DRAD data.

4th Itab contains the fields u required from the above itabs in common.

Now Read Data to it_fm from Function Module.

Read data to it_mara and it_drad based on the key from it_fm.

Now Copy it_fm into it_final.

Again looping at it_mara MODIFY it_final setting corresponding fields.

Again looping at it_drad MODIFY it_final setting corresponding fields.

Thats the solution u require.

AWRD POINTS IF USEFUL

REPLY me for any further solution

Bhupal

16 REPLIES 16

Former Member
0 Kudos
147

Hope this is not Dynamic Interal Table.

Proceed Like this if it is not Dynamic Internal Table.

Declare Internal Tables for Each :

Itab for Function MOdule Data,

Itab for Mara Data,

Itab for DRAD data.

4th Itab contains the fields u required from the above itabs in common.

Now Read Data to it_fm from Function Module.

Read data to it_mara and it_drad based on the key from it_fm.

Now Copy it_fm into it_final.

Again looping at it_mara MODIFY it_final setting corresponding fields.

Again looping at it_drad MODIFY it_final setting corresponding fields.

Thats the solution u require.

AWRD POINTS IF USEFUL

REPLY me for any further solution

Bhupal

0 Kudos
146

Mr. Bhupal,

Thanks for the inputs. But what i really need is how should i define the internal table with the fields & the steps to read the value from MARC & DRAD tables, i.e. the syntax as i am still new to ABAP.

Also i would like to know, would it not be better to read the data from MARC & DRAD tables directly for the matching case, instead of first reading them into an internal table & then re-reading the values from this internal table?

Await your inputs.

Vivek

0 Kudos
146

its always better to get the data according to ur req from table like MARA MARC and DRAD and better read that table to fill ur output table,

sort table it_marc by primary key fields. < mandatory when binary search is used

sort table it_drad by primary key fields.

loop at it_output.

read table it_marc with key = k1 binary search.

if sy0subrc eq 0.

moves...

endif.

read table drad with key = k2 binary search.

if sy-subrc eq 0.

endif .

endloop.

Former Member
0 Kudos
146

Hi,

1.Execute the function module to get IT_FUNCMOD data.

2.Select it_funcmodf1 it_funcmodf2 af3 af4 bf5 b6

into table l_t_Tab

from MARC AS a

INNER JOIN DRAD AS b

ON amatnr = bobjky

FOR ALL ENTRIES IN it_funcmod

Where a~f1 = it_funcmod-f1.

Hope this helps u.

0 Kudos
146

Mr. Ramesh,

Thanks for your inputs. I tried the lines as per what you have mentioned & when i do a syntax check, the system prompts the error - 'The formal argument "AS" occurs twice.'

How to correct it? Also will the query output show the values in the 6 fields or would it require any ABAp statements as well?

Note for Mr. Manoj: Thank you for your help, will check the code which you have posted.

Note for Jackandijay: I am not sure how to use the Read / Write statements.

Await clarifications

Vivek

0 Kudos
146

Hi,

Try as follows:

All the 6 fields will be displayed properly.

Types: begin of itab,

f1 type ..

f2 type ...

f3 type marc-f3,

f4 type marc-f4,

f5 type drad-f5,

f6 type drad-f6,

end of itab.

data: l_t_tab type table of itab with header line,

l_r_tab type itab.

Select af3 af4 bf5 b6

into corresponding fields of l_r_tab

from MARC AS a

INNER JOIN DRAD AS b

ON amatnr = bobjky

FOR ALL ENTRIES IN it_funcmod

Where a~f1 = it_funcmod-f1.

l_r_tab-f1 = it_funcmod-f1.

l_r_tab-f2 = it_funcmod-f2.

append l_r_tab to l_t_tab.

Endselect.

0 Kudos
146

Mr. Ramesh,

Thanks for the inputs, but i am still getting the same error

'The formal argument "AS" occurs twice.'

I think there is some error in the join condition or the way in which the join is done. Also note i have changed af3LIKE bobjky as these 2 fields cannot be joined directly. But even if i keep it as '=' i get the same error. Any idea?

Select af3 af4 bf5 b6

into corresponding fields of l_r_tab

from MARC AS a

INNER JOIN DRAD AS b

ON af3 LIKE bobjky

FOR ALL ENTRIES IN IL_STBX

Where a~f3 = IL_STBX-f1.

former_member402443
Contributor
0 Kudos
146

Hi Vivek,

Check this code. This gives you an idea how to solve your problem.

Tables : IT_FUNcMod, marc, drad.

TYPES : BEGIN OF tab,

fld1 like IT_FUNcMod-fld1,

fld2 like IT_FUNcMod-fld2,

fld3 like marc-fld3,

fld4 like marc-fld4,

fld5 like drad-fld5,

fld6 like drad-fld6,

END OF tab.

SELECT IT_FUNcModfld1 IT_FUNcModfld2

marcfld3 marcfld4 drad~fld5

drad~fld6 FROM IT_FUNcMod INNER JOIN

marc ON IT_FUNcMod~fld1 = marc-fld1

INNER JOIN drad ON marcmatnr = dradObjky

INTO table it_final.

Reward Points, if useful.

Regards,

Manoj Kumar

0 Kudos
146

joins can be used,, but if its a report try not to use joins... join on marc and other tables will be a big burden on DB... if things are working well with read and index better to go with it..

former_member194613
Active Contributor
0 Kudos
146

How should a 'LIKE' in the ON condition work? I have never seen that.

I Think, only EQ is allowed.

Siegfried

0 Kudos
146

Hi Boes,

Even if i maintain EQ, system is prompting the syntax error

'The formal argument "AS" occurs twice.'

Vivek

Former Member
0 Kudos
146

Data: begin of itab1 occurs 0,

a1 type aaa-a1,

end of itab1.

data: wa like line of itab1.

Data: begin of itab2 occurs 0,

a1 type aaa1-a1,

a2 type aaa1-a2,

end of itab2.

data: wa1 like line of itab2.

Data: begin of final occurs 0,

a1 type aaa-a1,

a2 type aaa1-a2,

end of final.

data: wa_final like line of final.

Parameters: bb type jj-bb.

select <field name a1> from <table name> into table <itab1>

where kk = bb.

select <field name a2> from <table name> into table <itab2>

for all entries in itab1 where a1 = itab1-a1.

loop at itab1 into wa.

read table itab2 into wa1 with key a1 = wa-a1.

wa_final-a1 = wa-a1.

wa_final-a2 = wa1-a2.

append wa_final to it_final.

clear wa_final.

endloop.

Former Member
0 Kudos
146

Hi,

Here the require code.

loop at IT_FUNcMod.

loop at MARC where fld1 = IT_FUNcMod-Fld1.

read table DRAD with key Objky = MARC-matnr .

if sy-subrc eq 0.

IT_NEW-f1 = IT_FUNcMod-f1 .

IT_NEW-f2 = IT_FUNcMod-f2 .

IT_NEW-f3 = MARC-f3 .

IT_NEW-f4 = MARC-f4 .

IT_NEW-f5 = DRAD-f5 .

IT_NEW-f6 = DRAD-f6 .

APPEND IT_NEW.

CLEAR IT_NEW.

endif.

endloop.

Now IT_NEW contains required data.

Hope this helps you much.

Regards,

Rama.Pammi

0 Kudos
146

Hi Rama,

Thanks for your inputs, the system prompts the following error message when i do syntax check

"VERSION ... ." expected after "MARC".

how to resolve?

Vivek

0 Kudos
146

hi vivek..

do one thing.just declare a internal table like this..

data itab_marc type standard table of marc with header line.

then..

select ur fields from marc into table itab_marc.

loop at itab_funcmod.

loop at itab_marc (instead of marc)..

i hope this solves the problem.

Former Member
0 Kudos
146

.

Edited by: Kamini Rawat on Dec 27, 2007 1:30 PM