‎2006 Oct 27 6:06 PM
Hello,
Is there any function module to get all old materials for a material from MARA?? There can be many old materials for a material.
If not, What logic should I apply to get all old materials?
Thank you.
‎2006 Oct 27 6:33 PM
You might want to try something like this.
report zrich_0001 .
types: begin of tma,
matnr type mara-matnr,
bismt type mara-bismt,
end of tma.
data: ima type table of tma.
data: xma type tma.
data: yma type tma.
parameters: p_matnr type mara-matnr.
start-of-selection.
select matnr bismt into table ima
from mara
where matnr = p_matnr.
loop at ima into xma.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = xma-bismt
importing
output = xma-bismt.
clear yma.
select single matnr bismt into yma
from mara
where matnr = xma-bismt.
if not yma-bismt is initial.
append yma to ima.
endif.
endloop.
loop at ima into xma.
write:/ xma-matnr, xma-bismt.
endloop.
The reason for the call to 'CONVERSION_EXIT_ALPHA_INPUT' is that in my system, the old material numbers where not entered with leading zeros as the MATNR is stored in MARA, so I must convert in order to get a hit on MARA.
REgards,
Rich Heilman
‎2006 Oct 27 6:14 PM
‎2006 Oct 27 6:17 PM
You are correct. But this OLD material can have another old material and so on, over a period of time.
Thanks,
Amol..
‎2006 Oct 27 6:18 PM
‎2006 Oct 27 6:19 PM
You could do a recursive call to a select statement that retrieves the old number. Do this until none is found for a material.
Rob
‎2006 Oct 27 6:33 PM
Hi,
Function module GET_MATERIAL_ID retruns list of all materials for a given old material.
Please check the code from thsi function module. May be it is usefull to you.
Thanks
Ramakrishna
‎2006 Oct 27 6:19 PM
Hi,
In the table MARA you will current old material number..
To get all the old material numbers..
Use the FM CHANGEDOCUMENT_READ with the following data.
OBJECTCLASS MATERIAL
OBJECTID Material number
TABLEKEY
TABLENAME MARA
In the return parameter EDITPOS..
In the internal table EDITPOS.. check the field FNAME check for the value 'BSMIT' with CHNGIND = 'U'..
Then get the values from the field F_OLD with the above combinations..
You will all the old material numbers used for that material..
Hope this is what you want..
Thanks,
Naren
‎2006 Oct 27 6:19 PM
HI,
I don't think there will be many old materials for a material. I am not sure about this.
BUt you can findout old material for a material from MARA table. Field name is MARA-BISMT.
So you can get the list from MARA table.
Thanks,
Ramakrishna
‎2006 Oct 27 6:33 PM
You might want to try something like this.
report zrich_0001 .
types: begin of tma,
matnr type mara-matnr,
bismt type mara-bismt,
end of tma.
data: ima type table of tma.
data: xma type tma.
data: yma type tma.
parameters: p_matnr type mara-matnr.
start-of-selection.
select matnr bismt into table ima
from mara
where matnr = p_matnr.
loop at ima into xma.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = xma-bismt
importing
output = xma-bismt.
clear yma.
select single matnr bismt into yma
from mara
where matnr = xma-bismt.
if not yma-bismt is initial.
append yma to ima.
endif.
endloop.
loop at ima into xma.
write:/ xma-matnr, xma-bismt.
endloop.
The reason for the call to 'CONVERSION_EXIT_ALPHA_INPUT' is that in my system, the old material numbers where not entered with leading zeros as the MATNR is stored in MARA, so I must convert in order to get a hit on MARA.
REgards,
Rich Heilman
‎2006 Oct 27 6:57 PM
Thank you Rich. I will modify this program and use it for multiple materials. Any suggestions while doing so.
Thank you.