‎2008 Apr 04 7:07 PM
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
‎2008 Apr 04 7:10 PM
Whether COMMIT WORK is available after UPDATE zprodorder.?
SELECT SINGLE * FROM zprodorder.
zprodorder-aufnr = wa_afko-aufnr.
UPDATE zprodorder.
Commit work.
a®
‎2008 Apr 04 7:17 PM
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
‎2008 Apr 04 7:24 PM
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®
‎2008 Apr 04 7:32 PM
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
‎2008 Apr 04 7:17 PM
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.
‎2008 Apr 04 9:34 PM
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.