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

Table update/ Modify poblem....

Former Member
0 Likes
715

Hello,

I am trying to populate the custom table. Now after certain logic, I am using update statement as follows.

Loop.

:

:

WA_ZKEYSAP-KEYROLE = I_KEYROLE-KEYROLE.

WA_ZKEYSAP-ROLE = I_ROLE-ROLE.

UPDATE ZKEYSAPMAP FROM WA_ZKEYSAP.

:

:

ENDLOOP.

In every run the values of I_KEYROLE-KEYROLE and I_ROLE-ROLE but the table does not

get updated with a new line.

I want as following:

For example:

If in first loop run, the values of I_KEYROLE-KEYROLE = A and I_ROLE-ROLE =B,

then, table should have.

A...B

If in next run again the values are same as A and B for rescpective field then

no change in table

In third run if values are A and C, then table should get updated by A and C

Table will have final result like below.

A...B

A...C

Regards,

Rajesh.

1 ACCEPTED SOLUTION
Read only

former_member195698
Active Contributor
0 Likes
697

use MODIFY statement instead of Update.

5 REPLIES 5
Read only

former_member195698
Active Contributor
0 Likes
698

use MODIFY statement instead of Update.

Read only

0 Likes
697

It doesn't work. See the more simplified program below:

TABLES: ZKEYSAPMAP, ZROLEMAP.

DATA: WA_ZKEYSAP TYPE ZKEYSAPMAP.

DATA: BEGIN OF I_KEYROLE occurs 0,

KEYROLE LIKE ZROLEMAP-KEYROLE,

TCODE LIKE ZROLEMAP-TCODE,

OBJECT LIKE ZROLEMAP-OBJECT,

FIELD LIKE ZROLEMAP-FIELD,

VALUE LIKE ZROLEMAP-VALUE,

END OF I_KEYROLE.

Select KEYROLE TCODE OBJECT FIELD VALUE from ZROLEMAP into table

I_KEYROLE.

WA_ZKEYSAP-KEYROLE = 'KR001'.

WA_ZKEYSAP-ROLE = 'KIS09'.

MODIFY ZKEYSAPMAP FROM WA_ZKEYSAP.

WA_ZKEYSAP-KEYROLE = 'KR002'.

WA_ZKEYSAP-ROLE = 'KIS10'.

MODIFY ZKEYSAPMAP FROM WA_ZKEYSAP.

Still only one line getting updated and the ultimate result is:

KR002....KIS10

Read only

0 Likes
697

what is the key for this Ztable . Try making the two fields as key .

Read only

0 Likes
697

Hi..

The problem is the first field(KEYROLE) is the primary key..So it cant have duplicate entries...

Hence its modifying the existing entry...instead of appending a new entry....Try making the 2nd field the primary key...Or declare another field and make it primary key....Then u will get appending entries...as u want...

Reward points if the above ans is useful...

Edited by: Rudra Prasanna Mohapatra on Jun 20, 2008 6:55 AM

Read only

0 Likes
697

hi,

try to use clear statement after ur first modify statement.