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

Update statement not working

Former Member
0 Likes
759

I have the following in some code and the update statement isn't working:

    SELECT SINGLE * FROM zprodorder.
    zprodorder-aufnr = wa_afko-aufnr.
    UPDATE zprodorder.

Regards,

Davis

6 REPLIES 6
Read only

former_member194669
Active Contributor
0 Likes
730

Whether COMMIT WORK is available after UPDATE zprodorder.?


SELECT SINGLE * FROM zprodorder.
    zprodorder-aufnr = wa_afko-aufnr.
    UPDATE zprodorder.
    Commit work.

a®

Read only

0 Likes
730

I didn't think it was needed because I have an update statement directly above it (on a z-field on AFKO) and it works every time. Could the issue be that my table is starting off as initial? The table holds one field, aufnr and it is currently initial. We are using this table to hold one single record. It is being used to have a starting point for an idoc routine.

I just tried a commit work and it doesn't seem to help. I guess I'll try a using a work area next.

Edited by: Davis on Apr 4, 2008 2:22 PM

Read only

0 Likes
730

May be a chance of table be startoff with initial.,

make the code as this way


SELECT SINGLE * FROM zprodorder.
if sy-subrc eq 0.
    zprodorder-aufnr = wa_afko-aufnr.
    UPDATE zprodorder.
else.
    zprodorder-aufnr = wa_afko-aufnr.
    INSERT zprodorder.
endif

a®

Read only

0 Likes
730

Thanks but that code doesn't work. The reason is because it comes back with sy-subrc = 0 because there is a record in the table but zprodorder-aufnr is initial.

Regards,

Davis

I may just end up doing a delete then an insert.

Edited by: Davis on Apr 4, 2008 2:33 PM

Read only

Former Member
0 Likes
730

hi ,

check this simple example..to under stand the update command

PARAMETERS: p_carrid TYPE sflight-carrid,

percent TYPE p LENGTH 1 DECIMALS 0.

DATA sflight_tab TYPE TABLE OF sflight.

FIELD-SYMBOLS <sflight> TYPE sflight.

SELECT *

FROM sflight

INTO TABLE sflight_tab

WHERE carrid = p_carrid AND

fldate = sy-datum.

IF sy-subrc = 0.

LOOP AT sflight_tab ASSIGNING <sflight>.

<sflight>-price =

<sflight>-price * ( 1 - percent / 100 ).

ENDLOOP.

ENDIF.

UPDATE sflight FROM TABLE sflight_tab.

regards,

venkat.

Read only

Former Member
0 Likes
730

I ended up doing a delete then an insert. I assume I couldn't modify because the field zprodorder-aufnr was in the initial state.