‎2010 Mar 08 3:17 PM
Hi,
I have a big problem with Update instruction.
When I execute the first update is all right (sy-subrc eq 0 ), but when I execute the second update on the same table (pa2007)
not work and sy-subrc is 4.
Between first and second update I change only value of subty field.
LOOP AT tb_pa2007 INTO wa_pa2007.
IF wa_pa2007-subty EQ '03' OR wa_pa2007-subty EQ '04' OR wa_pa2007-subty EQ '05'.
MOVE '02' TO wa_anwko.
MOVE '02' to wa_subty.
UPDATE pa2007
SET ktart = wa_anwko
subty = '02'
WHERE pernr = wa_pa2007-pernr
AND begda = wa_pa2007-begda
AND endda = wa_pa2007-endda
AND subty = wa_pa2007-subty
AND sprps NE 'X'.
ENDIF.
ENDLOOP.
‎2010 Mar 08 3:24 PM
Maybe duplicate key ? Since you are updating 3 different subtypes into one, when you try the second update it might be trying to update to an already existing key record.
Anyway, and this is just a suggestion, updating PA tables in this fashion is not the most recommended, there is a FM for this which ensures that the validations are done as if you were doing these changes in PA30. FM is HR_INFOTYPE_OPERATION.
‎2010 Mar 08 3:24 PM
Maybe duplicate key ? Since you are updating 3 different subtypes into one, when you try the second update it might be trying to update to an already existing key record.
Anyway, and this is just a suggestion, updating PA tables in this fashion is not the most recommended, there is a FM for this which ensures that the validations are done as if you were doing these changes in PA30. FM is HR_INFOTYPE_OPERATION.
‎2010 Mar 08 3:33 PM