Avoid duplicates in detail-block

I have a master-detail form, the detail block have item, qty & rate. only 1 item_code is allowed to b entered per invoice, purchased at different rates. what i want to acheive is;
1) prevent user from entering duplicate item-code, if the detail record goes more then 1. and in case if there r more than 1 detail-record, then the new item-code shud appear the same as the item-code entered in the previous record.
B4 incorporating the above rule, i had already entered some records, thus manually taking into consideration the above rule. Later, when i tried to code the abov rule, m getting err-msg as per my triggers. what i did actually for this is;
i created a control-field m_item_code in control_block(Ctrl). NOT initialised anywhere.
then for the detail-block m using these triggers;
WHEN-REMOVE-RECORD
:dtl_blk.item_CODE = :ctrl.m_ITEM_code
WHEN-NEW-RECORD-INSTANCE
:dtl_blk.item_CODE = :ctrl.m_ITEM_code
for the field item_code triggers;
WHEN-VALIDATE-ITEM
DECLARE
     CURSOR C_ITEM IS SELECT ITEM_desc
     FROM item_MAST
     WHERE ITEM_code = :dtl_blk.item_CODE;
BEGIN
     IF :SYSTEM.CURSOR_VALUE IS NOT NULL AND
          :CTRL.M_item_CODE = :dtl_blk.item_CODE THEN
               OPEN C_ITEM;
               FETCH C_ITEM INTO :CTRL.M_ITEM_DESC;
               IF C_ITEM%NOTFOUND THEN
                    MESSAGE('ITEM does not exists!');
                    MESSAGE(' ');
                    RAISE FORM_TRIGGER_FAILURE;
               END IF;
               CLOSE C_ITEM;
     ELSE
               MESSAGE('Blank NOT allowed and NO different Item can be entered');
               MESSAGE(' ');
               RAISE FORM_TRIGGER_FAILURE;
     END IF;
END;
POST-TEXT-ITEM
:ctrl.m_item_code := :det_blk.item_code;
for the OLD RECORDs (those i entered b4 writing the above triggers), the rule works fine when i query, with whatever i have coded. BUT the problem is now for the NEW detail_RECORDS. as i enter in the detail block & give value in the first item-code field the err-msg ('Blank NOT allowed and NO different Item can be entered') in WVI above, flashes for the item-code. i dont know what i have done for this rule till now is corrct?
kindly give ur comments & guide me please for the more accurate & complete approach for my rule. kindly do tell where n which code to b used or crrected

Hi
You can achieve this by the use of PLSQL table create one small package in that defined your table and procdure, when user move to new record insert old record should be insert into the PLSQL table. select the value from PLSQL table to validate the next record. the ITEM_CODE must be delete from PLSQL table when user delete any ITEM_CODE from the block.

Similar Messages

  • HOWTO: Avoid go to detail block without fullfill the master block?

    Hi:
    I have a master detail form with 2 blocks. When the user open the form the focus is on the first text item (required = yes) of the master block. If the user tries to get out of that item with keyboard (tab or enter), it gets the correct message saying that the item is required and must be filled. But the problem starts when the user click with the mouse on another item of the detail block. Here, I will have 8 or 9 messages saying that is impossible to create records without a master record. This is really annoying. This message has no ID (FRM-XXXXX), and I really must get a way to forbide users to go to the detail block without filling required items in the master.
    Anyone?
    Best Regards
    Joao

    Hello,
    if there is a relation between the two blocks double click on that rel.and mark the check box property:prevent Masterless operation try this option and tell me what's ur feed back..?
    Regards,
    Abdetu..

  • Duplicate Item in Details Block

    Dear Expert,
    I written some code for checking of the same item in detail block, when I am using keyboard it is runing ok, but when I nevigate the same from mouse to another item, it will not check the duplicate item, my problem is when I move the mouse from one filed to another my Item-Code will be validate every time when I leave the mouse from One Item to another.
    Please give me your expert adive.
    s mishra

    Hi Mark,
    Actually this my code but it doesn't work.....
    if :slcl.bulk_question_answer = 'N' then
    Set_Item_Instance_Property('SLCL.BULK_ERROR_DETAILS', CURRENT_RECORD, UPDATE_ALLOWED,PROPERTY_TRUE);
    elsif :slcl.bulk_question_answer = 'Y' then
    Set_Item_Instance_Property('SLCL.BULK_ERROR_DETAILS', CURRENT_RECORD, UPDATE_ALLOWED, PROPERTY_FALSE);
    :SLCL.BULK_ERROR_DETAILS := '';      
    end if;
    Please remember I put this code in the when-checkbox-changed trigger the default if YES.
    Any further advice or idea are greatly appreciated....
    Thanks.
    Regards,
    Jun

  • How to prevent duplicate entry in Details block

    Dear All
    I am using Forms 10g.
    I have a detail block.
    There is a column called Ip_Address.
    There i want to prevent duplicate entry .
    How can i do this ?

    hey i have a requirement that to restrict duplicate entry in both block(both multi record).the blocks are DEPT(MATER)
    EMP(DETAIL)
    the associated fieds in master block DEPT.DEPT_NO,in detail EMP.EMP_ID .
    I have done' Kevin D Clarke’s calculated item ' both in master and detail block
    its working fine for master block but in case of detail block its only respond to the current session(i.e. if the new value is inserted or save it will restrict another record to be inserted of that last record's value),it does not restrict duplicate value enter ,checking with other existing records(which are saved in earlier session,though after query it is shown on the form)
    can anyone guide me why its not working

  • Duplicate a detail row to any position of a detail block

    Hi,
    The default performance of duplicate_record built-in is to copy the current detail row to the next created detail row.
    I use this code to do this:
    create_record;
    duplicate_record;
    How can i duplicate a row to any detail position of the detail block ?

    As usual, you can accomplish this task in one or more ways.
    Generally, I advise against using globals.
    Basically, you need to store the content of a record temporarily into a dummy record or other type of collection based upon the current record structure.
    The easiest, albeit the least reusable method, would be to create a dummy block with the same structure as the block containing the record you wish to duplicate.
    Using buttons, pop-up menus, etc, copy the desired record from the source table to the dummy table and back. This target record need not be a new record depending upon your requirements. In any case, be aware of unique value and other constraints.
    A more flexible solution would be to create a procedure, based upon a pl/sql table or other collection type that would duplicate the record structure on-the-fly. This could be included in a library and be usable by other forms.

  • To avoid duplicate entries in multi row

    Hi i need to avoid duplicate entries in multi record form.In the master block i have AGENCY CODE.These are the fields, RATING_CODE(composite primary key alng with AGENCY_CODE in the detail block,but set as hidden) and DESCRIPTION
    in the detail block.If AGENCY_CODE is CRISIL,then for that i should not enter duplicate RATING CODES.I have written
    DECLARE
         L_COUNT2 NUMBER;
         l_ret varchar2(20);
    BEGIN
         SELECT COUNT(*) INTO L_COUNT2 FROM CSTM_AGENCY_CODE_DETAIL
    WHERE AGENCY_CODE=:BLK_CSTM_AGENCY_CODE_DETAIL.AGENCY_CODE
    AND RATING_CODE=:BLK_CSTM_AGENCY_CODE_DETAIL.RATING_CODE;
    IF L_COUNT2 > 0 THEN
              l_ret := ovpkcs.fn_dispmsg('AGYCOD-03;',';',';');
    Raise Form_Trigger_Failure;
    END IF;
    END;
    in WHEN_VALIDATE_ITEM.
    Now when i press the TAB to move next time it gives the message,DUPLICATE RATING CODE.The
    problem is when i move back to the previous record by clicking mouse and change it to the already existing value,and while i save the validation is not happening and the message is not shown.Kindly tell me where i should code.
    Thank you

    hy,
    you can check whan commit( an save button)
    for i = 1 to n-1
    check condition (item = item +1)
    next_record
    end
    or by stored insert whit exception return to form program when duplicate key is found
    ...

  • How to avoid duplicates values from alvgird see below code

    how to avoid duplicates values from alvgird see below code
    in below query docno no is repeated again and again
    how i can avoid duplication in this query.
    select * into corresponding fields of table itab
             from  J_1IEXCHDR
                     inner join  J_1IEXCDTL
                        on  J_1IEXCDTLlifnr =  J_1IEXCHDRlifnr
                     where  J_1IEXCHDr~status = 'P'.

    Hi Laxman,
    after that select statement
    select * into corresponding fields of table itab
    from J_1IEXCHDR
    inner join J_1IEXCDTL
    on J_1IEXCDTLlifnr = J_1IEXCHDRlifnr
    where J_1IEXCHDr~status = 'P'.
    <b>if sy-subrc = 0.
    delete adjucent duplicates from itab comparing <field name of itab internal table>
    endif.</b>
    this will delete your duplicate entries.once you done with this call the alv FM.
    <b>  call function 'REUSE_ALV_GRID_DISPLAY'</b>
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = v_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = 'IT_USER_COMMAND'
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       i_grid_title                      = 'Purchase Order Details'
      I_GRID_SETTINGS                   = I_GRID_SETTINGS
       is_layout                         = wa_layout
       it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      = IT_EXCLUDING
      IT_SPECIAL_GROUPS                 = IT_SPECIAL_GROUPS
       it_sort                           = it_sort
      IT_FILTER                         = IT_FILTER
      IS_SEL_HIDE                       = IS_SEL_HIDE
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        = IS_VARIANT
       it_events                         = it_event
      IT_EVENT_EXIT                     = IT_EVENT_EXIT
      IS_PRINT                          = IS_PRINT
      IS_REPREP_ID                      = IS_REPREP_ID
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   = IT_ALV_GRAPHICS
      IT_HYPERLINK                      = IT_HYPERLINK
      IT_ADD_FIELDCAT                   = IT_ADD_FIELDCAT
      IT_EXCEPT_QINFO                   = IT_EXCEPT_QINFO
      IR_SALV_FULLSCREEN_ADAPTER        = IR_SALV_FULLSCREEN_ADAPTER
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           = E_EXIT_CAUSED_BY_CALLER
      ES_EXIT_CAUSED_BY_USER            = ES_EXIT_CAUSED_BY_USER
        tables
    <b>      t_outtab                          = ITAB</b>
    exceptions
       program_error                     = 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.
    Thanks
    Vikranth Khimavath

  • Validating primary key in Detail block...

    Dear Oracle Friends..
    I have a master-detail form. Detail blk (further referred as dtl) has primary key on 2 cols namely CODE1 and CODE2. CODE1 is foreign key to the master blk. CODE2 will have unique values with respect to CODE1.
    When I create the master-detail form the user can enter more that 1 records in detail block. Now I want to trace that the value of CODE2 field should not be duplicate while the entry of multiple records.
    I cannot POST the record as my some other functions will mal-function then. One thing to note that this field is a list item.
    I tried to validate it in when-validate-item using loop on all the fetched values by going on FIRST_RECORD and scanning all the values of CODE2 but it is restricted built-in and not supported here.
    POST_CHANGE trigger also not works.
    Can anybody suggest me a solution
    Thanks
    UMESH

    Hi
    There is the (in)famous solution of the 1-millisecond timer.
    In the item when-validate-item trigger, create a
    non-repeating timer of 1 ms, and in the form when-timer-expired
    trigger you can navigate by all the records and check if
    there is some duplicity, because there you can use restricted
    built-ins.
    Luis Cabral
    Dear Oracle Friends..
    I have a master-detail form. Detail blk (further referred as dtl) has primary key on 2 cols namely CODE1 and CODE2. CODE1 is foreign key to the master blk. CODE2 will have unique values with respect to CODE1.
    When I create the master-detail form the user can enter more that 1 records in detail block. Now I want to trace that the value of CODE2 field should not be duplicate while the entry of multiple records.
    I cannot POST the record as my some other functions will mal-function then. One thing to note that this field is a list item.
    I tried to validate it in when-validate-item using loop on all the fetched values by going on FIRST_RECORD and scanning all the values of CODE2 but it is restricted built-in and not supported here.
    POST_CHANGE trigger also not works.
    Can anybody suggest me a solution
    Thanks
    UMESH

  • How to avoid Duplicate Records  while joining two tables

    Hi,
    I am trying to join three tables, basically two tables are same one is like history table, so I wrote a query like
    select
    e.id,
    e.seqNo,
    e.name,
    d.resDate,
    d.details
    from employees e,
    ((select * from dept)union(select * from dept_hist)) d
    join on d.id=e.id and e.seqno=d.seqno
    but this returing duplicate records.
    Could anyone please tell me how to avoid duplicate records of this query.

    Actually it is like if the record is processed it will be moved to hist table, so both table will not have same records and I need the record from both the tables so i have done the union of both the tables, so d will have the union of both records.
    But I am getting duplicate records if even I am distinct.

  • Unable to see the values in detail block

    Hello,
    I have a master detail block, when I query the form, I am unable to see the values for a particular field(Column), all other columns appear properly in the details block, Upon checking the same table(s) in SQL ( by using the JOIN defined in the where clause of the relationship in Forms) , it shows the relevant records for all fields. So what could be wrong with the Form, please advise.
    Thanks
    FM

    IQ wrote:
    I have just checked the field its a non-database field which is being used as a LOV column to display a value derived from LOV. How do I make this populate at Query time, as obviously this works when the Form is in a insert mode but not for Query mode. How to make it work for Query ? As it for LOV column and non-database filed, ignore my first suggestion.
    Does your non-database filed has associate any column ?
    For example, you have SUPPLIER_ID (database column) and SUPPLIER_NAME (non-database column). SUPPLIER_NAME has LOV column. And when selecting supplier name from LOV value also assign at supplier_id.
    Now to show supplier name when querying, you have to write POST-CHANGE trigger at supplier_id. like
    SELECT ASSC_CODE INTO :MST_SUPPLIER.ACC_CODE
    FROM ACC_SUB_SUB_CONTROL
    WHERE ASSC_ID=:MST_SUPPLIER.SUPP_ASSC_ID;Hope this helps

  • Master - detail block (many-to-many)

    Hello, , I have 2 tables:
    1-(parts)its primary key : p_id
    2-(suppliers)its primary key : s_id
    and they have many-to-many relationship between them .
    the table Resulted from the relationship is(part_supp)
    How can I create master-detail block Based on this relationship.In other words, which of tables will be the master and which of them well be detail.
    I am using form 6i ..
    please help.....

    M3ATH wrote:
    Hello, , I have 2 tables:
    1-(parts)its primary key : p_id
    2-(suppliers)its primary key : s_id
    and they have many-to-many relationship between them .Many to many relation between two table isn't a good database design. You have to a junction table between them.
    the table Resulted from the relationship is(part_supp)Is this your junction table(part_supp) ?
    >
    How can I create master-detail block Based on this relationship.In other words, which of tables will be the master and which of them well be detail.If part_supp is your junction table between parts and suppliers then, try this..
    Use the junction table as a hidden block, then establish a standard Forms relation between
    Parts and (hidden)part_supp then between part_supp and suppliersHope this helps

  • How can I get a detail block to requery after a database change?

    Hi, I have a master/detail form. When the status of the master record changes, I need to update a date in one of the detail records. If I use SQL to update the detail row in the database in the ON-CHANGE trigger of the master block, how can I get the detail block to requery to show the change? When I try doing a go_block from any of the ...UPDATE triggers, it says it is restricted.

    wjpenfold,
    Do you have a "Relationship" defined between your Master and Detail blocks? If so, you simply need to requery your master block and the detail block will automatically be requeried. If you can't use a relationship, then you can use can create a timer in the trigger that updates the database and then in the When-Timer-Expired (WTE) trigger you can go to the detail block and execute a query. For example:
    /* Sample On-Change trigger */
    DECLARE
       timer_id  TIMER;
    BEGIN
    ....your code here that performs the update....
       /* Now create an instance of a timer */
       timer_id := Create_Timer ('upd_detail',1,NO_REPEAT);
    END;
    /* Sample Form Level When-Timer-Expired trigger */
    DECLARE
       timer_id   TIMER;
    BEGIN
       -- Find the timer first
       timer_id := FIND_TIMER('upd_detail');
       IF NOT ID_NULL(timer_id) THEN
          GO_BLOCK('DETAIL_BLOCK');
          Execute_Query;
       END IF;
    END;Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • How to display data in detail block from a table.

    Dear members,
    i have 2 blocks. 1 is master block and another is detail block with multiple records.
    the requirement is when i navigate to the detail block the data from a table is displayed in it. using a where clause depend on the value in an item in the master block.
    i wrote the following code and tried in when-new-block-instance, when-new-record-instance, pre-block and post-block
    but...
    DECLARE
         CURSOR ITEM_CUR IS
         SELECT ITEM_ID, QTY_APPROVED
         FROM IN_REQUEST_FORM_DETAIL
         WHERE RF_MASTER_ID = :IN_MASTER_PO.RF_ID;
    BEGIN
         FOR ITEM_REC IN ITEM_CUR LOOP
              :IN_PO_DETAIL.ITEM_ID := ITEM_REC.ITEM_ID;
              :IN_PO_DETAIL.DIS_APPROVED_QTY := ITEM_REC.QTY_APPROVED;
              NEXT_RECORD;
              END LOOP;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         MESSAGE ('THERE IS NO REQUESTS');
    END;

    thanks dear simon,
    i want to display the data from a table not included in this form. and these two tables are connected via a relation.
    i have the following tables.
    in_master_po
    PO_ID pk
    PO_DATE
    RF_DETAIL_ID fk (in_request_form_detail)
    in_po_detail
    DETAIL_PO_ID pk
    ITEM_ID fk
    PO_ID fk (in_master_po)
    QTY
    the above 2 tables are datablocks connected via relation
    the following is the from which i want to bring the data to display
    in_request_form_detail
    RF_DETAIL_ID pk
    ITEM_ID fk (items)
    QTY_REQ
    i tried my code on the sample tables with scott/tiger there it works good.
    thanks
    Muhammad Nadeem

  • How to query the master block based on one of the values in detail block

    Hi,
    In version 6i forms, I have a field in data block which is not set as a database item. I am using that field to store a value from detail block. If I want to query the form using that field (which represents one of the values from detail block), how do I do that? Any pointers?
    TIA,

    Do you want to query a master, which contains a specific detail? If so, here's an example how you could do it with a PRE-QUERY-trigger:
    DECLARE
      vcQuery VARCHAR2(4000);
    BEGIN
      IF :MASTERBLOCK.THE_DETAIL_SEARCH_ITEM IS NOT NULL THEN
        -- Build up an exists Sub-Query
        vcQuery:=' MASTERBLOCKID IN (SELECT FK_TO_MASTERBLOCK FROM DETAILTABLE WHERE DETAIL_COLUMN=''' || :MASTERBLOCK.THE_DETAIL_SEARCH_ITEM|| ''')';
      END IF;
      SET_BLOCK_PROPERTY('MASTERBLOCK', DEFAULT_WHERE, vcQuery);
    END;

  • Avoid duplicate batch (batch managment)

    dear all,
    We are facing problem related to batch managment .we are using manual batch entry .we don't want to make duplicate entry of same batch (which have already assign to material) against any material.what is solution to avoid duplicate batch entry.
    can u tell me the settings and any user exit in which we can avoid the duplicate batch.
    regards

    Hi hema,
                   in our scenario user  manually enter  batch of raw material in MIGO when we do good recipte in MIGO againts purchase order we enter batch manually.but we need that a batch which has already assign to raw material can not be assign again .if user enter the previous batch then system gives a error that batch has already exist.
    may be u know the prob

Maybe you are looking for

  • Still images blur on playback

    hello all: I am using Final Cut HD and I am having problems with jpgs and PSD files blurring on playback. they look fine as still... but when I press the space bar to playback they blur horribly. I didn't used to have this problem. A recent change to

  • How to redownload old messages from the server

    On my primary PC with Windows 7-64bit, I have my server settings to leave messages on the server for 55 days. I need to download the old messages again into Thunderbird probably due to some problems with Time Warner Road Runner sometimes blacklisting

  • Aptana Studio 1.x and Firefox 2.x [SOLVED]

    Those of you who have had problems with FF 2.x and new Aptana Studio, here's the solution: you need to set the MOZILLA_FIVE_HOME env var to point to /opt/mozilla/lib/firefox-2.0.0.11, not /opt/mozilla/bin as some have suggested elsewhere. On Arch, th

  • Memory full error...when it isn't

    Since updating to Belle I've been receiving a lot of "memory full" messages in a variety of applications, often with barely anything else running on the phone. I've done a fair bit of testing to try to narrow down the culprit but I'm coming around to

  • Audio book has no chapter headings

    Downloaded "Walden". It appears in iTunes as Part 1 and Part 2. No chapter headings. No way to navigate through eleven+ hours. Imagine a CD with no song titles. Think of a city with no street signs. Is this universal? Any help?