Skip to Content
author's profile photo Former Member
Former Member

Sorting

Hello Gurus !!!

I would like to SORT my list with the field

WA_ITAB-VVVPR (PRICE).

WHEN i USE

Sort wa_itab-vvvpr the error syntax error shows <b>'WA_ITAB is not an Internal table'</b>

well its the Work area...

and when I mention Sort itab by VPRSV <b>it shows itab has no header line..</b> I am working with 4.7c and We must use work area not header line while defining ITAB:

PLS HELP...

DATA: i_mbew TYPE TABLE OF mbew,

wa_mbew TYPE mbew.

SELECT * FROM mbew INTO TABLE i_mbew where

BWKEY Between '4010''4020' and '4030' .

LOOP AT itab INTO wa_itab.

READ TABLE i_mbew INTO wa_mbew WITH KEY

matnr = wa_itab-artnr.

IF wa_mbew-vprsv = 'V'.

wa_itab-vvvpr = wa_mbew-verpr.

ELSE.

wa_itab-vvvpr = wa_mbew-stprs.

ENDIF.

MODIFY itab FROM wa_itab.

WRITE:/4 wa_itab-artnr,

15 wa_itab-vvvpr,

41 wa_mbew-vprsv,

53 wa_mbew-bwkey,

71 wa_mbew-peinh.

ENDLOOP.

Message was edited by: Preetham

Add a comment
10|10000 characters needed characters exceeded

Related questions

7 Answers

  • Posted on Oct 17, 2005 at 11:47 AM

    Hi,

    You should specify the type of table in the declaration.You cannot sort the workarea wa_itab,since it's already having one record.You should only sort internal table.Check the below sample code and reward points by clicking the star on the left of reply,if it helps.

    DATA: i_mbew TYPE <b>standard</b> TABLE OF mbew,

    wa_mbew TYPE mbew.

    SELECT * FROM mbew INTO TABLE i_mbew where

    BWKEY Between '4010''4020' and '4030' .

    <b>sort itab by VPRSV.</b>

    LOOP AT itab INTO wa_itab.

    READ TABLE i_mbew INTO wa_mbew WITH KEY

    <b>matnr = wa_itab-matnr</b>.

    IF wa_mbew-vprsv = 'V'.

    wa_itab-vvvpr = wa_mbew-verpr.

    ELSE.

    wa_itab-vvvpr = wa_mbew-stprs.

    ENDIF.

    MODIFY itab FROM wa_itab.

    WRITE:/4 wa_itab-artnr,

    15 wa_itab-vvvpr,

    41 wa_mbew-vprsv,

    53 wa_mbew-bwkey,

    71 wa_mbew-peinh.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      Wa_itab will have only one record inside the loop.Each time in the loop,it will have the previous record overwritten.

      So you cannot sort a single record.

      Normally we will sort the table records for the read operation.

      Wa_itab is not an internal table.It is a workarea.

      Work area will have only one record at a time.

      So we can sort only internal table which is having more than one record.

      Hope this answers your question.If so,kindly reward points.

      SELECT * FROM mbew INTO TABLE i_mbew WHERE

      bwkey BETWEEN '4010''4020' and '4030' .

      <b>

      sort itab by vvvpr.</b>

      LOOP AT itab INTO wa_itab.

      READ TABLE i_mbew INTO wa_mbew WITH KEY

      matnr = wa_itab-artnr.

      IF wa_mbew-vprsv = 'V'.

      wa_itab-vvvpr = wa_mbew-verpr.

      ELSE.

      wa_itab-vvvpr = wa_mbew-stprs.

      ENDIF.

      MODIFY itab FROM wa_itab.

      WRITE:/4 wa_itab-artnr,

      15 wa_itab-vvvpr,

      41 wa_mbew-vprsv,

      53 wa_mbew-bwkey,

      71 wa_mbew-peinh.

      ENDLOOP.

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2005 at 10:03 AM

    Hi,

    check this it may help you...

    data : begin of wa.
            include structure mbew.
    data   end of wa.
    
    data : itab like table of wa with header line.
    
    SELECT * FROM mbew INTO corresponding field of wa where
    BWKEY Between '4010''4020' and '4030' .
    
    loop at itab into wa.
    
    endloop.
    
    
    

    hope this helps you...

    regards,

    venu.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2005 at 10:07 AM

    Hi

    I'm using working on 4.7C, but your statament works fine:

    DATA: i_mbew TYPE TABLE OF mbew.

    Sort i_mbew by VPRSV.

    Only error is occured was there isn't VRPSV, but VPRSV.

    Max

    Message was edited by: max bianchi

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2005 at 10:08 AM

    Hi,

    Use as

    DATA: i_mbew TYPE <b>STANDARD</b> TABLE OF mbew,
                wa_mbew TYPE mbew.

    Hope this helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2005 at 10:08 AM

    Preetam,

    it seems you defined wa as work_area not inernal table, thats why yu get the error.

    do the following to sort by vvvpr.

    sort itab by vvvpr.

    you can use addition ASCENDING or decending DESCENDING also.

    sort itab by vvvpr ASCENDING. or

    sort itab by vvvpr DESCENDING.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2005 at 10:18 AM

    hi,

    just add

    sort i_mbew by vvvpr above the loop

    cheers,

    sasi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2005 at 11:10 AM

    Hello Preetham,

    There's no version called 4.7C. We only have 4.6C. Furthermore, starting from SAP release 4.7, it is better to specify the ABAP / Basis release that you're working on, like 620, 640 etc.,

    Your code snippet doesn't have any SORT statement. and nor do you have a declaration for "itab" and "wa_itab". So it's difficult to say the reason for the syntax error.

    Regards,

    Anand Mandalika.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.