cancel
Showing results for 
Search instead for 
Did you mean: 

update ztable from screen

former_member190689
Contributor
0 Kudos

Hello Gurus,

       I have created an application in webdynpro , which holds a select-option and a textedit table.Whenever the range is provided in select-option the data will be displayed in change mode in the respective table names as Material.Now I have created one more transparent table named as Zmaterial_descp.Now the thing is whenever the user tries to change any field on the table Material like short text of a particular material then only that complete column should be saved into the Zmaterial_descp with a new change document number.So for the next time if the user enters that material number he could see both the tables i.e the actual table and the changed table.

Question:

1. how to updated only the changed field of a particular column in zmaterial_descp from material which is displayed on screen.

2. How to create the change document number for every change made by the user in Material table displayed on screen.

I have ref many other tutorials  but couldn't able to find the right option.

Thanks in advance

Gaurav Gautam

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

There is an interface IF_WD_CONTEXT_CHANGE_LOG which can store any changes made in the context of your application once you have activated it. You can use this to store your context changes.

Every change will appear as a line of a table using this. Based on every change you can create a new change document number. You can use Number Ranges for creating a new number.

former_member190689
Contributor
0 Kudos

Hi Khushboo,

     Could you please tell me in more detail about this interface like do we have to write any code for it.

Regards

Gaurav Gautam

Former Member
0 Kudos

Hi,

I am sorry for a mistake in my previous post.

To track changes in your context follow the steps:

1. Enable context change log IF_WD_CONTEXT->ENABLE_CONTEXT_CHANGE_LOG( ).

2. Get the changes in the context IF_WD_CONTEXT->GET_CONTEXT_CHANGE_LOG( ).

The GET_CONTEXT_CHANGE_LOG method will return you a table of all the changes in the context of your application.

After receiving the change log table, you can disable the context change log.

Former Member
0 Kudos

You can write this code whenever you are saving your changed data or or an action.

DATA: lo_context TYPE REF TO if_wd_context,

          lo_log        TYPE TABLE OF wdr_context_change.

lo_context = wd_context->get_context( ).

lo_context->enable_context_change_log( ).

lo_log = lo_context->get_context_change_log( ).

lo_context->disable_context_change_log( ).

former_member190689
Contributor
0 Kudos

Hi Khushboo,

     I hope my concern is cleard with you as I am also facing a problem that changes made to Material table which gets saved in Zmaterial_descp but after I refresh the session and again I do the change then the previous changes are re-written means previous changes are lost and new changes are saved.

Thanks and Regards

Gaurav Gautam

Former Member
0 Kudos

You question is not clear.

What i understand now is:

1. You make changes in your table data on screen on say Column 1.

2. You save them in table Zmaterial_descp with a change document Number. say for example Entry 1 in Zmaterial_descp.

3. Now you refresh the screen.

4. You change the table data on screen again on say Column 3.

5. And now you again save the data in table Zmaterial_descp. say for example Entry 2 in Zmaterial_descp.

Now, you said "previous changes are re-written means previous changes are lost and new changes are saved." This means what? Where are the changes lost - on screen?

It would be nice if you explain in steps.

former_member190689
Contributor
0 Kudos

Hi Khushboo,

      You got my point actually the data is being lost from Zmaterial_descp(Trans table). if user tries to re-write any change made to any other field

Now when user tries to change on with table name material the data should be saved in Zmater.table.

1. on screen there is one select-option for matnr now in table the required records with matnr like its descp , unit etc are displayed when he clicks submit button

2.the table which i used on screen is with testedit  property ,where user can change data accordingly.

3.Now when he clicks on Save means the changes he made to whichever field , the respective row  to that field should be saved in Zmaterial_descp.

4.Also when he clicks on Save a change request number should be generated accordingly with respect to that material number.

5.Again if he wants to refer to that field he can use his change document number to see what ever changes he has made to his material.

6.Also only the row in which the field is changed should be saved in Zmaterial_descp.Not all the items which are searched thr select-option.

In order to make this I used the key field Matnr but still its not working and the complete data is being saved in my ztable.Means all the records which I searched along with the field I changed.

I hope it would be clear to you now.

if you want then i can send u the screen shots if i am still not able to make you clear.

Regards

Gaurav Gautam

Former Member
0 Kudos

Hi,

Requirement 1: Only the row in which the data is changed should be saved. Not all the rows in the table.

Solution:

1. Internal Table ITAB_1 is bound to your node of the table. After this activate the change log.

    node->bind_table( itab_1).

    lo_context->enable_context_change_log( ).

2. On save

a. get the changes made.

    lt_change_table = lo_context->get_context_change_log( ).

b. Get the element number of the changed element from the table, get the data of this element and move this to your z Table

    LOOP AT lt_change_table INTO ls_change_row.    

          lv_element_index = ls_change_row-element_index.

          lo_element = node->get_element( lv_element_index ).

          lo_element->get_static_attributes( IMPORTING static_attributes = ls_data ).

          INSERT INTO zmater.desc FROM ls_data.

    ENDLOOP.

c. Deactivate log

     lo_context->disable_context_change_log( ).

Requirement 2: The data should not be over written.

Solution:

When you keep only MATNR as key in your zmater.desc table, if you make any changes again to the same material, it will cause problems.

Keep the Key of the table as MATNR and the CHANGE_DOC_NO.

Every time you insert a row in this table, MATNR may be same but CHANGE_DOC_NO will always be different because you must create a new change document number with every insert.

Message was edited by: Khushboo Sachdeva

former_member190689
Contributor
0 Kudos

Hi Khushboo

  Could you please tell which data element I should use to create that field in my ztable CHANGE_DOC_NO.thr which I can create the change document number.Do you know the process to create the change document number for ztable.

Regards
Gaurav Gautam

Former Member
0 Kudos

Hi Gaurav,

      Just add one field in your table as a key field because it will identify the a particular change instance.

Data element , you can use any data element of your choice. Create a new one & u can keep domain with CHAR /  NUMC data type.

If you want standard  u can also use data element 'AENNR'.  From your WDA application get the list of changes entries as khusboo suggested & then update your change document no as incremental value ,( like prev u have 0000001 now for all the changes make it 0000002 & update in your table,) there is no big deal in that.

Regards,

Monishankar Chatterjee

former_member211591
Contributor
0 Kudos

Hi,

I would prefer two more keyfields:

  • updat type dats
  • uptim type TIMS

and one further field:

  • upusr like sy-uname

When saving to your Zmaterial_descp set updat = sy-datum, uptim = sy-uzeit and upusr = sy-uname.

Thus you will have a chronological change log with date/time/"user who changed".

BR

former_member190689
Contributor
0 Kudos

Hi Khushboo,

Sorry for the delay

    Thanks a lot for your reply and it really helped me a lot.

Apart from that again i am facing a new problem for which i have written a new thread .

Thanks

Gaurav gautam

Answers (0)