Using substr function loses index. Query tune help

Hi
when i use substr function in the join condition it loses index and the query is slow. How to fix this problem or tune this query. These are the lines in the query.
and substr(a.invoice_num,1,9) = l.invoice_num
and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key
select
pap.full_name employe_name,
     k.SEGMENT1 ||'.' ||k.segment2 Cost_Center,
     a.invoice_num Invoice_Number,
     b.item_description Line_Item,
     b.amount Amount,
     cc.trx_id Corporate_Card_Transaction_Id,
     cc.transaction_date Date_Charge_Incurred,
     cc.posted_date Date_Charge_Posted_To_USBank,
     cc.creation_date Date_Posted_To_IExpense,
     a.creation_date Expense_Report_Creation_Date,
     l.report_submitted_date Expense_Report_Submitted_Date,
     mgr_apprv_lst.activity_begin_date Managers_Approval_Begin_Date,
     mgr_apprv_lst.activity_end_date Managers_Approval_End_Date,
     pbl_apprv_lst.activity_begin_date AP_Approval_Begin_Date,
     pbl_apprv_lst.activity_end_date AP_Approval_End_Date,
     e.check_date Payment_Date_To_USBank,
     e.check_number Payment_Number,
     mgr_apprv_lst.activity_result_display_name Managers_Process_Result,
     pbl_apprv_lst.activity_result_display_name AP_Process_Result
from
     ap_checks_all e,
     ap_invoice_payments_all d,
     ap_invoices_all c,
ap_expense_report_headers_all a,
     ap_credit_card_trxns_all cc,
     per_all_people_f pap,
     ap_expense_report_headers_all l,
     ap_expense_report_lines_all b,
     gl_code_combinations k,
     (select ias1.user_key,
     ias1.activity_result_display_name,
     ias1.activity_begin_date,
     ias1.activity_end_date
from wf_item_activity_statuses_v ias1,
(select c1.invoice_num
     from ap_checks_all e1,
     ap_invoice_payments_all d1,
     ap_invoices_all c1
     where trunc(e1.check_date) between nvl(:From_Date, trunc(e1.check_date))
     and nvl(:To_Date, trunc(e1.check_date))
and e1.org_id = 141
and e1.void_date IS null
and d1.check_id = e1.check_id
     and c1.invoice_id = d1.invoice_id) inv_lst1
where ias1.item_type = 'APEXP'
and ias1.user_key = inv_lst1.invoice_num
and ias1.activity_name = 'AP_MANAGER_APPROVAL_PROCESS') mgr_apprv_lst,
(select ias2.user_key,
     ias2.activity_result_display_name,
     ias2.activity_begin_date,
     ias2.activity_end_date
from wf_item_activity_statuses_v ias2,
(select c2.invoice_num
     from ap_checks_all e2,
     ap_invoice_payments_all d2,
     ap_invoices_all c2
     where trunc(e2.check_date) between nvl(:From_Date, trunc(e2.check_date))
     and nvl(:To_Date, trunc(e2.check_date))
and e2.org_id = 141
and e2.void_date IS null
and d2.check_id = e2.check_id
     and c2.invoice_id = d2.invoice_id) inv_lst2
where ias2.item_type = 'APEXP'
and ias2.user_key = inv_lst2.invoice_num
and ias2.activity_name = 'AP_PAYABLES_APPROVAL_PROCESS') pbl_apprv_lst
where
trunc(e.check_date) between nvl(:From_Date, trunc(e.check_date))
and nvl(:To_Date, trunc(e.check_date))
and e.org_id = 141
and e.void_date IS null
and d.check_id = e.check_id
and c.invoice_id = d.invoice_id
and a.invoice_num = c.invoice_num
and a.source = 'CREDIT CARD'
and a.employee_id = nvl(:Emp_id,a.employee_id)
and a.report_header_id = b.report_header_id
and cc.trx_id = b.credit_card_trx_id
and pap.person_id = a.employee_id
and pap.effective_start_date <= trunc(sysdate)
and pap.effective_end_date >= trunc(sysdate)
and k.code_combination_id = b.code_combination_id
and k.segment2 between nvl(:From_Cost_Center,k.segment2)
and nvl(:To_Cost_Center,k.segment2)
and substr(a.invoice_num,1,9) = l.invoice_num
and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key

Hi
If I understood correctly your logic, and if the columns involved are of type varchar2, you can use the like operator:
and a.invoice_num like l.invoice_num || '%'
and c.invoice_num like mgr_apprv_lst.user_key  || '%'
and c.invoice_num like pbl_apprv_lst.user_key  || '%'In this case, Oracle will be able to use the indexes. If they are numeric, you need to do something like:
and a.invoice_num between l.invoice_num * 1000000
                            and l.invoice_num * 1000000 + 999999I hope this makes sense...
Luis

Similar Messages

  • Function Based Index - Query Performance

    HI,
    Good Day to All..
    I'd like to use function based indexes on following column(to_char(ps.user_pc_id)).
    Whereas this column is part of PRIMARY KEY.
    Is it possible to create a function based index on PRIMARY KEY Column?
    Attached below is the query with the explain plan ...
    TO_CHAR Expression - Performance
    Thanks for your reply.

    DTYLER_APP@pssdev2> create table dt_fbi_pk(id varchar2(20));
    Table created.
    DTYLER_APP@pssdev2> drop table dt_fbi_pk;
    Table dropped.
    DTYLER_APP@pssdev2> create table dt_fbi(id number);
    Table created.
    DTYLER_APP@pssdev2> create index dt_fbi_idx on dt_fbi(to_char(id));
    Index created.
    DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_pk primary key (id);
    Table altered.
    DTYLER_APP@pssdev2> select constraint_name,constraint_type, index_name from user_constraints where table_name='DT_FBI';
    CONSTRAINT_NAME                C INDEX_NAME
    DT_FBI_PK                      P DT_FBI_PK
    1 row selected.When we created the primary key constraint, Oracle created a new index rather than using the existing one because....
    DTYLER_APP@pssdev2> alter table dt_fbi drop primary key;
    Table altered.
    DTYLER_APP@pssdev2> select index_name from user_indexes where table_name ='DT_FBI';
    INDEX_NAME
    DT_FBI_IDX
    1 row selected.
    DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_pk primary key (id) using index dt_fbi_idx;
    alter table dt_fbi add constraint dt_fbi_pk primary key (id) using index dt_fbi_idx
    ERROR at line 1:
    ORA-14196: Specified index cannot be used to enforce the constraint.
    DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_uk unique(id) using index dt_fbi_idx;
    alter table dt_fbi add constraint dt_fbi_uk unique(id) using index dt_fbi_idx
    ERROR at line 1:
    ORA-14196: Specified index cannot be used to enforce the constraint.We can't use a function based index to enforce a unique or primary key constraint. Changing the syntax does not help..
    DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_uk unique(TO_CHAR(id)) using index dt_fbi_idx;
    alter table dt_fbi add constraint dt_fbi_uk unique(TO_CHAR(id)) using index dt_fbi_idx
    ERROR at line 1:
    ORA-00904: : invalid identifierWe can create a unique index however
    DTYLER_APP@pssdev2> drop index dt_fbi_idx;
    Index dropped.
    DTYLER_APP@pssdev2> create unique index dt_fbi_idx on dt_fbi(to_char(id));
    Index created.but we still can't use it to enforce a unique or primary key constraint
    DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_pk primary key (id) using index dt_fbi_idx;
    alter table dt_fbi add constraint dt_fbi_pk primary key (id) using index dt_fbi_idx
    ERROR at line 1:
    ORA-14196: Specified index cannot be used to enforce the constraint.
    DTYLER_APP@pssdev2> alter table dt_fbi add constraint dt_fbi_uk unique(id) using index dt_fbi_idx;
    alter table dt_fbi add constraint dt_fbi_uk unique(id) using index dt_fbi_idx
    ERROR at line 1:
    ORA-14196: Specified index cannot be used to enforce the constraint.So no, you can't use it for a primary key. If you just want to enforce uniqueness then yes, you can do it with a unique index, but not a constraint.
    DTYLER_APP@pssdev2> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    5 rows selected.HTH
    Daviid

  • Can I use table function inside Dynamic query ?

    Dear Gurus,
    I have following code
    DECLARE
    TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
    OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
    QUERY_STRING VARCHAR2(4000);
    BEGIN
    OtherNoList := CRITERIA_LIST_TABLE();
    SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
    QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
    'SELECT C1,'||
    'C2 '||
    'FROM TAB1 ,'||
    'TABLE( '||
              'CAST (OtherNoList AS CRITERIA_LIST_TABLE) '||
                   ') OTHRNOS '||
    'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
    DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
    EXECUTE IMMEDIATE QUERY_STRING;
    END;
    Can I use Table function inside dynamic query.
    Thanking in advance
    Sanjeev

    Try:
    DECLARE
    TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
    OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
    QUERY_STRING VARCHAR2(4000);
    BEGIN
    OtherNoList := CRITERIA_LIST_TABLE();
    SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
    QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
    'SELECT C1,'||
    'C2 '||
    'FROM TAB1 ,'||
    'TABLE( '||
    'CAST (:OtherNoList AS CRITERIA_LIST_TABLE) '||
    ') OTHRNOS '||
    'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
    DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
    EXECUTE IMMEDIATE QUERY_STRING using OtherNoList;
    END;p.s. not tested
    Amiel Davis

  • Error in using aggregate function in Outer Query in Siebel Analytics

    Hi,
    When I am using aggregate function in outer query in Siebel Analytics I am facing error.
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 59111] The SQL statement must include a GROUP BY clause. (HY000)
    Bellow is the code.
    SELECT test1.username saw_0, test1.desg saw_1,COUNT (test2.querydate) saw_2
    FROM (SELECT POSITION.CBL username,
    POSITION.CBP desg
    FROM "CM"
    WHERE (POSITION.BPTCD = 'Marketing')
    AND (POSITION.EDate =TIMESTAMP '1899-01-01 00:00:00'
    ) test1,
    (SELECT users.UN username,
    measures."Query Count" querycount,
    measures."Max Total Time" secs,
    topic.db dashboardname,
    "Query Time".DATE querydate
    FROM "Plan"
    WHERE (topic."Dashboard Name" IN ('DS'))) test2
    WHERE test2.username = LOWER (test1.username)
    AND test2.dashboardname = 'DS'
    GROUP BY test1.username, test1.desg

    Should your query be a valid SQL query?
    I can't think that the query you have would be valid in a SQL plus window.
    Chris

  • Problem using two function based indexes at once!

    Hello Oracle!
    I've got problems using two function based indexes on geometries at once.
    The problem occures, when I use a spatial join between two geometries both using function based indexes.
    The test case:
    CREATE TABLE quad (centroid NUMBER);
    CREATE TABLE points (no NUMBER, point MDSYS.SDO_GEOMETRY);
    CREATE OR REPLACE FUNCTION getQuad (centroid NUMBER) RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC IS
    BEGIN
    RETURN MDSYS.SDO_GEOMETRY(2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),MDSYS.SDO_ORDINATE_ARRAY(centroid-5,centroid-5,centroid+5,centroid-5,centroid+5,centroid+5,centroid-5,centroid+5,centroid-5,centroid-5));
    END;
    INSERT INTO USER_SDO_GEOM_METADATA VALUES('quad','tiedge.getQuad(centroid)',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', -100, 100, .0000001), MDSYS.SDO_DIM_ELEMENT('Y', -100, 100, .0000001)),NULL);
    CREATE INDEX quad_idx on quad(getQuad(centroid)) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    INSERT INTO quad VALUES (0);
    INSERT INTO quad VALUES (5);
    INSERT INTO quad VALUES (10);
    INSERT INTO points VALUES (1, MDSYS.SDO_GEOMETRY(1001,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),MDSYS.SDO_ORDINATE_ARRAY(4,4)));
    ALTER SESSION SET QUERY_REWRITE_INTEGRITY=TRUSTED;
    ALTER SESSION SET QUERY_REWRITE_ENA[i]Long postings are being truncated to ~1 kB at this time.

    hi there,
    For a better audience for this question, I'd look at the database forum.
    guys on that will be a lot more familiar with FBIs
    thanks
    Barry

  • Using substring function with error

    Hi Guys,
    I have a source field with 1200 characters which need to map to multiple target segments for  132 count of this source field.
    This is not a mandatory field so it sometimes come without any value.
    I am using substring function to breakout the string for every 132 characters and mapped to the target segments.
    There are two problems, first it seems that if source is blank, there will be error.
    Second, if source field come with only eg. 300 characters, error will also occurs.
    I have searched thru SDN and try some of the UDF but to no avail.
    Appreciate your guidance on this problem.
    Regards
    FNG

    H Rahul,
    I have tried your quote but face some syntax error as follows
    Function calculate, Line 6:
    cannot find symbol symbol  : method length() location: class java.lang.String[] j = input.length();       
    Function calculate, Line 26:
    cannot find symbol symbol  : method subString(int,int) location: class java.lang.String[]           
    result.addValue(input.subString(0,EndIndex));                                      ^
    Function calculate, Line 34:
    cannot find symbol symbol  : method subString(int,int) location: class java.lang.String[]                result.addValue(input.subString(StartIndex,EndIndex));                                              ^
    Function calculate, Line 40:
    cannot find symbol symbol  : method subString(int,int) location: class java.lang.String[]                result.addValue(input.subString(StartIndex,EndIndex));                                              ^ Note: /usr/sap/D03/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapd66a3a60002911e09ba9e41f132d6b68/source/com/sap/xi/tf/_MM_MT_COMS_TO_ZME_CRE_CHG_CONTRACT_.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /usr/sap/D03/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapd66a3a60002911e09ba9e41f132d6b68/source/com/sap/xi/tf/_MM_MT_COMS_TO_ZME_CRE_CHG_CONTRACT_.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors

  • How to use Substring function with Case statement.

    Hello Everyone,
    I have one requirement where I have to use substring function on the field for report criteria.
    E.G.
    I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
    now i want to substing it but the character length varies for each branch.
    so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.

    Try something like this:
    CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
    where n is the number of characters you want to start the break.

  • Using substr / instr to parse a filepath help

    I'm having trouble parsing a string per say using sql. I have a column full of file paths. The file paths are similar to:
    C:\Users\Guest\Pictures\example.jp
    I want to be ablt to grab just the file name of the image. I've been working on several variations of a query using the substr function and the instr function. I've come up with the query below. FILEPATH is the name of the column. So far it gives me the file name, but has the '\' in front of it. Can anyone help me get rid of this. Thanks in advance.
    Select substr(FILEPATH, (instr(FILEPATH,'\',-1,1)))
    from Table_Name
    where ID = '101'

    Hi,
    Here's one way:
    SELECT  SUBSTR ( filepath
                   , INSTR ( filepath
                           , -1
                           , 1
                           ) + 1    -- Note   + 1   at end
                    ) AS file_name_only
    FROM    Table_Name 
    WHERE   id = '101'
    SUBSTR (str, p)        returns the last part of string str, starting at position p.  You were passing the position of the last '\' as p; that's why the '\' was included.  If you add 1 to p, like this:
    SUBSTR (str, p+1)      then you'll be passing the position of the 1st character after the last '\'.

  • Using substring function in the Universe

    What is the correct syntax of using the substring function in the Universe?
    I need to extract the numbers and decimal between the #'s, and the character length varies:
    From: DOE, JOHN  Added the following entry to work history:
    A1S#0.25#
    To: 0.25
    Please help!  Thanks!

    There are ticket details in the text - I replaced certain letters with x, o, or a.  I thought you would need the total number of characters in the text.
    0.25#"
    DOE, JOHN A Xddxd xxx xxllxwOIg xIxxI xx wxxk xOXxxxI:
    A1S#0.25#"O xxxxd Oxck xxxm CJ, xx XxOd xxxx wx xxx XuppxXxd xx Ox gxxxOIg xlxxxX xI xxOX.  Xx, xxx quxXxOxI xxmxOIX wxxx xx dx Ixw?  XOxxxx wx mxkx xxx dxcOXOxI xx OgIxxx xxOX cxIdOxOxI xId xxvx Ox xxmxvxd xxxm XmxxxX, xx wx xxI xx xxXxxxcx xxp xxlkxxX xId Xxx Ox wx cxI Xxxp Xxmx xx xxx xxxxxOc, xx wx xxdxx x OOggxx cOxcuOx xx xxIdlx xxx OuxXxX wOxxxux xII dxxpX.  O'll xxI xx xuI xxOX OI mxIxgxmxIx xId xxx xxXx xx xxx xxxm xx Xxx wxOcx wxI wx wxIx xx gx".
    1#"
    DXX, JXXN X XddXd xxX xxllxAxng XnxrN xx Axrk xxAxxrN:
    A1S#1#"X dxn'x AXX xxxA xn AxnAxrd.  X AxA gxxng xx AxXAk xxX xnxXrxxAX xx AXX xx ApxkXA xn xxrxugxpux AXrX xbAXrvXd xA xxA bXXn AuggXAxXd, xxAXvXr, xxA nxx xn AxnAxrd.  X AxXAkXd Dxrx xnd dxn'x AXX xnN xndxAxxxxn xxxx xxxA xA xn xnN xlxrI grxupA xxr xxrXAxxld Ixnxxxrxng, Ax X'I AxndXrxng AxXrX xxX xlxrI xA AxIxng xrxI.  Xx Axuld bX xxxx xxXrX xA nx xnxXnxxxn xx bX xlxrIxng xn xxxA xx xll xnd xxX xlxrIA Axuld bX AxIxng xrxI xn xld Ixnxxxrxng AxurAX xxxx xA nx lxngXr vxlxd (xX, xxxA AlxppXd xxrxugx xxX ArxAkA AxIXxxA).  X AXnx xn XIxxl xx AurxxA JxnXA xx AXX xx xX Axn xXll Axxx xxX AxurAX xx xxX xlxrI xA (xX, Axxx Ixnxxxrxng ANAxXI xAxuxllN gXnXrxxXd xxX xlxrI)."
    0.5#
    DOE, JOHN A Xaaxa xax OolloxixI xxxIx xo xoIk aisxoIx:
    A1S#.05# "XIxxsOxIIixI xo IXS XixI x quxux OoI xaaixioxxl ixOoIoxxiox xxa Ixcoooaxxioxs."

  • Optmizing use of function in a query

    select a1.*, test_pkg.test_function(section_id) record_id
    from (
    select project_id, student_id, max(se.section_id) section_id
    from college c, students s, sections se, zone z
    where c.college_id in (121, 123, 124)
    and s.student_id = c.student_id
    and s.section_id = z.response_id
    and z.section_id = s.section_id
    group by c.project_id, s.student_id) a1;
    the question is I am hitting the test_pkg.test_function for each student_id
    I want it only in case the section_id is different i.e for unique section_id..
    right now i use the inner query to populate the table and then use a cursor to update the
    record_id. this is fast since in the cursor i hit the funtion only for unique section_id's
    Is there a way to make my query faster and in 1 go instead of updating it later...
    I mean can i populate the table using a single query...
    NOTE: May be the joins are wrong, i just manipulated them.....
    using oracle 10g
    thank you

    Something else you can try is to use an inline view. Here when you say you only have 1500 sections, i'm assuming that's the number of records in your section table. I've also added the NO_MERGE hint in to this so that the optimizer doesn't decide to merge this inline query into the rest of the joins (then it would apply the function many more times).
    select project_id, student_id, max(se.section_id) section_id, se.record_id
    from college c, students s, (select /*+ NO_MERGE */ section_id, test_pkg.test_function(section_id) as record_id from sections) se, zone z
    where c.college_id in (121, 123, 124)
    and s.student_id = c.student_id
    and s.section_id = z.response_id
    and z.section_id = s.section_id
    [pre]
    as you said in your original post, the joins are not all correct (there is NO join to the sections table in your query....i'd assume there should be one.
    If the performance of that isn't acceptable you could look into making a materialized view, or a function based index, etc...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Using substring function in the dashboard prompt

    Hi,
    I want to use a function in the dashboard prompt.
    Example: Subject Area:Paint --> Products --> Color
    I want to take second letter of color, describe a label for it and use this label in prompt. The formula is below;
    CASE WHEN (SUBSTRING(Products.Color FROM 2 FOR 1) = 'a') THEN 'AAA' ELSE 'BBB' END
    Dashboard prompt should list 3 choices; All choices, AAA, BBB.
    When selecting AAA in the prompt, these colors should be listed in the request; Carriage House Red, Dante, Manchester Red.
    I created a dashboard prompt (add a function) and a request. When selecting AAA in the prompt, it sends "AAA" as prompt, not sends "a". So I couldn't reach the result.
    Is it possible? Could anyone help me ASAP?
    Thanks & Best Regards,

    Create a column in the logical layer using the same formula that you described. Then use the new column in the prompt. Then add the new column to the report as 'is prompted'.

  • Using a function module in a search help.

    People,
    I make a function module for a search help. Into the function module I call a function 'K_GROUP_SELECT' that show me a screen to make another search but I don't know how can I put the value that this function return me in the field that the user click the button of the search help in my program.
    This is the code that I put in the function module.
    Thanks!
    FUNCTION Z_GROUP_SELECT_ZFINCOKOH1_B.
    *"*"Local Interface:
    *"  TABLES
    *"      SHLP_TAB TYPE  SHLP_DESCT
    *"      RECORD_TAB STRUCTURE  SEAHLPRES
    *"  CHANGING
    *"     VALUE(CALLCONTROL) LIKE  DDSHF4CTRL STRUCTURE  DDSHF4CTRL
    *"     VALUE(SHLP) TYPE  SHLP_DESCR
    tables: setheader.
    data: setname type setheader-setname.
      CONSTANTS:
                  CLASS         TYPE SETCLASS VALUE '0103',
                  FIELD_NAME    TYPE RGSBS-FIELD  VALUE '*',
                  KOKRS         TYPE TKA01-KOKRS  VALUE 'BPPR',
                  KTOPL         TYPE TKA01-Ktopl VALUE 'CAPI'.
    IF callcontrol-step = 'SELECT'.
    *PERFORM k_group_select USING: CLASS, FIELD_NAME, KOKRS, KTOPL.
    CALL FUNCTION 'K_GROUP_SELECT'
      EXPORTING
       BUTTONS                  = 'X'
       CLASS                    = CLASS
       CRUSER                   = '*'
       field_name               = FIELD_NAME
       SEARCHFLD                = '    '
       SEARCHFLD_INPUT          = 'X'
       SEARCHFLD_REQUIRED       = 'X'
       SET                      = '*'
       START_COLUMN             = 10
       START_ROW                = 5
       TABLE                    = 'CCSS'
       TYPELIST                 = 'BS'
       UPDUSER                  = '*'
       KOKRS                    = KOKRS
       KTOPL                    = KTOPL
    IMPORTING
       SET_NAME                 = setname
    EXCEPTIONS
       NO_SET_PICKED            = 1
       OTHERS                   = 2
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endif.
    ENDFUNCTION.

    Carlos,  Please see the following program. It is working well in my system.  The only difference is that I've implemented you function module as a subroutine instead of in a FM.   You can see that it will return the selected value back to the screen field.
    report zrich_0002 .
    data: setname type setheader-setname.
    parameters: p_val type setheader-setname.
    data: dynfields type table of dynpread with header line.
    data: return type table of ddshretval with header line.
    at selection-screen on value-request for p_val.
      perform f4_help.
      p_val = setname.
    start-of-selection.
    *       FORM f4_help                                                  *
    form f4_help.
      constants: class  type setclass value '0103',
                 field_name    type rgsbs-field  value '*',
                 kokrs  type tka01-kokrs  value 'BPPR',
                 ktopl  type  tka01-ktopl value 'CAPI'.
      call function 'K_GROUP_SELECT'
           exporting
                buttons            = 'X'
                class              = class
                cruser             = '*'
                field_name         = field_name
                searchfld          = '    '
                searchfld_input    = 'X'
                searchfld_required = 'X'
                set                = '*'
                start_column       = 10
                start_row          = 5
                table              = 'CCSS'
                typelist           = 'BS'
                upduser            = '*'
                kokrs              = kokrs
                ktopl              = ktopl
           importing
                set_name           = setname
           exceptions
                no_set_picked      = 1
                others             = 2.
    endform.
    REgards,
    Rich HEilman

  • Using custom functions in a query

    Hi, I have a query in a PLSQL procedure where some of the fields are data retreived from custom functions,
    i. e.
    select a, b, funcThatNeedsA(a), funcThatNeedsB(b)
    from xxxx
    where ...
    but I also could use those functions by making a loop to a cursor
    i. e.
    cursor c_data is select a, b from xxxx where ...
    for r_data in c_data loop
    l_a = funcThatNeedsA(r_data.a);
    l_b = funcThatNeedsB(r_data.b);
    end loop;
    So, my question is: what is more efficient, to use the functions directly in the query or in a loop of a cursor?

    the overhead of calling your functions will not change based on using them in a loop vs a cursor. the concern is the performance of ANY loop vs not using a loop at all. so what else are you doing in the loop? does it really need to be in a loop? for example, this
    insert into a select * from b
    is faster than
    for rec in (select * from b) loop insert into a values(rec); end loop;

  • Cannot use MAX function in PS Query

    I am trying to use Query to select the max ( effdt ) from a table.
    First, I use the 'Criteria' page to have
    (1) Expression 1 = A.EFFDT - Effective Date, (2) Condition type = equal to, (3) Expression 2 = Subquery
    Then the Subquery is:
    (1) In the 'Field' page, I choose field E.EFFDT - Effective Date, (2) then click on 'EDIT', (3) then click on 'Max', (4) then click on 'OK' button
    I then get this message: 'This field is an aggregate field but is being used in non-having criteria.(139,136). The query may fail if this is not corrected'
    And as i try run anyway this query, i get this message:
    SQL error. Stmt #: 5653 Error Position: 349 Return: 934 - ORA-00934: group function is not allowed here
    A SQL error occurred. Please consult your system log for details.
    Error in running query because of SQL Error, Code=934, Message=ORA-00934: group function is not allowed here (50,380)
    NOTE: This max sql would work if i run using SqlPlus
    How can i get Query to use max( effdt ) ?
    Any clue anyone ? THANKS

    Yes Using it as MAX is OK.
    Problem is once you use it as MAX of a field, it wouln't allow this field for you to use it anymore.
    A workaround i found that helped is to use the expression let's say 'MAX( a.JOB )' and use this as field.
    This way, the system will allow me to use the JOBCODE field.
    Thank you for all your helps as it leads me to the soln.

  • Error while using substring function

    Hi,
    I am getting the below error while using this query.
    Substr("Fin Account".ASSET_NUM, instr(Fin Account".ASSET_NUM, ':')+1)
    (nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <(>: Syntax error [nQSError: 26012] . (HY000)
    Please help me..
    Edited by: user10441472 on Jun 24, 2009 12:49 PM

    Substr("Fin Account".ASSET_NUM, 1, instr(Fin Account".ASSET_NUM, ':')+1)
    or
    Substr("Fin Account".ASSET_NUM, instr(Fin Account".ASSET_NUM, ':')+1,50)
    i think you should use 3 parameters, did you try that if it would work?
    additionally check what is the default format of your data: go to column properties -> data format; if its text then ok; otherwise you will have to cast the number to char; in such a case the above could be:
    Substr(cast("Fin Account".ASSET_NUM as char(20)), 1, instr(cast(Fin Account".ASSET_NUM as char(20)), ':')+1)
    or
    Substr(cast("Fin Account".ASSET_NUM as char(20)), instr(cast(Fin Account".ASSET_NUM as char(20)), ':')+1,50)
    Edited by: UserMB on Jun 25, 2009 6:17 AM

Maybe you are looking for

  • Dowloading TV Shows from DVD's to Visio

    Does anyone know how to dowload TV shows from DVD's to your Vision M? I have Windows Media Player . For two days I've been trying to save (rip) one of my favorite televison show DVD's and I just can't get it right. Can I download the contents of the

  • Is there a Report Painter mass generate?

    We are in the process of upgrading to ECC 6.0 and all of our Z* Report Painters were not regenerated.  We can do them one at a time in trans code 'GRR3'.  I was wondering if there was a way to mass generate all Z* Report Painters at once?

  • Users getting upgrade prompt with SilentAutoUpdateEnable=1 set

    We've been deploying Flash Player  11.6.602.180 to our desktops recently, along with this mms.cfg: AutoUpdateDisable=0 SilentAutoUpdateEnable=1 SilentAutoUpdateServerDomain=(internal server) Users are getting propted to upgrade via the red Adobe box.

  • How much space does iTunes take?

    I'm afraid if it's too much, my laptop won't function properly. My laptop is already slowing down from all of it's contents. I want to know how much memory (in MB) iTunes takes up before downloading it on my laptop.

  • Picture to JDBC adapter.

    Hi, I need to send a picture to a Database table. Please can you assist? How do I get the picture into the SQL query. Your assistance in this regard will be highly appreciated. Regards Willie Hugo