‎2008 Jul 09 8:40 PM
Need to read all materials created or changed previous day for a specific MARC_MMSTA value.
Also need to add a filter where MARC_MMSTA value is '98' and this should be extracted only for certain plant codes.
Appreciate if someone can help me in this.
‎2008 Jul 09 9:15 PM
Firts go to the CDHDR Table (Change Document Header) and look for the Date Range you need.
OBJECTCLAS = 'MATERIAL'
OBJECTID = Your Material Number
From this table you will need the field CHANGENR (Change Number).
You need than need to look at the table CDPOS (Change Docuemnt Item). You will need:
OBJECTCLAS = 'MATERIAL'
OBJECTID = Your Material Number
CHANGENR = From above
TABNAME = MARC
FNAME = MMSTA
From here you can also get the Old and New Values.
‎2008 Jul 09 9:20 PM
Thanks Mike.
Since I am new to the Object Oriented, will it be ok to use simple select on MARA ?
If yes, Can i use the created on and last change date as a seletion criteria ? Will it be accurate ?
‎2008 Jul 09 9:22 PM
Hi Milke,
Forgot to mention, I don't want any old values except old material number MARA-BISMT.
Thank you.
‎2008 Jul 09 9:24 PM
The information I gave you above does not require objects and can be written with simple selects. I have included the Fields you will need from CDHDR and CDPOS. You could use MARA, but the information you are looking for is in the MARC table. If you do not need the old and new Values you can write a Select joining the Tables MARA and MARC.
‎2008 Jul 09 9:29 PM
Mike,
I don't see all information available in CDHDR also.It just shows who changed when.
If I have to get what was changed or what was the old value, how can i get that ?
Also, how can I get MARC_MMSTA from CDHDR ?
Sorry, if i am asking too many questions. Hope it is making sense..
Thanks,
JMC
‎2008 Jul 09 9:31 PM
You need to go to CDHDR to get the Change Number for the Date Range you need. The data you require is in CDPOS for the Old Value and New Value. You would specify MARC as the Value for the field TabName and MMSTA for the Field FName (as well as the values I stated earlier).
‎2008 Jul 09 9:39 PM
If you are only looking for a specific value of MARC-mmsta = '98' for any changes and not concerned about the Old and New Values, then the select mentioned by Michael would be what you are looking for. My recommendation from above would only give the the changes made to the field MMSTA where you could look for the Old or New Value = '98'.
‎2008 Jul 09 9:56 PM
Agree with you Mike.
Thanks a lot to you as well Michael for explaining me so clearly.
For now I will follow what Michael has suggested as Old Values and New Values not required.
Thanks,
JMC
‎2008 Jul 09 9:23 PM
Try something like this:
TYPES: BEGIN OF ty_mara,
matnr TYPE matnr,
END OF ty_mara.
DATA: lt_mara TYPE TABLE OF ty_mara,
lv_date TYPE dats.
RANGES: lr_werks FOR marc-werks.
* fill range table with appropriate values
lr_werks-sign = 'I'.
lr_werks-option = 'EQ'.
lr_werks-low = 'XXXX'.
APPEND lr_werks.
lv_date = sy-datum -1.
SELECT a~matnr INTO TABLE lt_mara
FROM mara AS a
INNER JOIN marc AS c
ON a~matnr = c~matnr
WHERE ( a~ersda EQ lv_date OR
a~laeda EQ lv_date )
AND c~mmsta EQ '98'
AND c~werks IN lr_werks.
In this example I only select MATNR but you can extend the type to as many fields as you need, don't forget to add those fields to the select statement as well.
Hope that helps,
Michael