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

BAPI for fetching materials changed in a specific time range

Former Member
0 Likes
2,979

Hi Folks,

I have a requirement in my project wherein, we want to pull only the latest changed or created materials from SAP by giving a time range.

The details about the requirement is that, initially we want to push all the materials created in ECC to an external legacy MES system.

Since materials are not changed or created very frequently, we want to schedule a background job that runs every day or every week to fetch materials, only created or changed in that duration.

Is there a standard BAPI to do so?

Regards,

Gita

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,977

Hi Gita,

there is a standard ALE scenario in SAP for distribution of material masters using change pointers and Idoc's. This might be an alternative for your requirement.

Maintain distribution module for MATMAS Idoc in BD64 and make sure change pointers are active.

Then run program RBDMIDOC for MATMAS regularly in a Job. This program will send all new and changed material masters since the last run.

The recieving application need of cource some logic for the Idoc processing or you use a middleware in between like PI.

Regards

Michael

9 REPLIES 9
Read only

Arun_Prabhu_K
Active Contributor
0 Likes
1,977

Hello Gita.

You find the date of last change in MARA-laeda for a material.

Using BAPI_MATERIAL_GET_DETAIL, you can get this data for a material.

Then using this data in an internal table, filter using date range and perform your business logic.

Regards.

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,977

Hi,

We are also tracking materials changes.

We use the "Change documentd" created during mm01 mm02 MM06.

using:

Object class: MATERIAL

TABLES: cdhdr,cdpos,cdred .

Note: It is worthwhile building index over CDHDR - fields OBJECTCLAS , UDATE .

CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

Regards.

Read only

Former Member
0 Likes
1,977

Hi Gita,

If you want to push data why need a BAPI....

You can query MARA directly

DATA : last_date type sy-datum.

Select * from MARA into table it_mara

                                    where ersda GE last_date or lesda GE last_date.

You can use the BAPI or Normal selects of required data for these materials.

OR

You can use IDoc methodology to update data in batches by activating change pointers no need to do any coding..

But the receiving system should understand IDoc....

I hope it helps.

Regards

Read only

Former Member
0 Likes
1,977

Hi Gita ,

I hope in SAP No Material Master BAPI available which fetch the Material Master Record based on Created or Changed in Particular Duration , you can create your own custom function module or program using "MARA" table .

Regard's

Smruti

Read only

Former Member
0 Likes
1,978

Hi Gita,

there is a standard ALE scenario in SAP for distribution of material masters using change pointers and Idoc's. This might be an alternative for your requirement.

Maintain distribution module for MATMAS Idoc in BD64 and make sure change pointers are active.

Then run program RBDMIDOC for MATMAS regularly in a Job. This program will send all new and changed material masters since the last run.

The recieving application need of cource some logic for the Idoc processing or you use a middleware in between like PI.

Regards

Michael

Read only

0 Likes
1,977

Thanks Michael,

I think I will go for this approach.

Do we have something similar for inventory?

I have another requirement where in any inventory change (GR/GI/Stock status change) needs to push the details to an external system whenever the change is carried out.

Regards,

Gita

Read only

0 Likes
1,977

Hi Gita,

change pointer are used for master data, like material, customer, vendor.

In case of status change you sometimes find an event of the corresponding business object where you can develop an event receiver like it is in production order (BUS2005). In transactional data you often find message control like in purchase or sales orders where also Idoc's can be created based on conditions.

I am not sure if there is something for stock changes.

What do you mean by stock status change and in which SAP transaction you can see it?

/Michael

Read only

0 Likes
1,977

Thanks Michael.

By Stock Status change, i mean when the status changes from unrestricted/blocked/quality etc.

For inventory my requirement is. Whenever there is a change in the inventory stock, like credit or debit, or the stock changes from unrestricted to blocked or vice versa, in real time I want some idoc to be sent to a MES so that both are in sync.

PLease help me with this requirement.

Regards,

Gita

Read only

0 Likes
1,977

Hi Gita,

I did some investigation. There are options for message output of material documents.

But I would prefer to implement enhancement MB_CF001 in CMOD. Within FM EXIT_SAPLMBMB_001, which is called before a material document change is commited, you have to write your own logic for the checks and the interface. So you are free to define an own file structure or Idoc.

I would probably use the existing Idoc type WMMBID02 and fill the values within the exit.

You can transfer it to the ALE outbound layer by means of FM MASTER_IDOC_DISTRIBUTE. Rest are Idoc settings as usual in WE20, WE21.

Hope this helps to find your solution. It will not be so easy then it is for "out-of-the-box" material master distribution.

/Michael