Application Development and Automation 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: 
Read only

Change pointers and deletion

Former Member
0 Likes
2,295

hello everyone,

I am posting the following from another posting 'Change Pointers' so that I can reward points for helpful answers.

<b>By: Srinivas Adavi</b>

"When you say MM, you are talking about Material Master data, correct? For that the object class will be MATERIAL. But remember that the change indicator on CDHDR for a newly created material will also be 'U' not 'I'. I don't know why. But the change indicator on CDPOS will be 'I'.

Go to SM30, enter table name TVARV, click on maintain. Once inside, select the tab 'Parameter'. Switch to change mode and click on 'Create' icon. Enter a name like ZZ_LAST_RUN_DATE for name and some initial date for value(in YYYYMMDD) format. Repeat the process for time say, ZZ_LAST_RUN_TIME.

When you create the variant for your program, Go to change variant attributes. Select the checkbox for 'Selection Variable' identified by column 'L'. Then click on 'Selection Variables' pushbutton. Make sure that the green traffic light is in the column 'T' and enter your ZZ variable that you just created. This will take care of your selection screen.

Now you will pass these two parameters to the function module call.

In your program you will update the TVARV table(see help on UPDATE statement) for these variables passing your new values.

For deletion, there is no direct way to do it, except that in CDPOS, the field that changed will be LVORM and the table will be MARA, MARC, MARD etc. depending on at what level the material is marked for deletion. The flag will still be 'U' on CDHDR and CDPOS."

<b>My reply:</b>

Yes by MM i mean material master.

I went into SM30 and created date and time. I put value for date as 20060301 and time i left blank.

I already have a parameter for material type because I will be getting data from MM for only some specific material types.

I went into my program and created 2 more parameters for date and time. can i declare them as sy-datum and sy-uzeit if i don't want to put any value in TVARV table?

Then i went to GOTO -> Variants. I created variant called 'date' and put todays date in there and went into its attributes. BUT i don't see any checkbox for 'Selection Variable'. When i click on it, i just see two variables:

'T' for Table variable from TVARV

'D' for Dynamic date calculation

and there is no green traffic light as well.

Am i doing something wrong?

Regards,

Eddie

hello everyone,

I am posting the following from another posting 'Change Pointers' so that I can reward points for helpful answers.

<b>By: Srinivas Adavi</b>

"When you say MM, you are talking about Material Master data, correct? For that the object class will be MATERIAL. But remember that the change indicator on CDHDR for a newly created material will also be 'U' not 'I'. I don't know why. But the change indicator on CDPOS will be 'I'.

Go to SM30, enter table name TVARV, click on maintain. Once inside, select the tab 'Parameter'. Switch to change mode and click on 'Create' icon. Enter a name like ZZ_LAST_RUN_DATE for name and some initial date for value(in YYYYMMDD) format. Repeat the process for time say, ZZ_LAST_RUN_TIME.

When you create the variant for your program, Go to change variant attributes. Select the checkbox for 'Selection Variable' identified by column 'L'. Then click on 'Selection Variables' pushbutton. Make sure that the green traffic light is in the column 'T' and enter your ZZ variable that you just created. This will take care of your selection screen.

Now you will pass these two parameters to the function module call.

In your program you will update the TVARV table(see help on UPDATE statement) for these variables passing your new values.

For deletion, there is no direct way to do it, except that in CDPOS, the field that changed will be LVORM and the table will be MARA, MARC, MARD etc. depending on at what level the material is marked for deletion. The flag will still be 'U' on CDHDR and CDPOS."

<b>My reply:</b>

Yes by MM i mean material master.

I went into SM30 and created date and time. I put value for date as 20060301 and time i left blank.

I already have a parameter for material type because I will be getting data from MM for only some specific material types.

I went into my program and created 2 more parameters for date and time. can i declare them as sy-datum and sy-uzeit if i don't want to put any value in TVARV table?

Then i went to GOTO -> Variants. I created variant called 'date' and put todays date in there and went into its attributes. BUT i don't see any checkbox for 'Selection Variable'. When i click on it, i just see two variables:

'T' for Table variable from TVARV

'D' for Dynamic date calculation

and there is no green traffic light as well.

Am i doing something wrong?

Regards,

Eddie

7 REPLIES 7
Read only

christian_wohlfahrt
Active Contributor
0 Likes
1,774

Hi Eddi!

Yes, you are doing totally wrong. Go with the proposal of Saquib Khan. Once you read the change pointers, you set the selected pointers to status = 'X' and you have no trouble with selection any longer.

If you don't no how to set up change pointers (own Z-message type), search the forum (for more than 90 days) and come back with further questions afterwards.

Going for change documents (CDHDR/CDPOS) instead of change pointers (BDCP/BDCPS) is much slower and puts you into a struggle with last run time and so on. Change pointers are <i>designed</i> for this purpose.

Regards,

Christian

Read only

0 Likes
1,774

Hi,

I wanted to clear out my doubt. Aren't BDCP/BDCPS used in the case of IDOCs? As to what I've been told, I need to use CDHDR in the case of my report. I just need to know the changed data from CDHDR and store updates in TVARV table.

I wrote the following:

parameters: p_matl like mara-mtart,

beg_date like sy-datum,

end_date like sy-datum,

beg_time like sy-uzeit,

end_time like sy-uzeit.

data: pt_cdhdr TYPE cdhdr_tab.

start-of-selection.

SELECT * FROM cdhdr APPENDING TABLE pt_cdhdr

WHERE objectclas = 'material'

AND username = sy-uname

AND (

(

udate = beg_date

AND

utime >= beg_time

)

OR

udate > beg_date

)

AND (

(

udate = end_date

AND

utime <= end_time

)

OR

udate < end_date

).

I put 4 additions in TVARV table. From/To Date and From/To Time. After running the report once, the 'To' date and time need to become the 'From' date and time so that when the report is run next time, it will pick up 'To' date/time (which will be last run)

I have already linked variants with the TVARV table, so selection part is taken care of.

Can somebody tell how to put the logic for updating the TVARV table based on my above logic?

Also, I need to do an extract report for materials that will be deleted. Do I check for the deletion flag and based on that just list those materials? How do I put in separate report?

Thanks in advance.

Regards,

Eddie.

Read only

0 Likes
1,774

Hi Eddi!

It's possible to base the report on change documents, but it's easier to use change pointers - some standard features can be used without own programming.

Have a look at this topic. Also transaction BD52, where fields to the message type have to be assigned.

With three fast customizing steps you can get your <i>own</i> change pointers. With the first FM you can get all 'open' change pointers without any difficulties and with the second FM you can set the status to 'old' -> you won't read any change twice.

With transaction BD22 also archiving or other deletions are available.

Regards,

Christian

Read only

0 Likes
1,774

Hi Christian,

I now kinda understand what you are trying to say here. I haven't dealt with this earlier, I would appreciate if I can get some more info regarding this. I got the following information from another post:

Re: Moving from Change document to change pointers on Z tables

Posted: Oct 26, 2005 3:19 AM

by: Kim Ternstrøm

Created a new messagte type in WE81 (name of the interface)

Map the message type to change document items (table fields) in BD52

Aktivate change pointers for message type in BD50.

The result is that every time a change document is created records also are written to table BDCP.

All I have to do now is to change the interface to use the FM CHAGE_POINTER_READ and CHANGE_POINTER_STATUS_WRITE instead of reading CDHDR and CDPOS.

So, when mapping the msge type in BD52, I will put the fields that I am extracting from material master, right? Will I be attaching function modules in BD60? If so, then what will it be and what will be my object type?

Coming back to my report, would I still be using the same parameters for date/time. In short, this is what my report is about. I need to set up the change pointers and then do selections from material master based on material type, reading the required fields and putting them in csv format.

Initially, when data will be loaded, there will be no changes, but after that I need to read the changes.

So how would I implement the above process for calling Function Modules into my report? Will I still call the FMs before my selections?

Thanks in advance.

Regards,

Eddie.

Read only

0 Likes
1,774

Hi,

I also wanted to say that I checked BD22 and it is deleting change pointers from the database.

When I was talking about deletion, I was referring about generating a report to display list of all materials that have been deleted.

Regards,

Eddie

Read only

0 Likes
1,774

Hi Eddie!

Deletion: for sure materials, but it's good to know how to get rid of the own messages, too. Deletions are triggered with change pointers like with CDHDR, so no difference in this part.

BD60 is not necessary. Maybe change pointers have still to be activated in general (when you are the first one in the company), please deactivate then all other pointers in BD50 (otherwise a lot of pointers are created without anyone using them).

If you just want to send some material types, then don't forget to set status of pointers to other articles, too - or you would read them again and again.

If you want to schedule different programs per material type, then one program version should not touch pointers of other version (variant).

Yes, looks like you got the point. Any date / time selection in your report is obsolete, because pointer handling with status is replacing this.

Regards,

Christian

Read only

0 Likes
1,774

Hi Christian,

Thanx for the quick reply.

So, the particular deletion will be reflected in the status through the FM. am i right?

I don't have different programs per material type. My program has parameter for material type, and based on that data will be loaded. Secondly, will i be calling the FMs change_pointers_read and change_pointers_status_write in the beginning of my report before I even do selections for material data?

I don't get the part where you say <i>Maybe change pointers have still to be activated in general (when you are the first one in the company), please deactivate then all other pointers in BD50 (otherwise a lot of pointers are created without anyone using them).</i>

I'm kinda new at this, so thats why I'm kinda confused. Is it possible I email you my program so you can see whats going on?

Regards,

Eddie.