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

updating database table

Former Member
0 Likes
1,155

hi,

I have done an append structure in the database EBAN

and i am doing an update in the table EBAN

UPDATE EBAN SET ZFLAG = 'X'

WHERE using all the primary condition

The row that i am trying to update exist in the table Eban. The problem that i am having is that sometimes the update is done sometimes not.

I check in debug for the data that is done updating properly and in debug the update is done. But not when executing the program without debug. I've tried COMMIT statement after UPDATE but it didn't work. how can i solve this?

11 REPLIES 11
Read only

Former Member
0 Likes
1,114

Hi Deniz,

try like this...

SELECT *

FROM EBAN

INTO WA_EBAN

WHERE <primary conditions which you are giving in UPDATE>.

if sy-subrc eq 0.

wa_eban-zfalg = 'X'.

update eban from wa_eban.

endif.

it should work.

-- Jyothi

Read only

0 Likes
1,114

hi Jyothi,

thanks for the quick answer. i've tried your suggestion but it didn't work.

Read only

0 Likes
1,114

Hi

My intention there is whether the record is existing in the system or not. What is the sy-subrc value. Did you check?

if that is zero then it must work.

Ensure that it is zero and then remove the select. It is just for checking.

- Jyothi

Read only

0 Likes
1,114

>

> the select. It is just for checking.

its more then superfluous

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,114

check sy-subrc after your update. its not necessary to do a select before update as suggested before.

Read only

Former Member
0 Likes
1,114

after commit. jus try using the WAIT statement and check.

Read only

Former Member
0 Likes
1,114

if you added field in standard strcture in EABN , for this you can find any exit you have to appned the strcture in exit level that will update the standard table automatically...

Read only

Former Member
0 Likes
1,114

Hi,

Lock the record before you update and unlock it after the update is done.

Use the lock object EMEBANE


CALL FUNCTION 'ENQUEUE_EMEBANE'  " for locking, pass the necessary parameters

IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

UPDATE EBAN SET ZFLAG = 'X'
WHERE using all the primary condition.

if sy-subrc = 0.
 " Update successfull !
else.
 " Update unsuccessfull !
endif.

call function DEQUEUE_EMEBANE      " For unlocking. Pass the necessary parameters 

IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

regards,

Advait

Read only

0 Likes
1,114

hi Advait,

i've tried your suggestion but it didn't work. like before when i check in debug mode the field is updated but when i execute the program without debug it doesn't work (i got error message: "Object requested is currently locked by user "). i want to know the differance between running program with debug mode and without debug mode.

Read only

0 Likes
1,114

Ideally it should work.

Have you written this code in a user exit or it is a stand alone program ?

regards,

Advait

Edited by: Advait Gode on Jan 22, 2009 4:15 PM

Read only

0 Likes
1,114

I've written code in a function module i wrote.