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: 

Store changes into new user tables

Former Member
0 Kudos

Hi,

I've created several user tables in order to store new data about customers. But I also need to store the changes into the tables.

I've read about change documents, but I'm not very sure of how can I use these, for example what are the functions that I have to use or where to put this code in my program.

Any example of how to use this would be very appreciated

thanks in advance

4 REPLIES 4

Former Member
0 Kudos

Hi,

Your user tables are Z tables and you want to insert or modify lines of the tables?

former_member188685
Active Contributor
0 Kudos

HI <b>CDHDR and CDPOS</b> will have all the changes or updates.

write a code in your program read the tables and update your tables based on the transaction.

regards

vijay

abdul_hakim
Active Contributor
0 Kudos

Hi,

Use the tables CDHDR and CDPOS to fetch the old and new values..

A sample code

**fetch header records from cdhdr table

SELECT OBJECTID

CHANGENR

USERNAME

UDATE

UTIME

FROM CDHDR

INTO TABLE I_CDHDR

WHERE UDATE IN S_DATE AND

OBJECTCLAS EQ 'ADRESSE' AND "address change

TCODE EQ 'VA02' AND "tcode

CHANGE_IND EQ 'U'. "change type update(U)

**fetch the position records based on the cdhdr entries

IF NOT I_CDHDR IS INITIAL.

SELECT CHANGENR

TABNAME

FNAME

VALUE_NEW "new value

VALUE_OLD " old value

FROM CDPOS

INTO TABLE I_CDPOS

FOR ALL ENTRIES IN I_CDHDR

WHERE CHANGENR EQ I_CDHDR-CHANGENR AND

TABNAME IN R_TFIELDS AND

FNAME IN R_FIELDS.

ENDIF.

Note: R_TFIELDS is the table name stored in ranges table.

I mean changes to these table entries only..

R_FIELDS is the field name of the corresponding tables in R_TFIELDS.

You define as below in the data declaration.

*ranges r_fields for cdpos-fname.

RANGES: R_FIELDS FOR CDPOS-FNAME,

R_TFIELDS FOR CDPOS-TABNAME.

In the INIITIALIZATION event fill these ranges with the corresponding value...

Regards,

Abdul