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: 

Internal table

Former Member
0 Kudos

I have a Database Table called Zcustomers.

An internal table called ITZcustomers. I have read all the records from Zcustomers into ITZcusotmers. I have modified my ITZcusomers using my business logice and now I need to move this ITZcustomers modifications to my Zcustomers DB table?

Whats the Syntax for this? Thanks a lot.

1 ACCEPTED SOLUTION

former_member223537
Active Contributor
0 Kudos

Hi,

Loop at itzcustomers into wa_customers.

modify zcustomers from wa_customers.

endloop.

Best regards,

Prashant

10 REPLIES 10

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos



data: itzcustomers type table of zcustomers with header line.

loop at itzcustomers.
  modify zcustomers from itzcustomers.
endloop.

or.....




data: itzcustomers type table of zcustomers .
data: wazcustomers type zcustomers.

loop at itzcustomers into wazcustomers.
  modify zcustomers from wazcustomers.
endloop.

Regards,

Rich Heilman

former_member223537
Active Contributor
0 Kudos

Hi,

Loop at itzcustomers into wa_customers.

modify zcustomers from wa_customers.

endloop.

Best regards,

Prashant

0 Kudos

<b>Loop at itzcustomers into wa.

modify zcustomers from wa.

endloop.</b>

0 Kudos

Or......

 

* No need for a loop here.
MODIFY zcustomers FROM TABLE itzcustomers.


Regards,

Rich Heilman

Former Member
0 Kudos

Are you only changing existing records, or might you insert or delete records as well?

Rob

0 Kudos

If you are only changing existing records, you should use:

update zcustomers from table itzcustomers.

This will be quicker than modify.

Rob

laxmanakumar_appana
Active Contributor
0 Kudos

MODIFY Zcustomers FROM TABLE ITZcustomers .

Laxman

Former Member
0 Kudos

Hi vijaya,

check this, hope it helps u.

Inserting or Changing Single Lines

To insert or change a single line in a database table, use the following:

MODIFY <target> FROM <wa> .

The contents of the work area <wa> are written to the database table <dbtab>. The work area <wa> must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.

If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0.

A shortened form of the above statement is:

MODIFY <dbtab>.

In this case, the contents of the table work area <dbtab> are inserted into the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.

Inserting or Changing Several Lines

To insert or change several lines in a database table, use the following:

MODIFY <target> FROM TABLE <itab> .

Those lines of the internal table <itab> for which there is not already a line in the database table with the same primary key are inserted into the table. Those lines of the internal table <itab> for which there is already a line in the database table with the same primary key overwrite the existing line in the database table. The same rules apply to the line type of <itab> as to the work area <wa> described above.

SY-SUBRC is always set to 0. SY-DBCNT is set to the number of lines in the internal table.

regards,

keerthi.

Former Member
0 Kudos

HI Vijaya,

Loop at internal table into workarea.

Modify internal table from workarea

endloop.

Ex:

loop at itab into wa.

modify ztab from wa.

endloop.

Regards

Laxmi.

Message was edited by: Laxmi

Former Member
0 Kudos

Hi Vijaya,

You can use the Modify statement. The advantage of this statement is that if the record you are updating the table is already there it justs modifies the record else it updates a new entry in the database table.

MODIFY Zcustomers from table ITZcustomers.