Skip to Content
avatar image
Former Member

How to change code in SAP Query

Hi Experts !!

In SAP QUERY I am getting the PO with all delivey dates & deliveried Qty but I have to select only single PO with latest delivery date & qty. If there r more than one record for latest delivery date than deliveried QTY must be sum of all QTY (for the latest delivery date). for example :

this is coming

Po delivery date qty

10001 30.06.2009 4

10001 30.06.2009 5

10001 01.05.2009 4

we want

Po delivery date qty

10001 30.06.2009 9

Thanks in advance.

Thanks & Regards

Navneet Singhal

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 05, 2009 at 06:42 AM

    Open the transaction SQ02, give the infoset name and click on change button.

    click on the EXTRAS button, and under the CODE tab select the event and write your logic in the down.

    Thanks,

    Srinivas

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      >

      > There is an internal table %G00 in query generated program (AQCSZPCWMM======Z_PCW_ORDER_V2) when I use this table in Code section (END-OF-SELECTION ) system thro msg %G00 is not defined . if I define this table in DATA section than run the query , It gives the DUMP with error %G00 is already decleared.

      >

      > How can I use %G00 internal table in my code section.

      I have the same problem as the OP. I need to get rid of the duplicates and have all sumarized in just one row. I was thinking about this same solution, but when I add code to the END-OF-SELECTION event, this doesn't appears anywhere (but if I add code to any calculated field, yes).

      And the problem of the quoted message. I tried using field-symbols but I have errors saying that it's nos a valid table, etc...

      Any ideas???

      Thanks!!!

  • avatar image
    Former Member
    Jun 05, 2009 at 06:37 AM

    Hi Navneeth,

    Selection depends on your where clause,

    so please can you post your query to help u out,,

    Here is a sample method,

    DATA : P_WADAT TYPE LIKP-WADAT.
    
    SELECT MAX(WADAT) INTO P_WADAT FROM LIKP.
    
    SELECT VBELN WADAT LFIMG INTO (VBELN, DATE, QTY) WHERE WADAT EQ P_WADAT AND VBELN EQ VBELN.
    
    IT_FINAL-QTY = IT_FINAL-QTY + QTY .
    IT_FINAL-VBELN = VBELN.
    IT_FINAL-DATE = DATE.
    
    CLEAR : VBELN, DATE, QTY.
    ENDSELECT.
    

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 05, 2009 at 09:11 AM

    Hi,

    The folowing code will help you.

    TABLES: EKPO.

    DATA : P_WADAT TYPE EKPO-AEDAT ,

    P_EBELN TYPE EKPO-EBELN VALUE '3000000004',

    X LIKE EKPO-AEDAT,

    Y LIKE EKPO-EBELN,

    Z LIKE EKPO-MENGE,

    M LIKE EKPO-AEDAT.

    SELECT MAX( AEDAT ) INTO EKPO-AEDAT FROM EKPO WHERE EBELN = P_EBELN.

    M = EKPO-AEDAT.

    SELECT SUM( MENGE ) EBELN AEDAT INTO (Z, Y, X) FROM EKPO WHERE AEDAT EQ M AND EBELN EQ P_EBELN GROUP BY MENGE EBELN AEDAT.

    ENDSELECT.

    Z gives the sum of quantity.

    Aswarth

    Add comment
    10|10000 characters needed characters exceeded