Query modification

hi
i have this query taken from the data model of report named "prepayment status report"
the rdf is APXINPSR.rdf
the query
SELECT     AID.invoice_id      C_prepay_inv_id,
     AID.distribution_line_number          C_prepay_dist_number,
     nvl(AID.prepay_amount_remaining,AID.amount) C_prepay_amount_remaining,
     AP_UTILITIES_PKG.Get_Charge_Account( AID.dist_code_combination_id,
          :P_chart_of_accounts_id, 'APXINPSR')      c_prepay_charge_account,
     PH.segment1                C_prepay_po_number,
     RSH.receipt_num               C_prepay_receipt_number
FROM      AP_INVOICES AI,
     AP_INVOICE_DISTRIBUTIONS AID,
     PO_DISTRIBUTIONS PD,
     PO_HEADERS PH,
     PO_LINES PL,
     PO_LINE_LOCATIONS PLL,
     RCV_TRANSACTIONS RTXNS,
     RCV_SHIPMENT_HEADERS RSH,
     RCV_SHIPMENT_LINES RSL
WHERE AI.INVOICE_ID = AID.INVOICE_ID
AND AID.LINE_TYPE_LOOKUP_CODE = 'ITEM'
AND AI.INVOICE_TYPE_LOOKUP_CODE = 'PREPAYMENT'
AND AI.PAYMENT_STATUS_FLAG||'' = 'Y'
AND nvl(AID.PREPAY_AMOUNT_REMAINING,AID.AMOUNT) > 0
AND nvl(AID.REVERSAL_FLAG,'N') != 'Y'
AND AID.PO_DISTRIBUTION_ID = PD.PO_DISTRIBUTION_ID (+)
AND PD.PO_HEADER_ID = PH.PO_HEADER_ID (+)
AND PD.LINE_LOCATION_ID = PLL.LINE_LOCATION_ID (+)
AND PLL.PO_LINE_ID = PL.PO_LINE_ID (+)
AND AID.RCV_TRANSACTION_ID = RTXNS.TRANSACTION_ID (+)
AND RTXNS.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID (+)
AND RSL.SHIPMENT_HEADER_ID = RSH.SHIPMENT_HEADER_ID (+)
AND :P_prepayment_dist_flag = 'Y'can some on eguide me on
how to modify the c_prepay_charge_account in the query so output doesnt get affected , i need it in olap report so i have to get rid of the bind parameters
what do i replace :P_chart_of_accounts_id with
if i comment AND :P_prepayment_dist_flag = 'Y' will the output differ or what do i have to relace it with
both the bind parametes are specified in user parameters but no values mentioned
the code of the function
FUNCTION get_charge_account
                          ( p_ccid                 IN  NUMBER,
                            p_chart_of_accounts_id IN  NUMBER,
                            p_calling_sequence     IN  VARCHAR2)
RETURN VARCHAR2 IS
    current_calling_sequence        VARCHAR2(2000);
    debug_info                      VARCHAR2(500);
    l_return_val                    VARCHAR2(2000);
BEGIN
    -- Update the calling sequence
    current_calling_sequence := 'AP_UTILITIES_PKG.get_charge_account<-'||p_calling_sequence;
    debug_info := 'Calling fnd function to validate ccid';
      if p_ccid <> -1 then
            l_return_val := FND_FLEX_EXT.GET_SEGS(
                               APPLICATION_SHORT_NAME => 'SQLGL',
                               KEY_FLEX_CODE          => 'GL#',
                               STRUCTURE_NUMBER       => P_CHART_OF_ACCOUNTS_ID,
                               COMBINATION_ID         => P_CCID);
       else
  l_return_val := null;
     end if;
                return (l_return_val);
EXCEPTION
WHEN OTHERS THEN
    if (SQLCODE <> -20001) then
        FND_MESSAGE.SET_NAME('SQLAP', 'AP_DEBUG');
        FND_MESSAGE.SET_TOKEN('ERROR', SQLERRM);
        FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', current_calling_sequence);
        FND_MESSAGE.SET_TOKEN('DEBUG_INFO', debug_info);
    end if;
        return NULL;
END get_charge_account;kindly guide me
kindly help me
Edited by: makdutakdu on Jul 4, 2010 2:19 PM

hi
for get_segments
FUNCTION get_segments(application_short_name      IN  VARCHAR2,
               key_flex_code            IN  VARCHAR2,
               structure_number     IN  NUMBER,
               combination_id            IN  NUMBER,
               concat_segment_values     OUT VARCHAR2)
                                   RETURN BOOLEAN IS
    n_segs_out     NUMBER;
    segs_out     SegmentArray;
    catvals_out VARCHAR2(2000);
  BEGIN
     init_message;
--  Call version that returns segments in array, then concatenate them.
    if(get_segments(application_short_name, key_flex_code, structure_number,
               combination_id, n_segs_out, segs_out) and
       concat_segs(n_segs_out, segs_out, delim, catvals_out)) then
       return(output_string(catvals_out, concat_segment_values));
    end if;
    set_failed;
    return(FALSE);
  EXCEPTION
    WHEN OTHERS then
      FND_MESSAGE.set_name('FND', 'FLEX-SSV EXCEPTION');
      FND_MESSAGE.set_token('MSG', 'get_segments() exception:  ' || SQLERRM);
      set_failed;
      return(FALSE);
  END get_segments;set_name and set_Token
    procedure SET_NAME(APPLICATION in varchar2, NAME in varchar2) is
    begin
        MSGAPP  := APPLICATION;
        MSGNAME := NAME;
        MSGDATA := '';
        FND_LOG_MODULE := DEFAULT_FND_LOG_MODULE;
        MSGSET  := TRUE;
    end;
    **  ### OVERLOADED (new private version) ###
    **     SET_TOKEN - define a message token with a value
    **  Private:  This procedure is only to be called by the ATG
    **            not for external use
    **  Arguments:
    **   token    - message token
    **   value    - value to substitute for token
    **   ttype    - type of token substitution:
    **                 'Y' translated, or "Yes, translated"
    **                 'N' constant, or "No, not translated"
    **                 'S' SQL query
    procedure SET_TOKEN(TOKEN in varchar2,
                        VALUE in varchar2,
                        TTYPE in varchar2 default 'N') is
    tok_type varchar2(1);
    begin
        if ( TTYPE not in ('Y','N','S')) then
           tok_type := 'N';
        else
           tok_type := TTYPE;
        end if;
        /* Note that we are intentionally using chr(0) rather than */
        /* FND_GLOBAL.LOCAL_CHR() for a performance bug (982909) */
     /* 3722358 - replace chr(0) in VALUE with spaces */
        MSGDATA := MSGDATA||tok_type||chr(0)||TOKEN||chr(0)||
                   replace(VALUE,chr(0),' ')||chr(0);
    end set_token;
    **  ### OVERLOADED (original version) ###
    **     SET_TOKEN - define a message token with a value,
    **              either constant or translated
    **  Public:  This procedure to be used by all
    procedure SET_TOKEN(TOKEN in varchar2,
                        VALUE in varchar2,
                        TRANSLATE in boolean default false) is
    TTYPE varchar2(1);
    begin
        if TRANSLATE then
            TTYPE := 'Y';
        else
            TTYPE := 'N';
        end if;
        SET_TOKEN(TOKEN, VALUE, TTYPE);
    end set_token;
    ** SET_TOKEN_SQL - define a message token with a SQL query value
    ** Description:
    **   Like SET_TOKEN, except here the value is a SQL statement which
    **   returns a single varchar2 value.  (e.g. A translated concurrent
    **   manager name.)  This statement is run when the message text is
    **   resolved, and the result is used in the token substitution.
    ** Arguments:
    **   token - Token name
    **   value - Token value.  A SQL statement
    procedure SET_TOKEN_SQL (TOKEN in varchar2,
                             VALUE in varchar2) is
    TTYPE  varchar2(1) := 'S';  -- SQL Query
    begin
        SET_TOKEN(TOKEN, VALUE, TTYPE );
    end set_token_sql;kindly guide

Similar Messages

  • Query modification problem after Business Content upgrade

    Hi,
    We have upgraded two systems from Business Content 3.1 to BC3.3. After the upgrade we have a problem when opening queries for modification: a dialogue window is opened and system says:
    "<i>AUTOMATIC CORRECTION
    The following objects were not found when accessing server
    Press 'Repair' to correct the problem (incorrect parts of the query are automatically deleted)
    Press 'Cancel' to undo the last action
    Missing objects:
    - InfoObjects
    |  |- InfoObject 0HIER_VERS
    - Affected Items
       |- Hierarchy version</i>"
    Strange thing is that the problem cannot be reproduced on consultants' laptops, only on clients' PC-s, so we believe there must be something about Windows/Excel security that produces the error message.
    Have you ever experienced this (kind of) problem before? Do you have any idea what I should check?
    I checked
         - Macro security settings in MS Excel,
         - logged on to the PC's as Administrator
         - logged on to BW with clients'/consultants' user ID's on clients'/consultants' PC's, problem appeared only on client PC-s
         - SAP GUI version (it is the same)
         - MS Excel, MS Windows version (the same)
    I have also checked InfoObject 0HIER_VERS, it really does not exist in the system. But it does not exist in our Production system either, while the query is completely the same in both systems.
    0HIER_VERS is a "technical attribute" (as I read in an SAP documentation - however, I don't really understand this term), it is attached to 0CS_GROUP (Consolidation group).
    Thanks,
    Csaba

    Hi,
    Before checking that did u acvtivate and update all the datasources at the source system level.
    Thanks
    sampath

  • Metadata Extraction query modification

    Hi,
    I have extracted metadata in Parent child format by doing some modifications through the query provided on following link
    http://camerons-blog-for-essbase-hackers.blogspot.com/2011/09/stupid-planning-queries-5-dimension.html
    Now i want output in form:
    In 1st column gen1, in second column its children(means gen2).
    Gen1 Gen2 Gen3 Gen4 Alias Operator
    Region-Fm               +
    Can-Reg               +
    A               +
    A1          +
    A2          +
    A3     
    A4          -
    A5          -
    B               
    B1          +
    B2          -
                   B3          +
                   B4          -
         Nam-Reg                    
              C               
                   C1          
                   C2          
    I want Each generation in seperate column.
    Can you please help me in modifying the same query as m unable to do it.
    Edited by: 962794 on 24 Oct, 2012 8:23 PM

    Check out Gary Crisci's blog post on this very subject:
    http://garycris.blogspot.com/2011/02/sql-queries-for-essbase-developers.html
    Search for "Using a basic Parent/Child table going to Generations would look like this" in his post.
    Regards,
    Cameron Lackpour

  • InfoSet Query modification error

    Hi,
    I am trying to modify a InfoSet Query in SQ01 developed by a SD consultant last time. I already assigned my user ID in the User Group (in SQ03) which is referred by this Query. At the same time, I also assigned the Change Authorization to my ID.
    After that, I modified this InfoSet in the SQ02 to add on 1 table and the Save is successful. Then I try to modify the display layout of the Query in SQ01. When I save it, it give me a message "The query is locked for changes by SDUSER". The ID SDUSER is used by the SD consultant last time. Then the modification is not saved.
    I already checked in AL08 and also SM04, and found that this user is not log in at that time.
    I already done whatever I know to try to solve this problem but I still can't settle it. Can anyone please help me on this? Why can this happen? How can I unlock it?
    Thank you.

    Hi,
    the lock was made by SDUSER when he created the querie. It's an option in the first screen "Title, Format" (specials attributes). When this option is select, only the specific user can change the query (sometimes some modifications are allowed by other user's in specific conditions).
    The only way of resolving the problem, is the SDUSER to disable that option from there. After that you will be able to change it.
    If that user doesn't exists, you must call the Basis team to create the user again, log on, and change the option.
    Regards,

  • Need to do Query Modifications

    Hi
    I am doing one report daywise production in that i am getting different values in below cases.
    1. if i comment transaction date in group by getting quantity is differ.
    2. when i commented or uncommented there is no diff. in quantity
    --and bd.department_code<>'OSP'
    3. if i use and bd.department_code='OSP' only this
    i am getting some quantity..
    select sum(a.Quantity_LLST/1000)--,to_char(a.transaction_date,'DD')
    from
    (select nvl((mmt.primary_quantity),0) Quantity_LLST
    , trunc(mmt.transaction_date) transaction_date
    from mtl_material_transactions mmt
    , mtl_system_items_b msi
    , wip_discrete_jobs wd
    , wip_operations wo
    , bom_departments bd
    where 1=1
    and mmt.organization_id=nvl(:P_ORG_ID,mmt.organization_id)
    and mmt.transaction_type_id=44
    and msi.inventory_item_id=wd.primary_item_id
    and msi.organization_id=wd.organization_id
    and wd.wip_entity_id=wo.wip_entity_id
    and wd.organization_id=wo.organization_id
    and wo.department_id=bd.department_id
    and wo.organization_id=bd.organization_id
    --and bd.department_code!='OSP'
    and msi.segment1 like 'FG%LL%'
    and mmt.inventory_item_id=msi.inventory_item_id
    and mmt.organization_id=msi.organization_id
    and trunc(mmt.transaction_date) between nvl(:P_FROM_DATE, trunc(mmt.transaction_date)) and nvl(:P_TO_DATE, trunc(mmt.transaction_date))
    group by mmt.primary_quantity,trunc(mmt.transaction_date) )a
    --group by to_char(a.transaction_date,'DD')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    You really didn't say what you want. If you get different results when you remove different parts of your original query, it is not unusual.
    What do you want in the first place? Your subject says you need to modify the query, what is the modification you want us to suggest when you have already commented out many parts of your code.
    Cheers
    Sarma.

  • Infoset Query Modification Suggestion

    I'm new to ABAP Infoset and logical database, and need your help.
      I have a query running based on Infoset Z_FI_CHILE_XX(same copy from /SAPQUERY/FI_CHILE_PERU) and logical database SDF. Now I'm trying to modify the selection screen, for example: get rid of 'Fiscal year' and 'Period', and adding 'Posting data' criteria.
      As I can see so far, 'Fiscal year' critieria is from logical database SDF, and 'Period' was adding in Infoset. Please give me some suggestion, should we modified logical database, or you have better solution?
      Also do you have better documentation on how to modify the selection criteria in infoset rather than SAP library?
      Thanks a lot!

    Thanks for all help from you.
      I realised that my problem actually can not be just simply solved by modify the selection screen, since I need selection some periods from one fiscal year, then get some periods from another fiscal year, which two part of periods are not the same. Also I need the sum the total from all the periods that I selected, instead of list them in report.
      My solution is modified the code behind the infoset to control selection in different periods for different fiscal year, then adding the subtotal total section in infoset Query, finally use a menu function(total drilldown) to leave only subtotal sections in report.
      Thanks anyway, if you think there has better solution, please feel free to let me know. I would like to learn from you.

  • Main Query modification result Report builder crash [Solved]

    Hi,
    I want to modify main Query of report builder because (it shows two columns which are not generated by query and when I run report it raises error that columns not found) but when I modify the query it result in report builder crash, plz give me any solution, I had experience same issue a month ago and I created new query with all formula columns but this time I have too much CF and CP columns is there any way to drop it from one group to another.
    Thanks and Regards, Khawar.
    Details:
    OS windows XP/2000
    Report Builder 10.1.2.0.2
    ORACLE Server Release 10.1.0.4.2
    Oracle Procedure Builder 10.1.2.0.2
    Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
    Oracle CORE     10.1.0.4.0     Production
    Oracle Tools Integration Services 10.1.2.0.2
    Oracle Tools Common Area 10.1.2.0.2
    Oracle Toolkit 2 for Windows 32-bit platforms 10.1.2.0.2
    Resource Object Store 10.1.2.0.2
    Oracle Help 10.1.2.0.2
    Oracle Sqlmgr 10.1.2.0.2
    Oracle Query Builder 10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle ZRC 10.1.2.0.2
    Oracle XML Developers Kit 10.1.0.4.2 - Production
    Oracle Virtual Graphics System 10.1.2.0.2
    Oracle Image 10.1.2.0.2
    Oracle Multimedia Widget 10.1.2.0.2
    Oracle Tools GUI Utilities 10.1.2.0.2
    Message was edited by:
    S. Khawar

    Hi,
    I saved the report in JSP format and did the required change and it works great.
    Regards, Khawar.

  • SELECT query modification

    step-1 select * from t1 --has one column c1 number
    step-2 select * from t2 --has two columns c1 number, c2 number (FK of t1.c1), c3 number (FK of t3.c1)
    step-3 select * from t3 --has two columns c1 number, c2 varchar2
    step-4 SELECT t1.*,t2.*,t3.*,
                  ROW_NUMBER() OVER ( ORDER BY t3.c2 ASC
                                            ) RowNumber
              FROM t1
                    LEFT JOIN t2 ON t2.c2=t1.c1
                    LEFT JOIN t3 ON t3.c1 = t2.c3
    step-1
    c1
    101
    102
    103
    104
    105
    step-2
    c1     c2     c3
    1     101     1
    2     102     2
    3     103     0
    step-3
    c1     c2
    0     c
    1     b
    2     a
    step-4
    c1     c1     c2     c3     c1     c2     RowNumber
    104     NULL     NULL     NULL     NULL     NULL     1
    105     NULL     NULL     NULL     NULL     NULL     2
    102     2     102     2     2     a     3
    101     1     101     1     1     b     4
    103     3     103     0     0     c     5
    --In above step-4 you will notice that column c2(near RowNumber column) has NULL value. This is because that the record is present in t1 table but it is missing in detail(t2) table. Here I am trying to sort the records on c2 column of t3 table, which is of varchar type. I want to set the default value of column c2 (near RowNumber column) to 'c' and then perform the sorting.
    --the expected output is:
    c1     c1     c2     c3     c1     c2     RowNumber
    102     2     102     2     2     a     1
    101     1     101     1     1     b     2
    103     3     103     0     0     c     3
    104     NULL     NULL     NULL     NULL     c<--     4
    105     NULL     NULL     NULL     NULL     c<--     5
    --notice the last two row having '<--'
    --how can i achieve this by modifying above step-4 query?

    Please find the below given script.
    CREATE TABLE T1
      C1 NUMBER NOT NULL
    CREATE TABLE T2
      C1 NUMBER NOT NULL,
      C2 NUMBER NOT NULL,
      C3 NUMBER NOT NULL
    CREATE TABLE T3
      C1 NUMBER NOT NULL,
      C2 VARCHAR2(20) NOT NULL
    INSERT INTO T1 (C1) VALUES ('101');
    INSERT INTO T1 (C1) VALUES ('102');
    INSERT INTO T1 (C1) VALUES ('103');
    INSERT INTO T1 (C1) VALUES ('104');
    INSERT INTO T1 (C1) VALUES ('105');
    INSERT INTO T2 (C1, C2, C3) VALUES ('1', '101', '1');
    INSERT INTO T2 (C1, C2, C3) VALUES ('2', '102', '2');
    INSERT INTO T2 (C1, C2, C3) VALUES ('3', '103', '0');
    INSERT INTO T3 (C1, C2) VALUES ('0', 'c');
    INSERT INTO T3 (C1, C2) VALUES ('1', 'b');
    INSERT INTO T3 (C1, C2) VALUES ('2', 'a');--for simplicity i have not created constraints.
    Thanks,
    Jigs

  • SQL Query Modification

    Hi ,
    I have created a SQL query using SQVI.
    But I need to write some additional conditions in the logic which are not possible through SQVI / SQ01.
    Therefore I am wondering ......
    if we have some functionality where we can add my own logic/conditions in the SQL program generated by Std SAP.
    Also I would appreciate if you could let me know the difference between SQVI and SQ01 and how to conver a SQL query to transaction code.
    Regards
    Shrey

    Thx for your reply .... but I am some different query.
    I have created a SQL query using SQVI.
    The purpose of this query was to extract data from two tables.The query is working fine , till the time linked data is available is both tables
    I am giving below example to explain my problem. I have two tables A and B with below fields
    Table A
          S.No
          Student Name
         Class
    Table B
          S.No
          Teacher name
          Education
    both the tables are are linked thru common S.No field in my query and I am extracting data fields ,
    S.No | Student Name| Class | Teacher Name
    My Query is working fine till the time data record of respective S.No is available in both the tables. But there are cases when data is only available in TABLE A, such cases are not being extract through my SQL query.
    Therefore i wanted to change the PROGRAM of my SQL query so that system should extract the data even when data is available in ONE TABLE only.
    Therefore , is it possible to change the program generated by SAP through my SQL Query (SQVI) or this can only be achieved through a T.Code ?
    If It is possible thru SQVI , then how should be proceed ?
    Sorry for asking such a foolish query.
    Regards
    Shrey

  • Query Modification in Quality Systems.

    Hi Gurus,
    I have very complex Query in Quality .. Production.
    1) I have created one RKF directly in Quality with out techical name
    2) I have created one formula directly in Quality with out techical name
    3) Hidden some RKF in Query Properties in Quality Directly.
    I know what changes i made . Next when i am transporting Do i face any issue.
    Since it is very very complex Query, i do not want to take a chance.
    1) shall i delete the RKF & Formula, unhide the RKF  that i created in Quality
    and recreate it in Dev and transport it to Quality then to Production.
    2) Or Can i create the same RKF ,Formula , hide the RKF which is presently
    hidden in Quality and transport it with out deleting the above in Quality.
    What is the best way to make the next transport successful.
    Advance thanks
    Magge

    HI ,
    Thanks for reply.
    I know it's not a best Practice. But There was no proper data in Dev to test . So that's why
    i changed directly in Quality BWQ Environment.
    I do not have that flexibility to transport back from BWQ to dev and Production. .
    As per MKR, I can change the Query in Dev and transport it to Quality then Production.
    That does not work .It will create duplicate elements.Checked with Arun 's blog.
    Any other suggestions are welcome.
    How about deleting those which are created in QUality and create them back in Dev and transport.
    My concern is transport might fail. Any suggestions.
    thanks
    Magge

  • Query Modification 2

    Hello All --
    We use the below Query and would like to change the BT Address to show just the address -- not the City, State, Zip and Country.  Help?!  Thanks -- Mike
    SELECT 'Invoice' "Invoice/AR CM", T0.CardCode
    "BP Code", T0.CardName 'Company',
    T0.Address 'BT Address', T2.City 'BT City', T2.State1 'BT State', T2.ZipCode 'BT Zip',
    T2.Phone1 'BT Phone', T0.Address2 'ST Address',
    T3.Name, T0.DocDate,T0.DocNum,
    T0.DocTotal 'Gross Amt', T0.TotalExpns 'Freight/Svc Charge',
    (T0.DocTotal - T0.VatSum-T0.TotalExpns) 'Net Order',
    T1.SlpName 'Sales Rep',
    T1.Commission '% Commision',
    ((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(T1.Commission/100))
    'Commission Amount', T4.GroupName 'Group'
    FROM dbo.OINV T0 LEFT JOIN dbo.OSLP T1 ON T0.SlpCode = T1.SlpCode
    LEFT JOIN dbo.OCRD T2 ON T0.CardCode = T2.CardCode
    LEFT JOIN dbo.OCPR T3 ON T0.CntctCode = T3.CntctCode
    LEFT JOIN dbo.OCRG T4 ON T4.GroupCode = T2.GroupCode
    WHERE (T1.SlpName BETWEEN '[%0]' and '[%1]') AND
    (T0.DocDate BETWEEN '[%2]' AND '[%3]')
    UNION ALL
    SELECT 'Credit Memo' "Credit", T0.CardCode, T0.CardName,
    T0.Address, T2.City, T2.State1, T2.ZipCode, T2.Phone1,T0.Address2,
    T3.Name, T0.DocDate,T0.DocNum,
    -T0.DocTotal, -T0.TotalExpns,
    -(T0.DocTotal - T0.VatSum-T0.TotalExpns),
    T1.SlpName,
    T1.Commission,
    ((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(-T1.Commission/100)),
    T4.GroupName 'Group'
    FROM dbo.ORIN T0 LEFT JOIN dbo.OSLP T1 ON T0.SlpCode = T1.SlpCode
    LEFT JOIN dbo.OCRD T2 ON T0.CardCode = T2.CardCode
    LEFT JOIN dbo.OCPR T3 ON T0.CntctCode = T3.CntctCode
    LEFT JOIN dbo.OCRG T4 ON T4.GroupCode = T2.GroupCode
    WHERE (T1.SlpName BETWEEN '[%0]' and '[%1]') AND
    (T0.DocDate BETWEEN '[%2]' AND '[%3]')

    Hi Mike,
    you wrote or use such a complicated query, but u re not able to change a easy select? U should understand what u are doing there!
    Well, here we go, i tried this query and it works :
    SELECT 'Invoice' "Invoice/AR CM", T0.CardCode
    "BP Code", T0.CardName 'Company',
    T0.Address 'BT Address',
    T2.Phone1 'BT Phone', T0.Address2 'ST Address',
    T3.Name, T0.DocDate,T0.DocNum,
    T0.DocTotal 'Gross Amt', T0.TotalExpns 'Freight/Svc Charge',
    (T0.DocTotal - T0.VatSum-T0.TotalExpns) 'Net Order',
    T1.SlpName 'Sales Rep',
    T1.Commission '% Commision',
    ((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(T1.Commission/100))
    'Commission Amount', T4.GroupName 'Group'
    FROM dbo.OINV T0 LEFT JOIN dbo.OSLP T1 ON T0.SlpCode = T1.SlpCode
    LEFT JOIN dbo.OCRD T2 ON T0.CardCode = T2.CardCode
    LEFT JOIN dbo.OCPR T3 ON T0.CntctCode = T3.CntctCode
    LEFT JOIN dbo.OCRG T4 ON T4.GroupCode = T2.GroupCode
    WHERE (T1.SlpName BETWEEN '%0' and '%1') AND
    (T0.DocDate BETWEEN '%2' AND '%3')
    UNION ALL
    SELECT 'Credit Memo' "Credit", T0.CardCode, T0.CardName,
    T0.Address, T2.Phone1,T0.Address2,
    T3.Name, T0.DocDate,T0.DocNum,
    -T0.DocTotal, -T0.TotalExpns,
    -(T0.DocTotal - T0.VatSum-T0.TotalExpns),
    T1.SlpName,
    T1.Commission,
    ((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(-T1.Commission/100)),
    T4.GroupName 'Group'
    FROM dbo.ORIN T0 LEFT JOIN dbo.OSLP T1 ON T0.SlpCode = T1.SlpCode
    LEFT JOIN dbo.OCRD T2 ON T0.CardCode = T2.CardCode
    LEFT JOIN dbo.OCPR T3 ON T0.CntctCode = T3.CntctCode
    LEFT JOIN dbo.OCRG T4 ON T4.GroupCode = T2.GroupCode
    WHERE (T1.SlpName BETWEEN '%0' and '%1') AND
    (T0.DocDate BETWEEN '%2' AND '%3')
    regards

  • Query Modification for Invoice Outstanding

    Hi ,
    Can anybody modify this code by DocNum. This query displays the same invoice 2 times when the invoice is having more than 1 item. How to get the report without invoice number repeat.
    SELECT T0.[DocNum], T0.[DocDate], T0.[CardName], T1.[OpenSum] ,T1.[VatSum],
    T0.WTSum AS 'TDS Amount',
    T0.DocTotal,
    (T0.DocTotal-T0.[PaidToDate]) as 'BalanceDue',
    (SELECT CASE
    WHEN T1.TargetType='14' THEN 'A/R CreditMemo'
    Else ' '
    End) as 'Target Type'
    FROM OINV T0  INNER JOIN INV1 T1 ON
    T0.DocEntry = T1.DocEntry 
    WHERE T0.[DocDate] BETWEEN '[%0]' AND '[%1]' 
    Regards
    Srini

    Hi Srini,
    Try this first:
    SELECT T0.DocNum, T0.DocDate, T0.CardName, SUM(T1.OpenSum) 'Open Sum',SUM(T1.VatSum) 'Vat Sum',
    T0.WTSum AS 'TDS Amount',
    T0.DocTotal,
    (T0.DocTotal-T0.PaidToDate) as 'BalanceDue'
    FROM OINV T0 INNER JOIN INV1 T1 ON
    T0.DocEntry = T1.DocEntry
    WHERE T0.DocDate BETWEEN '[%0\]' AND '[%1\]'
    GROUP BY T0.DocNum, T0.DocDate, T0.CardName,
    T0.WTSum,
    T0.DocTotal,T0.PaidToDate
    Thanks,
    Gordon

  • PLSQL Query modification

    Following query is returning the records as below:
    SELECT
      A.CHEQUE_CODE AS COL1, 
      A.ACC_ADD_REF AS COL2
    FROM CTSCHEQUEBOOK A, BRANCHES B, CTSCHEQUEBOOK_DESIGN C
    WHERE A.COMP_CODE = 1
    AND A.COMP_CODE = B.COMP_CODE
    AND A.BRANCH_CODE = B.BRANCH_CODE
    AND A.COMP_CODE = C.COMP_CODE
    AND A.CHEQUE_CODE = C.CODE
    ORDER BY 1
    COL1 COL2
    1     01616005034001
    1     01616005034001
    1     01616005128001
    2     01616005197001
    2     01616005197001
    3      01616005144001
    3     01616005144001
    3     01616005144001I want to display the records like only in column but group on COL1:
    1
    01616005034001
    01616005034001
    01616005128001
    2
    01616005197001
    01616005197001
    3
    01616005144001
    01616005144001
    01616005144001How can I do this with my query?

    I tried your query :
    WITH DATA AS
      (SELECT TO_CHAR(A.CHEQUE_CODE) AS COL1,
        A.ACC_ADD_REF       AS COL2
      FROM CTSCHEQUEBOOK A,
        BRANCHES B,
        CTSCHEQUEBOOK_DESIGN C
      WHERE A.COMP_CODE = 1
      AND A.COMP_CODE   = B.COMP_CODE
      AND A.BRANCH_CODE = B.BRANCH_CODE
      AND A.COMP_CODE   = C.COMP_CODE
      AND A.CHEQUE_CODE = C.CODE
      ORDER BY 1
    SELECT (
      CASE
        WHEN RN IS NULL
        THEN COL1
        ELSE COL2
      END) COL1
    FROM
      (SELECT ROWNUM RN,
        COL1,
        COL2,
        COUNT(COL2)
      FROM DATA
      GROUP BY CUBE(ROWNUM),
        COL1,
        COL2
      );But it is repeating values like following:
    1
    01616005034001
    01616005034001
    01616005034001
    01616005034001
    01616005034001
    1
    01616005128001
    01616005128001
    01616005128001
    01616005128001
    01616005128001
    01616005128001
    01616005128001
    2
    01616005197001
    01616005197001
    3
    01616005089001
    3
    01616005144001
    01616005144001
    01616005144001

  • RE : user group(sq01) -- query modification

    Hi All,
    when i am trying to execute the query called ZTIMES in the user group SQ01 it is navigating the screen to selection-screen with some inputs to be given here on the selection screen company code is mandatory as an input.So, i want to set default value for the company code as 1000 in the selection screen while i am executing.
    Thanks
    Raju M

    Hi Anitha,
    How to Enhance the Standard Report? :
    When I am trying to execute the query called ZTIMES in the user group SQ01 it is navigating the screen to selection-screen with some inputs to be given here on the selection screen company code is mandatory as an input. The company code field is having the search help and it is fetching the values for the company code from table called PROJ  Table (Project definition Table).But I want the company code should fetch the value from the  PRPS Table ( Work break structure(WBS Element) Level).
    Tables used are PROJ and PRPS.
    The company code in PROJ is PROJ-VBUKR
                                    In PRPS is PRPS-PBUKR
    In the coding part related to that selection screen I have to replace PROJ-VBUKR with
    PRPS-PBUKR.But it is standard report to enhance.
    What is suggestible solution for this issue?
    Thanks,
    Raju M.

  • Query Authorization for acessing , modification

    Hai
    I created the InfoCube and Query . I want give query auhtorization and query access and query modifications to some superusers.
    How can i give tht authorization to superuser. Pls tell me in step-by-step.
    I will assing th points
    kumar

    Hi,
    You have to provide authorization for The Query & Cube.
    1. Add the query/Workbook to the role in PFCG.
    2. Create/ Assign Authorization profile.
    3. Assign Authorization objects S_RS_COMP & S_RS_COMP1
    4. Provide desired authorization for Diaplsy,Execute etc.
    Regards
    SS

Maybe you are looking for

  • Hyperlinks not working in PDF created from Word

    I have created a Word document containing hyperlinks but when I print it to a PDF file (using Acrobat 7.0.9 on Windows Server 2003), the hyperlinks look OK in the PDF file but nothing happens when I click on them. In Acrobat, under Edit > Preferences

  • How do you know what's in your sharing queue?

    I've got 10+ videos in my upload to youtube queue In the background task list, all I see is youtube upload Details are only given when a file is processed Let's say i want to cancel one of the video uploads, how do I know which one in the queue?? Tha

  • JCA and Sun Connector tool

    I am trying to find the sun connector tool to develop connectors and I do not seem to find it. Any hints? thanks a lot!

  • My hp elitebook 6930p shows BIOS error on starting

    my hp elitebook 6930p shows BIOS error on starting

  • Is 219mhz bug fixed or not?

    i was wondering whether msi has fixed the 219mhz bug because i'm obviously experiencing it. have they fixed it with a newer bios version or i shouldn't bother flashing. or maybe somebody thought of a workaround of this bug before msi did. p.s. i have