‎2008 Feb 18 5:38 AM
Hi All,
Am using Change Document read function module to find out the changed material details. i want to fetch the plant from marc to filter the records am having the only relationship i.e material to fetch the details from marc and mara,with this i can't filter because for one material four plants will be there.so am using the tabkey from that function module to fetch the plant i don't think is this a right way can anyone explain how i can get a plant.
‎2008 Feb 19 2:34 AM
Think you query is misleading...
As per my understanding you are trying to find all changes for materials in a specific plant right????
If so below code can give you some idea:
TABLES: mara.
SELECT-OPTIONS: so_date FOR mara-laeda. " Date Criteria
PARAMETERS: p_werks TYPE werks_d obligatory. " Plant
CONSTANTS: c_tcode TYPE sytcode VALUE 'MM02'.
TYPES: BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
DATA: i_cdocs TYPE STANDARD TABLE OF cdred, " Change Docs
wa_cdocs TYPE cdred,
i_marc TYPE STANDARD TABLE OF ty_marc, " Plant Existence
wa_marc TYPE ty_marc.
START-OF-SELECTION.
" Read Change documents
CALL FUNCTION 'CHANGEDOCUMENT_READ'
EXPORTING
date_of_change = so_date-low
objectclass = 'MATERIAL'
date_until = so_date-high
TABLES
editpos = i_cdocs
EXCEPTIONS
no_position_found = 1
wrong_access_to_archive = 2
time_zone_conversion_error = 3
OTHERS = 4.
" Delete documents where materials are not changed
DELETE i_cdocs WHERE tcode NE c_tcode.
CHECK NOT i_cdocs[] IS INITIAL.
* Check for Material existence in Plant
SELECT matnr werks INTO TABLE i_marc
FROM marc
FOR ALL ENTRIES IN i_cdocs
WHERE matnr = i_cdocs-objectid(18)
AND werks = p_werks.
LOOP AT i_cdocs INTO wa_cdocs.
READ TABLE i_marc INTO wa_marc
WITH KEY matnr = wa_cdocs-objectid.
IF sy-subrc EQ 0. " Material Defined in specified plant
" Further Processing statements
ENDIF.
ENDLOOP.
Correct me if my understanding is wrong.
Regards
Eswar
‎2008 Feb 18 5:56 AM
Check out how the data for change documents is stored - I browsed tables CDHDR and CDPOS for Change Document Object "MATERIAL" and it seems that in CDPOS the entries for changes to MARC are stored with a "Table Key" value made up of the Client, Material Number, and Plant. So this should show you which plants the details were changed for. I believe the change document read function module returns the data from these tables, and should therefore have this level of detail available.
Andrew
‎2008 Feb 18 12:06 PM
Dear ,
Use this FM for fetch the Change document read CHANGEDOCU_CDPOS_READ and pass arguments accordingly ,
Objectid - Guid
Tabname - Marc
Fname - Plant
Regards,
Kumaresan P
‎2008 Feb 19 2:34 AM
Think you query is misleading...
As per my understanding you are trying to find all changes for materials in a specific plant right????
If so below code can give you some idea:
TABLES: mara.
SELECT-OPTIONS: so_date FOR mara-laeda. " Date Criteria
PARAMETERS: p_werks TYPE werks_d obligatory. " Plant
CONSTANTS: c_tcode TYPE sytcode VALUE 'MM02'.
TYPES: BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
DATA: i_cdocs TYPE STANDARD TABLE OF cdred, " Change Docs
wa_cdocs TYPE cdred,
i_marc TYPE STANDARD TABLE OF ty_marc, " Plant Existence
wa_marc TYPE ty_marc.
START-OF-SELECTION.
" Read Change documents
CALL FUNCTION 'CHANGEDOCUMENT_READ'
EXPORTING
date_of_change = so_date-low
objectclass = 'MATERIAL'
date_until = so_date-high
TABLES
editpos = i_cdocs
EXCEPTIONS
no_position_found = 1
wrong_access_to_archive = 2
time_zone_conversion_error = 3
OTHERS = 4.
" Delete documents where materials are not changed
DELETE i_cdocs WHERE tcode NE c_tcode.
CHECK NOT i_cdocs[] IS INITIAL.
* Check for Material existence in Plant
SELECT matnr werks INTO TABLE i_marc
FROM marc
FOR ALL ENTRIES IN i_cdocs
WHERE matnr = i_cdocs-objectid(18)
AND werks = p_werks.
LOOP AT i_cdocs INTO wa_cdocs.
READ TABLE i_marc INTO wa_marc
WITH KEY matnr = wa_cdocs-objectid.
IF sy-subrc EQ 0. " Material Defined in specified plant
" Further Processing statements
ENDIF.
ENDLOOP.
Correct me if my understanding is wrong.
Regards
Eswar
‎2008 Feb 20 1:29 PM