‎2008 Mar 08 1:28 AM
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
‎2008 Mar 08 2:43 AM
hi
add COMMIT WORK. statement after update..
u can also use COMMIT WORK AND WAIT.
‎2008 Mar 08 3:13 AM
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
‎2008 Mar 08 2:51 AM
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.
‎2008 Mar 08 3:10 AM
Sorry, ZPV_TARGET has same fields which i am updating,
Werks,
mmyy,
trgt.
Regards,
Nik
‎2008 Mar 08 3:16 AM
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.
‎2008 Mar 08 3:00 AM
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
‎2008 Mar 08 3:15 AM
HI Sona,
I tried Modify too, even that not worked
If you need i can send u the whole code.
regards,
Nik
‎2008 Mar 08 3:29 AM
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.
‎2009 Apr 26 1:26 PM