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

problm in selecting max value

Former Member
0 Likes
419

hi

i have written below code

wn i execute im getting error as 'You cannot use an internal table as a work area.'

how to solve this?

SELECT  a~aufnr
          a~plnbez
          a~gstrp
          a~gltrp
          a~gstri
          a~gltri
          a~gstrs
          a~gltrs
*         a~getri
          a~FTRMI
          b~ktext
          b~objnr
          c~charg
          c~dwerk
     INTO TABLE it_final
     FROM afko AS a
     INNER JOIN aufk AS b ON a~aufnr = b~aufnr
     INNER JOIN afpo AS c ON a~aufnr = c~aufnr
     WHERE  (cond_syntax)
     AND c~dwerk = p_werk
     AND a~fevor IN s_fevor
     AND a~dispo IN s_dispo .

*get actual Finish Date
IF NOT IT_FINAL[] IS INITIAL.
SELECT MAX( BUDAT ) aufnr
     FROM AFRU
    INTO IT_AFRU
*    FOR ALL ENTRIES IN IT_FINAL
    WHERE AUFNR = IT_FINAL-AUFNR
    AND WERKS = P_WERKS.
ENDSELECT.
ENDIF.

Regard

Smitha

2 REPLIES 2
Read only

Former Member
0 Likes
360

HI,

SELECT  a~aufnr
          a~plnbez
          a~gstrp
          a~gltrp
          a~gstri
          a~gltri
          a~gstrs
          a~gltrs
*         a~getri
          a~FTRMI
          b~ktext
          b~objnr
          c~charg
          c~dwerk
     INTO TABLE it_final
     FROM afko AS a
     INNER JOIN aufk AS b ON a~aufnr = b~aufnr
     INNER JOIN afpo AS c ON a~aufnr = c~aufnr
     WHERE  (cond_syntax)
     AND c~dwerk = p_werk
     AND a~fevor IN s_fevor
     AND a~dispo IN s_dispo .
 
*get actual Finish Date
IF NOT IT_FINAL[] IS INITIAL.
SELECT MAX( BUDAT ) aufnr
     FROM AFRU
    INTO TABLE IT_AFRU                    " Add Table declaration
*    FOR ALL ENTRIES IN IT_FINAL
    WHERE AUFNR = IT_FINAL-AUFNR
    AND WERKS = P_WERKS.
* ENDSELECT.                                   "  Comment Endselect
ENDIF.

Read only

Former Member
0 Likes
360

Hi Smitha,

For all the tables with header line a simple TABLE prefix should be added thats the solution to your problem,

add TABLE infront of internal table in the select query.

For further details

http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb36a1358411d1829f0000e829fbfe/content.htm

Thanks

Ram