Skip to Content

Maintenance (Update) view from two tables

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Sep 20, 2006 at 12: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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • Posted on Sep 19, 2006 at 10: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 Maintenance" target="_blank">http://help.sap.com/saphelp_erp2005/helpdata/EN/cf/21ecdf446011d189700000e8322d00/frameset.htm">Maintenance Views for complete help.

    Regards,

    Christian

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2006 at 10:35 AM

    Hi,

    check out maintainence view v_159R and simulate

    your view creation.

    Regards

    Amole

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2006 at 09: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.