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

how i can insert into ztable.

i need to select data from standard table and insert into zTAB

8 REPLIES 8

Former Member
0 Kudos

Select * from std table into itab and then do a array insert using the insert command.

INSERT ZTAB FROM ITAB.

Cheers

VJ

former_member181962
Active Contributor
0 Kudos

Use Modify statment

select *

from std table

into corresponding fields of itab.

modify ztab from table itab.

REgards,

Ravi

0 Kudos

SELECT *

FROM tabl

INTO TABLE itab.

INSERT ztabl FROM TABLE itab.

Former Member
0 Kudos

HI Rani,

select * into table itab1 from <table>.

insert ztable from table itab1.

regards

satesh

0 Kudos

hi Rani,

Check it out with this ..

<b>SELECT *

FROM IT_TAB

INTO TABLE ITAB.</b>

<b>INSERT ZTAB FROM ITAB.</b>

Regards,

Santosh

Former Member
0 Kudos

Hi Rani,

Create work area of ZTAB if one record

insert into ztab form workarea

create internal table if more than one record

and insert records into it

insert into ztab form table

Eg.

INSERT dbtab FROM TABLE itab ACCEPTING DUPLICATE KEYS

(----


ACCEPTING DUPLICATE KEYS ... this required for more than one record otherwise; dump if duplicate entries are present )

if more than one record in the internal table .

  • itab should be of type ztab( table name)

data itab type standard of ztab

INSERT dbtab FROM wa

if contains single record

wa type ztab.

-


DATA select----


u can directly select data into ZTAB INTERNAL TABLE provided the data type of the fields in the ztable is same as standard table .

select f1 f2 f3 form st_table

into ztab

where ......

order of the field selectED should match the order of the ztab filed otherwise DUMP.

..........If the data type are different that of standard table filed then select data in to temp_internal table ( data type should be specific )

........loop at the temp table and append into ztab with direct assign method to each field.

then try to insert.

Reagards

Manoj

Message was edited by: Manoj Gupta

Message was edited by: Manoj Gupta

Message was edited by: Manoj Gupta

ferry_lianto
Active Contributor
0 Kudos

Hi Rani,

You can code something like this.


SELECT * 
FROM <STANDARD TABLE>
INTO ITAB
WHERE <CONDITION>.

IF SY-SUBRC = 0.
  MODIFY ZTAB FROM TABLE ITAB.
ENDIF.

Hope this will help.

Regards,

Ferry Lianto

Former Member
0 Kudos

You can use either INSERT or MODIFY to add values to the Ztable. INSERT pushes a row into the table, so the update could fail if a duplicate record exists.

MODIFY will check for existing records with the same primary keys, add a new row if no duplicates exist, and update the existing row if one already exists.

Hope this helps.

Sudha