AR - How to Combine the AR Aging Reports of 2 companies in one SQL?

Hi!
I just completed a query which mimics the Official Aged Analysis of Debtors in SAP B1 8.8, and it works well.
Now I want to combine 2 companies in a single Query. Is this possible, and how can this be done?
Why do I need this?
I work for 2 related companies dealing with different product lines and each company maintains SAP B1 separately.
The 2 companies have the same clients, and send their own separate invoices. But our clients do not recognize this internal division: They make a single order for their purchases and settle their debts by a single remittance.
It would be useful to have an Aging which groups the results of both companies.
I know the names of the 2 databases, say Comp1 and Comp2.
I tried this clause: USE Comp1   GO, but query gives error message "Incorrect syntax near GO"
My idea is group the 2 databases in a single query and use UNION ALL, for example:
USE Comp1
GO
SELECT .....etc
UNION ALL
USE Comp2
GO
SELECT ... etc..
Is this the correct way to proceed? If not, could you tell me what is the best way to develop the query?
Here is a simplified version of my query
SELECT
T1.CardCode + '' AS 'BP Code',
T2.Notes2 AS 'BP Name',
T0.RefDate,
CASE
     WHEN T0.TransType = 13 THEN 'IN'
     WHEN T0.TransType = 14 THEN 'CN'
     WHEN T0.TransType = 30 THEN 'JE'
     WHEN T0.TransType = 24 THEN 'RC'
     WHEN T0.TransType = 46 THEN 'PS'
     ELSE 'Error ! ! !'
END AS 'Doc Type',
T0.Ref1 'Doc. Number',
ISNULL(T0.FCCurrency, ' - ') AS 'Ccy',
(T0.BalFcDeb - T0.BalFcCred) AS 'Bal. F. Ccy',
(T0.BalDueDeb - T0.BalDueCred) AS 'Bal. Rs',
ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred WHERE DateDiff(mm, T0.RefDate, '[%1]') <= -1)                     ,0) AS 'Future',
ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred WHERE DateDiff(mm, T0.RefDate, '[%1]') = 0)                         ,0) AS 'Current Mth',
ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred WHERE DateDiff(mm, T0.RefDate, '[%1]') = 1)                         ,0) AS '1 Mth Ago',
ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred WHERE DateDiff(mm, T0.RefDate, '[%1]') = 2)                         ,0) AS '2 Mth Ago',
ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred WHERE DateDiff(mm, T0.RefDate ,'[%1]') = 3)                         ,0) AS '3 Mth Ago',
ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred WHERE DateDiff(mm, T0.RefDate, '[%1]') between 4 and 6)    ,0) AS '4 - 6 Mth Ago',
ISNULL((SELECT T0.BalDueDeb -T0.BalDueCred WHERE DateDiff(mm, T0.RefDate, '[%1]') >= 7)                       ,0) AS '>7 Mth Ago'
FROM JDT1 T0
INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
LEFT OUTER JOIN OCPR T2 ON T1.CardCode = T2.Cardcode
LEFT OUTER JOIN OJDT T3 ON T0.TransID = T3.TransID
LEFT OUTER JOIN OINV  T4 ON T3.TransID = T4.TransID
LEFT OUTER JOIN ORIN  T5 ON T3.TransID = T5.TransID
WHERE
T1.CardType = 'C' and Balance != 0
and (T0.BalDueDeb - T0.BalDueCred) != 0

Hi Gordon,
Do you mean the following?
Instead of writing:
SELECT ...
FROM JDT1 T0
I should write
SELECT...
FROM Company1.dbo.JDT1 T0
UNION
SELECT...
FROM Company2.dbo.JDT1 T5
I shall try it tomorrow morning when I return to Office.
Thanks a lot
Leon Lai

Similar Messages

  • How to Calculate the Stock aging report in BW

    Dear All,
    Please let me know the process to calculating the Stock Aging report in BW.
    And what are date field need to be consider and what are customer exits used to populated different agings in Stock like 0-30 days etc.
    Thanks
    Regards,
    Sai

    Hello,
    I would be very happy if you send me some sample code to implement this in User exits.
    I mean which ABAP statements are useful in this case. I think we need to implement the following logic for User Exit variable.
    1. At run time, retieve the SSN data from BW dabase
    2. Convert the first 5 digets into *****
    3. Make it available to report in BEX.
    Thanks
    VNM

  • How to split the particle analysis report in order to extract one particular information(for eg. orientation)??)

    hi .. i need to extract the orientation and centroid information from the particle analysis report (image processing is done in NI Vision and then converted to labview vi) for further processing. However once processing is done in Vision ,after converting to labview vi the particle analysis report comes as 1D array of size 1 and thus am unable to extract one particular information from the report. Plz help!   

    duplicate

  • How to combine the same variables from 2 queries in one webi report

    HI ALL,
    I created two BW queries/universe and put them into one web intelligence report. Both queries have the same mandatory variable. I combined the relevant dimensions but can't find how to combine the two variables, which resulted in pop-up for 2 variables.
    Any idea?

    Hey Dick Zheng,
    Just to close it,
    Instead of working on existing reports.
    Create new report(s) on top of these changed Universes(2).
    1. New WebI report on top of Univ1 (With Prompt)
    2. New WebI report on top of Univ2 (Without Prompt)
    If both are working as expected. Do follow below:
    1. Open any Report (just created in above steps)
    2. Edit Query
    3. Add Query
    4. Select another Universe
    5. Drag few objects
    6. Run Queries
    Now see it is working as expected or not.??
    Still any issues post here...,,
    Gracias...!!

  • How to read the Variance Analysis report S_ALR_87013139,  Pdt cost by Order

    Hi,
    Could someone tell me how to read the variance analysis report, S_ALR_87013139 - Cumulative for product cost by order. The report has the following fields, Target (Debits),     Actual (Debits),     Scrap,     Var. Without Scrap,     Work in Process(WIP),     Control Costs.
    I am looking to find how the numbers add up.
    Thanks for your help.
    Ram
    Message was edited by:
            Ram R

    Thanks Sridhar,
    When I analyse the report S_ALR_87013139 - Cumulative , for a product for a period (with no scrap), I get the following
    Target (Deb) -   46,855.55
    Act (Deb) - 58,315.87
    Scrap - 0.00
    Var W/O- Scrap -  11,269
    WIP- 0
    Control Cost - 0
    Here Actual - Target is not equal to Variance. What could be the issue?
    Could you please tell me how SAP would update this report  with target & actual costs with respect to open production orders, carried over from previous periods.
    Thanks,
    Ram

  • How to restrict the display of report variants

    Hello All,
    I want t know how to restrict the display of report variants.
    I mean, when a user saves a variant for his/her purpuse on some report program, only he/she can refer the variant while other users cannot.
    I know that by setting the attribute of the variant ("Protect Variant ", "Only Display in Catalog"), this would be possible, but I want to know another way, without this setting.
    Thank you for your help in advance.
    Regards,

    Hi,
    Can you just try this
    DATA:it_varid TYPE TABLE OF varid.
    DATA:wa_varid TYPE varid.
    INITIALIZATION.
      SELECT * FROM varid INTO TABLE it_varid
          WHERE report = sy-repid
          and ename = sy-uname.
      IF sy-subrc = 0.
        LOOP AT it_varid INTO wa_varid .
          CALL FUNCTION 'RS_SUPPORT_SELECTIONS'
            EXPORTING
              report               = sy-repid
              variant              = wa_varid-variant
            EXCEPTIONS
              variant_not_existent = 1
              variant_obsolete     = 2
              OTHERS               = 3.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
        ENDLOOP.
      ENDIF.

  • How to combine the line items of 2 Sales orders into 1 delivry

    how to combine the line items of 2 Sales orders into 1 delivry
    and their process, pre-requisites and tcode

    The prerequisites are:
    1) In the customer master sales area data, shipping tab, there is a field called Order combination. u must tick that.
    2) for the two orders, the sold to party & ship to party must be same
    3) both orders must have created from same plant & shipping points
    4) the line items must have same loading grp.
    5) the both orders sheduline line date must be same.
    transaction code for the same is VL04.
    enter the required data and select the order nos to be processed.
    Do reward points if it is useful

  • How to do the Validations in Report Programming?

    How to do the Validations in Report Programming?
    how to do screen Validations and Field Validations if posssible can any one send the code regarding the Validation ....
    Tks
    Durusoju

    AT SELECTION-SCREEN - selscreen_event
    Syntax
      | { ON {para|selcrit} }
      | { ON END OF selcrit }
      | { ON BLOCK block }
      | { ON RADIOBUTTON GROUP radi }
      | { }
      | { ON {HELP-REQUEST|VALUE-REQUEST}
      |   FOR {para|selcrit-low|selcrit-high} }
      | { ON EXIT-COMMAND }.
    Alternatives:
    1. ... OUTPUT
    2. ... ON {para|selcrit}
    3. ... ON END OF selcrit
    4. ... ON BLOCK block
    5. ... ON RADIOBUTTON GROUP radi
    6. ... { }
    7. ... ON {HELP-REQUEST|VALUE-REQUEST} FOR
          {para|selcrit-low|selcrit-high} }
    8. ... ON EXIT-COMMAND
    Effect
    These additions allow individual evaluation of specific elements of the selection screens of the program. The information as to which selection has triggered the event is contained in the system field sy-dynnr.
    Alternative 1
    ... OUTPUT
    Effect
    This event is triggered at the screen event PBO of a selection screen. In the event block, the selection screen can be prepared through assignments to the data objects of parameters and selection criteria and through dynamic screen modifications.
    Note
    The assignments to input fields in the event block AT SELECTION-SCREEN OUTPUT always affect the selection screen and overwrite the user inputs from previous displays of the same selection screen. Assignments in the event blocks LOAD-OF-PROGRAM oder INITIALIZATION, on the other hand, only have an effect at first program start.
    Alternative 2
    ... ON {para|selcrit}
    Effect
    This event is triggered at the screen event PAI of a selection screen if the content of the input field of a parameter para or a line of a selection criterion selcrit was passed to the ABAP program. In the event block, the user input can be checked. Sending a warning or an error message in the event block makes the fields para and selcrit ready for input again.
    No parameter that is defined as a radio button can be specified. For this purpose, the addition ON RADIOBUTTON GROUP is provided.
    Note
    If a user action takes place in the dialog box for the multiple selection of a selection criterion selcrit, the entries of the selection table are passed to the program, line by line. For each line, the event AT SELECTION-SCREEN ON selcrit is triggered.
    Alternative 3
    ... ON END OF selcrit
    Effect
    This event is triggered after the selection table selcrit has been fully passed to the program after a user action in the dialog box for the multiple selection has taken place. In the event block, the entire selection table can be checked.
    Alternative 4
    ... ON BLOCK block
    Effect
    This event is triggered at the screen event PAI of a selection screen if all the input fields of a block block of the selection screen were passed to the ABAP program. In the event block, the user inputs can be checked. Sending a warning or an error message in the event block makes all the fields of the block block ready for input again.
    Alternative 5
    ... ON RADIOBUTTON GROUP radi
    Effect
    This event is triggered at the screen event PAI of a selection screen if all the fields of a radio button group radi of the selection screen were passed to the ABAP program. In the event block, the user input can be checked. Sending a warning or error message in the event block makes all the radion buttons of the block radi ready for input again.
    Note
    The individual fields of a radio button group are not passed individually and do not trigger the event AT SELECTION-SCREEN ON par.
    Alternative 6
    Effect
    The event AT SELECTION-SCREEN itself is triggered as the last event of selection screen processing if all the input values were passed to the program. In this event block, all the user inputs can be checked. Sending a warning or an error message in the event block makes all the screen fields ready for input once again.
    Alternative 7
    ... ON { HELP-REQUEST | VALUE-REQUEST } FOR
        {para|selcrit-low|selcrit-high} }
    Effect
    The two events ON HELP-REQUEST and ON VALUE-REQUEST are triggered at the screen events POH and POV of a selection screen if - for the input field of a parameter para or one of the input fields of a selection criterion selcrit - the field help F1 or the input help F4 was called. Other selection events are not triggered.
    In the event blocks, a self-defined field or input field can be programmed, which overrides any helps possibly defined in the ABAP Dictionary.
    Notes
    These event blocks can only be implemented for fields of the selection screen that are defined in the same ABAP program and not in a possibly linked logical database.
    With the events for the field and input help, no data is transported between the selection screen and the ABAP program. As with general screens, suitable function modules must be used for these. The parameters and selection criteria changed for the input help are transported to the selection screen.
    Alternative 8
    ... ON EXIT-COMMAND
    Effect
    This event is triggered if the user has called one of the functions Back, Exit or Cancel. In the event block, possible clean-up actions can be executed.
    Example
    In these executable programs, a standard selection screen and a further selection screen are defined. In the event blocks AT SELECTION-SCREEN, the inputs in the selection screens can be specially handled using the name p_carrid and the screen number in sy-dynnr.
    REPORT demo_at_selection_screen.
    Global data
    DATA: sflight_tab TYPE TABLE OF sflight,
          sflight_wa  LIKE LINE  OF sflight_tab.
    Selection screens
    PARAMETERS p_carrid TYPE spfli-carrid.
    SELECTION-SCREEN BEGIN OF SCREEN 500.
      SELECT-OPTIONS s_conn FOR sflight_wa-connid.
      DATA s_conn_wa LIKE LINE OF s_conn.
    SELECTION-SCREEN END OF SCREEN 500.
    Handling selection screen events
    AT SELECTION-SCREEN ON p_carrid.
      IF p_carrid IS INITIAL.
        MESSAGE 'Please enter a value' TYPE 'E'.
      ENDIF.
      AUTHORITY-CHECK OBJECT 'S_CARRID'
                          ID 'CARRID' FIELD p_carrid
                          ID 'ACTVT'  FIELD '03'.
      IF sy-subrc = 4.
        MESSAGE 'No authorization for carrier' TYPE 'E'.
      ELSEIF sy-subrc <> 0.
        MESSAGE 'Error in authority check' TYPE 'A'.
      ELSE.
        IF sy-ucomm = 'ONLI'.
          CALL SELECTION-SCREEN '0500'.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN.
      IF sy-dynnr = '0500'.
        IF s_conn IS INITIAL.
          MESSAGE 'Please enter values' TYPE 'W'.
        ELSE.
          SELECT *
                 FROM sflight
                 INTO TABLE sflight_tab
                 WHERE carrid = p_carrid AND
                       connid IN s_conn.
          IF sy-subrc <> 0.
            MESSAGE 'No flights found' TYPE 'E'.
          ENDIF.
        ENDIF.
      ENDIF.
    Main program
    START-OF-SELECTION.

  • How to control the permission for reports in share folder?

    Hi Experts,
    In OBIEE 11.1.1.6.0.
    I have created two folders in share folder,one is sales folder which contains some sales reports,and the other is dashboard folder which contains some dashboard pages that have these sales reports.
    So I want to new users who do not access the sales folder, but can view the sales reports in dashboard pages.
    How to control the permission for reports in share folder? Thanks for your help.
    Note: Dashboard pages have whole sales reports for showing.

    Hi User,
    1. Give access to the users for all reports.
    2. Give No Access to Retail Folder
    3. GIve read or full access to dashboard folder.
    To set the permission , click on the object/folder bottom left you will find Permission. you set there.
    Mark if correct,
    fiaz

  • How to know the list of reports that are in usage

    Hello,
    How to know the list of reports that are in use from the last 3 months by the users on Bw server.How basis team will help me in this regard?
    Regards,
    Anand.

    Hi,
    Pl look at following tables if you need any further detailed information
    Table Name  Use of the table 
    RSZELTDIR
    Directory of the reporting component elements
    RSZELTTXT  Texts of reporting component elements 
    RSZELTXREF  Directory of query element references .
    To get a list of query elements built on that cube.filter by: OBJVERS = 'A', INFOCUBE= [stage:cubename] 
    RSRREPDIR
    Directory of all reports (Query GENUNIID) .
    To get all queries of a cube.filter by: OBJVERS = 'A', INFOCUBE= [stage:cubename] 
    RSZCOMPDIR  Directory of reporting components.
    To get query change status (version, last changed by, owner) of a cube. 
    RSZRANGE  Selection specification for an element 
    RSZSELECT
    Selection properties of an element
    RSZCOMPIC
    Assignment reuseable component <-> InfoCube 
    RSZELTPRIO  Priorities with element collisions
    RSZELTPROP  Element properties (settings)
    RSZELTATTR  Attribute selection per dimension element 
    RSZCALC  Definition of a formula element 
    RSZCEL   Query Designer: Directory of Cells 
    RSZGLOBV
    Global Variables in Reporting 
    RSZCHANGES  Change history of reporting components
    Thanks and regards

  • How to move the pages and reports from one dashboard to another

    hi all
    can please any one tel me hw to copy the reports along with pages from one dashboard to another
    Thanks

    Hi,
    Go to Administrator->Manage Presentation Catalg->Click on Group folder under which the dashboard and reports are present
    1)Create one folder and copy the reports which are present in the dashboard pages you want(reports will be under some specific folder,open and copy one after the other to the newly created folder).Do this if you want other set of same reports for new dashboard that you are creating
    2)Click on _portal and create a new folder(new dashboard)
    3)Click on dashboad that is to be copied
    4)copy the pages one after the other into new dashboard folder
    If you are not keeping new set of reports then no need to point reports in pages,if reports are placed under new folder then go to each page and pull those reports from newly created folder.
    Regards,
    Srikanth

  • HOW to download The Demo Version of Oracle JD Edwards Enterprise One 9.0,

    Dear Friends,
    Can any one tell me how to download The Demo Version of Oracle JD Edwards Enterprise One 9.0, for Practice purpose,
    if you have any links please tell me,
    and how much capacity of hard disk need to store the same.
    I am Learning the Oracle JD Edwards ERP, so that i want to Practice it in my home.
    Is it possible to work demo version with out Internet facilities?
    regards.
    AR

    user11690597 wrote:
    Thanks for the link, but not able to find JDE demo version for download.It's not quite as simple as 'click the download' button. You gotta get the infrastructure in place.
    As recommended, go to http://edelivery.oracle.com , click on Continue, fill the legal page, select JD Edwards for your OS, and start downloading. I would probably start and stop with the Installation document, since that likely has information such 'how much of the 60GB download is really required'.
    In the Oracle world, learning and practicing starts with reading.

  • How to get the query result of improvement (Before and After ) using sql de

    how to get the query result of improvement (Before and After ) using sql developer.

    Check
    http://www.oracle.com/technetwork/articles/sql/exploring-sql-developer-1637307.html

  • HT5100 How to limit the number of downloaded videos in parallel to one.i want my iPad itunesu to download only one video at once at time and when finished from downloading it to pass to the second queued one.

    How to limit the number of downloaded videos in parallel to one.i want my iPad itunesu to download only one video at once at time and when finished from downloading it to pass to the second queued one.

    @Tylerdowner: hmm.. maybe yes.. I just want to use the DOWNTHEMALL AddsOn for the saving file not the default download.. because my costumer download MP3 files and save it 3 or more files at a time so my Internet Connection goes down :( so I just want to limit them to save 1 file at a time.
    or if there is another way to limit it to 1.. please tell me :(

  • Could somebody teach me how to set the lastest iTunes so that it repeats just one of the numbers installed from the CD? I've alreadly tried it by clicking "control" and the bottom, but it doesn't work. Thank you.

    Could somebody teach me how to set the latest iTunes so that it repeats just one of the numbers installed from the CD?
    I've already given it a try by clicking "control" and the bottom item which means one item in Japanese, but it doesn't work.
    Thank you.

    You can access the repeat options if you right-click on the shuffle icon or if menus are enabled you can use
    Controls > Repeat > Off | All | One.
    Once the control is visible you can click it to switch between states as before. If the control is turned to off it disappears on the next track change. In contrast the shuffle control remains visible whenever it is appropriate. Hopefully the next release will fix this.
    The bottom one should do it.
    tt2

Maybe you are looking for