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 sql instruction problem

Former Member
0 Likes
460

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.

1 ACCEPTED SOLUTION
Read only

PedroGuarita
Active Contributor
0 Likes
426

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.

2 REPLIES 2
Read only

PedroGuarita
Active Contributor
0 Likes
427

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.

Read only

0 Likes
426

Thank you very much!!

The problem is the SEQNR number.