SAP-Forum.ORG
   
This web site isn't affiliated with, sponsored by, or approved by SAP AG. Is only a SAP users community.

Go Back   SAP-Forum.ORG > SAP Forums > SAP ABAP

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update termination error while calling FM in Update task ERP SAP ABAP 2 12-29-2011 10:53 PM
Where and Why do we use "for all entries" in select statement nblogs News in SAP blogs 0 12-29-2011 06:52 PM
not getting actual value in loop on select statement SAPMM SAP ABAP 2 03-26-2011 11:19 PM
Select statement not working on table ADRC? Mirna SAP ABAP 2 02-16-2011 11:53 PM
How to transport set values only (and not the whole set)? Zoom SAP ABAP 2 08-30-2010 04:57 PM

Aprenda SAP!
Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2012, 08:34 PM
Zoom Zoom is offline
Senior Member
 
Join Date: May 2010
Location: Pennsylvania
Posts: 322
Default Help with doing SELECT sub query within the SET of an UPDATE statement

Hello experts,

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:

Code:
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.
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!

Best regards,
Zoom
Reply With Quote
Sponsors
  #2  
Old 01-17-2012, 08:35 PM
Portal Portal is offline
Senior Member
 
Join Date: May 2010
Location: Miami
Posts: 791
Default Re: Help with doing SELECT sub query within the SET of an UPDATE statement

Hi,

Do you still get the error if you remove the GROUP BY?

Regards,
Portal
Reply With Quote
  #3  
Old 01-17-2012, 08:41 PM
Golfi Golfi is offline
Senior Member
 
Join Date: May 2010
Location: Delaware
Posts: 824
Default Re: Help with doing SELECT sub query within the SET of an UPDATE statement

Hi Zoom,

I cannot find supporting documentation that subqueries are allowed in this spot. You can use a dynamic "(expr_syntax)", but this would contain syntax of the fields to be updated.
Also, is it correct that your UPDATE statement does not have a WHERE-condition, as you are updating all rows this way?

Regards,
Golfi
Reply With Quote
Entre a los Links relacionados
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 09:10 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Forum Design By inferno