Query for PO and GPRO

Hi guys. I am relatively new to SAP Business with less than one month experience handling this software. I was given a task by my superior last week, whereby I was asked to create a query that will enable both PO and GRPO "combine" together, thus enabling my colleagues to skip the tradition manual way of doing things.
I have tried a first code which I manage to combine both PO and GRPO. However, there is this problem whereby should I link it via the coding I have done, both specific PO and GRPO must exist on the database for it to be listed out on the query (Should PO is present but GRPO is not, then it do not appear on the query). Below is the code that I have done:
SELECT T0.[DocNum] as 'PO No.', T0.[DocDate], T0.[DocStatus], T0.[CardName] as 'Supplier', T1.[ItemCode], T1.[Quantity], T1.[Price], T1.[LineTotal] as 'Total Amount', T1.[U_Ship_ETA] as ' Expected Arrival Date',T2.[WhsCode], T2.[OrderedQty], T2.[DelivrdQty], T3.[DocNum] as 'GRPO No.' FROM OPOR T0  INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PDN1 T2 ON T1.DocEntry = T2.BaseEntry AND T1.LineNum = T2.BaseLine INNER JOIN OPDN T3 ON  T2.DocEntry = T3.DocEntry WHERE T1.[U_Ship_ETA] >= [%0] AND T2.[WhsCode] = 'PE-PG'
The entire purpose of this assignment is to create a query that will facilitate the work of my colleague in HQ and warehouse. This specific person in HQ should be able to key in the PO then followed by another person on warehouse aware of the supply arrival date (expected) and to fill up the GRPO. The coding above, require both PO and GRPO to be present at the same time, which resulting in my colleague at warehouse unaware of the expected arrival date from PO.
Edited by: AlexAkane on Oct 27, 2009 10:17 AM

Second question:
Due to this, I have recreated two different query. One query on PO and another on GRPO. Below are the coding for both,
GRPO Tracking
SELECT T0.[DocNum] as 'GRPO', T0.[DocStatus], T0.[DocDate], T0.[CardName] as 'Supplier',T1.[ItemCode], T1.[OrderedQty] as 'Ordered Quantity', T1.[DelivrdQty] as 'Delivered Quantity' , T1.[OpenQty] 'Remaining Open Quantity',T1.[WhsCode], T1.[U_Job_No] FROM OPDN T0  INNER JOIN PDN1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[WhsCode] =[%0] ORDER BY T0.[CardName]
PO Tracking
SELECT T0.[DocNum] as 'PO Number', T0.[DocDate], T0.[DocStatus], T0.[CardName] as 'Supplier', T1.[ItemCode], T1.[Quantity] as 'Ordered  Quantity', T1.[Price] as 'Price Per Unit', T1.[LineTotal] as 'Total Amount' , T1.[WhsCode], T1.[U_Ship_ETA] as 'Expected Arrival Date' FROM OPOR T0  INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[WhsCode] =[%0]
I would like to know, is it possible to join into a single table?  Example- A and B . Join become AB.
Sorry for this long post. I just don't know how to put in simpler words :). And I would appreciate any help or advice.
Thank You !
Regards,
Alex
Edited by: AlexAkane on Oct 27, 2009 10:16 AM

Similar Messages

  • Query for Opening And  Closing Stock

    Hi Experts...
    I need a report for Opening and Closing stocks and Goods Receipt and Goods Issue for Raw Materials and Finished Goods and Consumbles ..instead of going for different reports for each we need a combined report which can display for all Raw Materials, Finished Goods and Consumbles and we need it for a specific date range Material type(Raw MAterials,Finished Goods, Consumbales)
    and below is the format i needed.
                                                                           RAW MATERIALS /FINISHED GOODS/CONSUMBALES
                            Opening Stock                      Closing Stock         Goods Receipt                  Goods Issue
                             Qty   Value                             Qty   Value                     Qty   Value                      Qty   Value
    Item Name
    Regards,
    Vamsi.

    Hi Guys.
    I need an Inventory stock report with Item name, Opening Stock,Goods issue Quantity,Goods Received ,Item Price,Location ,(Closing Stock)Total Value.
    We need the input by Date Range and Item Group and Location(if Possible) Below is the Code i used to run the report.
    Pls Update the Query...
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    Declare @Group nvarchar(10)
    Declare @Whse nvarchar(10)
    Set @FromDate = (Select min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]')
    Set @ToDate = (Select max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]')
    Set @Group = (Select Max(s2.ItmsGrpCod) from dbo.OITB S2 Where S2.ItmsGrpNam = '[%2]')
    Set @Whse = (Select Max(s3.Warehouse) from dbo.OINM S3 Where S3.Warehouse = '[%3]')
    Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription), sum(a.[Opening Balance]) as [Opening Balance], sum(a.[IN]) as [IN], sum(a.OUT) as OUT,max(a.Price) as 'Price', ((sum(a.[Opening Balance]) + sum(a.[IN])) - Sum(a.OUT)) as Closing from dbo.OITM I1
    Left JOIN (Select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.Price, (sum(N1.inqty)-sum(n1.outqty)) as [Opening Balance], 0 as [IN], 0 as OUT
    From dbo.OINM N1
    Where N1.DocDate < @FromDate and N1.Warehouse = @Whse
    Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.Price
    Union All
    select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.price, 0 as [Opening Balance], sum(N1.inqty) as [IN], 0 as OUT From dbo.OINM N1 Where N1.DocDate >= @FromDate and N1.DocDate <= @ToDate and N1.Inqty >0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.price
    Union All
    select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.price, 0 as [Opening Balance], 0 as [IN], sum(N1.outqty) as OUT From dbo.OINM N1 Where N1.DocDate >= @FromDate and N1.DocDate <=@ToDate and N1.OutQty > 0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.price) a ON a.ItemCode=I1.ItemCode
    where  I1.ItmsGrpCod = @Group
    Group By a.Itemcode
    Order By a.Itemcode
    Regards,
    Vamsi.

  • How to model query for -- existing and unchanged values

    Hello BW Experts,
    I have material and material group as navigational time-dependent attributes. I have a requirement to show the existing and unchanged values for the material and material group in the time frame 2003 to 2006 . how to create a query for this.
    Suggestions appreciated.
    Thanks,
    BWer

    HI ,
    I think u need to add two more date fields as the attributes  to the master data and then use them and give restriction in the query with the Keydate to see data which has unchanged from One range to another . As key Date applies to only the system defined to and from dates present in the Master Data .
    In query give Keydate as 31.dec.2006 and then give restriction for user defined dates sa follows :
    User From : 01.01.1000 - 31.12.2002.
    User To : 01.01.2007 -- 31.12.9999 .
    Regards,
    Vijay.
    Message was edited by: vijay Kumar
    Message was edited by: vijay Kumar
    Message was edited by: vijay Kumar

  • Query for invoice and distribution detail

    hi 2 all
    anybody have the query for getting invoice with distribution detail in oracle payable r12.
    thanks
    zulqarnain

    select ass.SEGMENT1 vendor_number,
    ass.VENDOR_NAME,
    assa.VENDOR_SITE_CODE VENDOR_SITE,
    aia.INVOICE_NUM,
    aia.INVOICE_DATE,
    aia.INVOICE_AMOUNT,
    aia.INVOICE_TYPE_LOOKUP_CODE,
    gcc.CONCATENATED_SEGMENTS distribution_account ,
    gcc1.CONCATENATED_SEGMENTS liability_account,
    to_char(aia.GL_DATE) GL_DATE,
    AP_INVOICES_PKG.GET_APPROVAL_STATUS( AIa.INVOICE_ID,
    AIa.INVOICE_AMOUNT, AIa.PAYMENT_STATUS_FLAG,
    AIa.INVOICE_TYPE_LOOKUP_CODE) APPROVAL_STATUS_LOOKUP_CODE
    from ap_invoices_all aia,
    ap_suppliers ass,
    ap_supplier_sites_all assa,
    ap_invoice_distributions_all aid,
    gl_code_combinations_kfv gcc,
    gl_code_combinations_kfv gcc1
    where aia.VENDOR_ID = ass.VENDOR_ID
    and assa.VENDOR_SITE_ID = aia.VENDOR_SITE_ID
    and ass.VENDOR_ID = assa.VENDOR_ID
    and aid.INVOICE_ID = aia.INVOICE_ID
    and aid.DIST_CODE_COMBINATION_ID = gcc.CODE_COMBINATION_ID
    and assa.ACCTS_PAY_CODE_COMBINATION_ID = gcc1.CODE_COMBINATION_ID
    --and aia.INVOICE_ID =  81000
    and aia.GL_DATE between '01-JAN-12' and '31-MAR-12'
    order by aia.GL_DATE
    Thanks,
    Atul

  • Query for Day and Month Only

    I have a table with a date field that I need to query by day
    and month only. Basically, if I search for "04/15", the query would
    return records whose date includes: 04/15/2006, 04/15/2007,
    04/15/2008, etc. How can I do that on SQL Server?
    Thx!

    ColdFusion and SQL Server have functions called DatePart.
    ColdFusion
    SQL
    Server

  • Query for releasing and closing Production order ststus in bulk

    Hi
    Releasing planed to released
    1. i want to release all those production orders entered in system which are in planned status.I want to apply one query for that which should change the status of Prod orders to release in systems automatically by applying this query.Please give me that suitable query and how to use it for proper result.
    closing released to planned
    2. Same like above i want to close all those Production orders whose receipt quantity is equal to planned quantity. i.e i want one query which should change the status of production order from release to closed on condition that receipt quantity is equal to the planned quantity.Please give me that suitable query and how to use it for proper result.
    Thanks

    For point 1 and 2:  It should not be tried and using a Query does not comply with SAP Support policy.  Doing so would lead you to lose SAP Support.

  • Query for  customer and its all the underlying sites in AR

    Hi Expert,
      Please help me to build a query for a customer and its all the underlying sites .
    Thanks

    Please check this thread:
    Running Total in QLD
    Thanks,
    Gordon

  • Re:Query for Item and its first child Itemcode from BOM...!!!

    Dear SAP Members,
    I need a query that contains
    ItemCode,ItemDescription from oitm table and its first child item code,Item Description,Quantity,currency and price from itt1 table.I have taken all the datas but there is no ItemDescription from itt1 table.How to join all these datas.
    Please Give suggestions or query for this issue.
    With Regards,
    Revathy

    Hi try this
    Declare @BOMDetails table(TreeType Nvarchar(MAX),PItem NVARCHAR(Max),PName NVARCHAR(MAX),CItem  NVARCHAR(Max),CName NVARCHAR(MAX),Comment NVARCHAR(MAX),onHand Numeric(18,0),[Committed] Numeric(18,0),FreeStock Numeric(18,0),[Status] NVARCHAR(MAX),Quantity numeric(18,0),Price numeric(18,0),Warehouse nvarchar(MAX),Currency nvarchar(MAX))
    INSERT Into @BOMDetails
    SELECT T1.TreeType ,T0.Father AS [Parent Code], T2.ItemName AS [Parent Description], T0.Code AS [Child Code],
    T1.ItemName AS [Child Description], T0.Comment, cast((T1.OnHand ) as Numeric(18,0)) as [Un-Committed Stock],
    cast(T1.IsCommited as Numeric(18,0)) AS [Committed Stock], cast((T1.OnHand - T1.IsCommited)as Numeric(18,0)) AS [Free Stock], T2.FrgnName AS [Status],T0.Quantity,T0.Price ,T0.Warehouse,T0.Currency
    FROM ITT1 T0 INNER JOIN OITM T1 ON T0.Code = T1.ItemCode
                 INNER JOIN OITM T2 ON T0.Father = T2.ItemCode
    WHERE T0.ChildNum=1
    Union All
    SELECT ' ',T0.Father as [Parent Code], T2.ItemName AS [Parent Description], '', '', '', 0,0,0 , '',0,0,'','' FROM ITT1 T0 INNER JOIN OITM T1
    ON T0.Code = T1.ItemCode INNER JOIN OITM T2 ON T0.Father = T2.ItemCode
    Group By T0.Father,T2.ItemName
    ORDER BY T0.Father, T0.Code
    update @BOMDetails set PItem='' ,PName='' where TreeType='N' or TreeType='P'
    Select PItem as[Parent Code] ,PName as [Parent Description],CItem as [Child Code],CName as [Child Description],Comment,Quantity,Price,Warehouse,Currency   from @BOMDetails
    thanks,
    Neetu

  • Query for 0FI_AP_4 and 0FI_AR_4

    Hi,
    I am currently working with the 0FI_AP_4 and 0FI_AR_4 datamodel and would need a sample of a query for these datamodels. I am especially interested in the logic of the query, I already have built the datamodel with DSOs and cubes.
    Are their buildup somewhere available, I unfortunately couldn't find that on help.sap.com.
    Thanks!

    hi,
    Check the below links
    For AR
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/e3/ab7937b566ab49e10000009b38f842/content.htm
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/40/94af39a3488979e10000000a11402f/content.htm
    for AP
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/9e/b77237902ae147e10000009b38f842/content.htm
    regards,
    Arvind,

  • Select query for KONV and VBAK table

    hy Experts.
    Please Help me For this Query, i got error on it.
    I wnt to take KONV-KBETR (RATE FIELD) for particular  SO number. and i used following query but it gives error i cant relate VBAK & KONV table.
    Please do needful
    SELECT KBETR KNUMV FROM KONV INTO (ITAB-KBETR, ITAB-KNUMV) WHERE VBAK-KNUMV = KONV-KNUMV AND VBAK-VBELN IN VBELN.
    Thnks
    Bhavesh Panchal.

    Hello Thnks For Reply,
    but still i cant take solution. i am making a Sales order Rports. i got all field but i cant fetch filed for RATE and Pending Order Value.
    Please check following  Code. if need to change u can.
    Thnks
    Bhavesh Panchal.
    REPORT  ZTESTCODE.
    TYPE-POOLS:slis.
    TABLES: VBEP , VBAP ,  VBPA , VBKD , VBAK , LIKP , LIPS , VBUP , VBBE, KONV, KNA1.
    DATA :BEGIN OF itab  OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    EDATU LIKE VBEP-EDATU,
    KNUMV LIKE VBAK-KNUMV,
    WMENG LIKE VBEP-WMENG,
    BMENG LIKE VBEP-BMENG,
    LFIMG LIKE LIPS-LFIMG,
    OMENG LIKE VBBE-OMENG,
    POSAR LIKE VBAP-POSAR,
    NETWR LIKE VBAP-NETWR,
    NTGEW LIKE VBAP-NTGEW,
    KBETR LIKE KOMV-KBETR,
    KUNNR LIKE  VBAK-KUNNR,
    NAME1 LIKE  KNA1-NAME1,
    *BRGEW LIKE  VBAP-BRGEW,
    BSTKD LIKE VBKD-BSTKD,
    BSTDK LIKE VBKD-BSTDK,
    LFSTA LIKE VBUP-LFSTA,
    *KNUMV LIKE VBAK-KNUMV,
    *posnr LIKE LIPS-POSNR,
    *NETWR LIKE VBAK-NETWR,
    BRGEW LIKE VBAP-BRGEW,
    LFDAT LIKE LIKP-LFDAT,
    *NTGEW LIKE LIKP-NTGEW,
    DELIVERY LIKE LIPS-VBELN,
    WEIGHT like VBAP-NTGEW,
    END OF itab.
    *variable for Report ID
    DATA: v_repid LIKE sy-repid .
    *declaration for fieldcatalog
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          wa_fieldcat TYPE slis_fieldcat_alv.
    DATA: it_listheader TYPE slis_t_listheader.
    declartion for layout
    DATA: alv_layout TYPE slis_layout_alv.
    *Title displayed when the alv list is displayed
    *DATA:  i_title_main TYPE lvc_title VALUE 'FIRST LIST DISPLAYED'.
    DATA:  i_title_main TYPE lvc_title VALUE 'Reports : Bhavesh Pacnhal'.
    INITIALIZATION.
      v_repid = sy-repid.
      PERFORM build_fieldcatlog.
      SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
         SELECT-OPTIONS : VBELN FOR VBAK-VBELN ,
                          KUNNR FOR VBPA-KUNNR ,
                          EDATU for ITAB-EDATU.
      SELECTION-SCREEN: END OF BLOCK b1.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_listheader USING it_listheader.
      PERFORM display_alv_report.
    FORM build_fieldcatlog.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'VBELN'.
      wa_fieldcat-seltext_m = 'SalesOrderNo'.
      wa_fieldcat-outputlen = '12'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Field for Customer Name.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'NAME1'.
      wa_fieldcat-seltext_m = 'Customer Name'.
      wa_fieldcat-outputlen = '30'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Field For Po Number.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'BSTKD'.
      wa_fieldcat-seltext_m = 'PO No'.
      wa_fieldcat-outputlen = '20'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    Field For Order Value
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'NETWR'.
      wa_fieldcat-seltext_m = 'Order Value '.
      wa_fieldcat-outputlen = '12'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Field For Po Date.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'BSTDK'.
      wa_fieldcat-seltext_m = 'PO Date'.
      wa_fieldcat-outputlen = '20'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    wa_fieldcat-tabname = 'ITAB'.
    wa_fieldcat-fieldname = 'POSNR'.
    wa_fieldcat-seltext_m = 'Item No'.
    wa_fieldcat-outputlen = '20'.
    APPEND wa_fieldcat TO i_fieldcat.
    CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'EDATU'.
      wa_fieldcat-seltext_m = 'Delivery Date'.
      wa_fieldcat-outputlen = '12'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    wa_fieldcat-tabname = 'VBAP'.
    wa_fieldcat-fieldname = 'KWMENG'.
    wa_fieldcat-seltext_m = 'Order QTY VABP.'.
    wa_fieldcat-outputlen = '14'.
    APPEND wa_fieldcat TO i_fieldcat.
    CLEAR wa_fieldcat.
    Field For Order Qty.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'WMENG'.
      wa_fieldcat-seltext_m = 'Ord.QT.WMEN.'.
      wa_fieldcat-outputlen = '20'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Field For Order Qty.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'BMENG'.
      wa_fieldcat-seltext_m = 'Ord.QT.BMEN.'.
      wa_fieldcat-outputlen = '20'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    field For Delivery Qty.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'LFMING'.
      wa_fieldcat-seltext_m = 'DEL QTY.'.
      wa_fieldcat-outputlen = '20'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Field For Open Qty from ITAB.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'OMENG'.
      wa_fieldcat-seltext_m = 'OPEN QTY.'.
      wa_fieldcat-outputlen = '20'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Field For Pending Weight from ITAB.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'BRGEW'.
      wa_fieldcat-seltext_m = 'Pending Weight'.
      wa_fieldcat-outputlen = '12'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    Field For netweight.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'NTGEW'.
      wa_fieldcat-seltext_m = 'Net Weight'.
      wa_fieldcat-outputlen = '20'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    Field For Actual Delivery.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'LFDAT'.
      wa_fieldcat-seltext_m = 'Actual Delivery'.
      wa_fieldcat-outputlen = '12'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
      wa_fieldcat-tabname = 'ITAB'.
      wa_fieldcat-fieldname = 'KBETR'.
      wa_fieldcat-seltext_m = 'RATE'.
      wa_fieldcat-outputlen = '20'.
      append wa_fieldcat to i_fieldcat.
      clear wa_fieldcat.
    Field For Actual Delivery.
    wa_fieldcat-tabname = 'LIPS'.
    wa_fieldcat-fieldname = 'POSNR'.
    wa_fieldcat-seltext_m = 'Delivery ITEM'.
    wa_fieldcat-outputlen = '20'.
    append wa_fieldcat to i_fieldcat.
    clear wa_fieldcat.
    Field For Pending Value.
    VBUP-LFSTA
    wa_fieldcat-tabname = 'VBUP'.
    wa_fieldcat-fieldname = 'LFSTA'.
    wa_fieldcat-seltext_m = 'Pending Value'.
    wa_fieldcat-outputlen = '20'.
    append wa_fieldcat to i_fieldcat.
    clear wa_fieldcat.
    Field For pending weight.
    wa_fieldcat-tabname = 'ITAB'.
    wa_fieldcat-fieldname = 'ITAB-OMENG * KOMV-KBETR'.
    wa_fieldcat-seltext_m = 'Pending VALUE'.
    wa_fieldcat-outputlen = '20'.
    APPEND wa_fieldcat TO i_fieldcat.
    CLEAR wa_fieldcat.
    ENDFORM.                    "BUILD_FIELDCATLOG
    FORM data_retrieval.
    SELECT VBELN  NETWR KUNNR FROM VBAK INTO (ITAB-VBELN,ITAB-NETWR,ITAB-KUNNR) WHERE VBELN IN VBELN .
    SELECT POSNR POSAR BRGEW FROM VBAP INTO (ITAB-POSNR,ITAB-POSAR,ITAB-BRGEW) WHERE VBELN = ITAB-VBELN .
    SELECT EDATU FROM VBEP INTO (ITAB-EDATU) WHERE VBELN = ITAB-VBELN AND POSNR = ITAB-POSNR.
    SELECT NAME1 FROM KNA1 INTO (ITAB-NAME1) WHERE KUNNR = ITAB-KUNNR .
    SELECT BSTKD BSTDK FROM VBKD INTO (ITAB-BSTKD,ITAB-BSTDK) WHERE VBELN = ITAB-VBELN AND POSNR = ITAB-POSNR.
    SELECT VBELN LFIMG FROM LIPS INTO (ITAB-DELIVERY, ITAB-LFIMG) WHERE VGBEL = ITAB-VBELN AND VGPOS = ITAB-POSNR.
    SELECT LFDAT NTGEW FROM LIKP INTO (ITAB-LFDAT,ITAB-NTGEW) WHERE VBELN = ITAB-DELIVERY .
    SELECT WMENG BMENG FROM VBEP INTO (ITAB-WMENG,ITAB-BMENG) WHERE VBELN IN VBELN .
    SELECT SINGLE OMENG FROM VBBE INTO (ITAB-OMENG) WHERE VBELN IN VBELN.
    SELECT SINGLE NETWR FROM VBAK INTO (ITAB-NETWR) WHERE VBELN IN VBELN.
    SELECT KNUMV FROM VBAK INTO (ITAB-KNUMV) WHERE VBELN IN VBELN.
    *SELECT KBETR KNUMV FROM KONV INTO (ITAB-KBETR, ITAB-KNUMV) WHERE KNUMV = VBAK-KNUMV.
    *assign VAR1 = itab-kbetr.
    *append itab.
    *ENDSELECT.
    SELECT KBETR KNUMV FROM KONV INTO (ITAB-KBETR, ITAB-KNUMV)WHERE KNUMV = VBAK-KNUMV.
    ITAB-KBETR = KONV-KBETR.
    ENDSELECT.
    APPEND ITAB.
    ENDSELECT.
    ENDSELECT.
    ENDSELECT.
    ENDSELECT.
    ENDSELECT.
    ENDSELECT.
    ENDSELECT.
    ENDSELECT.
    ENDSELECT.
    *ENDSELECT.
    ENDFORM.                    "data_retrieval
    FORM build_listheader  USING it_listheader TYPE slis_t_listheader.
    DATA HLINE TYPE SLIS_LISTHEADER.
      DATA: ls_line TYPE slis_listheader.
    bhavesh
    HLINE-INFO = 'report Developed by Bhavesh'.
    HLINE-TYP = 'H'.
    Header
    Bhavesh
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    LS_LINE-KEY: not used for this type
      ls_line-info = 'Sales ORDER Report'.
      APPEND ls_line TO it_listheader.
    bhavesh
    ***Selection
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'Key 1'.
      ls_line-info = 'SFEL'.
      APPEND ls_line TO it_listheader.
      ls_line-key  = 'Key 2'.
      ls_line-info = 'SFEL'.
      APPEND ls_line TO it_listheader.
    ***Action
      CLEAR ls_line.
      ls_line-typ  = 'A'.
    LS_LINE-KEY: not used for this type
      ls_line-info = 'Status list'.
      APPEND ls_line TO it_listheader.
      ENDFORM.                    "BUILD_LISTHEADER
    *ENDFORM.                   "build_listheader
    FORM display_alv_report.
      v_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = v_repid
       I_CALLBACK_PF_STATUS_SET          = 'STATUS'(002)
         i_callback_user_command           = 'USER_COMMAND'
       i_callback_top_of_page            = 'TOP_OF_PAGE'
         i_grid_title                      = 'SFEL SALES EXPEDITING REPORT'
         i_background_id         = 'ALV_BACKGROUND'
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         = LAYO
      IS_LAYOUT                         = ALV_LAYOUT
        it_fieldcat                       = i_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
        i_default                         = 'ZLAY1'
        I_SAVE                            = 'A'
        is_variant                        = i_variant
        IT_EVENTS                         = V_EVENTS
        TABLES
          t_outtab                          = itab[]
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "display_alv_report
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_listheader[].
         i_logo             = 'ENJOYSAP_LOGO'.
       I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP_OF_PAGE

  • Query for SO and INV Tracking

    Hi guys.
    I have another problem now. I was asked to help to create a query that can track SO and INV independently (which means the absence of INV will not affect the presence of SO on the query). I have tried to code it out and it seems that it works perfectly fine. Just that I ain't that sure whether my code is a correct one as I doesn't want to cause my colleague to make mistakes on her report. So, I need you guys to check the code below and if possible, suggest some improvement that could be made to it.
    SELECT T0.[DocNum] as 'S/O No.', T0.[DocStatus],T0.[DocDate],  T0.[CardCode], T0.[CardName], T4.[DocNum] as 'INV No.'
    FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
    LEFT JOIN DLN1 T2 ON T1.DocEntry = T2.BaseEntry AND T1.LineNum = T2.BaseLine
    LEFT JOIN INV1 T3 ON T2.DocEntry = T3.BaseEntry AND T2.LineNum = T3.BaseLine
    LEFT JOIN OINV T4 ON T3.DocEntry = T4.DocEntry
    ORDER BY T0.[CardName]
    The main reason I link them via LineNum is because in some of the older database, JobNo were not input into the A/R Invoice form and thus I can't directly link SO with INV. Thus, I link it via DO row level. Please advice whether this way is a correct way, or its a big mistake.
    Thanks !!!

    Hi Gordon.
    There is a problem now. The joining that we use on the code above involves SO, DO and INV. However, the piority is on INV No and SO No. There are some issue now, in which some SO were directly copied into INV without DO. Thus the linking that we use on top doesnt work for these SO or INV - it wouldnt query them out.
    I know we can join these documents via linenum or job no, but using job no is out of the question as in the past practice or even now, some of these SO and INV doesn't have any job no entered. Thus, I can only depend on linenum. I have done another query by using linenum only. 
    SELECT Distinct T0.[DocNum] as 'S/O No.', T0.[DocStatus],T0.[DocDate],  T0.[CardCode], T0.[CardName], T0.[DocTotal] as 'SO Doc Total', T3.[DocNum] as 'INV No.'
    FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
    LEFT JOIN INV1 T2 ON T1.DocEntry = T2.BaseEntry AND T1.LineNum = T2.BaseLine
    INNER JOIN OINV T3 ON T2.DocEntry = T3.DocEntry
    ORDER BY T0.[CardName]
    It is working fine, but I afraid that this way it will overlook any SO or INV with DO ?

  • Need query for requistion and rfq numbers

    Dear All,
    I need a query to list all requisition number for which RFQ is created and RFQ  is partially converted to PO, if RFQ is fully converted to PO, it should not fetch the details.please help me on this.
    Thanks
    Debendra

    Are you referring to sourcing RFQ or core quotations?

  • Query for monthly and QTR change

    Post Author: sugumar
    CA Forum: General Feedback
    monthly change= previous month amount - current month amt
    Quarterly Change= Previous Quarter amt - current quarter amt

    Post Author: amr_foci
    CA Forum: General Feedback
    if i got you right,, you can make two queries one for the current month and one for the previous month, thats will give you two measures , Q1.current_month and Q2.previous_month
    substarct them to get the month change
    and you can use merge dimensions for any dimensions
    good luck

  • Query for RFQ and ME59N

    Hi Gurus,
    I have two basic queries.
    1. Can info record get updated automatically when I save RFQ via ME47? IF yes, where is the info update button at item level?
    2. If I have 4 line items (example) in PR and all are for different vendors and Plant...then can system convert that requsition to PO via ME59N or system will convert only first line item?
    Thanks in advance.

    Not sure why you want an extra button, SAP takes care when you save, based on the settings made for info update indicator and the SAP special programmed logic (which was numerous times subject to questions - please search in SCN - there is even a FAQ SAP note on that)
    What would you call it if you give your son a shopping list with 4 items and he comes back with the first item only ?
    I would certainly not think that this is the expected behavior.
    Hence you have to analyze why this happened.
    And as you already pointed out: "I have two basic queries."
    You can certainly find endless discussions on ME59N and even 43 which talk about a check report, hence search with this term: me59n check report

  • SPAU query for documentation and maintainance and transport object

    Hi All,
    I am working on upgrade using SPAU. In without modification assistant there are two nodes and objects in red- 1. maintenance and transport object 2. Documentation.
    When I click on maintenance and transport object , I get the red button for cluster maintenance SOBJ.I try to open in maintain/change mode but it is not giving any option to activate or anything. As it is maintenance it gives an option to create a new entry only.( see attached capture1 & capture2)
    What do we need to do to make it green ? I tried to search but did not get anything related to this. I have attached screen shot for the same.
    Also for documentation, what needs to be done as adopt modification ? I get the pop up for create modification when I click on data element documentation. Do I need to create modification ? what should be the template type ? (Please see the attached screen shot capture3 ).
    Also for both I get 'no version found'.
    I would really appreciate your help.
    Thanks,
    Niki

    Can anybody help/guide on this please ....

Maybe you are looking for

  • How do you change the direction of a Tween Wipe effect

    Hi all, Completely new to the forums and I hopefully my query is straight forward.  How do you change the direction in the pre-built tween effects available within Flash CS3 (primarily the Wipe effect).  Example code: var Animate_Box:Tween = new Twee

  • How to configure SFTP Adapter in XI?

    Hi All, How to configure SFTP adapter in XI?, It would be great if anyone sends a step-by-step documentation on the same. Thanks in advance

  • DJ 3545 copying resolution issue

    Hi there I am having a problem with my DJ 3545 when I use the copy function. The printout has vertical lines missing in a number of locations on the document. I have tried copying different documents just to make sure that it's not a bad quality docu

  • Link imac and ipad

    how to link with new email address

  • BPC10 Reporting Error

    Dear All We are using EPM 10 with SP 16. Till last week we were able to perform reporting in our Dev system. since yesterday whenever we try to create new report it is throwing the following error. Nothing has been changed in setting since last week.