cancel
Showing results for 
Search instead for 
Did you mean: 

Delete a Material

bharath_padmanabhan
Participant
0 Kudos

Experts,
My requirement is to delete a material at client level and also at specific plant level via SE38 program. I searched the forum and I see that there are 3 options:

1) BAPI_MATERIAL_DELETE

This won't work for me as this calls MM06 Tcode in foreground. I want the deletion indication to be set the moment my SE38 program is executed without any user intervention.

2) OL_SET_LVORM_MATERIAL

I am passing PI_LVORM as 'X', PI_MATNR as Material no. I am not passing anything else. My expectation is that this FM will set LVORM(Del Indicator) only at MARA level. But the FM sets the Del Ind for all plants in MARC for that Material which is not my requirement. The same FM works fine if I pass a Material and plant as input. It is correctly setting the del ind only for that plant. But I want to set Del indicator(LVORM) at MARA as well as MARC level. So this FM isn't meeting my requirements.

3) BAPI_MATERIAL_SAVEDATA

I am following the approach in this thread Rich's post When I test in SE37, I see that the BAPI is setting deletion indication at all plants where the Material exists. My requirement is to only delete at the client level(MARA) and set del Ind only for selected plants in MARC and not all plants.

Requirement looks straight forward. Even after passing the exact parameters as Rich Heilman, I see that BAPI always sets the deletion indicator for the Material in MARA and also for all the plants in which the Material exists in MARC.

Can this be happening because of any MM config? Do we have to fetch all the plants for the Material and pass the del flag as space explcitly in order to delete the Material only at MARA level?

BR,

Bharath

Accepted Solutions (1)

Accepted Solutions (1)

raymond_giuseppi
Active Contributor

You want to ' My requirement is to only delete at the client level(MARA) and set del Ind only for selected plants in MARC and not all plants.' that should not be possible, what would happen to remainting plant-material if you archive and remove from database the main client record?

  • every plant (and other level) must be set to deletion before the main (client) data.
  • You should perform some check with transaction MM02 and MM06
bharath_padmanabhan
Participant
0 Kudos

Hi Raymond,

Firstly I want to thank you for a helpful reply you had posted related to my requirement. You had mentioned in a thread that we need to call BAPI_STDMATERIAL_GETINTNUMBER to generate Material no if the number range is internal. That was extremely helpful to me and I am using this BAPI in my report.

I am creating a material upload program from an excel file. Users will maintain a couple of plants in a TVARVC variant and I will be programmatically extending the material to these plants. Program will have functionality to create, update, delete and block materials.

You make a good point that when the material is deleted at the MARA level, how does it help to leave it active in a handful of plants.
Let us take this example. Say users upload a file to create 10 materials. For all these newly created materials, I will be extended the material to the list of plants maintained in the TVARVC variant. This activity happens for every single material that will be created from this program. Let us assume that the users decide that 2 out of these 6 plants in TVARVC variant are not relevant anymore. At this point, users will upload an excel file mentioning the material no and those 2 plants where this material has to be deleted. This is one of my requirements where I want to set deletion indicator flag only for a select list of plants.

Coming to MARA level deletion ind, I will have a discussion with them tomorrow to understand why they are asking for it.

Based on my understanding, SAP BAPI call behavior is exactly same as what you said. Standard code finds out the list of plants in which material exists. Then it finds out the plants from that list for which LVORM is not set and the code sets the del ind for all the plants. Once this is done, deletion ind is also set at the MARA level for the Material.

This raises a question in mind - Can this behavior be something that got introduced in the last couple of years? Because Rich's SCN thread shows that its possible to set LVORM only at MARA level. I too remember doing this a couple of years back for one of my projects although I don't have the code backup with me now to confirm.

MM06 tcode allows us to set deletion ind only at the MARA level or only for a specific plant. This makes me believe that SAP should have provided similar functionality in its BAPI as well.

BR,

Bharath

bharath_padmanabhan
Participant
0 Kudos

Hi Raymond,

Thank you so much for pointing my in the right direction. I was able to convince my client that whenever we set deletion ind at Material level, del ind will also be set at all the plants in MARC for the Material. Users have agreed and they agreed with your suggestion that it makes the best business sense.

For those who want to set LVORM flag specifically at plant level, you can use function modules in option 2 or 3 of my initial post.

BR,

Bharath

Answers (0)