Skip to Content
0
Former Member
Jan 17, 2012 at 03:49 PM

Help with doing SELECT sub query within the SET of an UPDATE statement

631 Views

After doing some research, it appears as if it's possible to use a SELECT subquery in the SET of an UPDATE statement. i did find some examples and here is my code, however when I click the "check" button it's saying the field (my entire select subquery) is unknown and neither in one of the specified tables or defined by a "DATA". Do I have a syntax issue or is there another reason why it's not taking this as a valid statement? Thanks for the help!

LOOP AT IT_DATA
UPDATE /BIC/AZDP_O0140
   SET /BIC/ZCOUNTER = (SELECT COUNT( DISTINCT MATERIAL )
                        FROM /BIC/AZDP_O0140
                        WHERE MATERIAL EQ IT_DATA-MATERIAL
                        GROUP BY MATERIAL).
ENDLOOP.