Foreign key validation while creating master/detail record in document mode

I am creating master/detail records in the document mode. And I am generating the master primary key in the create() method of the master Entity Object. Now I valdate the foreign key in the detail Entity Object's validateEntity() method by doing a query to the master table through some View Object.
But since the master record has not yet been posted (since it hasn't been committed) to the database, this query does not return any record and the validation fails in detail object.
And thus the create fails.
Please let me know if this is the right approach for doing this. If so where I am going wrong? Else please let me know if there are any better approach to do this.
Kunal

Kunal:
Use a code snippet like the following:
--- Assuming you're in the detail EO's create method ---
oracle.jbo.server.EntityDefImpl eDef = oracle.jbo.server.EntityDefImpl.findDefObject(<package-qualified-name-of-the-master-Entity-Object>);
oracle.jbo.Row masterRow = eDef.findByPrimaryKey(this.getDBTransaction(), <foreign-key>);
If the row does not exist, masterRow will be null.
findByPrimaryKey first checks the entity cache (which will include your new master row(s)) and then go out to database (if it's not in cache).
Thanks.
Sung

Similar Messages

  • Using EJB creating Master/Detail Record

    Hi All
    I would really in need of your help regarding how to show the information of master detail records in a single form
    eg: one text field with department Id and a Search button which should give relevent employees details working in that particular department.
    I tried with ADF business components it works fine..
    I need to do through pure Session Beans and Entity Beans(note : not thru using EJB:UseBean Tag)
    Please i will really appreciate your valuable help..
    Thanks All
    Have a Nice day
    Mohamed Anez

    Kunal:
    Use a code snippet like the following:
    --- Assuming you're in the detail EO's create method ---
    oracle.jbo.server.EntityDefImpl eDef = oracle.jbo.server.EntityDefImpl.findDefObject(<package-qualified-name-of-the-master-Entity-Object>);
    oracle.jbo.Row masterRow = eDef.findByPrimaryKey(this.getDBTransaction(), <foreign-key>);
    If the row does not exist, masterRow will be null.
    findByPrimaryKey first checks the entity cache (which will include your new master row(s)) and then go out to database (if it's not in cache).
    Thanks.
    Sung

  • I want validation while creating material master with profit center

    Dear Experts,
                           I want validation while creating material master with profit center.
    If 0001 plant having 100100 profit center
       0002 plant having  200200 profit center
    Material A cant be created for 0001 plant for with wrong profit center 200200.
    Kindly help & provide me solution clearly

    Hi,
    Profit centers are assigned to controlling areas. And controlling areas can have many plants under them. So as long as both the plants and profit centers are in the same controlling area users will be able to extend the materials.
    You should put in your validation control in the material master user exit. One of the exits you can use is
    MGA00001  Material Master (Industry): Checks and Enhancements
    Thanks & regards
    Hameed Parvez

  • Creating master detail rows

    using adf/bc with jsf. I have defined a master detail relationship between two entities. This relationship is a composition relationship. The entities are related by a view link which link the master and detail view objects. i have a need to create/insert a master row and a detail row programmatically "on the fly" so that when the jsp renders, the user will see blank inputs for both the master and detail view objects. The problem is that the primary key of the master record is not known at creation time ( it will be entered by the user) and therefore the detail record cannot be created by the framework because of the unknown value of the parent's primary key. I was hoping the following section in the adf guide would eliminate my problem, but it doesn't appear to:
    This is from section 26.7.3.2 of the adf developer's guide
    Note: An alternative to the programmatic technique discussed
    above, which solves the problem at the J2EE application layer, is the
    use of deferrable constraints at the database layer. If you have control
    over your database schema, consider defining (or altering) your
    foreign key constraints to be DEFERRABLE INITIALLY DEFERRED.
    This causes the database to defer checking the constraint until
    transaction commit time. This allows the application to perform DML
    operations in any order provided that by COMMIT time all appropriate
    related rows have been saved and would alleviate the parent/child
    ordering described above. However, you would still need to write the
    code described in the following sections to cascade-update the foreign
    key values if the parent’s primary key is assigned from a sequence.
    This approach did not help in allowing me to create the detail record without first knowing the value of the parent's primary key record in a composition relationship. The only thing i've found to work is define the relationship as just an association, and not a composition. However, this is a true one to many (composition) relationship and i would like to take advantage of some of the features of the framework that are there when a relationship is defined as a composition relationship. Is there any way to do what i need to do with a composition relationship defined between these two entities? Thanks.

    Hi,
    I guess you need a "Cascading LOVs".
    1) Create viewObject for country values list. Named VO1.
    2) Create viewObject for state values list. Named VO2.
    3) Create view criteria for (bind variable) VO2 which can restrict the result by country.
    4) Create view accessor to get VO1.
    5) Create view accessor to get VO2. Define the bind variable value which can provide country info dynamically. I guess it should be a Groovy expression.
    6) Create country LOV on step 4) view accessor.
    7) Create state LOV on step 5) view accessor.
    Done
    On the view layer, you may enable PPR between country and state attributes.
    Todd

  • What is the proper way to record line numbers in Master/Detail records?

    Guys and Gals,
    Been thinking about this for awhile, but thought it best to ask the people who really know what they are doing.
    What is the proper way to record & show line numbers in a Master / Detail record set?
    For example, take Master/Detail relationship Orders and OrderItems. Orders has a column Document_Number and OrderItems has Document_Number, Line_Number. Line_Number should contain the row number 1,2,3,4 ... etc. for each row in a document.
    Should I ...
    <ol><li>Add a sequence and a trigger in the database? The FusionOrderDemo does this, but then the sequence never "resets" and I've got row numbers that keep incrementing. So one document has rows 4,5,6 and the next document has 7,8,9 when they should both have 1,2,3.</li>
    <li>Programmatically take care of the row numbers? This seems like I'm asking for trouble. Anytime an insert or delete operation gets done, I'll have to iterate through rows and re-assign row numbers.</li>
    <li>Is there a way to assign row numbers in a table iterator (or data collection?) to an entity?</li></ol>
    Any suggestions would be appreciated. It's looking like #2 is my only option, but if anyone knows different I'd love the input.
    Will

    Thank you both guys.
    As John said, I believe I'm looking for a gap-free sequence per master record.
    The line number of the OrderItems table is the second half of the primary key. The first half of the primary key (DocumentNumber) is the foreign key to the Orders table.
    Think of it like line items on an order or invoice. For example, if you were talking to someone on the phone concerning an invoice, you might say, "The pricing for line item #3 is incorrect." In this case, it's good to have a common reference. Or imagine a Microsoft Excel spreadsheet with no row numbers displayed! You'd never get anywhere if you had to explain something over the phone.
    If this is tricky to perform, I take it using a sequence and trigger such as the Fusion Order Demo is the best way to approach the challenge for simplicity's sake?
    Will

  • Creating master-detail VO in custom AppModule method

    Hi.
    I need to create master-detail view objects and save them in DB in my custom AppModule Service Interface method.
    I have the next master-detail view objects:
    RegistryVO (1) -- (*) RegistryItemVO
    Also I have a view link for this relationship.
    I wrote custom method with next signature:
    Integer createRegistry(RegistryVORowImpl registry) {
    Then, I added this method to my AppModule Service Interface.
    Method works fine, but only master row is created and inserted to DB (only Registry but not RegistryItem). I.e. when I testing this method in EM I fill full RegistryVO with nested RegistryItemVO data but in my method RegistryVO comes without nested RegistryItemVOs.
    Then, I added SERVICE_PROCESS_CHILDREN custom property to view link (RegistryVO-RegistryItemVO) as it described in chapter 11.2.5 of Fusion Developer 's Guide for Oracle Application Development.
    After that nested RegisttryVO in my method contains nested RegistryItemVOs.
    In my custom method i need to set primary key for RegistryVO. So I set it in registryVO to PK attribute and set it in nested registryItems to FK attribute.
    But when I doing commit I have an exception:
    Exception while executing the business logic: JBO-26048: Constraint "PP_PST_RG_IT_PP_PST_FK" is violated during post operation "Insert" using SQL stat
    ement " *INSERT INTO PP_PERSON_ST_RG_ITEM* (PP_PERSON_ST_RG_ITEM_ID,IN_DOCUMENT_ID,POL,FULLNAME,NAME,FULLOT,TIN,D_ROG_DT,D_REEST
    _DT,PROCESSING_DT,PROCESSING_STATE_CD,RECEIVE_YEAR) VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12)".: ORA-02291: integrity
    constraint (PP_PST_RG_IT_PP_PST_FK) violated - parent key not found
    It seems that only registryItems are commited in DB. I'm not seeing INSERT for Registry in ServieInterface log...
    But if I setting primary key for RegistryVO when I invoking method (if I setting id for registry in test console of EM, not in method) - it's work fine .
    What I'm doing wrong ?
    How can I create custom method for AppModule Service Interface to create master-detail view objects and set PK for master and FK for details within method ?
    Edited by: user2975420 on 19.10.2010 4:46
    Edited by: user2975420 on 19.10.2010 4:49

    Thanks for reply, John.
    I have already added master and detail view objects usages to my AppModule Data Model. And yes, I add detail VO as child of master.
    It seems that the reason of my problem is another...
    I can't create master/detail when I'm setting id of master in custom method. If I set id of master in input parameter (RegisterVORowImpl) then method invokes successfull.
    I noted one moment - if I'm not setting SERVICE_PROCESS_CHILDREN custom property for view link, I can set id of master VO inside method. But in this case my master VO haven't got nested RegisterItemVOs.
    Edited by: user2975420 on 19.10.2010 10:23
    Edited by: user2975420 on 20.10.2010 1:31

  • Error occured while creating purchase info record in mm

    sir,
    while creating purchase info record  an error occured while inserting net price. it said
    NOT POSSIBLE TO DETERMINE A CONDITION TYPE FOR A PRICE
    when it attempted to generate the time dependent condition for the price you entered the systeem was unable to determine a condition type, price determination is therefore not possible.
    please inform me how to solve this problem.
    thankyou

    I think you are not using the stdard pricing becuse of that it is thrwing error
    Ok First check your pricing procedure which your using for PO
    than in that pricing procedure if you are using PB00 fro Gross price than you will have antoher pricing procedure attached to this condition.
    check in M/06 for your gross price conditon
    now did you assign the pricing procedure to vendor?
    bottom line is somthing missing in your config.
    Check all the config as below
    Pricing Procedure:
    In MM module, pricing procedure is used during RFQ and PO creation. Total value of material based on all addition and subtraction like discount, surcharge, tax, freight, etc. In this we are defining pricing procedure and linking to vendor and purchase department through the virtual schemas.
    Following steps for pricing procedure as,
    1. Define conditions.
    2. Define pricing procedure.
    3. Define virtual purchase organization and vendor.
    4. Info Record.
    Customization for Pricing Procedure :
    1. Definition of Conditions :
    /NMEK0-condition typeu2026condition types- definition (define for basic price, net price, discount, surcharge, tax etc.)
    2. Defining pricing procedure :
    /NMEK0- calculation schema-calculation schemasu2014New entries (Define procedure and put the conditions like formula so that final price will be net price / total value as per company requirement)
    3. Linking pricing procedure to independent condition types.
    /NMEK0-condition typeu2026condition types- definition for position for defined conditions (Enter the defined pricing procedure in the each independent conditions u201CPricing Procedureu201D box)
    4. Defining Schema group for Vendor :
    /NMEK0- calculation schema-schema groupsu2014vendoru2014New Entries.
    5. Defining Schema group for Purchase Organization--- New entries.
    /NMEK0- calculation schema- schema groups---- purchasing organization--- new entries.
    6. Linking Virtual Purchase Organization to actual Purchase Organization.
    /NMEK0- calculation schema- schema groups----- Assign P.Org. (in actual P.Org, enter virtual P.Org)
    7. Linking Pricing procedure to virtual P.Org and virtual vendor :
    /NMEK0- calculation schema- Determine Schema--- -Standard --- New entries (Enter virtual schema and P.Org. along with pricing procedure)
    8. Linking virtual vendor to actual vendor-- /NXK02 then enter schema group vendor in Purchasing Data )
    9. Info Records (/NME11)---- click on u201CPurch. Org. data1u201D and enter condition types and pricing procedure
    What are the steps in pricing determination in MM? Condition, Access sequence and schema.
    In the SAP MM Pricing is more important. Just yesterday I have completed the Pricing as I am doing the SAPMM now. I can give some light on this Topic, not 100%. After 2 days definitely some more I can share.
    The Basic thing is Condition Technique. In which there are
    1. Access Sequence 2. Condition Record 3. Condition Type 4. Condition Table.
    A Access Sequence access a Condition Record of a Condition Type in a Condition Table is a Condition Technique.This is a simple logic
    Here the Condition Type is very important like PB00, PBXX,RA01 etc.
    In the background every Condition Type has its own defition means the purpose of the Condition Type like, is it for Pricing or Percentage, Quntity base, Accrual Feilds etc is to be defined to work this functions.
    Normally we use the existing ones without any risk. But some cases, we have to Create a New Condition Types as per the organisation requirement.
    The Pricing Schema is useful to minimise condition types while mention prices for Vendor on the basis of Pricing Schema which we defined according to organisation requirement.
    The Pricing Schema means the calculations procedure of Condition Type.
    Ex. RA01 - Discoount % is caclulated on PB00 - Gross Price means
    RA01 is based on PB00 like that we have to define in the Pricing Schema
    which makes easy to use in realtime.
    Here PB00 has the Access Sequence - 0002.
    But RA01 does not have the Access Sequence.Why because it is a dependent on PB00. But both are Condition Types.
    In the system, by default some standard Scheme will be there at Vendor Schema Group in the Vendor Master Screen means the standard one is assigned which is very lengthy which may fullfil our requirement. But some cases which may not fullfil our requirement, in such we have to define.
    For the configuration, I may not able to explain properly through here but will give some Idea.
    Configuration: SPRO-IMG-Material Management- Purchasing- Conditions-Define Price Deternmination Process
    1. Define Access Sequence
    2. Define Condition Type
    3. Defince Calculation Schema:- Here you have to define the Schema
    Define Schema group
    1. Define Schema Group vendor
    2. Define Pricing Schema group
    3. Schema group for Purchase Organisation
    4. Assign Schema group to Purchase Organisation
    Define Schema determination
    1.define calculation schema for Standard purchase organisation
    After completion of the Schema Group, we have to assign it to Vendors.
    Then whenever we use any transaction with this Vendor, the concerned Schema will work as configured by us.
    I think this will help you. Actually the Pricing is a vast. Becuase each Condition have its own importance and each Access Sequence have its own importance. So you need not bother about this. First you learn how to define the Calculation Schema through the above.
    Here we can create many Calculation Schemas which can assign one schema to Local vendors
    another schema to out side vendor one more schema to foreign vendors like that we can classify.

  • Unable to create master detail report

    Hi,
    I´ve two tables (Organisation and Purchases) and want to create a master-deatil with the wizard.
    At the end an error occurs:
    ORA-20001: Unable to create master detail page. ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Unable to create Master Detail pages.
    Return to application.
    Any ideas ? Any reaction will be appreciated
    Leo

    Leo,
    How are your two tables related? Do you have a foreign key constraint? It sounds like that there may be a datatype mismatch between the master table's PK and the detail table's FK - check to make sure that they are both NUMBER.
    Thanks,
    - Scott -

  • Master-Details Record

    I have a Master and two details records. I need to generate report for the Master-Details record.
    I need to include some details from the Master table and some details from each of the detail tables.
    For example :
    In Master table: Employee_Number
    Employee_Name
    Company_Code
    Company_Name
    In Application Detail table: Application_Code
    Application_Name
    In Non-Application Details table: Non-Application_Code
    Non-Application_Name
    I need to include Employee_Name, Company_Name, Application_Name and Non-Application_Name in my report. How should I go about creating the report?and may I know what type of report style should I use?Should I use Tabular or Group Above?
    Thank for your help

    hello,
    you might want to start off with a regular master detail layout and then modify the layout manually to fit your needs.
    when running throught he wizard, you just select whichever fields you want to display.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Having problem with creating Master Detail form , please help

    I have to work on a project to create a survey system using APEX, as am new on using this tool , am still facing some problems to finish my job..
    i created Master/Detail form using wizard, the master form is working fine but am when i try to add data using the detail form its giving me error :
    Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-20001: ORA-20001: Current version of data in database has changed since user initiated update process. current checksum = "A884FA378C851786DDFE3A33709CB23C", item checksum = "5F8B1EE5CD3D46437455F43B37B9A6A0"., update "ABA"."ABA_SURVEY_SUBCATEGORY_MAST" set "ASCM_CATEGORY_ID" = :b1, "ASM_SURVEY_CODE" = :b2, "ASSM_SUBCATEGORY_ID" = :b3, "ASSM_SUBCATEGORY_DESC" = :b4
    i tried to go through the posts from others but i still dunno what is this error !!!& how to solve it..
    my master data table have 2 primary keys.. the details data table have 3 primary key all of them using trigger to fire a sequence to get the next_val!!
    am desperate & need help urgently for this ASAP.

    hello
    here is the solution,i hope this might help u.
    go to the code of your button and change write the following
    go_block('name of your master block');
    execute_query(no_validate);
    and in the object navigator make the first item in the master
    block that it should be displayed in the canvas and it must be a
    navigable item too.not a display item.
    thank you
    Zeeshan Ahmad

  • Master-details records

    Hi Everybody,
    i have a requirement to show master detail records.to show data i have 3 tables
    they are 1) Flat_Master(flat_id,flat_desc,pic)
    2)Flat_Detail(flat_id,flat_face_id,flat_loc)
    3)face_tab(face_id,face_desc)
    in my jsf page i displayed flat_master as master records and flat_detail as detail records
    here flat_detail is updatable.so for flat_face_id i created a lov choice list based on face_tab table(ADF BC level).
    so when master record i changed, my choice list is not getting changed amd even when page load also for the first record also it is not selecting..
    How can i set this choice list value programatically based on master records?
    Any ideas can you please share with me?
    thanks
    KM.
    Edited by: Mr. Murali on Sep 13, 2011 3:21 AM

    pls provide me the detailed view.,
    what ur trying to say and wat s ur use case?

  • How can I create master detail reprot output

    Hi to all!
    I have one question about creating master-detail report.
    My report must show asset's and depreciation and all other information for that asset. I can have one asset at two or more locations, cost numbers, ...
    Now I have 2 SQL's in my XML file. Q1 is master data for some asset and Q2 is detail for that asset, if I run my report with all parameters (book type, asset nubmer, cost nubmer) then it runs OK (I get master-detail report, for each asset I get separate page, even if asset has multiple cost number or locations), but if I run that report without cost number parameter I get multiple pages for master (data from Q1 on each page), but detail data is all together on each page.
    Can you help me how can I also get separate detail data in that case?
    I hope we understand each other!
    Regards,
    drama9346

    Hi Mustafa,
    Thanks for ur response.
    Actually, In my first tab page I have some details of employ which is based on a database table.
    The second tab page also contain the details of employ which based on backend stored procedure. I used a REF cursor in that stored procedure.
    When I have created a master detail relationship based on employee_id, it created the relationship but while executing the form it is giving error like
    'pk_empdetails.query' must be declared.
    pk_empdetails.query(is backend procedure).
    Hope u got my point.
    Regards
    sonali
    null

  • Error while Creating Master Repository: ORA-01031: insufficient Privileges

    Hi,
    I'm trying to install ODI into my VM.
    I have done the installation and while creating Master Repository, I'm getting following error:
    ORA-01031: insufficient Privileges
    I'm using Oracle & have created user as ODI_MASTER with Admin Privileges.
    I'll be using it to load metadata onto planning (Version 11.1.2)
    Is there anything that I'm missing out on.
    Jitendra.

    Seems missing grants on the user you are using to create Master Repository.
    you are using Oracle .. grant connect, resource to <your_user>. These two rolesa have sufficient access to db to create the master repository.
    execuute the sql from sys user
    Regards,
    Amit
    Edited by: amitgupta1202 on 20 Aug, 2009 10:42 PM

  • ERROR Message while creating Rebate condition record T code VBO1

    Dear Experts,
    I am getting error message while creating rebate condition record T code-VBO1-Error Msg-862 system cannot read the structure for table,because of this i could not create condition record.
    Please give the solution to create condition record.
    Regards
    siva

    Hi,
    You said you are trying to do this stuff in IDES right.
    If you are using IDES provided by a company and where many people play on IDES, then you can get many such issues...
    This is by our experience.  Today you do something in IDES and tommorow that thing or config is screwed up by others.
    If you have your own IDES, then check the suggestion given by the forum Guru's.
    Regards,
    SB

  • While creating master item, can I add a check to copy from template

    Hi,
    While creating master items, can I add a check on copy template on the item to ensure item is created using some template?
    This will ensure many attributes gets proper value. If template is not copied, in later phases user faces problem with few attributes not being set.

    Regarding the final PDF you produce with the Print button; when the user hits the Print button the usual printer dialogue box is launched and s/he can select which pages he wants to print and the number of copies. I think this is what you said this is what your customer wants.
    Note: when you add the Print button, within the Acrobat Forms facility, you then go to Button Properties dialogue box and select  Actions, select the trigger (i.e. On Mouse Down); Add an Execute a menu Item, click on Add and select File > Print from the drop-down list. A bit complicated to explain here, but easier enough if you have a play around with it. Acrobat Forms are a wonderful facility – well worth exploring the many things you can do with them. Especially if you set up your document first in InDesign!
    Derek

Maybe you are looking for