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: 

insert into ZTAB

Former Member
0 Kudos
206

i want to insert data from ITAB into ZTABLE(SE11)

<b>how i can do it.</b>

i made this but i get dump

bestand---itab

zmb5b--table in se11

INSERT zmb5b FROM bestand.

PLS

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
132

Does ITAB have the same structure as ZMB5B? If not, they should be the same. If they are not the same, you can use another work area. Also, what does the dump say?

  • THis would be inserting one record at a time.

data: xzmb5b type zbm5b.

move-corresponding bestand to xzmb5b.

insert zmb5b from xzmb5b.

  • THis would be inserting all records of itab if the structure was the same.



insert zmb5b from table itab.

Regards,

Rich Heilman

11 REPLIES 11

laxmanakumar_appana
Active Contributor
0 Kudos
132

Hi,

Check this syntax:

INSERT (dbtabname) FROM TABLE itab.

Laxman

FredericGirod
Active Contributor
0 Kudos
132

Hi,

did you have create BESTAND like this:

data : bestand like table of ztable with header line.

??

Rgd

Frédéric

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
133

Does ITAB have the same structure as ZMB5B? If not, they should be the same. If they are not the same, you can use another work area. Also, what does the dump say?

  • THis would be inserting one record at a time.

data: xzmb5b type zbm5b.

move-corresponding bestand to xzmb5b.

insert zmb5b from xzmb5b.

  • THis would be inserting all records of itab if the structure was the same.



insert zmb5b from table itab.

Regards,

Rich Heilman

0 Kudos
132

bestand it's itab form trans MB5b

i made you say rich it's not work i tried both.

0 Kudos
132

the itab dont have mandt and the ztable have

0 Kudos
132

Hi

You have to define ITAB as ZTABLE, so it needs the MANDT too.

DATA: ITAB LIKE TABLE OF ZTABLE WITH HEADER LINE.

0 Kudos
132

Then you need to move the data to an itab where the structure is exactly the same. You can loop the BESTAND intab and move the values to an itab just like your "Z" table.

data: upd_tab type table of zmb5b with header line.

clear upd_tab. refresh upd_tab.
loop at bestand.
move-corresponding bestand to upd_tab.
append upd_tab.
endloop.

insert zmb5b from table upd_tab.

Regards,

Rich Heilman

0 Kudos
132

thanks it's work

but wht e didnt take bestand from the beging

i reward point

thanks again.

Former Member
0 Kudos
132

Hello,

If u want to insert a record from Itab, it should satisfy these condiitons.

1. Itab should have the structure similar to ZTABLE.

2. The Key fields value should not be repeated.

Hope this will be helpful for u.

Dön't forget to award points.

Regards,

Vasanth

Former Member
0 Kudos
132

Hi

But what' ITAB? An internal table or field of ZMB5B?

and TABLE?

DATA: BESTAND LIKE ZMB5B.

BESTAND-ITAB = .....

INSERT zmb5b FROM bestand.

or

DATA: BESTAND LIKE TABLE OF ZMB5B WITH HEADER LINE.

BESTAND-ITAB = .....

APPEND BESTAND.

INSERT zmb5b FROM TABLE bestand.

Max

Former Member
0 Kudos
132

ur syntax is correct,,

but makesure...

bestand(itab) is same structure of zmb5b(table in se11)

...read this for further details.....

INSERT dbtab [CLIENT SPECIFIED] FROM TABLE itab. or INSERT (dbtabname) [CLIENT SPECIFIED] FROM TABLE itab.

Addition: ... ACCEPTING DUPLICATE KEYS

Effect

Mass insert: Inserts all lines of table itab in a single operation. The lines of itab must satisfy the same condition as the work area wa in variant 1.

After the statement has been executed, the system field SY-DBCNT contains the number of lines inserted.

The return code is set as follows:

SY-SUBRC = 0:

All lines inserted successfully. Any other situation causes a runtime error.

Note

If the internal table itab is empty, SY-SUBRC and SY-DBCNT are both 0 after the call.

Regards,

Ramesh

Addition

... ACCEPTING DUPLICATE KEYS

Effect

If the system cannot insert a line, the program does not terminate with a runtime error. Instead, SY-SUBRC is set to 4. All lines of the internal table after the one that could not be inserted are still inserted into the database table.