10-09-2007 2:28 PM
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
10-09-2007 2:38 PM
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
10-09-2007 2:44 PM
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
10-09-2007 2:50 PM
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
10-09-2007 2:39 PM
10-09-2007 2:48 PM
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
10-09-2007 2:53 PM
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
10-09-2007 2:59 PM
Karan,
if you do like this:
INSERT ztable FROM table itab.
your ztable and itab has to be identical as well.
ec
10-09-2007 3:36 PM
yes eric both are same but still i m not getting.
regards,
karan
Message was edited by:
karan kakkad
10-09-2007 3:43 PM
10-09-2007 3:49 PM
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
10-09-2007 4:00 PM
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
10-09-2007 4:10 PM
Hi karan,
clear the append-statement.
the select ... into table itab makes an append.
regards, Dieter
10-09-2007 4:14 PM
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
10-09-2007 4:16 PM
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
10-09-2007 2:53 PM
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