Reg.write query for report

Dear Experts
I am MM consultant and I am in need of generate reports.I don't know how to get the data from two table. Pls help me
with some codings
Thanks
Rajakumar.K

Hi.....
Check this... Here Iam joining MARA and MAKT tables.....
data: begin of itab occurs 0,
      matnr like mara-matnr,             <----like this you can select no.of fields from MARA
      spras like makt-spras,             <----like this you declare ur internal table with no.of fields of MAKT table
      end of itab.    
parameters: p_matnr like mara-matnr.      <------ Later according to this material number you can display details
select p~matnr q~spras          <----with p~ you can declare no.of from MARA, but those should me mention in above ITAB , also MAKT with q~
         from
         mara as p                      <---- p is for first table fileds
         inner join                         <----- key word
         makt as q                          <----- q is for second table fields
          on p~matnr = q~matnr       <----this is for link
          into corresponding fields of table itab
          where p~matnr = p_matnr.       <------checking where condition with parameter
loop at itab.
write:/ itab-matnr,            <--------here you can display the fields which you defined in ITAB
          itab-spras.
endloop.
Also check this query....
Here you can display all the details of that tables...
data: begin of itab occurs 0,
      matnr like mara-matnr,
      spras like makt-spras,
      end of itab.
data: p_matnr like mara-matnr.
select-options: g_matnr for p_matnr.              <------First change
select p~matnr q~spras from mara as p inner join makt as q
          on p~matnr = q~matnr
          into corresponding fields of table itab
          where p~matnr in g_matnr.                   <----second change
loop at itab.
write:/ itab-matnr,
          itab-spras.
endloop.
Also check this code and get an idea about for all entries method and joining of more than two tables...
data: begin of itab occurs 0,
      matnr like mara-matnr,
      spras like makt-spras,
      end of itab.
data: begin of jtab occurs 0,
      matnr like marc-matnr,
      werks like marc-werks,
      end of jtab.
data: begin of t_out occurs 0,
      matnr like mara-matnr,
      spras like makt-spras,
      werks like marc-werks,
      end of t_out.
data: p_matnr like mara-matnr.
select-options: g_matnr for p_matnr.
select p~matnr q~spras from mara as p inner join makt as q
          on p~matnr = q~matnr
          into corresponding fields of table itab
          where p~matnr in g_matnr.
if itab[] is not initial.
  select * from marc into corresponding fields of table jtab
            for all entries in itab
            where matnr = itab-matnr.
endif.
loop at itab.
  t_out-matnr = itab-matnr.
  t_out-spras = itab-spras.
  read table jtab with key matnr = itab-matnr.
  if sy-subrc = 0.
    t_out-werks = jtab-werks.
  endif.
  append t_out.
  clear t_out.
endloop.
loop at t_out.
  write:/ t_out-matnr,
          t_out-spras,
          t_out-werks.
endloop.
All the best!!
Thanks,
Naveen.I

Similar Messages

  • Can we write query for fomatted search without from clause

    can we write query for fomatted search without from clause as below.
    SELECT (($(u_amt)*14)/100)
    here U_amt is a UDF .I want to assign this to another field .
    Rgds,
    Rajeev

    Hi Rajeev,
    You can write query for FMS without from.  That is because you can omit it when you get value from active form by default.  The grammar of it is:
    Select $[$38.u_amt.0\] * 14/100 in your case if you have item type marketing document @line level.
    From View-System Information, you can get the info you need for your FMS query at the left bottom of your screen.
    Thanks,
    Gordon

  • How to write query for this in TopLink ?

    I am doing a simple search in jsp where the search will the based on the choices chosen by user.
    I had given 3 check boxes for those choices.
    The problem is, query will be based on the choice or choices chosed by the user.
    How to write query for this in TopLink ?
    Thanks in Advance..
    Jayaganesh

    Try below solution, it is NOT best solution but might work:
    Declare @Questions TABLE (QuestionID INT, QuestionText Varchar(100))
    INSERT INTO @Questions
    VALUES (1, 'Comment'), (2, 'Score')
    DECLARE @Answers TABLE (authkey INT, QuestionID INT, questiontext VARCHAR(100), answertext VARCHAR(100))
    INSERT INTO @Answers
    VALUES (101, 1, 'comment', 'hi!!'), (101, 2, 'score', '4'), (102, 1, 'comment', 'excellent'), (102, 2, 'score', '5'), (103, 2, 'score', '6'), (104, 2, 'score', '8')
    SELECT
    A.AuthKey
    ,Q.QuestionID
    ,Q.QuestionText
    ,A.AnswerText
    FROM
    @Questions Q
    INNER JOIN @Answers A ON Q.QuestionID = A.QuestionID
    UNION
    SELECT
    A.AuthKey
    ,Q.QuestionID
    ,Q.QuestionText
    ,Null
    FROM
    @Questions Q
    CROSS JOIN @Answers A
    WHERE
    NOT EXISTS (SELECT 1 FROM @Answers SubQry WHERE SubQry.AuthKey = A.AuthKey AND SubQry.QuestionID = Q.QuestionID)
    Output
    AuthKey | QuestionID
    | QuestionText
    | AnswerText
    101 | 1 | Comment | hi!!
    101 | 2 | Score | 4
    102 | 1 | Comment | excellent
    102 | 2 | Score | 5
    103 | 1 | Comment | NULL
    103 | 2 | Score | 6
    104 | 1 | Comment | NULL
    104 | 2 | Score | 8
    Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

  • Reg. Query for UDFs.

    Hello All,
    I've created a multiple UDFs Like, Vendor Name,Vendor Address,Vendor Excise Details like ECC No,Range, Division,VAT No,CST No. in Marketing Documents.
    I want to write a query, for example if I select the Vendor Name, the vendor address and excise details should pick up automatically from that vendor master record. Please help.
    Thanks,
    Pratheeviraj.

    Dear Avijit,
    Thanks for your reply.
    I can't understand your solution.  Can you please explain me in detail?
    I'm giving the scenario in detail,
    In the marketing document 'Outgoing Excise Invoice', I've created UDFs like vendor name, vendor address, vendor excise number, etc., my requirement is the moment I select the vendor in Vendor Name UDF, the address and excise number should get populated in the respective UDFs.
    Thanks,
    Pratheeviraj

  • In Fi Hw we wll interact with Abapers and hw we wll write logic for reports

    hi every body...
    my name is ravi prasad.  i need one help.in FI....in real time as a sap FI consultant how we will interact with Abapers.and
    how we will write Logic for the Reports. please send me step by step.
    My mail id is    [email protected]
    Thank you very much.
    Awaiting for your response.

    hi,
    Please give me one example , and how we enter into tables, and how we know which table we have to use, and we will write logic.
    Ex;---if our client needs total sales commission payed by him.... if it is below 100,
    and if it above hundred....like that
    for that purpose in which place we will write logic.; i need the place where we write the logic.
    please send me tcodes and step by steps.
    Thank you very much,
    awaiting for your reply.
    my mail id is      [email protected]

  • Complex query for Reports

    Hi !!
    I have to create a report,which would be called from a form, and I require your help to code a query for a complex logic involving two tables. My application is on Oracle8i and Developer6. The table structures and their values are as below:
    Table1
    (Main-Part, Sub-Part is a composite key)
    MainPart Sub-part
    M0001 S0001
    M0001 S0002
    M0001 S0003
    M0002 S0004
    M0002 S0101
    M0002 S0909
    M0003 S1909
    Table2 (Part is a primary key)
    Part Qty-in-store qty-in-prodn qty-rejected
    M0001 10 10 10
    S0001 1 10 1
    M0003 1 1 1
    M0002 2 1 2
    S0004 3 2 5
    S0003 1 1 8
    S0002 10 11 12
    S0101 100 200 100
    The requirement is that for every fetch of the Main-Sub part pair from table1, details should be fetched from the table2. Since the Main-Sub part pair is a composite key in table1, details from Table2 should be fetched only once for a repeating Main part but as many times for the number of sub-parts. For example, although M0001 is repeated 3 times in table1, it's details should be fetched only once from table2 whereas for the sub-parts of M0001(S0001, S0002, S0003) details should be fetched from table2 for each sub-part.
    I tried a query which first fetches the details for the main-part, and in the repeating frame I put formula columns(with appropriate select stmts) for sub-parts. This approach I feel could affect performance because select statement is fired as many times as the number of formula columns.
    My report should look like this
    ============================================================
    Part qty-in-store qty-in-prodn qty-rejected
    ============================================================
    M0001 10 10 10
    S0001 1 10 1
    S0002 10 11 12
    S0003 1 1 8
    Total 22 32 31
    M0002 2 1 2
    S0004 3 2 5
    S0101 100 200 100
    Total 105 203 107
    I would like your help to know if there is another way to code a query(or queries) in report builder which will help me solve this above requirement.
    Also, is it possibe to do an Update operation on a Database Table from within a report, bcos the totals as shown above need to be updated to the table?
    Thanks in advance for the help?
    Regards,
    Ajay

    John,
    I believe this is to create the column types in BIRT. Can you open a
    bugzilla entry to look at this?
    Jason
    On 7/27/2010 10:45 AM, john mcteague wrote:
    > I have resolved this by changing config.xml in oda-jdbc.jar to use
    > policy 1 for the jConnect driver.
    >
    > Policy 2 executes the query with a maxrows of 1, gets the metadata then
    > executes the query again with the desired number of rows.
    > Does anyone know why jConnect was set to policy 2 in the first place?

  • How to write query for shuttle box

    hi
    i am creating an shuttle box on my input page and need to write a query to display the selected columns in the shuttle box..
    i have created the shuttle bottle and gave the static values in it , i can view my values but cannot understand how to give the condition which allows me to display the data
    only for selected columns ...
    Please Help

    thank you for reply..
    I am completely new to oracle apex...i think here there is a prcodure to get default values into the right side box, my question is , how do i write a query for all the items in the left side box columns when selected to right side, the data has to be displayed only for those columns...
    i am looking for syntax of the query ...
    For eg there 4 columns on the left hand side of the shuttle box
    job_id
    cluster_id
    cluster_code
    cluster_name
    and i select just job_id and cluster_id to right hand side , i need to display data associated with only these 2 columns...
    Please Help
    Edited by: user12855387 on Apr 20, 2010 11:08 AM

  • Write query for Customer recievable Report.

    *1.No concrete solution given to take project wise, bill wise. 2. Opening dues break up - project wise. Bill wise. 3. Aging days not able to select the required interval. Only standard intervals are available. 4. How to find the exact payment receivable for an customer. Pl tell me. How write a query in query generator..Sl no     V.Code     Customer Name     Project Code     Prj Type     Series     In no     Posting Date     Due Date     Future Remit     0 - 30     30 - 60     60 - 90     90 +     Total
    For getting Customer receivable Aging Reports. Its SAP B1 2005 Version.*

    Hi,
    Try this. May be this will help you.
    select OCRD.cardcode 'Supplier Code',OCRD.cardname 'Name',sysdeb 'Debit GBP',syscred 'Credit GBP',
    case JDT1.transtype
    when '-2' then 'OB'
    when '13' then 'IN'
    when '16' then 'DN'
    when '24' then 'RC'
    else 'Other'
    end 'Type',
    Ref1,
    fccurrency 'BP Currency',
    CONVERT(VARCHAR(10), refdate, 103)'Posting Date' ,
    CONVERT(VARCHAR(10), duedate, 103) 'Due Date',
    CONVERT(VARCHAR(10), taxdate, 103) 'Doc Date' ,
    CASE
    when DATEDIFF(dd,taxdate,current_timestamp) < 31
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "0-30 days",
    case when (datediff(dd,taxdate,current_timestamp) > 30
    and datediff(dd,taxdate,current_timestamp)< 61)
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "31 to 60 days",
    case when (datediff(dd,taxdate,current_timestamp) > 60
    and datediff(dd,taxdate,current_timestamp)< 91)
    then
    case
    when syscred <> 0 then syscred * - 1
    else sysdeb
    end
    end "61 to 90 days",
    CASE
    when DATEDIFF(dd,taxdate,current_timestamp) > 90
    then
    case
    when syscred  0 then syscred * - 1
    else sysdeb
    end
    end "90 + days"
    from JDT1,OCRD where JDT1.shortname = OCRD.cardcode and cardtype = 'C' and intrnmatch = '0'
    ORDER BY OCRD.CARDCODE, taxdate
    Thanks
    Pradnya

  • Query  for report to show Invoices, Payments and Discounts

    Hi All
    I am hoping someone can help me with this query.
    What the customer needs is the invoices for a specific date range, the payments applied to the invoices and the discount amount
    Eg...
    Invoice    payment   discount
    100         90              10   
    This would be easy to get from the ORCT and RCT2 tables.
    However, sometime the users add the payment on account and reconciles the invoices and a manual journal for the discounts.
    So it would be best to look at the OITR and ITR1 tables?
    This is what I have so far and it almost balances...
    I am using this query to create the report in crystal,
    To create the discount amount from the incoming payment window i said (T0.ReconSum - T3.TrsfrSum)
    I also took out the vat amount within that formula.
    With the amounts from the manual journal, i just took the amount as is.
    select T2.CardCode, T2.CardName, T0.SrcObjTyp, T0.SrcObjAbs, T0.ReconSum, T3.TrsfrSum, T4.ReconDate, T2.U_FundedNonFunded, (T5.Debit - T5.Credit), T6.PymntGroup
    from ITR1 T0
                 inner join OCRD T2 on T0.Shortname = T2.CardCode
                 left outer join ORCT T3 on T3.DocEntry = T0.SrcObjAbs  and T3.CardCode = T0.ShortName
                 inner join OITR T4 on T4.ReconNum = T0.ReconNum
                 left outer join JDT1 T5 on T5.TransId = T0.TransId and T5.ObjType = T0.SrcObjAbs and T0.ShortName = T5.ShortName
                 inner join OCTG T6 on T6.GroupNum = T2.GroupNum
                where T3.DocDate <= getdate() or T5.ContraAct = '1127331'
    the account 1127331 is the Discount GL account.
    Based on the example the Payment + discount = Invoices
    however not all the customers are balancing..
    any ideas? it looks like my query is getting only the invoices where a payment has been done. The amounts just dont seem to match.
    Thank you
    Jerusha

    hi
    I think your join with OJDT is wrong in this part : T5.ObjType = T0.SrcObjAbs
    you should write
    T5.ObjType = T0.SrcObjTyp
    (I think you don't need this part at all )
    try this:
    select T2.CardCode, T2.CardName, T0.SrcObjTyp, T0.SrcObjAbs, T0.ReconSum, T3.TrsfrSum, T4.ReconDate, T2.U_FundedNonFunded, (T5.Debit - T5.Credit), T6.PymntGroup
    from
    ITR1 T0
    inner
    join OITR T4 on T4.ReconNum = T0.ReconNum
    inner
    join OCRD T2 on T0.Shortname = T2.CardCode
    left
    outer join ORCT T3 on T3.DocEntry = T0.SrcObjAbs and T3.CardCode = T0.ShortName
    left
    outer join JDT1 T5 on T5.TransId = T0.TransId and T5.ObjType = T0.SrcObjTyp and T0.ShortName = T5.ShortName
    inner
    join OCTG T6 on T6.GroupNum = T2.GroupNum
    where
    T3.DocDate <= getdate() or T5.ContraAct =
    '1127331'
    please let me know if it works now
    shachar

  • SAP Query-for  Reporting   how to create and use it

    Hi SAP Gurus,
    i need your help. in my project, client is asking to create queries to generate reports, i am not familiar with queries, so would appreciate it if any one can guide me and tell me the procedure for writing and creating queries soon.
    also if you have any study material on steps on How to write and create queries for PP module
    thank you very much

    Hi
    Please refer below document
    http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Introduction.asp
    Also refer below
    How to Create Infoset Query (SAP Query)
    Steps on how to proceed to create a Query:
    ADHOC QUERY
    A query can be created to extract information from master records  i.e  Infotypes.  For example, by creating a query , the data relating to an employee contained in various Infotypes can be extracted.
    Proceedure :  
    Decide on  the various Infotypes we  want to make the query.  Decide on the area where we  want to query  i.e  Global area or Standard area.  Standard area is client specific and globel area will include all clients.
    Menu : HR – PM – Admn -  Information System -  Adhoc Query
    Select area standard and select the  user group already created
    Creation of new query  :  
    TC SQ03  -  Select Environment – Select Standard Area -  Enter  --  If new user group is to be created, enter name of the user group, click on create and enter necessary information and  exit after saving
    TC SQ02  -  Enter name of the Infoset – Create – enter name of Infoset -  Data source -- >  Table join by basis table – give name of table e.g  pa0000 -  Enter -  Click on insert table if we  want to include more tables – give name of table one by one and after finishing,  place cursor on the joining lines and right click to delete unwanted relationships  - check  - and go back  - field groups  -  include all table fields  - click on generate button   -  go out
    TC SQ03  -  Select user group  -   eg.  Payroll
    Infoset  - Enter name of newly created Infoset 
    Assign users and Infosets  -  Assign infosets  -  put tick on payroll  - save and go back
    TC  PAAH  -  Expand the nodes and put tick on relevant fields depending upon necessity
    Save the query  by giving the same name as infoset for easyness..
    For executing a query which is already created
    1. Go to SQ01 transaction
    2. Go to Environment menu->query areas->std areas
    3. Then choose the user group where the query is created
    4. It will display all the queries created for the group.choose the query you want to executeand click execute.
    5. will take to the initial screen
    6. Enter the required parameters and execute
    Regards
    Ranga
    Message was edited by:
            Ranganathan Srinivasamurthy

  • Select Query for Report

    Hi All
    I have a table called Agent. Each Agent processes requests.
    So accordingly Request is another table.
    Now the Agent can process the request successfully, fail or it could be
    in progress.
    So accordingly I have a status column in the Request table which can have the following values
    New - when the request is allocated to the agent
    Open- When the agent opens the request
    Action- when the agent acted upon the request
    Sold - when the agent was successful in processing the request
    Fail - when the agent could not process the request
    In the Request table there is column called requestDate which is the
    date when the Request was first inserted (i.e when its New)
    Now whenever the agent acts upon the request from the front end
    the status change is logged in a RequestLog table.
    So when the agent changes the status to Open, an entry is logged into
    RequestLog table.
    So when the agent open the request an entry in the RequestLog table
    would go with the status as open , the reference of the requestId &
    the date on which the status is changed
    Similar entries will be logged for each request when the agent acts on
    the respective requests like if its Sold then the status will be sold,
    the date of sale & the corresponding request Id will be logged into the
    RequestLog table.
    In the Request table the status will be changed to "Open" or "Sold" but the
    requestDate will not change & it will remain the date when it was inserted
    Now I want to generate a Report which shows the list of all agents within a state
    with all total number of requests they have handled, how many are in Opened status,
    how many are in Sold status & how many are in Fail status. I also have to show the
    average time(in days) it took for each agent to Open the request, make the sale or qualify it
    as Fail. This average time I want it for an agent & not request specific.
    & In the end I have to show the grand total of all the requests handled by all the agents,
    grand total of opened status requests,grand total of Sold status requests,grand total of Fail status requests as well as the total average time it took to Open ,total average time it took to sale & total average time it takes to Fail
    I have dabbled with simple SQL but not a complex report type like above. So I would need help from all you experts.
    Here is what I plan to do
    my from clause would include the Agent, Request, RequestLog table
    where Request.requestdate between <fromDate> and <toDate>
    group by agent.agentname,
    Select would have count(agent.requestid),
    Now how do i show the list of Open requests, sold requests & fail requests in different columns since all these values are in the same column.
    Also I am aware of the average fnction but I need help on how to use the same in such a scenario.
    Do post your thoughts on the same.
    Regards

    Hi All
    I have made some queries to fetch the Report data. I would want you to post your comments on the same.
    This is my first query which returns the total count of request per dealer, how much are in open, sent & dead state & total per status.
    select AGENT.COMPANY_NAME,count(REQUEST.REQUEST_ID) TOTAL ,
    sum(decode(REQUEST.status,'Open',1,0)) OPEN,
    sum(decode(REQUEST.status,'Sent',1,0)) SENT,
    sum(decode(REQUEST.status,'Dead',1,0)) DEAD
    from AGENT, REQUEST
    where
    AGENT.STATE='ACT'
    and REQUEST.REQUEST_TYPE='B'
    and REQUEST.CONFIRMATION='Y'
    and AGENT.DEALER_ID = REQUEST.DEALER_NUMBER
    group by grouping sets(AGENT.COMPANY_NAME, ())
    Then I have to retrieve the average number of days it takes to change the request to Open, average number of days it takes to change the request to Sent & average number of days it takes to change the request to Dead
    per Agent. The base date is stored in REQUEST table (request_date column) & the subsequent change of status is stored in activity_date column
    of ACTIVITY table
    Here is what I do get the average number of days it takes to change the status for the Agent
    select AGENT.COMPANY_NAME,
    avg( decode (REQUEST.status,'Open',ACTIVITY.ACTIVITY_DATE - REQUEST.REQUEST_DATE,0)) AVG_OPEN,
    avg( decode (REQUEST.status,'Sent',ACTIVITY.ACTIVITY_DATE - REQUEST.REQUEST_DATE,0)) AVG_SENT,
    avg( decode (REQUEST.status,'Dead',ACTIVITY.ACTIVITY_DATE - REQUEST.REQUEST_DATE,0)) AVG_DEAD
    from REQUEST, ACTIVITY, AGENT
    where
    AGENT.STATE='ACT'
    and REQUEST.REQUEST_TYPE='B'
    and REQUEST.CONFIRMATION='Y '
    and REQUEST.dealer_number = AGENT.DEALER_ID
    and REQUEST.STATUS = ACTIVITY.STATUS
    group by grouping sets(AGENT.COMPANY_NAME, ())
    I hope this is the right way for calculating average number of days
    Since most part of the queries is the same
    I tried to merge both the queries into one because I need to render the report in that fashion. But the moment I merge the query its giving absurd results.
    Do post your thoughts on the same
    Regards

  • Query for reporting need to be tuned

    Hi,
    I working on aoracle 10.2.0.4 on solaris platform 32 GB physical memory.This database is being used for both daily transaction and reporting purpose.One of the reporting query taking high time..
    SQL> set autotrace traceonly
    SQL> select substr(tr_ldt,4,6),tr_di,sum(tr_val) from tr_all
    2 where tr_ay_bt>='15-APR-11'
    3 group by substr(tr_ldt,4,6),tr_di
    4 order by substr(tr_ldt,4,6),tr_di;
    Execution Plan
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 1488 | 37200 | 198K|
    | 1 | SORT GROUP BY | | 1488 | 37200 | 198K|
    | 2 | TABLE ACCESS FULL| TR_ALL | 6575K| 156M| 197K|
    Statistics
    1030 recursive calls
    0 db block gets
    721737 consistent gets
    624840 physical reads
    0 redo size
    1682 bytes sent via SQL*Net to client
    514 bytes received via SQL*Net from client
    4 SQL*Net roundtrips to/from client
    23 sorts (memory)
    0 sorts (disk)
    33 rows processed
    and i have tried autometic sql tuning...
    But the result of tuning task is null. No suggestion.
    Can u tell me how can i reduce the time of execution.
    1.The wait event involved is *'db file scatter read'*.
    I have index on tr_ldt column and bitmap index on tr_di column.
    Pls suggest how to tune this query????

    See template postings:
    [url https://forums.oracle.com/forums/thread.jspa?threadID=863295]How to post a sql tuning request
    [url https://forums.oracle.com/forums/thread.jspa?messageID=1812597]When your query takes too long
    The wait event involved is 'db file scatter read'.Subject to oracle version, "db file scattered read" is the expected wait event for a FULL TABLE SCAN where the blocks are not in the buffer cache and physical IO is required.
    where tr_ay_bt>='15-APR-11'As an aside, never rely on implicit conversions, use TO_DATE('15-APR-2011','DD-MON-YYYY').
    It wouldn't make a difference to your full table scan, unless the relevant column was indexed but an implcit datatype conversion was preventing usage thereof.
    I have index on tr_ldt column and bitmap index on tr_di column.But the query restricts by TR_AY_BT.
    If this is unindexed a full table scan is pretty much inevitable.
    In the continued absence of an index, perhaps doing the work in parallel is an option?

  • Dynamic sql query for report based on user input

    Hi everyone,
    I have built custom search fields (name, date born, gender etc.) in the search region and in the results region a report need to be displayed.
    Now I'm not very experienced with Apex or Oracle sql, but could anyone telll me how to first check if a user filled in a field and then build a query based upon what field the user filled in to submit.
    Any help would be appreciated, thanks in advance.
    regards,
    Cleo
    Edited by: Cleopatra on Jan 18, 2011 5:51 AM

    Hi, Cleopatra. Welcome to OTN!
    If you don't have too many fields instead of checking to see if they're filled in you can use OR conditions in yoru WHERE_CLAUSE to check for NULLS to ignore NULLS, something like (you will have to test this carefully!)
    AND some_column = NVL(:P24_1,some_column)the idea being that if the field is NULL then the column will match itself - in this case assuming the column itself does not have a null value

  • Help with PL/SQL returning SQL query for Report

    Hi
    I have got a report which I have formatted as PL/SQL function body returning SQL query.
    I have the following code
    declare
    q VARCHAR2(32000); -- query
    w VARCHAR2(4000) ; -- where clause
    begin
    q := 'select min(identified_date) first_identified,' ||
    ' max(actual_resolution_date) last_closed,' ||
    ' count("HELPDESK_CALL_ID) total_issues,' ||
    ' from tbl_helpdesk_calls';
    if :P9_call_type != '-1' then
    w := 'HELPDESK_CALL_TYPE_ID = :P9_call_type';
    end if;
    q := q || ' WHERE '|| w;
    return q;
    end;
    When I apply changes I get this error message
    Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00972: identifier is too long
    Any Idea where I maybe going wrong?

    thanks its compiling now but when I run the page I get this error message in the reports region
    failed to parse SQL query:
    ORA-00933: SQL command not properly ended
    This is my code that I have at the momment.
    declare
    q VARCHAR2(32000); -- query
    w VARCHAR2(4000) ; -- where clause
    we VARCHAR2(1) := 'N'; -- identifies if where clause exists
    begin
    q := 'select min(identified_date) first_identified,' ||
    ' max(actual_resolution_date) last_closed,' ||
    ' count(HELPDESK_CALL_ID) total_issues,' ||
    ' sum(decode(status,''Open'',1,0)) open_issues, ' ||
    ' sum(decode(status,''On-Hold'',1,0)) onhold_issues,' ||
    ' sum(decode(status,''Closed'',1,0)) closed_issues,' ||
    ' sum(decode(status,''Open'',decode
    (priority,''High'',1,0),0)) open_high_prior,' ||
    ' sum(decode(status,''Open'',decode
    (priority,''Medium'',1,0),0)) open_medium_prior, '||
    ' sum(decode(status,''Open'',decode
    (priority,''Low'',1,0),0)) open_low_prior '||
    ' from tbl_helpdesk_calls';
    if :P9_call_type != '-1' then
    w := 'where HELPDESK_CALL_TYPE_ID = :P9_call_type';
    we := 'Y';
    end if;
    if we = 'Y' then
    q := q ||w;
    end if;
    return q;
    end;
    I have a select list with a list of reports. what I am trying to do build an sql depending on what the :p9_call_type value is. -1 represents the display value of -All Reports- so if the user selects all reports it should display all results thus removing the where clause. However as my code stands when I user clicks on all reports he get the correct results for all reports. If the user selects anything else they get the error message above.

  • Query for Report Asset By Location

    Dear All,
    I want to record asset using add on SAP. I want to make a query report that show asset per location. I'm using field U_User01 to record location of FA. The report will contain Code of FA, Name of FA, location, Acquisition value, Accum Depr and Net book value. This report will be made per period.
    Is there any one can help me to make the query ?
    Thanks a lot for your help

    Hai..is there anyone that can help me to solve this problem ? Thanks for the help

Maybe you are looking for

  • I have a new PC, and i was wondering how i can transfer the playlist  from my iPhone to the PC?

    I recently bought a new pc, because my old one was trashed. i had all the songs in a external hard drive. i put it on to my new computer but i dont want to manually put those songs back into the playlists that i had. is there a way that i can transfe

  • Scores of Duplicates in Address Book

    Somehow I have come up with scores of duplicates in my address book. Short of going through one by one, how can I eliminate the duplicates?

  • Failure accessing WMS theme

    Hi to All, I'm trying to call a WMS with mapviewer (OC4J 10g)to add a Layer to an existing map, so as i've seen from documentation i've added a new theme to my maprequest: <theme name="WMS" > <wms_getmap_request isBackgroundImage="false" > <service_u

  • Configuration Error 1 avec Acrobat Pro XI

    Bonjour, J'ai supprimé toute ma série CS6 au profit de CC et j'avais également supprimé Acrobat XI Pro pour le réinstaller car j'avais des alertes d'update pour Acrobat qui venez régulièrement me déranger alors que le cloud était à jour... Mais à ce

  • ClassCastException with Query

    This simple query gives me a ClassCastException: Extent users = pm.getExtent (User.class, false); String filter = "userid == \"test_michael\""; Query query = pm.newQuery (users, filter); Collection results = (Collection) query.execute (); From the lo