Application Development 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: 

SAP Query with Date Range

0 Kudos

Hi! I am new to the query generator. How do I create a summary of all issue for production rows (IGE1) with posting date range? I tried using the query wizard, but I cannot seem to add the filter for posting date range. Thanks.

  • SAP Managed Tags:
1 ACCEPTED SOLUTION

mgregur
Active Contributor
0 Kudos

Hi,

the reason you cannot find the filter is because the date itself is saved in the header table (OIGE). You need to join those two tables:

SELECT *
FROM IGE1 T0
INNER JOIN OIGE T1 ON T0."DocEntry" = T1."DocEntry"
WHERE T1."DocDate" > [%0] AND  T1."DocDate" <= [%1]

BR,

Matija

  • SAP Managed Tags:
6 REPLIES 6

former_member30
Community Manager
Community Manager
0 Kudos

Hi and welcome to the SAP Community!

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful) and share screenshots of what you've seen/done. The more details you provide, the more likely it is that members will be able to assist you.

Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Cheers,

Julia SAP Community Moderator

  • SAP Managed Tags:

mgregur
Active Contributor
0 Kudos

Hi,

the reason you cannot find the filter is because the date itself is saved in the header table (OIGE). You need to join those two tables:

SELECT *
FROM IGE1 T0
INNER JOIN OIGE T1 ON T0."DocEntry" = T1."DocEntry"
WHERE T1."DocDate" > [%0] AND  T1."DocDate" <= [%1]

BR,

Matija

  • SAP Managed Tags:

0 Kudos

Hi Matija,

Thank you! It works. 🙂 Can you also help me figure out how I can add the header details of OIGE, specifically the document number?

  • SAP Managed Tags:

mgregur
Active Contributor
0 Kudos

Hi,

Document Number is OIGE."DocNum" so just add it to your select.

BR,

Matija

  • SAP Managed Tags:

0 Kudos

Thank you, Matija! It works.

  • SAP Managed Tags:

former_member932476
Discoverer
0 Kudos

I have a simple query for that.

SELECT T1.[ItemCode], T1.[Dscription], SUM(T1.[Quantity]) FROM OIGE T0 INNER JOIN IGE1 T1 ON T0.[DocEntry] = T1.[DocEntry] WHERE T0.[DocDate] BETWEEN [%0] AND [%1] GROUP BY T1.[ItemCode], T1.[Dscription], T1.[Quantity] ORDER BY T1.[ItemCode]

  • SAP Managed Tags: