Dynamic Sort of Records in a Block

Dear Experts
I am using only Forms 4.5.
I have two separate datatable blocks, which I want to consolidate and move it to another block and sort on itemwise.
What is the command to sort the block based on a column dynamically ?
Should I have to do it by writing procedure ?
Please help.
Thanks
Richard, India
null

If it's a database block, then it's best to use set_block_property(your_block, order_by, ord_by_clause). That really means a requery, for the server is really efficient in sorting.
Otherways ... Sorting the block on the client side, that would be really slooooow if using PL/SQL, and not some efficient program written in C/C++.
null

Similar Messages

  • Dynamic Sorting on Multiple filed in Crystal report 2008

    Hi
      I am using Crystal report 2008 sp3 full build with hotfix 3.3 along with ASP.NET 2.0
      I have implimented the multi filed sorting using the record sort export and setting the sort order in the report designer.
    Now my requirement is such that i would like to have dynamic sorting on multiple fileds while report is displayed in the UI.
    Means suppose i have a report with Customer region,name,city,rating,status etc.
    Now by using the sort control  i would like to have the functionality in such a way that if user
    a)  first sorts on the region then the records should be first sorted by region
    b)  then sorts on the city then the records should be sorted first by region then by city
    c) now sorts on the  rating then the records should be sorted first by region ,second by city and then by rating
    Now other user may do
    a) first sorts on the rating then the records should be first sorted by rating
    b)  then sorts on the status then the records should be sorted first by rating then by status
    c) now user sorts on the  region then the records should be sorted first by rating,second by status and then by region
    and so on the sorting criteria changes from user to user through the UI.
    Is there any way to achieve the dynamic kind of sorting with Crytsal report 2008 where we can set the order of the fileds at sorting in UI dynamically .The sorting order of the fields are not known at the time of design of the report and its completely depends on the user's need.
    Please let me know if you require any information on the same.
    Regards,
    smitha

    Hello,
       Good Day!
       Thanks for your answer.
       Could you please explain me in detail how to achieve this functionality?
       Do i need to create a static parameter?
       I  get my data set through the command option in crystal report.So i think i need to go by formula in the report.
       i am just putting down the steps to follow.Please correct me if i am wrong.
      step1 :Create s static parameter with the name SORT.
    step2: create the formula as you have mentioned like     
        (IF {?Sort}='Vendor Number' THEN {Pr_Voucher_Status;1.Vendor_Key}& " "& {Pr_Voucher_Status;1.ap_remt_key}
        & " " & {@date}
       else
        IF {?Sort}='Invoice Number' THEN {Pr_Voucher_Status;1.ap_vchr_invno}& " " & {Pr_Voucher_Status;1.Vendor_Key}&
        " " &{@date}
       else
       IF {?Sort}='Invoice Amount' THEN {Pr_Voucher_Status;1.ap_vchr_amtc}& " " & {Pr_Voucher_Status;1.Vendor_Key}&
         " " &{@date})
        I could not  understand what this formula is really doing .
        Could you please tell me what the following names indicates? :
                  Pr_Voucher_Status :- Table/Command name ??
                  Vendor Number,Invoice Number etc.. :-  ??
                 Vendor_Key,ap_vchr_invno,ap_vchr_amtc .. :-  Filed names ??
                 use of 1.{} :- ??                              
    step3: place the below formula in the page header  to display the sort order
        (if {?SORT}='Vendor Number' then "Vendor Number, Remit To, Invoice Date"
              else if {?SORT}='Invoice Number' then "Invoice Number, Vendor Number, Invoice Date"
              else if {?SORT}='Invoice Amount' then "Invoice Amount, Vendor Number, Invoice Date") .
    Note:-My report does not have grouping.Do i need to have grouping?
    in this case how the sort control will work  ?
    As i have mentioned in the first post the order of sorting is completely depends on the user's perspective .
    The report is used by the whole organization ..
    i mean the people with different roles like Manger,Team leads,modul leads,developers ,testers etc..
    the usage of report varies according to the roles so the sort order also.
    Regards,
    smitha.
    Edited by: smitha thomas on Mar 16, 2011 5:01 AM

  • Dynamically creating a Record Group based on Previously entered Record Grou

    Forms [32 Bit] Version 10.1.2.3.0 (Production)
    Hi,
    I know how to dynamically create a record group based on a query and putting the code in When new form instance.
    My query is. I have a form which has multiple Record Groups and the user wants to dynamically create subsequent groups based on previous groups.
    For example
    I have a record group with selects a Location,
    when the user selects the Location from a list of values
    the 2nd record group called 'Cost Centres' will have to filter out only those with the locations selected above.
    How can I populate the 2nd record group at run-time when I do not know what site the user will select?
    If I simply populate in when new form instance as in location and just select everything, the list of values populates.
    CC field is a LIST ITEM and the list style is a POP LIST, it is not required.
    I have put the code in the Location field in the when-list-changed trigger.
    I am getting this error:
    frm-41337: cannot populate the list from the record group
    here is the code:
    DECLARE
    v_recsql Varchar2(1000); -- The SQL for creating the Record Group.
    v_recgrp RecordGroup; -- Record Group
    v_status Number; -- Return Value of Populate_Group function.
    c_where VARCHAR2(1000);
    BEGIN
         IF :location = '1' THEN
              c_where := ' substr(cost_centre,1,2) in (''01'',''02'')';
         ELSIF :location  = '2' THEN
              c_where := ' substr(cost_centre,1,2) in (''02'',''03'')';
         ELSIF :location   = '3' THEN
              c_where := ' substr(cost_centre,1,2) in (''01'',''11'',''07'')';
                   ELSE
              c_where :=  ' 1=1'; --EVERYTHING
         END IF;
    v_recsql := 'SELECT cost_centre, description  FROM   cost_centres  where '||c_where;
    -- Create the Record Group
    v_recgrp := CREATE_GROUP_FROM_QUERY('v_recgrp', v_recsql);
    IF NOT ID_NULL(v_recgrp)
    THEN -- No Error, record group has been successfully created.
    -- Populate Record Group
    v_status := POPULATE_GROUP('v_recgrp');
    IF v_status = 0
    THEN -- No Error. Record Group has been Populated.
    POPULATE_LIST('block.CC', 'v_recgrp');
    END IF; -- IF v_status = 0
    -- Delete the Record Group as it is no longer needed.
    DELETE_GROUP('v_recgrp');
    END IF; -- IF NOT ID_NULL(v_recgrp)
    END;thanks for your assistance.

    Hi,
    Once record status gets change for block you can not populate/repopulate the list item. Keep those list items as non-database item with different names and create different items as database orignal items. Than assign the values in WHEN-LIST-CHANGE trigger to the actual database items.
    -Ammad

  • Filtering records in a block

    Hi all,
    I am working on form developed by some other party.
    In this form one is control block which contains a combo box.
    There is another data block which is based on a table.
    When I run the form the records in this block are filtered by the value chosen in combo box.
    But I am not able to find the code where this functionality is achieved.
    I have checked WHERE clause property of block and the property is null.
    Also default_where is not set at runtime.
    Is there any other way to filter records in a block?
    Thanks in advance.
    MK

    Hi there,
    If there a Push Button on the Control Block to initiate the Execute query for the data block, then the code is in the When-Button-pressed trigger.
    If there is no Push Button and if the data block (based on table) changes after a new value is chosen from the combo box, then the default_where or onetime_where code may be hiding behind a When-Validate-item trigger (or some other trigger) in the combo box.
    In our application, we have many 'search' fields in the control block. We use a Push Button to build the dynamic where clause for the data block.
    Regards,
    John

  • Want to sort the records based on non-base table item

    I have a multi-record block and I am trying to sort the data based on nbt item
    I have a table called X which has x_type,x_code fields.
    The table on which the block is created is Y. the table Y has x_type and y_desc as its fields
    form layout is like below .the x_type is key field on which I have to query the records
    and x_code is a non-base item in the form.I want to sort the records by X_code.
    x_code y_desc
    A     xyz
    c par
    B     lmn
    my pre-query has this code
    select x_type from y
    where
    x_type := x_type;
    post-query has this code
    select x_code from x
    where x_type = :x_type;     
    It works fine in Enter-Queryand execute query mode. but when I am sorting the records on
    nbt item x_code by SET-BLOCK-PROPERTY it doesn't do any thing

    Hi Tony ,
    I have created a function and in Pre-Query & have add this
    SET_BLOCK_PROPERTY('b1', ORDER_BY, 'fn_get_code(x_type)');
    and the function created is as below
    Function fn_get_code (p_x_type in varchar2) return varchar2 is
    v_code varchar2(40);
    begin
    select x_code into v_code
    from X, Y
    where X.x_type = Y.x_type
    and y.x_type = p_x_type
    return v_code;
    end;
    when I run the form and execute query it comes up with the error message
    FRM-40505 and when I pressed display error it shows
    SQL Statement error:
    SELECT ROWID,X_TYPE,X_CODE
    FROM Y order by fn_get_code(x_type)
    Error:
    "ORA-00904: "FN_GET_code": invalid identifier"
    Is it that I need to create a function on the database?. As I have created function
    in program unit section

  • How to acheive Pagination and Dynamic sorting in Web layout.

    Hi All,
    I'm new to Oracle Reports. I use Report Builder 10.1.2.0.2.
    I tried creating a template for simple tabular report. I modified the tempalte for Paper layout, Web layout ie modified .tdf, html, css files.
    When the data is dispalyed in the web browser, i need to do Pagination and dynamic sorting (ie when the column heading is clicked, it needs to do sorting by that column).
    In the jsp page of the report, it is possible but i want to incorporate this functionality in the Template. So that a single template can be used across multiple reprots with out any modification.
    Can any one please tell me how to do this.
    Please reply me at the earliest. Its very urgent.
    Thanks & Regards,
    P. Gayathri Devi

    Igor,
    You'll need to switch from using Partial Page Rendering to full page submits on that report. In version 4.0 we should be getting more control over event handling in PPRs but to what extent is still unknown.
    Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen
    http://sourceforge.net/projects/plrecur

  • How can I update record in the block that Data Source is PROCEDURE?

    I like use Procedure as the Data Source of block.It's very flexible.
    Usually I do this only query the record,but now I must update record in the block that Data Source is Procedure.
    What next step can I do?Can anyone offer some examples?
    This is example, you goto
    http://www.2shared.com/file/1923834/e0b65fb7/Example.html
    Wait about 30 sec, Click "Save file to your PC: click here",and then you can download it.

    <p>I have written an article about some advanced Forms features.
    Have a look at the 2.3.2 paragraph</p>
    Francois

  • Dynamically  populate  a  record  group  on  the  fly uisng LOV

    Hi,
    I want to create dynamically populate a record group on the fly uisng LOV.
    1. This is how the RG_BANKNAME Record Group object look like
    Object : Record Group
    Name : RG_BANKNAME
    Record Group Query : SELECT NAME, SHORT_NAME FROM C_BANKS
    2. I create the Push Button and when user click it will popup the LOV.
    DECLARE
         rg_id RecordGroup;
         errcode NUMBER;
         status BOOLEAN;
    BEGIN
         rg_id := Find_Group('RG_BANKNAME');
         IF Id_Null(rg_id) THEN
              Message('No such group: ',ACKNOWLEDGE);
              RAISE Form_Trigger_Failure;
         ELSE
              errcode :=POPULATE_GROUP(rg_id);     
              SET_LOV_PROPERTY('LV_NAME', TITLE, 'My Own LOV');
              SET_LOV_PROPERTY('LV_NAME', GROUP_NAME, rg_id);
              SET_LOV_COLUMN_PROPERTY('LV_NAME', 1 ,Title, 'NAME');
              SET_LOV_COLUMN_PROPERTY('LV_NAME', 1 ,Width, 150);     
              SET_LOV_COLUMN_PROPERTY('LV_NAME', 2 ,Title, 'SHORT NAME');
              SET_LOV_COLUMN_PROPERTY('LV_NAME', 2 ,Width, 100);     
              status := Show_LOV('LV_NAME',10,20);
              IF NOT status THEN
                   Message('You have not selected a value.');
                   Bell;
              END IF;
         END IF;
    END;
    My question is do I need to create the LOV Object name call 'LV_NAME'? since I don't have this
    create on my design times, because I thought it can be done dynamically on the fly.
    The problem is compliant that the Lov Id is not valid.
    Thanks
    David
    Edited by: user445990 on May 24, 2011 9:19 PM

    Hello,
    You request is not clear. Do you need to display the LOV or not ? In other words, what is the goal of your record group ?
    Francois

  • Error in ST05 - trace record pair error block. How to resolve/tackle issue?

    Hello,
    Someone approached me last week in asking me how to resolve an issue in ST05. Basically I used the transaction to filter "inclusive VBPA".
    The error is ....
    Internal error - trace record pair error block 8 link no. 0
    Message no. 0S 026
    Diagnosis
        Each SQL statement is described by two SQL trace records that have the
        same link number. In this case, there are at least three records with the
        same link number.
        The system outputs the number of the block in which the third SQL trace
        record was found, as well as the link number of the records.
    System response
        Program processing continues after the message is displayed. The system
        processes all of the trace records. You should assume, however, that the
        SQL trace in this case is not displayed correctly.
    Procedure
    You cannot correct this error yourself. If you can reproduce the error,
    contact the SAP Hotline.
    SQL trace list editing terminated after 6 errors
    While using the trace I am executing the program that selects VBPA once and, I am assuming, as it goes through the BAPI BAPI_SALESORDER_CHANGE used to unblock a delivery block. I am guessing the problem or source is from the BAPI but do you guys have other insights in what is causing this issue?
    Thanks again, hope to hear from you soon, and good day.

    Our ERP LIVE Production around 11am all users encountered cannot generate print record from the submit new request. see below errorFor production issues, please log a SR.
    ORA-00060: Deadlock detected. More info in file /u/oracle/PROD/db/tech_st/11.1.0/admin/PROD_tailindb/diag/rdbms/prod/PROD/trace/PROD_ora_4026.trc.
    ORA-00060: Deadlock detected. More info in file /u/oracle/PROD/db/tech_st/11.1.0/admin/PROD_tailindb/diag/rdbms/prod/PROD/trace/PROD_ora_4026.trc.
    ORA-00060: Deadlock detected. More info in file /u/oracle/PROD/db/tech_st/11.1.0/admin/PROD_tailindb/diag/rdbms/prod/PROD/trace/PROD_ora_4026.trc.Please see these docs.
    OERR: ORA 60 "deadlock detected while waiting for resource" [ID 18251.1]
    What to do with "ORA-60 Deadlock Detected" Errors [ID 62365.1]
    Thanks,
    Hussein

  • Dynamic call for records in a table

    hI,
    Im having a ztable, the structure is as follows:
    tabold fldold tabnew fldnew
    The records in this table is are:
    1.yvbap  posnr xvbap posnr
    2.yvbak  auart xvbak auart
    3.yvbak  augru xvbak augru.
    Now, i have to use this table dynamically to check each and every record in the program:mv45afzz.
    So, my problem is that, i have to dynamically pass these records which contains table name and its field name.
    i can write as: xvbap-posnr = yvbap-posnr for all the three records (the values will come from sales order tranx, report: mv45afzz)
    but in future if the records are added then i have to again change the code, so this shouldn't happen.
    It should dynamically call all the records in this table and check the condition.
    Thanx
    Rohith

    Hello Rohith
    What is your question???
    You described a few ingredients of your scenario (not all of them) and do not really explain your requirements.
    Given the descriptions of the Z-table fields I assume you need to check whether OLD values are equal to NEW values.
    If this assumption is correct then the solution is quite simple (except for XVBAP / YVBAP: Does this mean single entries or looping over all entries?)
    DATA:
      lt_ztable     TYPE STANDARD TABLE OF zstructure,
      ls_ztable     TYPE zstructure.
      FIELD-SYMBOLS:
        <lt_tab>     TYPE table,
        <ls_struct_old>    TYPE any,
        <ls_struct_new>   TYPE any,
        <ld_old>    TYPE any,
       <ld_new>    TYPE any.
    " Read entries from z-table
      SELECT * FROM ztable INTO table lt_ztable.
      LOOP AT lt_ztable INTO ls_ztable.
        ASSIGN (ls_ztable-tabold) TO <ls_struct_old>.
        ASSIGN (ls_ztable-tabnew) TO <ls_struct_new>.
        ASSIGN COMPONENT (ls_ztable-fldold) OF STRUCTURE <ls_struct_old> TO <ld_old>.
        ASSIGN COMPONENT (ls_ztable-fldnew) OF STRUCTURE <ls_struct_new> TO <ld_new>.
        IF ( <ld_old> = <ld_new> ).
          " do something...
        ENDIF.
      ENDLOOP.
    For the sake of simplicity I did not add the required statements for checking successful ASSIGN's.
    Regards
      Uwe

  • Unable to insert record in child block

    Dear all,
    I am facing a very strange problem.
    Actually i have a master-detail form where i need to insert master record as well as child records for the corresponding master item.
    For this i have a LOV in master block which populate the master item and execute the coresponding child records.
    so first time when i load the form i select a item from master block through a LOV this time :SYSTEM.BLOCK_STATUS is NEW and i populate a item from LOV then :SYSTEM.BLOCK_STATUS is NEW changed to query and i have inserted a next record in child block pressed F10 and it saved very well.
    But the problem is when i again select another item from master block through LOV and again tried to insert a record in child record this time it won't saved and the very stragly the cusor moved to master item showing the FRM-40600'Record has already been inserted'
    Please help why is it happening ?
    Need yours help.

    But the problem is when i again select another item from master block through LOV and again tried to insert a record in child record this time it won't saved and the very stragly the cusor moved to master item showing the FRM-40600'Record has already been inserted'When you select a new record in the Master block through the LOV, make sure you clear your form before you query the selected record. Forms thinks you are modifying the same master record and not a new record.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • FRM-40654 error in master-detail form while deleting record in detail block

    Hi,
    I am facing an issue in a custom form which is a Master-detail form while deleting a record in detail block. It is giving an error "FRM-40654 Record has been Updated by another user. Re-query to see change". I have checked the record is matching with that in database.
    Can anyone help on this.
    Thanks In Advance,
    Midhun

    Hi jan,
    master block is based on Table "A" and detail block is based on a View "X".
    View "X" definitions includes the tables "A","B","C" etc..
    Now I have tried removing table"A" from view "X", even then the same error is ocuuring but the lock is happening on table "B" instead of "A"
    Thanks,
    Midhun

  • How to loop through records in a block

    How do I get the count of records in a data block after the EXECUTE_QUERY?
    If I want to manually insert or update records into the table from the datablock how do I loop thru' records in the block.?
    Also for 'WHERE' clause of update statement is there anyway to tie up the rowid to the current row in the form.

    Use get_block_property('block',QUERY_HITS).
    For the second question :
    Set the properties of block to be INSERT_ALLOWED=FALSE,UPDATE_ALLOWED=FALSE, next do:
    go_block('block');
    first_record;
    set a local handler of errors
    loop
    next_record;
    end loop;
    when others then
    catch the error "Record must be inserted first...'
    For the third question set the DML Returning Value = Yes in property palette of the block and access the rowid as
    declare
    rowid_ rowid;
    begin
    rowid_:=:block.rowid;
    end;
    HTH

  • How to get the total record in the block before save them

    Hello,
    I need to recalculate the amout for all records in one block before saving them.
    How can I get it?
    Thanks for your helping

    You write a loop, something like this:
    Go_block('B1');
    If not form_success then
      Raise Form_Trigger_failure;
    End if;
    First_Record;
    If not form_success then
      Raise Form_Trigger_failure;
    End if;
    Loop
      If :system.record_status in('CHANGED','INSERT') then
        -- modify the record here--
      End if;
      Exit when :System.Last_Record = 'TRUE';
      Next_Record;
    End Loop;
    First_Record;But be very careful-- If your block can fetch a large number of rows, (over 100), this loop can take a long time, and you should not use this method. The loop will continue fetching more rows from the database until all rows satisfying the query are retrieved.

  • Dynamic sort in ALV

    hi all,
    HOw can we write the dynamic sort in ALV.
    regards,
    AJ

    Hi,
    Please find the sample code for dynamic sort in OO ALV
      perform built_sort_table.
    form built_sort_table.
      data ls_sort_wa type lvc_s_sort.
      ls_sort_wa-spos = 1.
      ls_sort_wa-fieldname = 'MATNR'.    "<< here your pass fieldname to sort dynamically
      ls_sort_wa-up = selected.
      ls_sort_wa-subtot = ''.
      append ls_sort_wa to gt_sort.
      ls_sort_wa-spos = 2.
      ls_sort_wa-fieldname = 'STATUS'.  "<< here your pass fieldname to sort dynamically
      ls_sort_wa-up = selected.
      ls_sort_wa-subtot = ''.
      append ls_sort_wa to gt_sort.
    endform.                               " BUILT_SORT_TABLE
        call method grid1->set_table_for_first_display
          exporting
            is_layout                     = gs_layout
            is_variant                    = gs_variant
            i_save                        = 'A'
            it_toolbar_excluding          = i_exclude[]
          changing
            it_outtab                     = i_output[]
            it_fieldcatalog               = i_fieldcat[]
            it_sort                       = gt_sort[]
          exceptions
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            others                        = 4.
    aRs

Maybe you are looking for

  • How to use J2IUN for Excise Payable

    Hi Guru's, Can anyone help me how to utilized J2IUN for excise payment. Regards

  • Numbers formula math incorrect!

    EDIT: I was being stupid! Problem solved. I just bought iWork '08 tonight and love Numbers. But it doesn't add up correct. I created a table and a chart. The following is the table and it adds correctly. $5004.00 => Required Support $500.4 => Committ

  • Trying to migrate DB to 9i

    Hi everybody, I installed 9i and I am trying to manually migrate my previous 8i (Rel 1) db. C:\Oracle\admin\act\pfile>mig PFILE=initact.ora starting up database ... Error code 161 ORA-01061: cannot start up a V8 server using a V7 client application I

  • Using the StringTokenizer

    Hi all, I'ld like to use the StringTokenizer to solve the following situatio: I have a dynamic String as: |type_1:value-1|,...,|type_1:value-n|,|type_2:value-1|,...,|type_2:value-n|,...,|type_n:value-1|,...|type_n:value-n|. So My idea is to get for e

  • Changing phone button template on default device profile?

    I have a default device profile for 7941 that is currently using a phone button template that is one line. What is the impact of changing that to two-line phone button template? Can this be done live, on the fly?