Problem in selecting a single record...

Hello experts,
How can I modify my code below in selecting only one wrbtr from table ekbe? Also, what is wrbtr and how does it relate to a certain PO? is it the balance? the PO amount? Thanks guys and take care!
CONCATENATE t_pohistory-mat_doc t_pohistory-doc_year
                INTO bkpf-awkey.
          SELECT SINGLE * FROM bkpf
                WHERE awkey = bkpf-awkey.
*AVH - removed wrbtr from selection
          SELECT augdt augbl shkzg dmbtr FROM bsak
                INTO (bsak-augdt,bsak-augbl,bsak-shkzg,
                      bsak-dmbtr)
                WHERE bukrs = bkpf-bukrs
                  AND gjahr = bkpf-gjahr
                  AND belnr = bkpf-belnr.
*AVH
            if not bsak-augbl is initial.
              select belnr gjahr from bsak
               into (bsak-belnr, bsak-gjahr)
                where bukrs = bkpf-bukrs
                 and belnr = bkpf-belnr
                 and gjahr = bkpf-gjahr.
                select awkey from bkpf
                 into v_bkpf_aw
                 where bukrs = 'GLOB'
                   and belnr = bsak-belnr
                   and gjahr = bsak-gjahr.
                  w_len = strlen( v_bkpf_aw ).
                  w_off = w_len - 4.
                  v_awkey_1 = v_bkpf_aw+0(10).
                  v_awkey_2 = v_bkpf_aw+w_off(4).
                  select wrbtr from ekbe
                    into ekbe-wrbtr
                   where belnr = v_awkey_1
                     and gjahr = v_awkey_2.
*AVH - Changed all bsak-wrbtr to ekbe-wrbtr.
                    IF bsak-shkzg = 'H'.
                      bsak-dmbtr = - bsak-dmbtr.
                      ekbe-wrbtr = - ekbe-wrbtr.
                    ENDIF.
                    IF t_pohistory-currency <> 'PHP'.
                      IF bsak-augdt GT pa_augdt.
             IF bsak-augdt IN so_augdt.
            t_amount-tramt = t_amount-tramt + ekbe-wrbtr.
                      ENDIF.
                    ELSE.
                      IF bsak-augdt GT pa_augdt.
             IF bsak-augdt IN so_augdt.
             t_amount-tramt = t_amount-tramt + bsak-dmbtr.
                      ENDIF.
                    ENDIF.
                  endselect.
                endselect.
              endselect.
            endif.
          ENDSELECT.
        ENDIF.

Hi,
I think you want total for a PO.
Write this :
data : ZWRBTR type EKBE-WRBTR.
select SUM ( wrbtr )from ekbe  into ZWRBTR           where belnr = v_awkey_1 
and gjahr = v_awkey_2.
ZWRBTR   will be the total amount of a PO means sum of all line items.
As you are using BELNR(Number of Material Document) and year then you want only one record then I think you want total PO value. The above code will retrieve total PO value.
Regards,
Lanka

Similar Messages

  • Problem with Select query fetching records.

    Hi All,
    SELECT bukrs belnr gjahr bldat cpudt aedat cputm usnam xblnr bktxt waers
                       FROM bkpf INTO TABLE bkpf_tbl
                       WHERE bukrs IN s_bukrs AND blart IN ('RE' , 'ZL')
    AND ( ( cpudt > prv_date )
                       OR    ( cpudt = prv_date AND cputm >= prv_time ) )
                       OR  ( ( aedat > prv_date )
                       OR    ( aedat = prv_date AND cputm >= prv_time ) )
                       AND gjahr IN s_gjahr
                       AND monat IN s_monat
                       AND belnr IN s_belnr
    My prv_date is 05/04/2010 while debugging.
    CPUDT (Accounting Document Entry Date) in BKPF doesnu2019t have any entries.
    But AEDAT (Date of the Last Document Change by Transaction) is having a single entry on date 05/04/2010.
    While this query is showing number of records around 200000. I feel something is wrong with the AND/OR statements.
    Please suggest some ideas?

    Hi Mishra,
    I dont know the excaly wht u r passing in the prv_date and cpudt . But one thing i notice that blart part.
    SELECT bukrs belnr gjahr bldat cpudt aedat cputm usnam xblnr bktxt waers
                       FROM bkpf INTO TABLE bkpf_tbl
                       WHERE bukrs IN s_bukrs AND blart eq  'RE' or  blart eq 'ZL'
      AND ( ( cpudt > prv_date )
                       OR    ( cpudt = prv_date AND cputm >= prv_time ) )
                       OR  ( ( aedat > prv_date )
                       OR    ( aedat = prv_date AND cputm >= prv_time ) )
                       AND gjahr IN s_gjahr
                       AND monat IN s_monat
                       AND belnr IN s_belnr.
    With Regards,
    Sumodh.P

  • Performance problem with selecting records from BSEG and KONV

    Hi,
    I am having performance problem while  selecting records from BSEG and KONV table. As these two tables have large amount of data , they are taking lot of time . Can anyone help me in improving the performance . Thanks in advance .
    Regards,
    Prashant

    Hi,
    Some steps to improve performance
    SOME STEPS USED TO IMPROVE UR PERFORMANCE:
    1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
    2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
    3. Design your Query to Use as much index fields as possible from left to right in your WHERE statement
    4. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
    5. Avoid using nested SELECT statement SELECT within LOOPs.
    6. Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
    7. Avoid using SELECT * and Select only the required fields from the table.
    8. Avoid nested loops when working with large internal tables.
    9. Use assign instead of into in LOOPs for table types with large work areas
    10. When in doubt call transaction SE30 and use the examples and check your code
    11. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table before binary search. This is a general thumb rule but typically if you are sure that the data in internal table is less than 200 entries you need not do SORT and use BINARY SEARCH since this is an overhead in performance.
    12. Use "CHECK" instead of IF/ENDIF whenever possible.
    13. Use "CASE" instead of IF/ENDIF whenever possible.
    14. Use "MOVE" with individual variable/field moves instead of "MOVE-
    CORRESPONDING" creates more coding but is more effcient.

  • Problem in selecting records

    Hi, everyone.
    I have a problem in selecting records.  In this case, I want to select records from database
    LFA1,and the components of this table are LIFNR,ERDAT,LOEVM ,and so on.The type of LIFNR is char(10).There is a internal table:tab_cdhdr , the elements of tab_cdhdr are: objectid,udate and change_ind.The type of objectid is char(50).
    And the select-rule is that: LIFNR = objectid. So I write like this:
    select   lifnr
                 erdat
                 loevm
    form     lfa1
    into       tab_lfa1
    for all entries in tab_cdhdr
    where   lfa1 = tab_cdhdr-objectid+0(10).
    But there is a warning: When using FOR ALL ENTRIES IN the specifyed length for "OBJECTID" is ignored in this condition.
    Can you help me to solve this problem?
    Thanks.

    Hi Feng..
    If you dont want to change the Internal table TAB_CDHDR, Then declare another internal table (TEMPTAB_CDHDR.) with the same structure but Objectid with only 10 chars.
    IF TAB_CDHDR[] IS NOT INITIAL.
    LOOP AT TAB_CDHDR.
    MOVE-CORRESPONDING TAB_CDHDR TO TEMPTAB_CDHDR.
    APPEND TEMPTAB_CDHDR.
    ENDLOOP.
    select lifnr
    erdat
    loevm
    form lfa1
    into tab_lfa1
    for all entries in tab_cdhdr
    where lfa1 = TEMPtab_cdhdr-objectid.
    ENDIF.
    Sure ... this will work for u.....
    REWARD IF HELPFUL.

  • Select query for single record

    hi all,
    i am working for script which is letter.
    i had to extract the fields as shown in the code. from two tables i had to extract single record. and pass this values to script.i developed the code. wen i execute the code its going to dump. can any body help me.
    TABLES : VBAK, KNA1.
    PARAMETERS : p_vbeln LIKE vbak-vbeln.
    Data : name like kna1-name1.
    Data: begin of wa_vbak ,
         vbeln(10),
           netwr(15),
           bstdk(8),
           kunnr(10),
           smenr(8),
           end of wa_vbak.
    Data: begin of wa_final,
           vbeln(10),
           netwr(15),
           bstdk(8),
           kunnr(10),
           smenr(8),
           name1(35),
           end of wa_final.
           Select single vbeln
                         netwr
                         bstdk
                         kunnr
                         smenr from vbak
                         into wa_vbak where vbeln = p_vbeln.
        If sy-subrc = 0.
           Select single name1 from kna1 into name  where kunnr  =  wa_vbak-kunnr.
        If sy-subrc = 0.
          Move wa_vbak-vbeln to wa_final-vbeln.
          Move wa_vbak-netwr to wa_final-netwr.
          Move wa_vbak-bstdk to wa_final-bstdk.
          Move wa_vbak-kunnr to wa_final-kunnr.
          Move wa_vbak-smenr to wa_final-smenr.
          Move name to wa_final-name1.
        endif.
        endif.
        write:/10 wa_final-vbeln, 20 wa_final-netwr.
    thanks
    venkat

    Hai,
    Make sure that field names(itab) are same as database tables.
    And also INTO CORRESPONDING FIELDS OF TABLE .
    The modified code is as below:
    TABLES : VBAK, KNA1.
    PARAMETERS : p_vbeln LIKE vbak-vbeln.
    Data : name like kna1-name1.
    Data: begin of wa_vbak ,
    vbeln(10),
    netwr(15),
    bstdk(8),
    kunnr(10),
    smenr(8),
    end of wa_vbak.
    Data: begin of wa_final,
    vbeln(10),
    netwr(15),
    bstdk(8),
    kunnr(10),
    smenr(8),
    name1(35),
    end of wa_final.
    Data:
      T_wa_vbak like standard table of  wa_vbak.
    Select single vbeln
    netwr
    bstdk
    kunnr
    smenr from vbak
    into <b>CORRESPONDING FIELDS OF TABLE T_</b>wa_vbak where vbeln = p_vbeln.
    If sy-subrc = 0.
    Select single name1 from kna1 into name where kunnr = wa_vbak-kunnr.
    If sy-subrc = 0.
    Move wa_vbak-vbeln to wa_final-vbeln.
    Move wa_vbak-netwr to wa_final-netwr.
    Move wa_vbak-bstdk to wa_final-bstdk.
    Move wa_vbak-kunnr to wa_final-kunnr.
    Move wa_vbak-smenr to wa_final-smenr.
    Move name to wa_final-name1.
    endif.
    endif.
    write:/10 wa_final-vbeln, 20 wa_final-netwr.
    Regards,
    Rama chary.Pammi

  • Recurrent single record Insert problems

    Hi,
    we have on production environment a Java based application that makes aprox 40.000 single record Inserts per hour into a table.
    We ha traced the performance of this Insert and the medium time is 3ms, that is ok. Our Java architecture is based in Websphere Application Server and we access to Oracle 10g through a WAS datasource.
    But we have detected that 3 or 4 times a day, during aprox 30 seconds, the Java service is not able to make any insertion in that table. And suddenly it makes all the "queued inserts" in only 1 second. That "pause" in the insertion cause problems of navigation because is the top layer there is a web application.
    We are sure that is not a problem with the WAS or the Java code. We are sure that is a problem with the Oracle configuration, or some tunning action for this kind of applications that we don´t know. We first thought it could be a problem with a sequence field in the table. Also, a problem when occurs the change of the redo log. But we've checked it with our DBA and this is not the problem.
    Has anybody any idea of what could be the origin of this extrange behaviour?
    Thanks a lot in advance.
    Jose.

    If by one single disk you mean a single physical disk then spreading the online redo lobs onto multiple disks would be a good idea. Log Group A should be on a seperate disk from Log Group B and the members of each log group should also be on seperate disks.
    Note that Oracle does not stop processing when it does a checkpoiint. Here is basically how it works. When online redo LogA fills a checkpoint is signaled and Oracle immediately starts writing to LogB. The ckeck point is processed by ckpt and dbwr.
    If logB fills and a switch to LogC occurs before the ckeckpoint signaled by the switch from LogA to LogB has completed then you get the checkpoint not complete information message. Oracle will continue processing though it has more work to do having to combine two ckeckpoints. If the problem continues then you get 3 and 4 checkpoints backed up. This will bog Oracle down as the buffer cache has to be pretty full at this point. You cannot read data unless you have a clean buffer to read into.
    The checkpoint not complete message normally means your online redo logs are too small and are filling too quickly. In the absence of Data Guard configured to use log shipping you should look to see how many log switches you are doing per day. If is is more the 24 - 48 then increase the size of the online redo logs.
    Database writer performance issues are the next area you would want to ckeck after properly sizing the online redo logs and verifying the IO performance of log writer. Pretty much all you can do to help log writer IO is put enough physical disk under the logs to spread the IO out.
    If your problem is caused by the activity level during peak periods then setting MTTR probably will not help since dbwr will be busy writing anyway.
    You really should run a statspack or AWR report to help clarify the issue.
    If you determine you are switching online redo logs too many times and increase the size take a set of statspack both before and after you make the change. This will help you see the effect on the database as a whole.
    HTH -- Mark D Powell --

  • Need single record for single period. Modify the select query.

    Requirement
    THere are 6 programs for each company for each billing period. If anyof the program for one billing period and period_balance>0 then display outstanding balance YES. if period_balance <=0 for all the programs for one period then outstanding balance=NO
    Below is the query i have used but i have to modify the query to get single record for each period whether outstandignbalance yes or no. Please help to resolve this issue. OR modify the query.
    select distinct B_Billing_key, B_COMPANY_ID company ,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) lastPaymentdate,
    SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,AMOUNT,
    (nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))"Period_Balance",
    decode(sign((nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))),1, 'Yes'
    ,'No'
    ) outstandingbalance
    p.PROGRAM_NAME_ID programname
    FROM tuff_balance_view,MV_PROG_SURCH S,MV_PAYMENT_HOLDING H,MV_PROGRAM_DICT P where
    b_company_id = 'U-7052-C'
    and B_Billing_key=s.BILLING_KEY
    and S.PROGRAM_KEY = P.PROGRAM_KEY
    and P.PROGRAM_KEY= H.PROGRAM_KEY
    GROUP BY B_Billing_key,B_COMPANY_ID,B_REPORT_PERIOD,SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,PROG_SURCH_KEY,
    S.PROGRAM_KEY,p.PROGRAM_NAME_ID,AMOUNT
    order by B_Billing_key desc
    B_Billing_key is the primary key. I am looking for the output only one record for each biling perid. there are 6 programs for each billing period. if any of the program has period balance >0 then outstanding balance should be yes. For sample i am giving 2 programs.
    Actual output from the above
    biling_key company billing period period_balance outstandingbalance programname
    123 xyz January 2011 $4 Yes ABC
    123 xyz January 2011 $-5 NO DEF
    456 xyz February 2011 $-3 NO ABC
    456 xyz February 2011 $- 2 NO DEF
    Need the output as below from the above query. Can you please help to simplify query. If anyof theprogram having outstanding balance for that particular period show the outstandigbalance as yes. Else NO.
    Expected output as below
    company billing period outstandingbalance programname
    xyz January 2011 Yes ABC
    xyz February 2011 No DEF
    Thanks,
    vi

    Hi G,
    With the same query i am gettting outs as NO for all months which is not true. can you pelase look at the following data.
    SELECT DISTINCT B_BILLING_KEY,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    B_company_id company,
    sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
    decode(sign(
    (nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
    FROM mv_program_dict P, tuff_balance_view T WHERE
    b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
    B_ORG_PI_AMOUNT,P_AMOUNT
    order by B_BILLING_KEY desc
    Actual
    Billing key Billing company periodbalance lastpayment date outs
    110631534073     November 2010     U-7052-C     270          Yes
    110631534073     November 2010     U-7052-C     690          Yes
    110631534073     November 2010     U-7052-C     66          Yes
    110461533197     October 2010     U-7052-C     4740          Yes
    110461533197     October 2010     U-7052-C     27000          Yes
    110461533197     October 2010     U-7052-C     0          No
    110251532527     September 2010     U-7052-C     0     09/13/10     No
    110251532527     September 2010     U-7052-C     0          No
    110251532527     September 2010     U-7052-C     -18     09/13/10     No
    110251532484     August 2010     U-7052-C     0     09/13/10     No
    110251532484     August 2010     U-7052-C     2001     09/13/10     Yes
    110251532484     August 2010     U-7052-C     0          No
    Expectedoutput(need only following columns)
    Billing key Billing company lastpayment date outs
    110631534073     November 2010     U-7052-C               Yes
    110461533197     October 2010     U-7052-C               Yes
    110251532527     September 2010     U-7052-C          09/13/10     No
    110251532484     August 2010     U-7052-C          09/13/10     YES
    By using below query i am getting all output as NO. HOw to modify it.
    SELECT company,
    billing,LastPaymentDate,
    CASE
    WHEN SUM (DECODE (outs, 'YES', 1, 0)) > 0 THEN 'YES'
    ELSE 'NO'
    END Outstanding
    FROM (
    SELECT DISTINCT B_BILLING_KEY,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    B_company_id company,
    sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
    decode(sign(
    (nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
    FROM mv_program_dict P, tuff_balance_view T WHERE
    b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
    B_ORG_PI_AMOUNT,P_AMOUNT
    order by B_BILLING_KEY desc)
    GROUP BY company, billing,LastPaymentDate;
    Note:in the actual out put max(lastpayment date) is returing null values. if there is any date in one billing return that date only remove null example is september. in september it should return only 09/13/10 this date not null date. but if there is no other within one biling then consider that as null example november..
    Thanks,
    v

  • Selecting single record from multiple record based on date

    Hi experts,
    I have a table which contains the multiple records for single ID No. Now i have to select single record which contains the latest date.
    here is the structure
    Name   Null Type        
    ID_P        NUMBER      
    NAME_P      VARCHAR2(12)
    DATE_P      TIMESTAMP(6)
    Records
    1 loosi     22-AUG-13 01.27.48.000000000 PM
    1 nammi  26-AUG-13 01.28.10.000000000 PM
    2 kk        22-AUG-13 01.28.26.000000000 PM
    2 thej      26-AUG-13 01.28.42.000000000 PM
    now i have to select below 2 rows how can write select qurie for this?
    1 loosi     26-AUG-13 01.27.48.000000000 PM
    2 thej      26-AUG-13 01.28.42.000000000 PM

    Hi,
    You can use the analytic ROW_NUMBER function.
    I don't have a copy of your table, so I'll use scott.emp to illustrate.  In scott.emp, there may be multiple rows for a single job.  To display just 1 row per job, the row with the most recent hiredate:
    WITH got_r_num AS
         SELECT  empno, job, deptno, hiredate -- Or whatever columns you want
         ,       ROW_NUMBER () OVER ( PARTITION BY  job
                                      ORDER BY      hiredate DESC
                                    )  AS r_num
        FROM    scott.emp
    --  WHERE ...   -- If you need any filtering put it here
    SELECT   *      -- Or list all columns except r_num
    FROM     got_r_num
    WHERE    r_num   = 1
    What results do you want in case of ties?  Depending on your requirements, you may want to add tie-breaking expressions to the analytic ORDER BY clause, and/or use RANK instead of ROW_NUMBER.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Point out where the query above is producing the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    If you modify the query at all, post your modified version.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Single record insert performance problems

    Hi,
    we have on production environment a Java based application that makes aprox 40.000 single record Inserts per hour into a table.
    We ha traced the performance of this Insert and the medium time is 3ms, that is ok. Our Java architecture is based in Websphere Application Server and we access to Oracle 10g through a WAS datasource.
    But we have detected that 3 or 4 times a day, during aprox 30 seconds, the Java service is not able to make any insertion in that table. And suddenly it makes all the "queued inserts" in only 1 second. That "pause" in the insertion cause problems of navigation because is the top layer there is a web application.
    We are sure that is not a problem with the WAS or the Java code. We are sure that is a problem with the Oracle configuration, or some tunning action for this kind of applications that we don´t know. We first thought it could be a problem with a sequence field in the table. Also, a problem when occurs the change of the redo log. But we've checked it with our DBA and this is not the problem.
    Has anybody any idea of what could be the origin of this extrange behaviour?
    Thanks a lot in advance.
    Jose.

    There are a couple of things you'd need to look at to diagnose this - As Joe says it's not really a JDBC issue from what we know.
    I've seen issues with Oracle's automatic SGA resizing causing sporadic latency in OLTP systems. Another suspect would be log file sync wait events, which are associated with commits. Don't discount the impact of well meaning people using tools like TOAD to query the DB - they can sometimes cause more harm than good.
    Right now I'd suggest you run AWR at 10 minute intervals and compare reports from when you had your problem with a time when you didn't.

  • How can I add recording time to a single recording not a series recording?

    If I set-up a series recording it allows me to add minutes to the recording time why can't I add time to a single recording? For example if I want to record a single show tomorrow I find it on the guide and hit record. Now I want to add a few minutes on the end of the show because I know it always runs over it's advertised time why can't I add the time? It doesn't gives to extra options for a single recording. The only time I can add time to a single recording is if the show is currently on then it allows me to add time but, not before the show is on. So what good does that do? Comcast allowed me to set-up extra options to a single recording.

    Actually you can.  It's a bit clumsy but what you have to do is go to the DVR menu, select scheduled reordings, select the recording you want to extend, scroll through the menu and you will find an option to modify the start / end time.
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

  • Problem with Select

    Hi All,
    I am Facing one problem in select query. My requirement is as follows.
    User Screen will Have 4 Fileds.
    Country Code, Zip Code From, Zip Code To, Delivery Area.
    All are Parameter's only.
    For Example ZTABLE having below Entries.
    US  12345-6787  12345-6789   AKRON             AKRON/CANTON
    Once User try to create new entry by Click on SAVE, Below Possiblities are there.
    Case 1: US  12345-6787  12345-6789   AKRON             AKRON/CANTON ( Error Message)
    Case 2: US  12345-6786  12345-6787   AKRON             AKRON/CANTON ( Error Message)
    Case 3: US  12345-6789  12345-6790   AKRON             AKRON/CANTON ( Error Message)
    Case 4: US  12345-6789  12345-6790   AKRON             AKRON/CANTON ( Error Message)
    Case 5: US  12345-6786  12345-6787   AKRON             AKRON/CANTON ( Error Message)
    Case 6: US  12345-6785  12345-6786   AKRON             AKRON/CANTON ( Record Need To Insert)
    Case 7: US  12345-6785  12345-6785   AKRON             AKRON/CANTON ( Record Need To Insert)
    Case 8: US  12345-6790  12345-6790   AKRON             AKRON/CANTON ( Record Need To Insert)
    Case 9: US  12345-6790  12345-6791   AKRON             AKRON/CANTON ( Record Need To Insert)
    Case 10: US  12345-6788  12345-6788   AKRON             AKRON/CANTON ( Error Message)(This Condition is Failing)
    Case 11: US  12345-6788  12345-6789   AKRON             AKRON/CANTON ( Error Message)(This Condition is Failing)
    In the above cases 10 and 11 is failing.
    I am using the below select statment.
    SELECT SINGLE * FROM zdt_sd_dlv_zcode   WHERE mandt = sy-mandt
                                              AND land1 = g_land1
                                              AND ( post_code_from GE g_pbox_from AND post_code_from LE g_pbox_to )
                                              OR ( post_code_to GE g_pbox_from AND post_code_to LE g_pbox_to ).
    Friends can anyone give me some valuable inputs to solve this problem.
    Points will reward.
    Thanks in Advance,
    Srinivas.

    Please use Select-options instead of Parameters so that you can use complex "and" and "or" in your select statements.
    for eg:if you are declaring parameters like this below.
    parameters post_code1  LIKE adrc-post_code1.
    change to
    select-options post_code1 for  adrc-post_code1 no intervals.
    siddu

  • Want to show data from current month & prev month in single record on forms?

    Hello experts,
    i have this requirement:
    Table structure:
    MOnth       Division         totalAmount
    01-apr-2013      1               10000
    01-May-2013    1               20000
    01-apr-2013      2               30000
    01-May-2013    2               50000
    i want to display in forms like
    Form:
    Month  : 01-May-2013
    Month               Division               total               prev_Month          division               total                         dIFFERENCE
    01-May-2013               1              10000                01-Apr-2013               1               20000                        10000
    01-May-2013               2              30000                01-Apr-2013               2               50000                        20000
    I am using two procedure for fetching records for current month and previous month.
    but it will cause problem, if for some division previous month data not present.
    please suggest me some query with which i can fetch current and pre month data in single record.
    Please help me out.
    Thanks
    yash

    I'M NOT SURE BUT TRY IT ............
    select x.mn mnth, x.division, x.totalAmount total, y.mn prev_month,  y.division, y.totalAmount total, (y.totalAmount - nvl(y.totalAmount,0)) difference
    from
      (select month mn, division, totalAmount
      from table_name
      where month = (select max(month)
      from table_name
      ) x,
      (select month mn, division, totalAmount
      from table_name
      where month = (select add_months(max(month),-1)
      from table_name
      ) y
    where x.division = y.division(+)
    MOSTAFIZ MITUL
    DHAKA BANGLADESH

  • Problem with "SELECT...FOR UPDATE OF..." and "POST command" combination

    Problem with "SELECT...FOR UPDATE OF..." and "POST command" combination
    Problem in committing transactions in Multiple Forms (Oracle Forms) with POST built-in command:
    Consider that the following statements are written in WHEN-WINDOW-CLOSED trigger of a called form.
    Statements in called form (Form name: FORM_CHILD):
    go_block('display_block') ;
    do_key('execute_query') ;
    -- Data from table_b will be populated in this block, based on the value of COLUMN_1 obtained
    -- from TABLE_A.
    -- Example: If the value of COLUMN_1 is 10, then all the matching records from TABLE_B, which
    -- are inserted with value 10 in TABLE_B.COLUMN_1 will be fetched and shown here.
    if user_choice = 'YES' then
    commit ;
    else
    rollback ;
    end if ;
    Statements in calling forms:
    There are two calling forms having following statements and it is going to call the above said called form.
    CALLING FORM 1
    Statements in KEY-COMMIT trigger:
    post;
    call_form(form_child, no_activate) ;
    Statements in ON-INSERT trigger:
    select column_1
    from table_a
    for update of column_1
    where column_2 = 'X' ;
    update table_a
    set column_1 = column_1 + 1
    where column_2 = 'X' ;
    insert into table_b ...;
    insert into table_b ...; Statements in KEY-COMMIT trigger:
    post;
    call_form(form_child, no_activate) ;
    CALLING FORM 2:
    Statements in ON-INSERT trigger:
    select column_1
    from table_a
    for update of column_1
    where column_2 = 'X' ;
    update table_a
    set column_1 = column_1 + 1
    where column_2 = 'X' ;
    insert into table_b ...;
    insert into table_b ...;
    insert into table_b ...;
    Our understanding:
    Assume that both the forms are running from two different machines/instances, issuing commit at the same time. In this case, forms will start executing the statements written in ON-INSERT trigger, the moment POST command is executed. Though the commit is issued at the same time, according to oracle, only one of the request will be taken for processing first. Assume that calling form 1 is getting processed first.
    So, it fetches the value available in COLUMN_1 of TABLE_A and locks the row from further select, update, etc. as SELECT...FOR UPDATE command is used (note that NOWAIT is not given, hence the lock will be released only when COMMIT or ROLLBACK happens) and proceed executing further INSERT statements. Because of the lock provided by the SELECT...FOR UPDATE command, the statements in calling form 2 will wait for the resource.
    After executing the INSERT statements, the FORM_CHILD is called. The rows inserted in to TABLE_A will be queried and shown. The database changes will be committed when user closes the window (as COMMIT is issued in its WHEN-WINDOW-CLOSED trigger). Then the SELECT...FOR UPDATE lock will be released and calling form 2's statements will be executed.
    Actual happenings or Mis-behavior:
    Calling form 2 starts executing INSERT statements instead of waiting for SELECT...FOR UPDATE lock. Also, the value selected from TABLE_A.COLUMN_1 is same in both the calling forms, which is wrong.
    The rows inserted into TABLE_B are having similar COLUMN_1 values in calling form 2 and they are fetched and shown in the called form FORM_CHILD.
    Note that in calling form 2 also POST only is issued, but the changes posted there are accessible in calling form 1 also, which is wrong.
    Kindly suggest us as to how to fix above problem. It will be much use, if you can send us the information regarding the behavior of Oracle Forms POST built-in also.
    Our mail ID: [email protected]
    Thanks a lot in advance.

    You have several problems:
    1. On-Insert will ONLY run if you have created a new record in a base-table block. If you haven't done that, then the POST command will not cause it to run.
    2. Select for update without a "no wait" will lock records for the first form, but when the second form tries this, it will hit the ORA-00054 exception, and will NOT wait. The only way you could make it wait is to issue an UPDATE sql command, which is not such a good way to go.
    All POST does is issues SQL insert or update commands for any changes the user has made to records in a form's base-table blocks, without following with a Commit command.
    Also understand that Commit is the same as Commit_Form, and Rollback is the same as Clear_Form. You should read up on these in the Forms help topics.

  • How can I map last of the repeating records into a single record?

    I have a following input schema, I need to take only one of the <Student> records and map that to a single record in output. Doesn't matter if the first, second or last one of the records get mapped, I only need one in the output. Any idea how can
    this be accomplished?
    Input:
      <Students>
        <Student id="1">
            <Name>
              A
            </Name>
            <Roll>
              1
            </Roll>
        </Student>
          <Student id="2">
            <Name>
              A
            </Name>
            <Roll>
              1
            </Roll>
        </Student>
        <Student id="3">
            <Name>
              A
            </Name>
            <Roll>
              1
            </Roll>
        </Student>
      </Students>
    Expected Output:
    <Candidate>
      <Student>
        <Name>
           A
        </Name>
      </Student>
    </Candidate>

    Sounds rather complex for something that could be done very simple in custom XSLT like this:
    <?xml version="1.0" encoding="utf-16"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="Students">
    <Candidate>
    <Student>
    <Name>
    <xsl:value-of select="Student/Name" />
    </Name>
    </Student>
    </Candidate>
    </xsl:template>
    </xsl:stylesheet>
    Morten la Cour

  • Integrating number of records into a single record

    Hi
    I have a table where we store trainees with certifications, it stores trainees address, id, pass/fail flag, course codes, competetion date and certificate expiration date. WHat I need is to display a single record for each trainee in my query. In this case, what we have currently in the table is we might have 11 certificates for a trainee or 1 or maybe 5 etc. All I need is to display all his information, address, trainee id, courrse code..course code11 in a signle record. Is it possible and how? Please help

    Try this one - it points to the same page and looks like it works:
    Re: How to show the SELECT result in a certain form?

Maybe you are looking for