cherokee
16th August 2013, 22:09
Hello everyone,

quick question regarding reference table(mandatory).

If have table B that refers to table A by primary key(cuno) both(A and B); when navigating on a session where A is the main table and on the form I have fields from table B, I would spect that while navigating on A, B will move as well and values in on form, B will be automatically fetched. Feel like why should I do on before.display read table B?

Thanks in advance

bhushanchanda
17th August 2013, 12:09
Hi Carlos,

A snapshot of the form and the attempted script can explain it.

You can fetch the required values of table B in before.display. What have you tried so far?

mark_h
17th August 2013, 22:06
I think what he was saying was he should not have to do a fetch - the records should stay in sync because of the reference. I can't answer the question because I thought it was mainly used to keep referential integrity in the tables, I just never really used these fields to link tables.

bhushanchanda
18th August 2013, 08:02
Ok, sorry I didn't understood at first. .

Well, yes it should work. I have done it in some cases. Say, I have a table A with 2 fields

1. srno
2. bpid

Where srno is the primary key (Index).

I have table B with 2 fields

1. bpid
2. nama

Where bpid is the primary key (Index).

In the table definition of Table A, you can define a reference of Table B for field bpid.

Now, on your form with main table A, if you include the field nama, it will automatically fetch the values from Table B related to the value in Table A.

vamsi_gujjula
18th August 2013, 09:39
Yes that is possible.....if. A --> ( refers ) B....the best example is the purchase order session in which the main table would be tdpur401 polines and item description.....where you have to just place tcibd001.dsca..on the form to fetch the description....( and mind you... the session should have view on the main table)

cherokee
19th August 2013, 14:59
Well, I did as I explained in my first post and after well explained by bhushanchanda but, seems that the table B is not fetching values automatically unless I put before.display.

Parent Table tccom010 :customers, refered field:cuno(primary key)
Child Table tccom956 : Legal, refered field: cuno(primary key) reference table tccom010, mandatory

I did convert DD for all packages just in case.

Session Maintain Customers session added field tccom956.blsl. values do not change when navigating on Maintain Customers.

Am I missing something?

Thanks in advance for the help.

bhushanchanda
19th August 2013, 15:29
Well, from your description I guess both the tables have similar index fields names i.e. cuno. Is it?? Well that might be causing the problem. I will post snapshots of my definitions once I get back on my desk.

bhushanchanda
19th August 2013, 17:26
Hi,

Check the snapshots.

I have 2 tables. Table A and Table B.

Table A has primary key as srno.
Table B has primary key as bpid.

The reference is added in Table A for Table B.

vamsi_gujjula
20th August 2013, 15:21
Hi Carlos,

i have a small query,is it that you are adding to an existing session (i am assuming it that you are on baan iv c )

Can you check that on new session (test).

cherokee
23rd August 2013, 14:27
Hello Vamsi,

Yes, the new session has no problem table B, when you navigate, fields are fetch with the refered table A. Why doesn't work the other way around?

Thanks for you help

frank.finke
24th August 2013, 02:36
What's why the maintable of your Session must include the declaration of the reference, wich you want to use. This means:
If the table B, field X has a reference declared to the primary key of table A, the session must have the table B as maintable in order to automatic fetch the data from the other table (A).
For example table tdsls401.item refers to table tcibd001. In a Session tdsls4101m000 with maintable tdsls401 the data from tcibd001 will automatic fetched. But in the other case in the session tcibd0101s000 the data from tdsls401 can't be automatic fetched. Thats why the relation from tcibd001 to tdsls401 is not unique but also why the reference is not declared in tcibd001.

Regards

cherokee
26th August 2013, 14:07
Make sense... I could be nice if would work both ways, tons of code would be saved.

Thanks to all.