Help in the below code

I want to run the below code for zone_id 1 to 12. How will I do that ?
Kindly help me on this.
DECLARE
  CURSOR c1 IS SELECT item FROM [email protected];
  CURSOR c2(tmp_item VARCHAR2) IS
    SELECT location FROM rpm_zone_location WHERE zone_id = 1
    MINUS
    SELECT DISTINCT location from rpm_clearance WHERE item = tmp_item AND reset_ind = 1 and location in
      (select location from rpm_zone_location where zone_id=1);
BEGIN
  FOR i IN c1
  LOOP
    FOR j IN c2 (i.item)
    LOOP
      INSERT INTO RMS12.RPM_CLEARANCE
(CLEARANCE_ID,
CLEARANCE_DISPLAY_ID,
STATE,
REASON_CODE,
LOC_EXCEPTION_PARENT_ID,
PARENT_EXCEPTION_PARENT_ID,
CLEARANCE_RESET_ID,
RESET_IND,
ITEM,
DIFF_ID,
ZONE_ID,
LOCATION,
ZONE_NODE_TYPE,
EFFECTIVE_DATE,
OUT_OF_STOCK_DATE,
RESET_DATE,
CHANGE_TYPE,
CHANGE_AMOUNT,
CHANGE_CURRENCY,
CHANGE_PERCENT,
CHANGE_SELLING_UOM,
PRICE_GUIDE_ID,
VENDOR_FUNDED_IND,
FUNDING_TYPE,
FUNDING_AMOUNT,
FUNDING_AMOUNT_CURRENCY,
FUNDING_PERCENT,
SUPPLIER,
DEAL_ID,
DEAL_DETAIL_ID,
PARTNER_TYPE,
PARTNER_ID,
CREATE_DATE,
CREATE_ID,
APPROVAL_DATE,
APPROVAL_ID,
LOCK_VERSION)
SELECT
RPM_CLEARANCE_SEQ.Nextval,
'reset:'||CLEARANCE_DISPLAY_ID,
'pricechange.state.approved',
REASON_CODE,
LOC_EXCEPTION_PARENT_ID,
PARENT_EXCEPTION_PARENT_ID,
CLEARANCE_RESET_ID,
1,
ITEM,
DIFF_ID,
null,
c2.location,
0,
null,
OUT_OF_STOCK_DATE,
null,
CHANGE_TYPE,
CHANGE_AMOUNT,
CHANGE_CURRENCY,
CHANGE_PERCENT,
CHANGE_SELLING_UOM,
PRICE_GUIDE_ID,
VENDOR_FUNDED_IND,
FUNDING_TYPE,
FUNDING_AMOUNT,
FUNDING_AMOUNT_CURRENCY,
FUNDING_PERCENT,
SUPPLIER,
DEAL_ID,
DEAL_DETAIL_ID,
PARTNER_TYPE,
PARTNER_ID,
CREATE_DATE,
'RMS12',
APPROVAL_DATE,
'RMS12',
LOCK_VERSION
from rpm_clearance where zone_id=1 and item = j.item;
    END LOOP;
    COMMIT;
  END LOOP;
END;

It might be a good idea to post this again using the "code" button so that it's properly formatted. Take your time so that it's as accurate as possible. And don't forget to say at what point as the program executes this eligibility is being considered.

Similar Messages

  • SQL command IN is working , but NOT IN is not working for the below code...

    In application code I have the below code.
    IF v_service_variant NOT IN(0,1,2,3,4) THEN --Checking whether existing service variant is applicable in 21Cn Fibre.
    v_service_variant := 3; --If not making it as a standard service
    UPDATE sspt_sessions_table SET service_variant = v_service_variant WHERE sess_id=v_sess_id; --Updating sspt_sessions_table
    SELECT DECODE(service_variant_id, 0, 'None', 1, 'Loadbalancing', 2, 'Failover',3, 'BGP4', 4, 'Backup') INTO l_service_variant --To get the service variant name
    FROM sspt_maj_resilience WHERE service_variant_id=v_service_variant;
    UPDATE sspt_prquote_details SET service_variant = l_service_variant WHERE ftip=l_ftip AND sess_id=v_sess_id; --Updating sspt_prquote_details
    COMMIT;
    END IF;
    Then the statements inside the if condition are not being executed. At the same time if I am replacing NOT IN with IN only and making changes to get if condition true then it is going inside the IF condition.... Could anyone please help me on this

    950474 wrote:
    In application code I have the below code.
    IF v_service_variant NOT IN(0,1,2,3,4) THEN --Checking whether existing service variant is applicable in 21Cn Fibre.
    v_service_variant := 3; --If not making it as a standard service
    UPDATE sspt_sessions_table SET service_variant = v_service_variant WHERE sess_id=v_sess_id; --Updating sspt_sessions_table
    SELECT DECODE(service_variant_id, 0, 'None', 1, 'Loadbalancing', 2, 'Failover',3, 'BGP4', 4, 'Backup') INTO l_service_variant --To get the service variant name
    FROM sspt_maj_resilience WHERE service_variant_id=v_service_variant;
    UPDATE sspt_prquote_details SET service_variant = l_service_variant WHERE ftip=l_ftip AND sess_id=v_sess_id; --Updating sspt_prquote_details
    COMMIT;
    END IF;
    Then the statements inside the if condition are not being executed. At the same time if I am replacing NOT IN with IN only and making changes to get if condition true then it is going inside the IF condition.... Could anyone please help me on thishow can we reproduce what you report?
    while "not working" may be 100%, it is also 100% devoid of any actionable detail.
    what results when it is not working?
    how would working results supposedly appear?
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • How can i write the below code using "For all entries"

    Hi
    How can we write the below code using "for all entries" and need to avoid joins...
    Please help
    SELECT aaufnr aobjnr aauart atxjcd a~pspel
    agstrp awerks carbpl cwerks
    INTO TABLE t_caufv
    FROM caufv AS a
    INNER JOIN afih AS b
    ON aaufnr = baufnr
    INNER JOIN crhd AS c
    ON bgewrk = cobjid
    AND c~objty = 'D'
    WHERE ( a~pspel = space
    OR a~txjcd = space
    OR NOT a~objnr IN
    ( select OBJNR from COBRB AS e
    WHERE objnr = a~objnr ) )
    AND a~werks IN s_plant
    AND a~auart IN s_wtype
    AND NOT a~objnr IN
    ( select OBJNR from JEST AS d
    WHERE objnr = a~objnr
    AND ( dstat = 'A0081'OR dstat = 'A0018' )
    AND d~inact 'X' ).
    Reward points for all helpfull answers
    Thanks
    Ammi.

    Hi,
    SELECT objnr objid aufnr
            from afih
            into table t_afih.
    SELECT objnr
            from JEST
            into table t_JEST
            where stat = 'A0045'
               OR stat = 'A0046'
               AND inact 'X'.
    SELECT objnr
            from COBRB
            into table t_cobrb.
    SELECT arbpl werks objid objty
          from crhd
          INTO table it_crhd
          FOR ALL ENTRIES IN it_afih
          WHERE objty eq 'D'
          AND gewrk = it_afih-objid.
    SELECT aufnr objnr auart txjcd pspel gstrp werks aufnr
            FROM caufv
            INTO table t_caufv
            FOR ALL ENTRIES IN it_afih
            WHERE aufnr = it_afih-aufnr
              And pspel = ' '
              AND txjcd = ' '
             ANd objnr ne it_crhd-objnr
              AND auart in s_wtype
              AND werks in s_plant.
             AND objnr ne it_jest-objnr.
    dont use NE in the select statements, it may effect performance also. Instead use if statements inside
    loops.
    loop at t_caufv.
    read table it_chrd............
      if t_caufv-objnr ne it_chrd-objnr.
      read table it_jest..........
       if   if t_caufv-objnr ne it_jest-objnr.
        (proceed further).
       endif.
      endif.
    endloop.
    hope this helps.
    Reward if useful.
    Regards,
    Anu

  • Performance for the below code

    Can any one help me in improving the performance for the below code.
    FORM RETRIEVE_DATA .
    CLEAR WA_TERRINFO.
    CLEAR WA_KNA1.
    CLEAR WA_ADRC.
    CLEAR SORT2.
    *To retrieve the territory information from ZPSDSALREP
    SELECT ZZTERRMG
           ZZSALESREP
           NAME1
           ZREP_PROFILE
           ZTEAM
         INTO TABLE GT_TERRINFO
         FROM ZPSDSALREP.
    *Preparing Corporate ID from KNA1 & ADRC and storing it in SORT2 field
    LOOP AT GT_TERRINFO INTO WA_TERRINFO.
      SELECT SINGLE * FROM KNA1 INTO WA_KNA1
                      WHERE KUNNR = WA_TERRINFO-SALESREP.
      SELECT SINGLE * FROM ADRC INTO WA_ADRC
                      WHERE ADDRNUMBER = WA_KNA1-ADRNR.
      IF NOT WA_ADRC-SORT2 IS INITIAL.
      CONCATENATE 'U' WA_ADRC-SORT2 INTO SORT2.
      MOVE SORT2 TO WA_TERRINFO-SORT2.
    MODIFY GT_TERRINFO1 FROM WA_TERRINFO.
      APPEND WA_TERRINFO TO GT_TERRINFO1.
      CLEAR WA_TERRINFO.
      ENDIF.
      CLEAR WA_KNA1.
      CLEAR WA_ADRC.
    ENDLOOP.
    ENDFORM.                    " RETRIEVE_DATA

    Hi
    The code is easy so I don't think you can do nothing, only u can try to limit the reading of KNA1:
    FORM RETRIEVE_DATA .
      CLEAR WA_TERRINFO.
      CLEAR WA_KNA1.
      CLEAR WA_ADRC.
      CLEAR SORT2.
    *To retrieve the territory information from ZPSDSALREP
      SELECT ZZTERRMG
      ZZSALESREP
      NAME1
      ZREP_PROFILE
      ZTEAM
      INTO TABLE GT_TERRINFO
      FROM ZPSDSALREP.
      SORT GT_TERRINFO BY SALESREP.
    *Preparing Corporate ID from KNA1 & ADRC and storing it in SORT2 field
      LOOP AT GT_TERRINFO INTO WA_TERRINFO.
        IF KNA1-KUNNR <> WA_KNA1-KUNNR.
          SELECT SINGLE * FROM KNA1 INTO WA_KNA1
               WHERE KUNNR = WA_TERRINFO-SALESREP.
          IF SY-SUBRC <> 0.
            CLEAR: WA_KNA1, WA_ADRC.
          ELSE.
            SELECT SINGLE * FROM ADRC INTO WA_ADRC
                                     WHERE ADDRNUMBER = WA_KNA1-ADRNR.
            IF SY-SUBRC <> 0. WA_ADRC. ENDIF.
          ENDIF.
        ENDIF.
        IF NOT WA_ADRC-SORT2 IS INITIAL.
          CONCATENATE 'U' WA_ADRC-SORT2 INTO SORT2.
          MOVE SORT2 TO WA_TERRINFO-SORT2.
    * MODIFY GT_TERRINFO1 FROM WA_TERRINFO.
          APPEND WA_TERRINFO TO GT_TERRINFO1.
          CLEAR WA_TERRINFO.
        ENDIF.
      ENDLOOP.
    ENDFORM. " RETRIEVE_DATA
    If program takes many times to upload the data from ZPSDSALREP, you can try to split in sevaral packages:
    SELECT ZZTERRMG ZZSALESREP NAME1 ZREP_PROFILE ZTEAM
      INTO TABLE GT_TERRINFO PACKAGE SIZE <...>
      FROM ZPSDSALREP.
      SORT GT_TERRINFO BY SALESREP.
    *Preparing Corporate ID from KNA1 & ADRC and storing it in SORT2 field
      LOOP AT GT_TERRINFO INTO WA_TERRINFO.
        IF KNA1-KUNNR <> WA_KNA1-KUNNR.
          SELECT SINGLE * FROM KNA1 INTO WA_KNA1
               WHERE KUNNR = WA_TERRINFO-SALESREP.
          IF SY-SUBRC <> 0.
            CLEAR: WA_KNA1, WA_ADRC.
          ELSE.
            SELECT SINGLE * FROM ADRC INTO WA_ADRC
                                     WHERE ADDRNUMBER = WA_KNA1-ADRNR.
            IF SY-SUBRC <> 0. WA_ADRC. ENDIF.
          ENDIF.
        ENDIF.
        IF NOT WA_ADRC-SORT2 IS INITIAL.
          CONCATENATE 'U' WA_ADRC-SORT2 INTO SORT2.
          MOVE SORT2 TO WA_TERRINFO-SORT2.
    * MODIFY GT_TERRINFO1 FROM WA_TERRINFO.
          APPEND WA_TERRINFO TO GT_TERRINFO1.
          CLEAR WA_TERRINFO.
        ENDIF.
      ENDLOOP.
    ENDSELECT.
    Max

  • Exact fetch returns more than requested number of rows oracle error ; unable to find where exactly throwing error in the below code.

    hi i am receiving "exact fetch returns more than requested number of rows oracle error". but i am not able to locate the error in the below code. Any help would be appreciated!!!
    CREATE OR REPLACE PROCEDURE load_scene_collection_item (
    --pdname                                  VARCHAR2,
    -- LOCATION TO ADD/CHANGE below!!!
    pITEM_TYPE_ID                      INTEGER,
    pSCENE_COLLECTION_ID        INTEGER,
    pCOLLECTION_ITEM_NAME     VARCHAR2,
    pCOLLECTION_ITEM_DESC      VARCHAR2,
    pDEFAULT_COORD_X      NUMBER,
    pDEFAULT_COORD_Y      NUMBER,
    pDEFAULT_COORD_Z      NUMBER,
    pDEFAULT_WIDTH            NUMBER,
    pDEFAULT_HEIGHT            NUMBER,
    pDEFAULT_ROTATION      INTEGER,
    pDEFAULT_ALPHA            INTEGER,
    pfname                                 VARCHAR2)    IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('BUSINESSBLOBSIMAGES', pfname);
    -- insert a NULL record to lock
    Insert into SCENE_COLLECTION_ITEM
       ( ITEM_TYPE_ID,
       SCENE_COLLECTION_ID,
       COLLECTION_ITEM_NAME,
       COLLECTION_ITEM_DESC,
        COLLECTION_ITEM_IMAGE,
       DEFAULT_COORD_X,
       DEFAULT_COORD_Y,
       DEFAULT_COORD_Z,
       DEFAULT_WIDTH,
       DEFAULT_HEIGHT,
       DEFAULT_ROTATION,
       DEFAULT_ALPHA,
        CREATE_USER,
        CREATE_DATE)
    Values    ( pITEM_TYPE_ID, pSCENE_COLLECTION_ID, pCOLLECTION_ITEM_NAME, pCOLLECTION_ITEM_DESC, EMPTY_BLOB(),   
       pDEFAULT_COORD_X,
       pDEFAULT_COORD_Y,
       pDEFAULT_COORD_Z,
       pDEFAULT_WIDTH,
       pDEFAULT_HEIGHT,
       pDEFAULT_ROTATION,
       pDEFAULT_ALPHA,  
    sys_context('USERENV', 'OS_USER'), 
    sys_extract_utc(systimestamp))
    RETURNING COLLECTION_ITEM_IMAGE INTO dst_file;
    -- LOCATIONs(2) TO ADD/CHANGE above!!!
    -- lock record
    SELECT COLLECTION_ITEM_IMAGE
    INTO dst_file
    FROM SCENE_COLLECTION_ITEM
    WHERE ITEM_TYPE_ID     = pITEM_TYPE_ID
    AND SCENE_COLLECTION_ID = pSCENE_COLLECTION_ID
    AND COLLECTION_ITEM_NAME= pCOLLECTION_ITEM_NAME
    AND COLLECTION_ITEM_DESC= pCOLLECTION_ITEM_DESC
    AND    pDEFAULT_COORD_X = DEFAULT_COORD_X
    AND   pDEFAULT_COORD_Y  = DEFAULT_COORD_Y
    AND   pDEFAULT_COORD_Z  = DEFAULT_COORD_Z
    AND   pDEFAULT_WIDTH    = DEFAULT_WIDTH
    AND   pDEFAULT_HEIGHT   = DEFAULT_HEIGHT
    AND   pDEFAULT_ROTATION = DEFAULT_ROTATION
    AND   pDEFAULT_ALPHA    = DEFAULT_ALPHA
    FOR UPDATE;
    -- LOCATION TO ADD/CHANGE above!!!
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE SCENE_COLLECTION_ITEM
    SET COLLECTION_ITEM_IMAGE = dst_file
    WHERE ITEM_TYPE_ID     = pITEM_TYPE_ID
    AND SCENE_COLLECTION_ID = pSCENE_COLLECTION_ID
    AND COLLECTION_ITEM_NAME= pCOLLECTION_ITEM_NAME
    AND COLLECTION_ITEM_DESC= pCOLLECTION_ITEM_DESC
    AND    pDEFAULT_COORD_X = DEFAULT_COORD_X
    AND   pDEFAULT_COORD_Y  = DEFAULT_COORD_Y
    AND   pDEFAULT_COORD_Z  = DEFAULT_COORD_Z
    AND   pDEFAULT_WIDTH    = DEFAULT_WIDTH
    AND   pDEFAULT_HEIGHT   = DEFAULT_HEIGHT
    AND   pDEFAULT_ROTATION = DEFAULT_ROTATION
    AND   pDEFAULT_ALPHA    = DEFAULT_ALPHA
    -- LOCATION TO ADD/CHANGE above!!!
    -- close file
    dbms_lob.fileclose(src_file);
    END load_scene_collection_item;
    Thanks in advance!!!!

    Hi PaulHorth,
    Thanks for the quick reply.
    Actually, i am getting  error while updating the records.
    below is the error message:
    Error starting at line 1 in command:
    exec load_scene_collection_item(3,15,'2 Lane 4way Stop','4 Way Stop Intersection with 2 lanes in each direction',0,0,0,400,517,0,1,'2 Lane 4way Stop.PNG');
    Error report:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "DP_OWNER.LOAD_SCENE_COLLECTION_ITEM", line 55
    ORA-06512: at line 1
    01422. 00000 - "exact fetch returns more than requested number of rows"
    *Cause:    The number specified in exact fetch is less than the rows returned.
    *Action:   Rewrite the query or change number of rows requested

  • Required clarification for the below code:

    Hi All,
    For one of my requiremnet, i found one solution which worked as expected.. But i was not able to understand the logic.. Can any one explain me the below
    syntax what exactly the meaning for the below code:
    Code:
    SELECT NULL
    FROM apex_application_page_ir_cond cond
    WHERE cond.application_id = v('APP_ID')
    AND cond.page_id = v('APP_PAGE_ID')
    AND cond.condition_type = 'Filter'
    AND cond.condition_enabled = 'Yes'
    AND cond.report_id = (SELECT report_id
    FROM apex_application_page_ir_rpt
    WHERE application_id = v('APP_ID')
    AND page_id = v('APP_PAGE_ID')
    AND application_user = v('APP_USER')
    AND report_type = 'SESSION'
    AND TO_CHAR (session_id) = v('SESSION')
    AND report_name IS NULL))
    For your refernec i have enclosed the link also
    URL : Re: Interactive_Report with Search Bar only
    Thanks,
    Anoo..

    Anoo,
    Two things. First, it makes things a lot easier if you put "&#123;code}" (no quotes) around your SQL when you post it:
    SELECT rowid "EDIT", attr_code,ATTR_ATCL_CODE "Atcl Code", attr_description, attr_atcl_code,
                    attr_abbreviation,
                    attr_include_short_desc "Include short desc",
                    attr_include_long_desc "Include long desc",
                    attr_attr_type "AttrType", rowid "DELETE"
               FROM t_new WHERE EXISTS (SELECT 1 FROM APEX_APPLICATION_PAGE_IR_COND WHERE APPLICATION_ID = :APP_ID AND PAGE_ID = :APP_PAGE_ID AND CONDITION_ENABLED = 'Yes'
    AND APPLICATION_USER = :APP_USER) ORDER BY attr_description;Though the spacing still needs work, it's a little easier to read.
    Second, your query's exist clause just checks for an enabled condition, without checking the condition type. Without checking, I'd guess that either APEX creates at least one internal condition, or that your IR has a default condition on it (other than a filter). Try adding the condition_type constraint to your where clause to see if that fixes it.
    Also, I noted that you don't have the extra code for getting the report_id. It shouldn't be necessary, since there's currently only support for one IR per page, but you asked what the differences are.
    -David

  • Need help in the below command excution

    Hi Champs,
    Can any one help with the below command, It is not working.
    Get-CsUser | Where-Object {$_.dialplan -eq "USDAL"} | Grant-CsLocationPolicy -PolicyName "Dallas Location Policy"
    Regards
    Vijendhar

    You could try something like: 
    $userlist = Get-CsUser -ResultSize Unlimited
    foreach ($user in $userlist)
    if ($user.dialplan -eq $Null)
    $pool = (Get-csdialplan | Where-Object {$_.Identity -like ("*" + $user.RegistrarPool)})
    if ($pool.length -ge "1") {write-host ("Pool simple name: " + $pool.simplename + ", Identity: " + $pool.identity)}
    if (($pool.simplename -eq "USDal") -or ($pool.identity -eq "USDal"))
    Write-host "Please Grant location policy to: $user.Displayname"
    # Get-csuser $user.identity | Grant-CsLocationPolicy -PolicyName "Dallas Location Policy"
    $pool = $Null
    Use at your own risk as I haven't had a chance to test, I have commented out the grant so you can test prior to changes.
    Please mark posts as answers/helpful if it answers your question.
    Blog
    Lync Validator - Used to assist in the validation and documentation of Lync Server 2013.

  • Need help on the below query.

    Hi All,
    I've a query given below..
    SELECT W.WONUM,
         W.STATUS,
         WS.CHANGEDATE,
         EH.OLD_RATE
         FROM
         WORKORDER W,
         WOSTATUS WS,
         ESTIMATE_HEADER@GQMFOF EH
    WHERE WS.CHANGEDATE BETWEEN '01-Oct-2009' AND '1-Nov-2009'
    AND W.WONUM = WS.WONUM
    AND EH.OLD_RATE = 'N'
    AND WS.WOSTATUS = 'CLOSE';
    I would like to get All the data which status =closed in the month of Oct for Old rate,
    So for this i am writing the query above. But not getting the o/p.
    It is giving me that " Table/View doesn't exist.
    There 2 schemas MAXIMO,GQMMGR..
    DBlinks are GQMFOF,MAXFOFNC..
    Can anyone help me while writing the above query...
    Regards,
    gr.

    A question was asked in your other thread. But the problem was you dint care to give an answer.
    Dont open duplicate post.
    I need help on the below problem..

  • I need help on the below problem..

    Hi All,
    I need help on the below problem..
    I've 2 Schemas called
         1. MAXIMO and DBLink is GQMFOF
         2. GQMMGR adn DBLink is MAXFOFNC
    Now i would likw to retrive the data from both the schemas,
    i.e some columns from WORKORDER table of maximo schema and some columns from ESTIMATE_HEADER table
    of GQMMGR schema..
    I'm trying to get the data using DB links, but it is giving TABLE/VIEW doesn't exist.
    Please help me on this.
    Regards,
    gr.

    Does your user has the SELECT privelage granted for accessing those tables?

  • HI ALL SINCE TWO DAYS I AM DOWNLOADING VIBER BUT I AM NOT HAVING MY ACCESS CODE AND EVERY TIME I DELETE THE APPLICATION AND DOWNLOADING IT AGAIN BUT ALWAYS THE SAME RESULT PLEASE I NEED YOUR HELP FOR THE ACCESS CODE.MY PHONE NUMBER IS 0022996969896.THANKS

    HI ALL SINCE TWO DAYS I AM DOWNLOADING VIBER BUT I AM NOT HAVING MY ACCESS CODE AND EVERY TIME I DELETE THE APPLICATION AND DOWNLOADING IT AGAIN BUT ALWAYS THE SAME RESULT PLEASE I NEED YOUR HELP FOR THE ACCESS CODE.MY PHONE NUMBER IS 0022996969896.THANKS IN ADVANCE

    try this website this should help you http://helpme.viber.com/index.php?/Knowledgebase/List/Index/1/iphone

  • Please optimize the below code!!!!urgent

    friends,
    i know that cluster tables cannot be joined with transparent tables....
    however i need performance improvement for the following code....
    if possible is there a way to join bkpf or bseg to improve performance....can we create view foe bkpf and bseg if yes then how.....
    please modify the below code for improvement in performance.
    START-OF-SELECTION.
    SELECT bukrs belnr gjahr budat FROM bkpf INTO TABLE i_bkpf
    WHERE bukrs = p_bukrs AND "COMPANY CODE
    gjahr = p_gjahr AND "FISCAL YEAR
    budat IN s_budat. "POSTING DATE IN DOC
    IF sy-subrc = 0.
    SELECT bukrs belnr gjahr hkont shkzg dmbtr FROM bseg INTO TABLE
    i_bseg FOR ALL ENTRIES IN i_bkpf
    WHERE bukrs = i_bkpf-bukrs AND "COMPANY CODE
    belnr = i_bkpf-belnr AND "A/CING DOC NO
    gjahr = i_bkpf-gjahr AND "FISCAL YEAR
    hkont = p_hkont. "General Ledger Account"
    IF sy-subrc = 0.
    SELECT bukrs belnr gjahr hkont shkzg dmbtr FROM bseg INTO TABLE
    i_bseg1 FOR ALL ENTRIES IN i_bseg
    WHERE bukrs = i_bseg-bukrs AND "COMPANY CODE
    belnr = i_bseg-belnr AND "A/CING DOC NO
    gjahr = i_bseg-gjahr. "FISCAL YEAR
    ENDIF.
    ENDIF.
    IF NOT i_bseg1[] IS INITIAL.
    LOOP AT i_bseg1.
    IF i_bseg1-hkont = p_hkont AND i_bseg1-shkzg = 'S'.
    v_sumgl = v_sumgl + i_bseg1-dmbtr.
    ELSEIF i_bseg1-hkont = p_hkont AND i_bseg1-shkzg = 'H'.
    v_sumgl = v_sumgl - i_bseg1-dmbtr.
    ELSEIF i_bseg1-hkont NE p_hkont .
    IF i_bseg1-shkzg = 'H'.
    i_bseg1-dmbtr = - i_bseg1-dmbtr.
    ENDIF.
    i_alv-hkont = i_bseg1-hkont.
    i_alv-dmbtr = i_bseg1-dmbtr.
    APPEND i_alv.
    v_sumoffset = v_sumoffset + i_bseg1-dmbtr.
    ENDIF.
    ENDLOOP.
    regards
    Essam.([email protected])

    Hi ,
    <b>Pls use for all entries as below to join these two tables :</b>
    For pool and cluster table you can create secondary index and you can use select distinct, group for pool and cluster table. You can use native SQL statement for pool and cluster table.
    see the query for Bseg table :
    example  :
    *Code to demonstrate select command
    *Code to demonstrate select into internal table command
    TYPES: BEGIN OF t_bkpf,
    *  include structure bkpf.
      bukrs LIKE bkpf-bukrs,
      belnr LIKE bkpf-belnr,
      gjahr LIKE bkpf-gjahr,
      bldat LIKE bkpf-bldat,
      monat LIKE bkpf-monat,
      budat LIKE bkpf-budat,
      xblnr LIKE bkpf-xblnr,
      awtyp LIKE bkpf-awtyp,
      awkey LIKE bkpf-awkey,
    END OF t_bkpf.
    DATA: it_bkpf TYPE STANDARD TABLE OF t_bkpf INITIAL SIZE 0,
          wa_bkpf TYPE t_bkpf.
    TYPES: BEGIN OF t_bseg,
    *include structure bseg.
      bukrs     LIKE bseg-bukrs,
      belnr     LIKE bseg-belnr,
      gjahr     LIKE bseg-gjahr,
      buzei     LIKE bseg-buzei,
      mwskz     LIKE bseg-mwskz,         "Tax code
      umsks     LIKE bseg-umsks,         "Special G/L transaction type
      prctr     LIKE bseg-prctr,         "Profit Centre
      hkont     LIKE bseg-hkont,         "G/L account
      xauto     LIKE bseg-xauto,
      koart     LIKE bseg-koart,
      dmbtr     LIKE bseg-dmbtr,
      mwart     LIKE bseg-mwart,
      hwbas     LIKE bseg-hwbas,
      aufnr     LIKE bseg-aufnr,
      projk     LIKE bseg-projk,
      shkzg     LIKE bseg-shkzg,
      kokrs     LIKE bseg-kokrs,
    END OF t_bseg.
    DATA: it_bseg TYPE STANDARD TABLE OF t_bseg INITIAL SIZE 0,
          wa_bseg TYPE t_bseg.
    *Select FOR ALL ENTRIES command
    SELECT bukrs belnr gjahr bldat monat budat xblnr awtyp awkey
      UP TO 100 ROWS
      FROM bkpf
      INTO TABLE it_bkpf.
    IF sy-subrc EQ 0.
    * The FOR ALL ENTRIES comand only retrieves data which matches
    * entries within a particular internal table.
      SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart
             dmbtr mwart hwbas aufnr projk shkzg kokrs
        FROM bseg
        INTO TABLE it_bseg
        FOR ALL ENTRIES IN it_bkpf
        WHERE bukrs EQ it_bkpf-bukrs AND
              belnr EQ it_bkpf-belnr AND
              gjahr EQ it_bkpf-gjahr.
    ENDIF.
    <b>Pls reward pts if found usefull :)</b>
    regards
    Sathish

  • Where can I see the error msg in the below code.

    Hi Gurus,
    Please have a look at the code.
           if abc is initial.
              return-message = cl_bsp_runtime=>get_otr_text( 'ZXYZ/ERR_EMPID' ).
              append test to test_tab.
            endif.
    In the above code, Emp id input field is being checked as its mandatory. I would like to know where can I see the error message per the above code. what is get_otr_test??

    go to SE63 and see it from there..
    SE63-> Translation->OTR Objects->Short Text
    in field <b>Package</b> key in 'ZXYZ'
    and in field <b>Text from OTR</b> key in 'ERR_EMPID'
    and go forward.
    I hope this helps.
    For more info see the link below
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2a/6ad43aa654be55e10000000a11402f/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/93/bccd3a00746f4ae10000000a11402f/frameset.htm
    <i>If useful answer..reward points and close the thread.</i>
    A.<b></b>

  • Need help on the below query or Pl-SQL

    Hello Every one,
    Please let me know if some one can help me out with the below scenario either in pl-sql or sql.
    Source Data:
    0000253800     0.25          0845A     0900A
    0000253800     1          0900A     1000A
    0000253800     1          1300P     1400P
    0000253800     1          1500P     1600P
    0000253800     1          1600P     1700P
    Output needed:
    0000253800     1.25          0845A     1000A
    0000253800     1          1300P     1400P
    0000253800     2          1500P     1700P
    Thanks in Advance....
    Edited by: user12564103 on Dec 11, 2011 5:54 PM

    Hi,
    Welcome to the forum!
    Depending on your data and your requirements:
    WITH     got_times     AS
         SELECT     column_1, column_2, column_3, column_4
         ,     TO_DATE ( substr (column_3, 1, 4)
                   , 'HH24MI'
                   )     AS time_3
         ,     TO_DATE ( SUBSTR (column_4, 1, 4)
                   , 'HH24MI'
                   )     AS time_4
         FROM     table_x
    ,     got_grp_id     AS
         SELECT     column_1, column_2, column_3, column_4
         ,     time_3, time_4
         ,     time_4 - SUM (time_4 - time_3) OVER ( PARTITION BY  column_1
                                        ORDER BY         time_3
                                      )     AS grp_id
         FROM     got_times
    SELECT       column_1
    ,       SUM (column_2)     AS sum_2
    ,       MIN (column_3) KEEP (DENSE_RANK FIRST ORDER BY time_3)
                        AS min_3
    ,       MAX (column_4) KEEP (DENSE_RANK LAST  ORDER BY time_4)
                        AS max_4
    FROM       got_grp_id
    GROUP BY  column_1
    ,       grp_id
    ORDER BY  column_1
    ,       grp_id
    ;Whenever you have a problem, please post CREATE TABLE and INSERT statements for your sample data, as well as the results you want from that data. Explain, with specific examples, how you get the results you want from that data.
    Always say which version of Oracle you're using. The query above will work in Oracle 9.1 (and higher).
    Since this is your first thread, I'll do this for you:
    CREATE TABLE     table_x
    (     column_1     NUMBER
    ,     column_2     NUMBER
    ,     column_3     VARCHAR2 (5)
    ,     column_4     VARCHAR2 (5)
    INSERT INTO table_x (column_1, column_2, column_3, column_4) VALUES (253800, .25, '0845A', '0900A');
    INSERT INTO table_x (column_1, column_2, column_3, column_4) VALUES (253800, 1,   '0900A', '1000A');
    INSERT INTO table_x (column_1, column_2, column_3, column_4) VALUES (253800, 1,   '1300P', '1400P');
    INSERT INTO table_x (column_1, column_2, column_3, column_4) VALUES (253800, 1,   '1500P', '1600P');
    INSERT INTO table_x (column_1, column_2, column_3, column_4) VALUES (253800, 1,   '1600P', '1700P');Column_1 identifes a day.
    Column_2 is an amount that I need to total.
    Column_3 and column_4 are starting and ending times. We can assume that they are all valid times (in 'HH24MI' format, plus a redundant 'A' or 'P') on the same day, column_3 is always less than column_4, and that the range of two rows for the same value of column_1 never overlap. Column_4 of one row may be equal to column_3 of another rows with the same column_1, but it will never be greater.
    Each row of the output represent a contiguous group of rows (each ending exactly when the next one begins) with the same column_1, with the common column_1, the total of column_2, and the range of the group.
    For example, the first two rows for a single group, because they have the same value for column_1, and one ends exactly when the other begins (at 9:00 AM). This group represents day 253800, from 8:45 AM to 10:00 AM. The totla of column_2 fro this group is .25 + 1 = 1.25.
    The next row (from 1:00 PM to 2:00 PM) is a group all by itself, because there is a gap one either side of it separating it from its nearest neighbor on the same day."
    Of course, I'm guessing at lots of things.
    Edited by: Frank Kulash on Dec 11, 2011 9:44 PM
    Changed TO_DATE calls.
    Edited by: Frank Kulash on Dec 11, 2011 9:52 PM
    Added sample question.

  • How to improve performance of the below code.

    Hello.
    This below code is show 80% database performance in runtime analysis ( transaction SE30). I am using view KNA1VV for retrieving data using customer and sales area from selection screen.
    Please advice how can I improve the performance of below code.
    Fetch the customer details from view KNA1VV
      SELECT kunnr
             vkorg
             vtweg
             spart
             land1
             name1
             ort01
             pstlz
             regio
             stras
            INTO TABLE t_cust
            FROM kna1vv
      WHERE kunnr IN s_kunnr
      AND   vkorg IN s_vkorg
      AND   vtweg IN s_vtweg
      AND   spart IN s_spart
      AND   loevm = space
      AND   loevm_knvv = space.
      IF sy-subrc EQ 0.
        SORT t_cust BY kunnr.
      ELSE.
        w_flag = c_true_x.
      ENDIF.
    Fetch customers for entered company code
      IF NOT t_cust[] IS INITIAL AND NOT s_bukrs IS INITIAL.
        SELECT kunnr
               FROM knb1
               INTO TABLE lt_knb1
               FOR ALL ENTRIES IN t_cust
        WHERE kunnr = t_cust-kunnr
        AND   bukrs IN s_bukrs
        AND   loevm = space.
    Thanks,

    80% is just a relation and must not be problematic, what about the absolute runtime, is that acceptable?
    Also, your range S_KUNNR could contain anything from a single value (super fast) to nothing (probably slow, depends on number of entries in KNA1VV), so what do you expect here?
    Thomas

  • How to disable attachment icon in the below code

    Session session = null;
              Properties props = new Properties();
              props.put("mail.smtp.host", mailHost);
              session = Session.getDefaultInstance(props, null);
              log.info("STEP 1");
              try {
                   Calendar currentDate = Calendar.getInstance();
                   currentDate.add(Calendar.DATE, 0);
                   log.info("STEP 2");
                   MimeMessage mesg = new MimeMessage(session);
                   log.info("STEP 3");
                   String mailBody = "RSS Feed link as of"
                             + (currentDate.get(Calendar.MONTH) + 1) + File.separator
                             + currentDate.get(Calendar.DATE) + File.separator
                             + currentDate.get(Calendar.YEAR) + messageText;
                   log.info("THE MAIL BODY IS :" + mailBody);
                   try {
                        mesg.setFrom(new InternetAddress(fromAddress));
                        InternetAddress toAddress = new InternetAddress(destAddr);
                        mesg.addRecipient(Message.RecipientType.TO, toAddress);
                   } catch (Exception x) {
                   mesg.setSubject("Cybermedia Dice Job Portal RSS Feed information link");
                   MimeBodyPart messageBodyPart = new MimeBodyPart();
                   messageBodyPart.setText(mailBody, "us-ascii");
                   Multipart multipart = new MimeMultipart();
                   multipart.addBodyPart(messageBodyPart);
                   mesg.setContent(multipart);
                   Transport.send(mesg);
                   * MimeBodyPart attachmentBodyPart = new MimeBodyPart(); DataSource
                   * source = new FileDataSource(outputFileName);
                   * attachmentBodyPart.setDataHandler(new DataHandler(source));
                   * attachmentBodyPart.setFileName(outputFileName);
                   * multipart.addBodyPart(attachmentBodyPart);
                   log.info("STOP HERE..");
              } catch (Exception ex) {
                   StringWriter writer = new StringWriter();
                   ex.printStackTrace(new PrintWriter(writer));
                   String trace = writer.toString();
                   log.error(trace);
    Can any one help what should be modified so that the attachment icon is disabled in mail
    Presently it shows attachment icon using the above code

    Hi naga,
    1. one option is to retrive the source code of the requried program,
       into internal table using the syntax READ REPORT (just see f1 help on it)
    READ REPORT prog INTO itab [MAXIMUM WIDTH INTO wid].
    2. Then we can loop / search the internal table for the required term.
    regards,
    amit m.

Maybe you are looking for

  • Cabling from MacBook 2 Vizio HDTV

    Is there a cable that can connect my MacBook to HDTV (have two, Vizio/Samsung) in order to watch movies currently residing on laptop?

  • Seeking Advice on Rejecting MR2 Update

    It appears that I may be on of the few very lucky TB users that has been satisfied with it's performance since I purchased it shortly after its' introduction.  I also rushed into the MR1 update and got lucky again.  When the MR2 came out I started ch

  • Combining Excel 2013 in Acrobat XI

    How do I get multiple sheets from excel 2013 files to combine into the pdf using Acrobat XI?  It worked fine with Office 2007.

  • Monitor color temperature is switching after launching a CC product

    Hello, i'm running OS X 10.8.5 on a Macbook Pro I didn't change nothing and never play with color profil on my computer Since this morning when i launch Photoshop CC or Illustrator CC color temperature switch automaticly to a cold white during softwa

  • Quer needed

    Hi.. I need a query to add a year to a date..