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

Reading Material Master Data

Former Member
0 Likes
1,275

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.

9 REPLIES 9
Read only

Former Member
0 Likes
1,250

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.

Read only

0 Likes
1,250

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 ?

Read only

0 Likes
1,250

Hi Milke,

Forgot to mention, I don't want any old values except old material number MARA-BISMT.

Thank you.

Read only

0 Likes
1,250

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.

Read only

0 Likes
1,250

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

Read only

0 Likes
1,250

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).

Read only

0 Likes
1,250

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'.

Read only

0 Likes
1,250

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

Read only

Former Member
0 Likes
1,250

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