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: 

Help on Modify.

Former Member
0 Kudos

Hi friends,

i am updating the following internal table XE1EDPT2.

this is having the following fields,

posex

posnr

tdid

tsspras

tdline

tdformat.

already its having one record,

now in my program i want to add some more records to it,

even if i give Append, the first record got over written,

how to add more records to this with out over writting the already existing records ?

Thanks & Regards,

Joseph.

6 REPLIES 6

former_member181962
Active Contributor
0 Kudos

Hi Joseph,

can you show your code?

Looks like you are extending an idoc.

check this link to know more.

http://help.sap.com/saphelp_erp2005/helpdata/en/dc/6b7d6243d711d1893e0000e8323c4f/frameset.htm

Regards,

Ravi

0 Kudos

Hi Ravi,

yes, i am extending the idoc only,

This is to modify the additional text filed in the Sales order at item level.

Already its having the text, now i want to add some more text to it.

how to do this ? can u help me ?

0 Kudos

1) modify record which is already exits.

2)now append new text.

3) u have to do both opration saprate.

vinod_gunaware2
Active Contributor
0 Kudos

MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2> ...].

The work area <wa>, which must be compatible with the line type of the internal table, plays a double role in this statement. Not only it is used to find the line that you want to change, but it also contains the new contents. The system searches the internal table for the line whose table key corresponds to the key fields in <wa>.

The system searches for the relevant lines as follows:

Standard tables

Linear search, where the runtime is in linear relation to the number of table entries. The first entry found is changed.

Sorted tables

Binary search, where the runtime is in logarithmic relation to the number of table entries. The first entry found is changed.

Hashed tables

The entry is found using the hash algorithm of the internal table. The runtime is independent of the number of table entries.

If a line is found, the contents of the non-key fields of the work area are copied into the corresponding fields of the line, and SY-SUBRC is set to 0. Otherwise, SY-SUBRC is set to 4. If the table has a non-unique key and the system finds duplicate entries, it changes the first entry.

You can specify the non-key fields that you want to assign to the table line in the TRANSPORTING addition. You can also specify a field <f i > dynamically as the contents of a field <n i > in the form (<n i >). If <n i > is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length.

For tables with a complex line structure, the usage of the transporting option results in better performance, if the system must not transport unnecessary table-like components.

Changing Several Lines Using a Condition

To change one or more lines using a condition, use the following statement:

MODIFY <itab> FROM <wa> TRANSPORTING <f1> <f 2> ... WHERE <cond>.

This processes all of the lines that meet the logical condition <cond>. The logical condition can consist of more than one comparison. In each comparison, the first operand must be a component of the line structure. If the table lines are not structured, the first operand can also be the expression TABLE LINE. The comparison then applies to the entire line.

The work area <wa>, which must be compatible with the line type of the internal table, contains the new contents, which will be assigned to the relevant table line using the TRANSPORTING addition. Unlike the above MODIFY statement, the TRANSPORTING addition is not optional here. Furthermore, you can only modify the key fields of the internal table if it is a standard table. If at least one line is changed, the system sets SY-SUBRC to 0, otherwise to 4.

regards

vinod

Former Member
0 Kudos

Hi,

You can use:

MODIFY itab [FROM wa] TRANSPORTING f1 ... fn WHERE cond.

Ex:

DATA: BEGIN OF TAB OCCURS 500,

FLAG TYPE C,

COMP(20) TYPE C,

END OF TAB.

CLEAR TAB-FLAG.

MODIFY TAB TRANSPORTING FLAG WHERE FLAG = 'X'.

When you use the WHERE condition with a STANDARD or HASHED table, a full table scan is always required.

If you are working with a SORTED TABLE, the partial sequential processing can be optimized so that only the entries that actually satisfy the WHERE condition are processed. This optimization requires that each sub-condition is linked with AND; that no parentheses are used; that at least one sub-condition is in the form k = v; and that the conditions in the form k1 = v1 ... kn = vn cover at least the first part of the table key.

If you use the TRANSPORTING addition together with an explicitly-specified work area, the work area must be compatible with the line type of the internal table.

The counter for table entries begins at 1.

A unique or summarized dataset built up using an internal table and COLLECT can be modified while you are constructing it using the "MODIFY ... TRANSPORTING ..." statement, as long as the components selected with TRANSPORTING are not contained in the key of the internal table. This method does not cause significant performance impairment.

<b>Reward if helpful.</b>

Regards,

Shakuntala

former_member181962
Active Contributor
0 Kudos

When you are appending ,

Give the same values for the folowing fields.

posex

posnr

tdid

tsspras

tdformat.

GIve the additional text in the tdline field.

Regards,

ravi