Count on a header table including the line data also in the query

Hi,
I have a requirement to develop a report which shows the metrics on supplier. I need to find the total PO's for this supplier that are matched to invoice
report has to have toatl#ofpo's, #invoice, total_inv_amt and total_po_amt, total_tax_amt with item numbers also with in a time period. So my question is how can we achieve this I have this below query whih gives all the data but not sure how to get the counts with this. Any ideas
SELECT hou.name,
pov.vendor_name,
api.invoice_num,
api.invoice_id,
invoice_date,
gl_date,
api.invoice_currency_code,
apid.line_type_lookup_code inv_line_type,
apid.description inv_description,
apid.amount,
apid.unit_price inv_price,
amount_paid,
apt.name payment_terms,
payment_status_flag,
apc.check_number,
apc.check_date,
poh.segment1 po_num,
poh.creation_date po_creation_date,
por.creation_date po_rel_creation_date,
por.release_num,
pol.line_num,
mc.segment1 category_name,
(select msi.segment1 item_num
from inv.mtl_system_items_b msi
where msi.inventory_item_id = pol.item_id
and msi.organization_id = 1) item_num,
pol.item_description po_item_description,
poll.need_by_date,
pol.unit_price po_price,
poll.quantity,
poll.quantity_cancelled,
poll.quantity_received,
poll.quantity_billed
FROM ap.ap_invoices_all api,
hr_operating_units hou,
ap_terms_tl apt,
ap.ap_invoice_distributions_all apid,
po.po_distributions_all pod,
po.po_vendors pov,
po.po_headers_all poh,
po.po_lines_all pol,
po.po_line_locations_all poll,
po.po_releases_all por,
ap.ap_checks_all apc,
ap.ap_invoice_payments_all apip,
-- inv.mtl_system_items_b msi,
apps.mtl_categories_b mc
WHERE apt.term_id = api.terms_id
AND hou.organization_id = api.org_id
AND TRUNC (poh.creation_date) BETWEEN :p_start_date AND :p_end_date
AND api.invoice_id = apid.invoice_id
AND apid.po_distribution_id = pod.po_distribution_id(+)
AND pov.vendor_id = api.vendor_id
AND poh.po_header_id(+) = pod.po_header_id
AND poll.line_location_id (+) = pod.line_location_id
AND pol.po_line_id (+) = pod.po_line_id
AND apip.check_id = apc.check_id(+)
AND apip.invoice_id(+) = api.invoice_id
AND mc.category_id(+) = pol.category_id
AND por.po_release_id (+) = pod.po_release_id
AND pov.vendor_id = 1

Hi,
The sounds like a job for the COUNT function. That's all I can say with any confidence based on the information you gave.
If you want to see, on each row of output, how many of the rows with the same value of api.invoice_num have a value for poh.po_header_id, the you can use
COUNT (poh.po_header_id) OVER (PARTITION BY api.invoice_num)   AS po_cntI could give much better directions if you could post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data. I realize that's hard with so many tables. Even seeing some of your current output, and the desired output, might help.

Similar Messages

  • All the message dates in the message list changed in every mailbox to a recent date, I don't know why.. The dates within the messages' headlines themselves remained correct.  How do I re-establish the correct dates also in the mailboxes' message list?

    All the message dates in the message list changed in every mailbox to a recent date, I don't know why.. The dates within the messages' headlines themselves remained correct.  How do I re-establish the correct dates also in the mailboxes' message list?

    First thing is to forget all the complex configs and just try to schedule the report to run once now, no alerts, no notifications, no nothing.
    Does that work?
    Then you can build up the schedule, to see where the problem is coming from.
    Sincerely,
    Ted Ueda

  • [SD] table for Schedule line date

    If we display a sales order through Va03 and Go to tab Item overview. There is a excel sheet kind of display showing
    all items. The 12th col is 'First Date' and the f1 help says its 'Schedule line date'.
    I need to display this date in my report.
    <i>F1 Help Says :</i>
    <b>Schedule line date</b>
    The delivery date for the schedule line. The delivery date can be the
    Date requested by the customer, or (if the requested date cannot be met)
    Earliest date proposed by the system after automatic availability checks and delivery scheduling
    <b>Use</b>
    The system uses the delivery date for each schedule line together with predefined time estimates for delivery activities (such as picking and packing) to determine the
    Material availability date
    Loading date
    Goods issue date
    Transportation planning date
    <b>Dependencies</b>
    If you want the system to automatically determine the above dates, the Delivery scheduling and Transportation scheduling fields must be active in the sales document definition ( Tools --> Customizing, Sales and Distribution --> Basic Functions --> Delivery scheduling and transportation scheduling --> Define scheduling by sales document type).
    <b>Note</b>
    If there is more than one schedule line for the item, the system displays the earliest delivery date in the item and overview screens.

    Hi flora
    You can get he details of the schedule line data in the VBEP table.
    EDATU is the schedule line date
    regards
    kishore

  • How to make plant default on the line item along with the item category

    Hi All,
    I want to default Plant on the line item along with the item category.In order to meet the following scnario.
    1. I have two plants,first plant is maintained for the valuated item and the second plant is maintained for the non valuated item (Free Goods).
    Whenever user is entering an item in the sales order for which corresponding free goods item is maintained in the master record.System is proposing two lines items in the sales order.
    First line item is the main item which appears along with the Plant 1 which contains valuated items
    Second line item is for the Free of charge item which is being proposed from Plant 2, which contains the non valuated items.
    I want that the system should always propose Plant 1 with main item and Plant 2 with the Free of Charge item by default. (Along with the item category TAN and TANN)
    Rahul

    Delivering Plant is determined in the following order
    1. Customer material info record.
    2. Customer master
    3. Material master.
    Use one of them an default your plant.
    I think in your case you can use the materila master which will give an item level plant different. The other two will default the plant at the header level.
    regards
    jude

  • Display the Line level details in the Notification - Urgent

    Hi,
    I have developed a Approval Workflow for customized form.
    I want to display the Line level details in the Notification/Message.Please guide me to do this?
    Thanks

    You can make use of the attribute type DOC. See 'To Define a Document Attribute' in the Workflow Development Guide. Then you just include it in the body of the message the same way you do with other attributes.
    Regards,
    Alejandro.

  • Line Graph repeats the starting data point at the end also

    Hi,
    We have a Line Graph as below. This graph is used to show the Salary changes of a person, over time.
    But this graph shows an additional non existing data point. Basically it shows the starting data point once again at the end of the other data points.
    The model VO for this graph, does not contain this additional data point record. But the graph repeats the starting data point at the end also.
    In the screen-shot you can see that, the graph has three data points. But the table has only two. The first data point in the graph is repeated as the last data point.
    Is this a Bug..?
    Or an issue with the usage of the DVT tags?
    The code is given below.
    Please advice.
    12 <dvt:graph id="lineGraph1" value="#{bindings.SalaryHistory.graphModel}"
    13 graphType="LINE_VERT_ABS"
    14 shortDesc="#{HcmEmploymentTopGenBundle}"
    15 markerDisplayed="true"
    16 continuousTimeAxisInterval="CTAI_DAY"
    17 contentDelivery="immediate" animationOnDisplay="AUTO"
    18 imageFormat="FLASH" stylePath="April"
    19 timeSelectorListener="#{backingBeanScope.AssignmentChangesAndSalaryBean.changeTime}"
    20 timeAxisType="TAT_MIXED_FREQUENCY" dynamicResize="DYNAMIC_SIZE"
    21 inlineStyle="height:40em;"
    22 binding="#{backingBeanScope.AssignmentChangesAndSalaryBean.asgSalaryGraph}">
    23 <dvt:background>
    24 <dvt:specialEffects/>
    25 </dvt:background>
    26 <dvt:graphPlotArea/>
    27 <dvt:seriesSet>
    28 <dvt:series/>
    29 </dvt:seriesSet>
    30
    31 <dvt:o1Axis scrolling="asNeeded"/>
    32 <dvt:y1Axis/>
    33 <!-- <dvt:legendArea automaticPlacement="AP_NEVER" rendered="false"/>-->
    34 <!-- <dvt:timeSelector mode="EXPLICIT"
    35 explicitStart="#{backingBeanScope.AssignmentChangesAndSalaryBean.timeSelectorStartDate}"
    36 explicitEnd="#{backingBeanScope.AssignmentChangesAndSalaryBean.timeSelectorEndDate}"
    37 id="ts34">
    38 <dvt:specialEffects>
    39 <dvt:gradientStopStyle/>
    40 </dvt:specialEffects>
    41 </dvt:timeSelector>-->
    42 <dvt:o1MajorTick/>
    43 <dvt:o1TickLabel/>
    44 <dvt:o1Title id="o1Title1">
    45 <dvt:graphFont id="graphFont1"/>
    46 </dvt:o1Title>
    47
    48 <dvt:attributeFormat id="af1" name="DateFrom">
    49 <af:convertDateTime pattern="#{applCorePrefs.dateFormatPattern}" />
    50 </dvt:attributeFormat>
    51
    52 <dvt:markerText>
    53 <dvt:y1Format>
    54 <af:convertNumber pattern="#{applCorePrefs.numberFormatPattern}"/>
    55 </dvt:y1Format>
    56 </dvt:markerText>
    57
    58
    59 </dvt:graph>

    If I understand your question, this from the Pages online help may give the answer:
    To mark line, area, and scatter charts with data point symbols:
    Select the entire chart. You can also select the chart series (the line or area shape) that you want to mark with data point symbols.
    Click Inspector in the toolbar, and then click the Chart Inspector button.
    Click Series (except for scatter charts).
    Choose a symbol from the Data Point Symbol pop-up menu.
    Choose one of the following options from the Symbol Fill pop-up menu:
    To fill the symbol with the same color as its outline, choose Use Stroke Color.
    To fill the symbol with a solid color, choose Color Fill, click the Fill color well, and pick a color.
    To fill the symbol with a gradient, choose Gradient Fill and use the gradient controls to set the colors and change the angle of the gradient.
    To fill the symbol with an image, choose Image Fill and select the image you want. You can also resize the image by choosing an option from the pop-up menu above the Choose button.
    To fill the symbol with a tinted image, choose Tinted Image Fill and select the image you want. Click the color well to the right of the Choose button to change the tint color. You can also resize the image by choosing an option from the pop-up menu above the Choose button.

  • Provide brings back the actual date , different to the table content

    Hi,
    I´m not a developer, but must do that part now in my company.
    We have a 46C with actual packages.
    In a customer report I have to add 2 fields to an output.
    It selects from PNP and provides data like follows:
    GET PERNR.
      PROVIDE * FROM P0000
    FROM P0001
    FROM P0002
    FROM P0006
    FROM P0007
    FROM P0013
    FROM P0016
    FROM P0053
        BETWEEN PN-BEGDA
            AND PN-ENDDA.
    That worked fine.
    Now I liked to set 2 fields with contents of IT 0000 (table PA0000):
        IF P0000-MASSG = '01'.            " MA aktuell im Vorruhestand ?
         TRANS-BEGVORRST = P0000-BEGDA.
         TRANS-ENDVORRST = P0000-ENDDA.
        ENDIF.
    At debugging I can see, that the requested fields from P0000 are set to the actual date, not to the value I can select from table or shown in the SAP transaction.
    All other fields from PA0000 are matching the row I expect, but not the date fields
    Any idea?

    Hi,
    That is the behavior of PROVIDE statement. If you combine (JOIN) several tables (P0001, P0002, etc) together, it will give you all the intersected dates.
    For example, in two tables itab1 and itab2, the respective columns col1 and col2 are interval limits of type i. The filling of the internal tables results in the following intervals (rows two and three):
    |   Itab1 Int1    |     |Itab1 Int2 |     |
    |        |      Itab2 Int1       |        |
    |  |          ... BETWEEN ...             |
    |  | i1  |   i2   | i3  |   i4   |i5|     |  <<<< This is the result
    Regards,
    Lim...
    Edited by: Ruslim Chang on Apr 17, 2009 11:26 AM

  • Hi I have a iPhone 4 and I seem to have a problem during calls. If I make or receive a call I can hear the person who is on the line with me but the other person can't hear me. This problem has occurred 1 week ago so please get back thank you

    Hi I have a iPhone 4 and I seem to have a problem during calls. If I make or receive a call I can hear the person who is on the line with me but the other person can't hear me. This problem has occurred 1 week ago so please get back thank you

    You use Restore to get the latest firmware build, not the Update button. You can only use the Update button, if there is an iOS update, say iOS 5.1.
    this link talks about updating to 9A406 to fix the "No Service" issue with iPhone 4S:
    http://iphone-and-i.blogspot.com/2011/12/fixing-iphone-4s-signal-problem.html

  • TS3276 When responding to an email, how do I suppress the "line" that appears on the left side of the originations email text?

    When responding to an email, how do I suppress the "line" that appears on the left side of the originations email text?

    Would you post a screen shot of a message so people can see what you are seeing? Make sure you cover any personal information using Preview. Post the screen shot in a Reply using the camera icon. Copy and paste doesn't work.
    Screen shots

  • How to delete the duplicated songs at the same time also from the source , hd

    i have lots of song twice or tripple in the song list. the main reason is i have them also in the source hd dupplicated. It is not easy to find the dupplicated songs in the hard disc, they are in different files with different names but same songs . ı have to delete them by checkin the files each for every duppliceted song it is not possible practically.
    but in i tunes i see them all in a list and can delete. but they will still be in hard disc. If for any reason i have to reload the files to  itunes, they come again and i have to start form the zero point.
    i want to delete them at the same time when i am deleting them on i tunes library.
    this options is available on windows media player. there is always an option when i delete a song the software asks '' delete only from the list or also from the source? ''
    is this optian available in i tunes ?

    Ting,
    Try this:
    Insert a group on body_code.  Then create a running total called Distinct Count.  Field to summarize -> ID, Evaluate on change of group Group # 1 Body Code, and Never Reset.
    Then insert a chart in the report header:
    In the advanced layout, select body_code on change of and select Distinct Count running total in the Show values.
    I hope I understood what you're looking to accomplish.
    Z

  • Why are your Data Plans SO SCREWED UP? You are Unfairly making the average data user Subsidize the Big Data Users. This kind of thing is why I left AT

    Why are your Data Plans SO SCREWED UP? You are Unfairly making the average data user Subsidize the Big Data Users. This kind of thing is why I left AT&T and came to Verizon a Decade ago. Their plans sound better now, maybe I should go back.

    I currently have 5 phones/lines. 2 Droid MAXX phones, a Samsung Galaxy S5 phone and 2 basic phones (4+ year old Motorola & Samsung). The cost for each line rose considerably and usage fees more than doubled on the 2 basic phones when I upgraded the 3 smartphones at the beginning of this year and Had to Convert from my old Unlimited Family Plan to the Newer Share Everything Plan. My Data Usage varies a lot due to occasional travel which I have little control over. At least you recently began including a $10 deduction on each of the 2 older phones (which I have not updated in order to save money though they need updating). My Sweet Spot on Data would be around 6GB Monthly Data. But that level is not offered. Only 2, 3, 4, 10, or 15 GB plans are offered.
    Verizon's Data Plans Offered Are:  2GB-$50/MO = $25/GB  *   3GB-$60/MO = $20/GB   *   4GB-$70/MO = $17.50/GB   *  10GB-$80/MO = $8/GB   *  15GB-$100/MO =  $6.66/GB   *   And Overages are Charged at $15 per 1k-1GB.
    Offers JUMP From 4GB TO 10GB (There's a 6GB GAP/JUMP - ***) - Why is there NO 6 or 8 GB offering?  Because Verizon is Overcharging the Lower Data Users!  Seems like All of the Other Cellular companies are Offering Better Deals.
    If you can offer something better please let me know, otherwise I may have to consider going back to AT&T or moving to one of the other cellular companies.

  • A good solution to set the actual data record after execute query ..

    Hi,
    in my Form there is a block on a temporary table.
    The user can add query results and wishes to save the last data focus on the last actual record before the execute query to restore this focus after the query.
    Is there a robust and fast solution to save the
    actual data focus - execute_query - restore the saved focus ?
    Thanks
    Friedhold

    Here is a simple solution to try:
    Create a package specification in your form: Package P0 is
      Save_rowid  varchar2(30);
      Found_rec   number;
    End;Create a Key-Entqry trigger on your block: P0.save_rowid := :Myblock.rowid;
    P0.Found_rec := null;
    Enter_Query;Create a Post-Query trigger on the block: If :Myblock.rowid = P0.save_rowid then
      P0.found_rec := :system.trigger_record;
    End if;Create a Key-Exeqry trigger on the block: Execute_Query;
    If P0.found_rec is not null then
      Go_record(P0.found_rec;
    End if;

  • How to set the Reverse date to be the same as the Actual GI date by default

    Hello,
    On VL09 (reverse goods movement) screen, default reversal date is the system date.
    Users have to select the line, click on define date button and enter the correct cancellation date to the local date field on the pop-up.
    I want the reversal date on VL09 screen to be the same as the Actual GI date by default.
    Thank you.

    Hi,
    I checked the program.
    Check in routine FORM insert_data_for_reversal  --->  IF Condition (( xlikpukwa-wbstk EQ charc AND xlikpukwa-vbtyp CA vbtyp_lief ) OR  ( xlikpukwa-wbstk CA 'BC'  AND xlikpukwa-vbtyp CA vbtyp_liav ). ---> 2 performs are there one with '01' and other with '02' as actual parameters.
    In your case '01' is passing to the routine. if you try to pass '02' u can achive your requirement.
    For testing in debug mode pass FIELDS-FIELD_ATTR = '02' for field name DATLO. then you can see the output.
    Try to handle this problem using Enhancement Operations.
    Hope this helps you.
    Thanks
    Raghavendra

  • How do I add new fields to the 'Customer Data' tab under the BP

    I had previously found a screen in the SAP GUI to add fields so that they would show up on the 'Custmer Data' tab under the Business Partner screen. I thought it had been somewhere in se80 but I cannot find it again. Does anyone know where this is? Thank you!

    Hi Mark,
    You can do this using transaction EEWB. This is the Easy Enhancement Workbench.
    within this, you can use the wizard which will guide you through a step by step process to add the fields you need. Basically, there are 2 ways to add new fields  :
    1. Add new fields - this adds fields to table BUT000, but places the fields on a new tab called 'Customer Data'
    2. Add new attributes table - creates a new table and links it to BUT000 using the partner number.
    Hope this helps you.
    Cheers,
    Rishu.

  • When I attempt to apply a lens profile in the Develop module the only choices are for the Fujifilm X100/S/T even though in the Library module the EXIF data correctly shows the camera as the X-T1 and the precise lens used to take the picture. How do I get

    When I attempt to apply a lens profile in the Develop module the only choices are for the Fujifilm X100/S/T even though in the Library module the EXIF data correctly shows the camera as the X-T1 and the precise lens used to take the picture. How do I get the right profile available?

    First, the required profile needs to be present. LR 5.4 supports the X-T1 in terms of understanding its Raw format, but will not come with a profile for every lens which can be mounted onto that.
    A profile is made for each specific lens, as mounted on a certain camera. It can also be used with pictures taken on a different (reasonably similar) camera body than the one originally used during profiling. This is subject to the sensor format: you can employ a given lens profile made for full frame, on an image from a crop sensor behind the same lens - but not vice versa.
    Next, the image type needs to correspond to the image type which has been built into the profile: Raw, or non-Raw.
    Lightroom offers only profiles of the right type for the image(s) concerned. There are many more provided for correcting camera Raw, than for correcting camera JPG. That is also the case with additional profiles, e.g. those accessed via the Adobe lens profile downloader utility.
    Finally, in the event that there simply is no profile out there for a given lens, it is not particularly difficult (though a little tedious) for the end user to generate one, using a further Adobe utility which is downloadable as a package, including a range of checkerboard calibration targets, each of which needs to be printed at a stated physical size.

Maybe you are looking for

  • IP phone CP7911G over VPN

    Hi, is there voice problem with CP7911G over VPN? I have a CP7911G that works fine on my network, but when i call another extension on VPN, i hear some noise during the call.

  • How can i change old icloud account on my 4s ios 8.1.1?

    i recently "upgraded" my old iphone 4 and bought a secondhand 4s, i forgot to ask the owner to reset the phone but it was pretty blank and now I can't change his icloud account to mine.... Any ideas on how to do that? I have some files on my icloud t

  • XML Output - Issue with multiple field labels.

    Dear Users, I am trying to create an XML sheet as output for my program, and am struck at a point where I don't need field labels appearing on the XML output. The code looks as below:       l_element_order = l_document->create_simple_element(        

  • I am facing problem in calling Ztransaction second time ?

    Hi All, I have no issues while calling ztransaction first time , but while calling second time it is taking too much time , if we are entering transaction code  in command field only i am facing this problem , no issues when we call tcode programatic

  • Lost the hpeprint.c​om email adress after upgrade

    Hi, After the firmware upgrade so we lost our email address. How can we get this back? We had to register the type again in our account with eprintcenter.com. When we try to register it with the address we have used until the firmware upgrade, so say