Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

VIEW_MAINTENANCE_CALL

Former Member
0 Kudos

I've seen lots of threads regarding this, but none of them address a request I've had about using this.

Is there a way, using this FM, to be able to create a report of what was done? I have a program that calls this FM and allows them to do all maintenance functions: insert, delete, change and my users asked me if there was anyway I could create a report each time they ran it to show what they did. Below is the code, which isn't much.

REPORT ZPAPAI0015_MERIT_INCR_INSERT

NO STANDARD PAGE HEADING.

*----


  • TABLES, ITABS AND STRUCTURES

*----


START-OF-SELECTION.

*Call function module using ZHCM_MERIT_ELIG which is a *maintenance view for ZHCM_MERIT_ELIG. All updating is *performed by the function module and the maintenance dialog.

CALL FUNCTION 'VIEW_MAINTENANCE_CALL'

EXPORTING

ACTION = 'U' "S = display

VIEW_NAME = 'ZVHCM_MERIT_ELIG'

NO_WARNING_FOR_CLIENTINDEP = 'X'

GENERATE_MAINT_TOOL_IF_MISSING = 'X'.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Duh, it does help to move the data from Total to my table.

What I'm seeing isn't what I expected. My Imported table contains the entire table I was maintaining with the latest data. It does not tell me what records were changed and if I deleted a record it's just deleted , the Mark and Action fields are blank. So the only way I could tell what was different would be to kind of follow the route you originally suggested and copy the table to an internal table before the call, and compare the Imported table to this table. I was hoping that the Mark and Action fields would allow me to read the Imported table and immediately see what was touched and how.

15 REPLIES 15

Former Member
0 Kudos

You can do this using the table change logging.

See transaction SCU3 for the programs, and RZ11 = "rec/client" for the activation and SE13 data change log flag, as after activated, this is per table settings.

Also search "OSS" for these terms.

Cheers,

Julius

Former Member
0 Kudos

Interesting answer Jules, but I'm not sure we want to go that extreme.

0 Kudos

The FM would do that generically for you, but after reading more closely and Naimesh Patel's answer I agree with you

naimesh_patel
Active Contributor
0 Kudos

You might think on this way also:

Before calling the FM VIEW_MAINTENANCE_CALL select the data from the table.

Now, in your table maintaince generator, implement the event 02. Here you can export the internal table TOTAL to some ABAP internal memory. This total table contains all the data with the Flag which can be useful to know, what was changed, deleted or inserted.

Help of event 02:

http://help.sap.com/saphelp_nw04/helpdata/en/91/ca9f11a9d111d1a5690000e82deaaa/frameset.htm

If you don't want the data with the flag, you can select the latest data again from the Database.

Now, after the function call, you can IMPORT the data from Memory, if exported in pervious step.

Now, compare the both the internal table: Before the Call and After the Call.

I am sure there is some FM or Class, which can be useful for comparision. But it is not handy for me rightnow.

Regards,

Naimesh Patel

uwe_schieferstein
Active Contributor
0 Kudos

Hello Richard

If you want to do a comparison at the record level (not fields within a record) then you may have a look at my Wiki posting

[Comparing Two Internal Tables - A Generic Approach|https://wiki.sdn.sap.com/wiki/display/Snippets/ComparingTwoInternalTables-AGeneric+Approach]

Regards

Uwe

Former Member
0 Kudos

Naimesh,

Your answer seems like a possible solution, but I'm not familiar with EVENTS so how do Implement this in my Table Maintenance?

0 Kudos

You can follow this path:

From the table maintaince screen:

Environment > Modification > Events

Here you can select the best possible Event for your requirement.

Say you selected 02.

Now you have to give the Subroutine name and by pressing the Editor ICON system will ask for the include and transport information.

Follow the link which I have provided in my earlier post for more info.

Regards,

Naimesh Patel

Former Member
0 Kudos

Ok Naimesh I'm getting there but I'm still got some questions.

You said:

"Before calling the FM VIEW_MAINTENANCE_CALL select the data from the table.

Now, in your table maintaince generator, implement the event 02. Here you can export the internal table TOTAL to some ABAP internal memory. This total table contains all the data with the Flag which can be useful to know, what was changed, deleted or inserted.

If you don't want the data with the flag, you can select the latest data again from the Database.

Now, after the function call, you can IMPORT the data from Memory, if exported in pervious step.

Now, compare the both the internal table: Before the Call and After the Call."

I went to my table and added Event 02 and it brought up a new window to create a new Include where I put the form name I referenced in the Event.

I understand that here is where I define my table and flags using the structures defined in your link and Export them back to my program that has the VIEW_MAINTENANCE_CALL which should have an identical table in it and should IMPORT into this table.

What I'm a bit confused about is why I need to copy the table I'm maintaining into an Internal Table before and after the Maintenance Call and compare them. Won't the TOTAL table tell me what got changed/added/deleted?

0 Kudos

Yes. After reading carefully again to my answer, I got it. We can use the TOTAL table to know the updated data. (Thanks for the Catch).

Now, you have the data with the flag and I guess that will help to create a list which can say what was changed.

Regards,

Naimesh Patel

Former Member
0 Kudos

I must not have done something right because my Total table has nothing in it, yet I'm changing data.

Here is the calling program:

START-OF-SELECTION.

DATA: BEGIN OF ZVHCM_MERIT_ELIG_TOTALA OCCURS 0.

INCLUDE STRUCTURE ZVHCM_MERIT_ELIG.

INCLUDE STRUCTURE VIMFLAGTAB.

DATA: END OF ZVHCM_MERIT_ELIG_TOTALA.

*Call function module using ZHCM_MERIT_ELIG which is a maintenance view

*for ZHCM_MERIT_ELIG. All updating is performed by the function module

*and the maintenance dialog.

CALL FUNCTION 'VIEW_MAINTENANCE_CALL'

EXPORTING

ACTION = 'U' "S = display

VIEW_NAME = 'ZVHCM_MERIT_ELIG'

NO_WARNING_FOR_CLIENTINDEP = 'X'

GENERATE_MAINT_TOOL_IF_MISSING = 'X'.

IMPORT ZVHCM_MERIT_ELIG_TOTAL TO ZVHCM_MERIT_ELIG_TOTALA

FROM MEMORY ID 'I_MERITTOT'.

LOOP AT ZVHCM_MERIT_ELIG_TOTALA.

ENDLOOP.

Here is the new include with the Form referenced in the Event, and debug shows that I am going through this code, but when I check the table before I EXPORT there is nothing in it.

FORM CHECK_MAINTENANCE_ACTION.

DATA: BEGIN OF ZVHCM_MERIT_ELIG_TOTAL OCCURS 0.

INCLUDE STRUCTURE ZVHCM_MERIT_ELIG.

INCLUDE STRUCTURE VIMFLAGTAB.

DATA: END OF ZVHCM_MERIT_ELIG_TOTAL.

free memory ID 'I_MERITTOT'.

export ZVHCM_MERIT_ELIG_TOTAL to memory ID 'I_MERITTOT'.

ENDFORM.

0 Kudos

Did you move your data from TOTAL table to ZVHCM_MERIT_ELIG_TOTAL .


FORM CHECK_MAINTENANCE_ACTION.

DATA: BEGIN OF ZVHCM_MERIT_ELIG_TOTAL OCCURS 0.
INCLUDE STRUCTURE ZVHCM_MERIT_ELIG.
INCLUDE STRUCTURE VIMFLAGTAB.
DATA: END OF ZVHCM_MERIT_ELIG_TOTAL.

ZVHCM_MERIT_ELIG_TOTAL[] = TOTAL[].    " <<

free memory ID 'I_MERITTOT'.

export ZVHCM_MERIT_ELIG_TOTAL to memory ID 'I_MERITTOT'.

ENDFORM.

Or just directly export the TOTAL table.


FORM CHECK_MAINTENANCE_ACTION.

free memory ID 'I_MERITTOT'.

export TOTAL to memory ID 'I_MERITTOT'.   " <<

ENDFORM.

Regards,

Naimesh Patel

0 Kudos

I tried with my test table and events.

I used 01 event.

Code in the 01 Event


DATA: BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE ZTEST_NP_EVENT.
INCLUDE STRUCTURE VIMFLAGTAB.
DATA: END OF ITAB.

ITAB[] = TOTAL[].  "<<

free memory ID 'ZTEST_EVENT'.

export ITAB = ITAB to memory ID 'ZTEST_EVENT'.   " << I am assingnig the ITAB to ITAB

In my program:


IMPORT ITAB TO ITAB FROM MEMORY ID 'ZTEST_EVENT'.

Regards,

Naimesh Patel

Former Member
0 Kudos

Duh, it does help to move the data from Total to my table.

What I'm seeing isn't what I expected. My Imported table contains the entire table I was maintaining with the latest data. It does not tell me what records were changed and if I deleted a record it's just deleted , the Mark and Action fields are blank. So the only way I could tell what was different would be to kind of follow the route you originally suggested and copy the table to an internal table before the call, and compare the Imported table to this table. I was hoping that the Mark and Action fields would allow me to read the Imported table and immediately see what was touched and how.

0 Kudos

If you use the event 01 (Before saving the data in the database) than it would work.

If you look closely in my previous post, I had noted that I used the event 01. Because 02 was not working as what we expected.

I am getting the ACTION as

D - Delete

U - Update

N - New Entry

Regards,

Naimesh Patel

Former Member
0 Kudos

I saw that post, but didn't read it close enough.

I really appreciate your help, this seems to be exactly what I was looking for.