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: 

inserting standard table data using ztable

Former Member
0 Kudos

Hi all,

I have an issue like i have created "ztable" where i am taking few of the mara table fields.

but my problem is i m not getting data into these fields , so can anyone tell me wht shuld be done to get the data into my ztable which will contain all these fields.

<code>

tables : mara.

data : begin of itab occurs 0,

matnr like mara-matnr,

ersda like mara-ersda,

ernam like mara-ernam,

vpsta like mara-vpsta,

mtart like mara-mtart,

mbrsh like mara-mbrsh,

matkl like mara-matkl,

meins like mara-meins,

end of itab.

data : wa like line of itab.

select matnr ersda ernam vpsta mtart mbrsh matkl meins from mara into corresponding fields of table itab .

  • what should be done , shuld i use INSERT INTO "ZTABLE FROM ITAB.

PLZZ SUGGEST.

Thanks,

karan

15 REPLIES 15

JozsefSzikszai
Active Contributor
0 Kudos

hi Karan,

the selection like:

select matnr ersda ernam vpsta mtart mbrsh matkl meins

from mara

into table itab .

the insert like:

INSERT ztable FROM table itab.

hope this helps

ec

0 Kudos

Hi Eric ,

Thanks for ur reply. but after doing that i am getting eroor like

Program ... The work area "ITAB" is not long enough . .

plz help.

regards,

karan

0 Kudos

pls check if there are the same fields in the internal table declaration, like in the select statement (and in the same order), the select has to look like:

SELECT ...

FROM mara

<b>INTO TABLE</b> itab

it has to work.

ec

Former Member
0 Kudos

any help frnds.

Former Member
0 Kudos

Hi karan,

i have done this:

TABLES : MARA.

*

DATA : BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

ERNAM LIKE MARA-ERNAM,

VPSTA LIKE MARA-VPSTA,

MTART LIKE MARA-MTART,

MBRSH LIKE MARA-MBRSH,

MATKL LIKE MARA-MATKL,

MEINS LIKE MARA-MEINS,

END OF ITAB.

DATA : WA LIKE LINE OF ITAB.

SELECT MATNR ERSDA ERNAM VPSTA MTART MBRSH MATKL MEINS FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB UP TO 100 ROWS.

*

BREAK-POINT.

it works ok.

Try it.

Regards, Dieter

0 Kudos

Hi Dieter,

i m gettig data in my internal table but i want to insert the data of the internal table into my ztable .

so when i use INSERT command i m getting error like.

The work area "ITAB" is not long enough . .

looking for ncessary help.

regards,

karan

0 Kudos

Karan,

if you do like this:

INSERT ztable FROM table itab.

your ztable and itab has to be identical as well.

ec

0 Kudos

yes eric both are same but still i m not getting.

regards,

karan

Message was edited by:

karan kakkad

0 Kudos

frnds i just want to know can we do that or not.

regards,

karan

0 Kudos

Hi

You can do it and what ever solutions have been given to you are correct.

If it is not working then your itab structure is not same as your ztable. If it is, then it will work because it has to work.

Your itab does not contain MANDT field and also populate MANDT field.

So declare itab as

DATA: itab like standard table of ztable occurs 0.

Regards

Navneet

0 Kudos

navneet its working now but ztable_12 where i am inserting data its not getting any data why?

below is my code.

<code>

tables : mara.

data : begin of itab occurs 0,

matnr like mara-matnr,

ersda like mara-ersda,

ernam like mara-ernam,

vpsta like mara-vpsta,

mtart like mara-mtart,

mbrsh like mara-mbrsh,

matkl like mara-matkl,

meins like mara-meins,

end of itab.

data : wa like line of itab.

select matnr ersda ernam vpsta mtart mbrsh matkl meins from mara into corresponding fields of table itab .

append itab.

INSERT ztable_12 from table itab.

</code>

thnks karan

0 Kudos

Hi karan,

clear the append-statement.

the select ... into table itab makes an append.

regards, Dieter

0 Kudos

Hi dieter,

see problem is its working fine after removing the append but problem is its going to dump and the error is

" The ABAP/4 Open SQL array insert results in duplicate database records"

plz suggest.

see zdata_12 is a ztable.

plzz help.

regards,

karan

0 Kudos

Karan,

Have you tried to use the SAP ABAP help to understand all this? There you will fnid examples for reading and updating database tables. Or you could search these forums - this sort of question has been asked countless times before.

Gareth

Former Member
0 Kudos

Hi Karan,

After the <b>SELECT</b> stmt. you need to pass the values retrieved from DB tables into <b> ITAB</b> to a <b>new WA</b> using

<b>LOOP AT ITAB INTO WA.</b>

Wherein , in that loop move the fields retrieved from itab to the new WA, and later append this WA to ITAB(New One). Outside the loop, you can use the <b>INSERT</b> keyword as used by you in the given code.

Hope this resolves your query.

Regards

Nagaraj