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

I need use conditions in the select fields of a query.

Hello,

Is possible, that I can have conditions in the select fields of a query? In a invoice when the type is cancellation I want to put *-1 to price and if is other type the price is normally.

If VBRK.FKART = 'S1' THEN KWERT*-1 else KWERT .

Thank you very much.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Dec 19, 2008 at 08:06 AM

    you can do two things:

    1. select the data into internal table and loop through the internal table and do the necessary changes

    SELECT fkart kwert
    FROM vbrk
    INTO TABLE itab
    WHERE ...
    
    LOOP AT itab.
    IF itab-fkart EQ 'S1'.
    itab-kwert = itab-kwert * -1 .
    MODIFY itab.
    ENDIF.
    ENDLOOP.

    2. use select-endselect and change the data acc. to your needs inbetween and append the internal table.

    SELECT fkart kwert
    FROM vbrk
    INTO wa
    WHERE ...
    IF wa-fkart EQ 'S1'.
    wa-kwert = wa-kwert * -1 .
    ENDIF.
    APPEND wa TO itab.
    ENDSELECT.

    (The first approach is probably faster.)

    Add a comment
    10|10000 characters needed characters exceeded

    • hi,

      What ever logic you write there it will directly update the program.

      Check whether the logic you are writing is correct or not.

      if suppose ZHRLEAVE is your query and you wrote some logic in infoset

      of this query then it will be updated in this below program.check in se38.

      AQZZZHRLEAVE====ZHRLEAVE======

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 08:09 AM

    HI,

    Select the data in to the table ..

    Loop at itab.

    if itab-FKART EQ 'S1'.

    itab-kwert = itab-kwert * -1.

    modify itab.

    endif.

    endloop.

    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.