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

Problem with Update Statement

Former Member
0 Likes
967

Hi Experts,

I am updating a custome table by using following statement.

*----


Update Ztable

gt_trgt-werks = it_werks-werks.

gt_trgt-mmyy = sy-datum(6).

gt_trgt-trgt = target.

PERFORM check_exits1 USING s_flag .

IF s_flag EQ 'X'.

UPDATE zpv_target FROM gt_trgt.

ELSE.

INSERT zpv_target FROM gt_trgt.

ENDIF.

ENDIF.

*--End of UPDATE ZTABLE

Here PERFORM check_exists check values exist or not. I am facing a problem in Update statement as it is not updating the custome table. While debugging in foun that i have new values in gt_targt but zpv_target is having the same values as it was. Means values are not updated in custome table.

It seems to me tht the problem is with custome table, as it is inserting values properly but not updating it.

Settings for the table is as follows:

-Fields

FIELD DATAELEMENT

Aufnr Aufnr

Cut char1

Probl char40

-Data Class APPL1

-size 5

-Delievery Class C

-Display/Maintainance Allowed.

-Buffering not allowed

-Log data changes.

-Maintainance generator is also created with authorization to all.

& one screen.

Please tell me Do i need to change anything in table or there in the Update statement?

Regards,

Nik

9 REPLIES 9
Read only

Former Member
0 Likes
908

hi

add COMMIT WORK. statement after update..

u can also use COMMIT WORK AND WAIT.

Read only

0 Likes
908

I tried commit work too.

The problem is on Update statement as while debugging on update line i found the values are not changed. First it should be change then only we can say for commit.

Regards,

Nik

Read only

Former Member
0 Likes
908

hi,

One thing am not understanding

U mentined the fields in ZPV_TARGET custom table are

Aufnr

Cut

Probl

But u inserting or updating with the following fields values.

gt_trgt-werks

gt_trgt-mmyy

gt_trgt-trgt

how order number and plant data will match.

cut is 1 length character field but u r inserting sy-datum value.

how they will match.

Read only

0 Likes
908

Sorry, ZPV_TARGET has same fields which i am updating,

Werks,

mmyy,

trgt.

Regards,

Nik

Read only

0 Likes
908

hi,

after update statment use commit statement.

don't try to update the same data which already there.

just change any field content and then try.

becoz even we try to update the same data we don't know whether data is updated or not.

in debugging check the sy-subrc value if it is equal to 0 means the data will definitly update in the database.

i will helpful for u.

Read only

Former Member
0 Likes
908

u can also use MODIFY statement instead of update .

check return code.

if sy-subrc = 0

commit work.

else write :'sy-subrc'.

endif.

Edited by: Sona on Mar 8, 2008 4:01 AM

Read only

0 Likes
908

HI Sona,

I tried Modify too, even that not worked

If you need i can send u the whole code.

regards,

Nik

Read only

Former Member
0 Likes
908

hey,

may be the value in IF condition is not = X thats why its not updated

thats why insert works..( u hv mentioned)

also check if the unique key value u have in internal has same value in ztable also.

Read only

Former Member
0 Likes
908

solved