09-19-2006 11:05 AM
Hi to all,
i have to solve this problem.
I've have two simple table : ZTAB1 and ZTAB2. Both table has one key field
called VKEY and one field. ZTAB1 has VFIELD1 and ZTAB2 has VFILED2.
I'd like to create a view that could input VFIELD1 and VFIELD2 both.
So with SE11 i've created a view that have these fields :
MANDT
VKEY ( from ZTAB1 )
VFIELD1( from ZTAB1)
VFIELD2( from ZTAB2 )
Join conditions and foreing keys are set correclty.
With se54, i've created the update view. So i've called SM30 trx.
I inputed VKEY field, VFIELD1 and VFIELD2 with values. But when i hit enter, the
value in the VFIELD2 disappear.
So i cannot save it in table. I was sure (also reading other posts) that
the update view should working in this way.
I have to programming the update of the second table manually ? I hope not
Usefull answers will be surely rewarded.
Thx a lot
Andrea
09-19-2006 11:14 AM
Hi Andrea!
Maybe the table definition is not correct. Do you have a foreign key definition?
"All the tables in a maintenance view must be linked with foreign keys, that is the join conditions for maintenance views are always derived from the foreign key (see Structure link Foreign Key Relationship and Join Condition). You cannot directly enter the join conditions as for database views."
Have a look at <a href="http://help.sap.com/saphelp_erp2005/helpdata/EN/cf/21ecdf446011d189700000e8322d00/frameset.htm">Maintenance Views</a> for complete help.
Regards,
Christian
09-19-2006 11:35 AM
Hi,
thx for reply,but i think that the foreign key is right.
I assume this because foreign key definition, is a requirement to create a update view in SE11.
The foreign key is set as follow :
ZTAB1-MANDT -> ZTAB2-MANDT
ZTAB1-VKEY -> ZTAB2-VKEY
In the foreign key definition i eliminated the flag "foreign key check", because at the begin, both tables are empty
Thx again
Andrea
09-19-2006 5:19 PM
Hi Andrea,
the flag 'foreign key check' is only important for automatic messages in dynpros - this shouldn't change anything here.
But did you specify the correct attributes? Sounds like you have a 1:1 connection. <a href="http://help.sap.com/saphelp_erp2005/helpdata/EN/cf/21ea91446011d189700000e8322d00/frameset.htm">Semantic Attributes of Foreign Keys</a> Look also at the restrictions mentioned there.
Regards,
Christian
09-20-2006 10:20 AM
Hi Christian,
thx for your reply.
Just to be sure,i've tried with all kind of foreign key between the two tables.
Each time i have generated again the update view with SE54 trx, but still not working.
I don't understand where i'm wrong. Are there in sap some example of view that works on different tables? Maybe a practical example will help me more (i hope).
Thx a lot
Andrea
09-20-2006 10:50 AM
Hi Andrea,
here some views:
V_IDMX_VAT
V_T683S
VV_161V_VB
V_161_N
Update view? I thought we were talking about maintenance views (Type C)?
Regards,
Christian
09-20-2006 10:55 AM
Hi,
again on this problem.
Using /h function, i've debugged the standard SM30 trx
This is the code that clear each time the field of the second table (that i shold be able to input and save):
*--------------------------------------------------------*
form compl_zvrfc using workarea.
* provides (read-only) fields from secondary tables * related
* to primary tables by foreignkey relationships
ztrfc1-mandt =
zvrfc-mandt .
ztrfc1-vkey =
zvrfc-vkey .
ztrfc1-vfield1 =
zvrfc-vfield1 .
select single * from ztrfc2 where
vkey = ztrfc1-vkey .
if sy-subrc eq 0.
zvrfc-vfield2 =
ztrfc2-vfield2 .
else.
clear sy-subrc.
clear zvrfc-vfield2 .
endif.
endform.
This code is generated automatically by the view generator (i think).
This shows that if the record is not found, the value (vfield2) is cleared otherwise, the value is always read from the check table.
But when the tables are both empty ... i cannot insert records! and when are not empty, i cannot change any value!.
Any suggestion?
Thx
Andrea
09-19-2006 11:35 AM
Hi,
check out maintainence view v_159R and simulate
your view creation.
Regards
Amole
09-19-2006 3:22 PM
Hi Amole,
thx for reply.
But i don't understand what do u mean with "simulation". The view to check that u suggest to me is very different from witch i would create (mine view must be composed by two different tables linked by foreign key - the V_159R view is just a simple table with an update view builded on it).
Good hints/solutions will surely rewarded.
Thx a lot
Andrea
09-20-2006 10:58 AM
Hi Andrea,
what i understand from your query is that from among the two tables one table has to act as a Check table for the other. Let us suppouse ZTAB1 is the check table for the table ZTAB2, so when u r defining the foreign key for ZTAB2 maintain cardinality as 1:N or C:N.
Now when u r creating the view give ZTAB2 first and then ZTAB1.
I have also faced a similar problem like this while creating a maintenance view and i am giving the solution on my approach in solving the problem. CARDINALITY plays a major role in Views.
If this solves the problem please respond.
Thanks and Regards,
Raghavendra Goutham P.
09-20-2006 1:31 PM
Hi,
i've done what u wrote.
The result is the same. The only difference now is that the field that is not valorized if VFIELD1.
As last step, i try to report some view info. Maybe i've missing something
Tables:
ZTRFC2
ZTRFC1
View fields
View field table Field
MANDT ZTRFC2 MANDT
VKEY ZTRFC2 VKEY
VFIELD1 ZTRFC1 VFIELD1
VFIELD2 ZTRFC2 VFIELD2
Main status
read,change delete and insert
display/maintenance allow
At dicitonary level ZTRFC2-VKEY has a foreign key so defined :
ZTRFC1 MANDT ZTRFC2 MANDT
ZTRFC1 VKEY ZTRFC2 VKEY
Cardinality is C:N
Thx
Andrea
09-20-2006 4:48 PM
Hi,
sounds like an insert in two tables is not possible - which would match my idea of 'check table' (it has to be available beforehand).
But I'm wondering how a customizing table / text table combination can be maintained. Somehow this should be possible, but most customizing transactions use special screens - maybe here the extra coding is included.
And finally: why do you have two tables with identical key? Can't you just append the fields of the second table to the first? Otherwise your tables have a chance to be out of sync - which is surely avoided by having one wider table.
Regards,
Christian
09-21-2006 8:39 AM
Thank u Christian for u replies.
i was sure i could save data in different tables using views.
Otherwise, why there are different type of view (projection, update...) in se11 trx?
I know it's betterer put the different fields in one table with the same key.
It was just an exercise to understand how views works and if i could save data in different tables only creating a view (type update).
Seems doesen't works.
Thx a lot anyway
Andrea