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

inner join

Former Member
0 Likes
949

hi friends..iam geting an error while doin this prog...

error is:::when i execute this prog,its goin into dump and showing an error "too few fields in INTO clause"...

TYPES : BEGIN OF str_mard,

matnr TYPE mard-matnr, "mat num

lgort TYPE mard-lgort, "stor loc

werks TYPE mard-werks, "plant

END OF str_mard.

DATA : wa_mard TYPE str_mard,

it_mard TYPE TABLE OF str_mard.

TYPES : BEGIN OF str_makt,

matnr TYPE makt-matnr, "mat num

maktg TYPE makt-maktg, "mat desc

spras type makt-spras,

END OF str_makt.

DATA : wa_makt TYPE str_makt,

it_makt TYPE TABLE OF str_makt.

data: v_matnr type matnr,

s_matnr type v_matnr.

select-options: z_matnr for v_matnr.

select mard~matnr

mard~lgort

mard~werks

makt~maktg

makt~spras

into table it_mard

from mard inner join makt

on mardmatnr = maktmatnr

where mard~matnr in z_matnr.

loop at it_mard into wa_mard.

write:/ wa_mard-matnr,

wa_mard-lgort,

wa_mard-werks,

wa_makt-maktg,

wa_makt-spras.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
911

your internal table has just 3 fileds, while yopu are tryiong to insert 5 fields in there

mard~matnr

mard~lgort

mard~werks

makt~maktg

makt~spras

while it has just matnr, lgort, werks. Change your definition.

8 REPLIES 8
Read only

Former Member
0 Likes
912

your internal table has just 3 fileds, while yopu are tryiong to insert 5 fields in there

mard~matnr

mard~lgort

mard~werks

makt~maktg

makt~spras

while it has just matnr, lgort, werks. Change your definition.

Read only

Former Member
0 Likes
910

Hi Gundala,

You have forgotten to add the two fields in the type declaration ( i.e mard~lgort

mard~werks).

Just add this two fields in the type declaration you will solve yourproblem.

Add this Type declaration in your code.


TYPES : BEGIN OF str_makt,
matnr TYPE makt-matnr, "mat num
lgort    TYPE mard-lgort,  "-->I have added this field in your type declartion.
werks TYPE mard-werks  "-->I have added this field in your type declartion.
maktg TYPE makt-maktg, "mat desc
spras type makt-spras,
END OF str_makt.

This will solve your problem.

Thanks,

Chidanand

Read only

0 Likes
910

is this the correct code???

TYPES : BEGIN OF str_mard,

matnr TYPE mard-matnr, "mat num

lgort TYPE mard-lgort, "stor loc

werks TYPE mard-werks, "plant

END OF str_mard.

DATA : wa_mard TYPE str_mard,

it_mard TYPE TABLE OF str_mard.

TYPES : BEGIN OF str_makt,

lgort TYPE mard-lgort, "stor loc

werks TYPE mard-werks, "plant

matnr TYPE makt-matnr, "mat num

maktg TYPE makt-maktg, "mat desc

spras type makt-spras,

END OF str_makt.

DATA : wa_makt TYPE str_makt,

it_makt TYPE TABLE OF str_makt.

data: v_matnr type matnr,

s_matnr type v_matnr.

select-options: z_matnr for v_matnr.

select mard~matnr

mard~lgort

mard~werks

makt~maktg

makt~spras

into table it_mard

from mard inner join makt

on mardmatnr = maktmatnr

where mard~matnr in z_matnr.

loop at it_mard into wa_mard.

write:/ wa_mard-matnr,

wa_mard-lgort,

wa_mard-werks,

wa_makt-maktg,

wa_makt-spras.

endloop.

Read only

0 Likes
911

no, check the fields you are moving to IT_MARD, and what have you defined for that.

matnr TYPE mard-matnr, "mat num

lgort TYPE mard-lgort, "stor loc

werks TYPE mard-werks, "plant

mard~matnr

mard~lgort

mard~werks

makt~maktg

makt~spras

??

you are trying to move 5 fields into a table defined with 3 fields.

Read only

0 Likes
911

Hi,

It looks good, but you need to keep the order of the fields you are selecting in the same way you defined the internal table or you need to write your query using into corresponding fields of table.


select mard~matnr
mard~lgort
mard~werks
makt~maktg
makt~spras

into corresponding fields of table it_mard   " i've added this 'corresponding fields of table'
from mard inner join makt
on mard~matnr = makt~matnr
where mard~matnr in z_matnr.


Also , you need to change the definition of the itab it_mard to add the remaining 2 fields.

regards,

Advait

Edited by: Advait Gode on Nov 8, 2008 7:57 PM

Read only

0 Likes
911

Hi

Try this code.. I have modified the fields in the type declaration. Actually the sequence between the table declaration and the select query should be same.

This time you have added the fields in the internal table but the sequence was correct. I have modified the table declaration.


TYPES : BEGIN OF str_mard,
matnr TYPE mard-matnr, "mat num
lgort TYPE mard-lgort, "stor loc
werks TYPE mard-werks, "plant
END OF str_mard.

DATA : wa_mard TYPE str_mard,
it_mard TYPE TABLE OF str_mard.

TYPES : BEGIN OF str_makt,
matnr TYPE makt-matnr, "mat num

lgort TYPE mard-lgort, "stor loc
werks TYPE mard-werks, "plant
maktg TYPE makt-maktg, "mat desc
spras type makt-spras,
END OF str_makt.

DATA : wa_makt TYPE str_makt,
it_makt TYPE TABLE OF str_makt.
data: v_matnr type matnr,
s_matnr type v_matnr.
select-options: z_matnr for v_matnr.

select mard~matnr
mard~lgort
mard~werks
makt~maktg
makt~spras

into table it_mard
from mard inner join makt
on mard~matnr = makt~matnr
where mard~matnr in z_matnr.


loop at it_mard into wa_mard.

write:/ wa_mard-matnr,
wa_mard-lgort,
wa_mard-werks,
wa_makt-maktg,
wa_makt-spras.
endloop.

Thanks,

Chidanand

Read only

0 Likes
911

Hi Chaidanand,

The sequence doesn't matter if you use into corresponding fields of table. The problem is with the definition of the type str_mard and not str_makt.

Hi Abhilash,

I would suggest you select the data in the table it_makt instead of it_mard.


select mard~matnr
mard~lgort
mard~werks
makt~maktg
makt~spras
 
into table it_makt   " Change it_mard to it_makt
from mard inner join makt
on mard~matnr = makt~matnr
where mard~matnr in z_matnr.

regards,

Advait

Read only

0 Likes
911

Yes Adavit,

You are right while using " into corresponding fields of" sequence doesn't matter. But for your information it affects the performance.Its better to avoid INTO CORRESSPONDING FIELDS OF statement.

Thanks,

Chidanand