Application Development and Automation 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: 
Read only

Modify Internal Table

Former Member
0 Likes
2,101

HI,ALL :

LOOP AT it_rbkp.

SELECT SINGLE name1 INTO it_rbkp-name1

FROM lfa1

WHERE lifnr = it_rbkp-lifnr.

MODIFY IT_RBKP.

CLEAR IT_RBKP.

ENDLOOP.

why can use "MODIFY IT_RBKP" without "index sy-tabix"?

6 REPLIES 6
Read only

Former Member
0 Likes
807

hi,

it will compare the key fields in the work area and will modify the correponding record in in itab with the same key.

so index is not needed.

or us can use the below procedure.

data : ind type sy-tabix.

LOOP AT it_rbkp.

ind = sy-tabix.

SELECT SINGLE name1 INTO it_rbkp-name1
FROM lfa1
WHERE lifnr = it_rbkp-lifnr.

MODIFY IT_RBKP index ind..
CLEAR IT_RBKP.

ENDLOOP

Regards

Reshma

Read only

0 Likes
807

Hi Reshma,

Good Logic yaar.

I leant one thing don't high always,think of bacics also.

Regards,

Sunil

Read only

Former Member
0 Likes
807

hi,

MODIFY IT_RBKP. statement is inside loop...endloop

so it refers to the pqarticular loop pass.

Present record in the internal table headerline is modified in the internal table.

Read only

Former Member
0 Likes
807

Hi

Modify statement,as it name indicates it modifies the internal table to the changes made.for the example you mentioned,

modify statement fetches the required record from lfa1 and append it into the name 1 field of it_rbkp.

so when you open the it_rbkp again it will be modified.

REWARD IT PLEASE...!!!

Read only

Former Member
0 Likes
807

hi

You r writing the MODIFY Statement inside the LOOP ENDLOOP statement.

The Processor executes This Statement just after processing SELECT SINGLE statement.

Unless the execution reaches the ENDLOOP statement the sy-tabix holds its value so there is no need for INDEX option.

Hope this will Help.

Reward if Useful.

Sumit Agarwal

Read only

Former Member
0 Likes
807

Hi,

After Fetching Records From Database table into Internal table You Are modyfying the Table.

Here The Index is Index of current loop pass i.e sy-tabix.

So No Need to mention Index explicitly.

internal table is modified for Every loop pass.

If You want then you can also mention it explicitly but effcet is same.

To change a line using its index, use the following statement:

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

Here The TRANSPORTING addition allows you to specify the fields that you want to change explicitly in a list. See also Changing Table Entries. If you change a sorted table, you may only specify non-key fields.

Again You can change lines of standard tables using the following statement:

WRITE <f> TO <itab> INDEX <idx>.

Regards,

Sujit

Edited by: Sujit Pal on Jun 28, 2008 6:49 AM