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

Old material

Former Member
0 Likes
1,502

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.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,268

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

9 REPLIES 9
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,268

Do you mean old material numbers? This is field BISMT in table MARA, you can simply do a SELECT statement again MARA.

Regards,

Rich Heilman

Read only

0 Likes
1,268

You are correct. But this OLD material can have another old material and so on, over a period of time.

Thanks,

Amol..

Read only

0 Likes
1,268

Oh, I see.........

Regards,

Rich Heilman

Read only

0 Likes
1,268

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

Read only

0 Likes
1,268

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

Read only

Former Member
0 Likes
1,268

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

Read only

venkata_ramisetti
Active Contributor
0 Likes
1,268

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

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,269

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

Read only

0 Likes
1,268

Thank you Rich. I will modify this program and use it for multiple materials. Any suggestions while doing so.

Thank you.