Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Sometimes the client or end-users says that some material master numbers are getting skipped due to some error in Material Master Record data during the data upload using RFC / BAPI. 


Scenario:


Material Numbers generated are “000000000200000020”, “000000000200000021”, “000000000200000022”, ‘‘000000000200000023”, “‘000000000200000026” and so on. The numbers between ‘‘000000000200000023” and “‘000000000200000026” are missing. What could be the reason?

Reason:


The Reason may be “N” number, but here I am Concentrate on data Error like Base Unit of Measure is Wrong, Instead of ‘EA’ wrongly transfer to SAP ‘EAA’, or Material Group is wrong..etc.. then your material record is not save or you lost one sequential number range, mean at end of day when you generate a daily report of material master you seen one or more than one material numbers are missing, may be above reason one of them.so how to use the Skipping number range using RFC/BAPI ?.


Solution:


Note: I not taking all Fields of Creating Material Master Only Use “Basic Data1” view data, like Industry Sector(I_MBRSH) , Material Type (I_MTART), Material Number(I_MATNR) , Base unit of measure (I_MEINS) and Material Shot Description , here i am using "BAPI_MATERIAL_SAVEDATA" for Material Master Creation and "BAPI_STDMATERIAL_GETINTNUMBER"  for getting One Internal Number range with Receptive Material type , Industry Sector .

I_MEINS(Base Unite of Measure) = ‘EAA’ (which is not available in SAP)

and once you execute below Function Module with wrong Base unit of Measure then you got below error, see in Screen Shot#1 With one error Material Number, that material is skipped, next time with correct value or next record of same material type when you transfer to SAP you never pick your skipped number, if you follow my below steps then you must use your skipping material master number s.



Screen Shot# 1

Step # 1: Create One “Z” or “Y” Table for Insert the Error Material Number or Skipping Material Numbers with Respective Material Type.

Screen Shot# 2

Step #2:


Write the Code as below Screen Shot,

  • Check is it Internal Number or External Number Range?
  • Internal Number Range.  (Screen Shot# 3 and 4 )
    • Check any Skipping Internal Number is available in “Y” Table for the Respective Material Type, here I am using Material Type = ‘ERSA’.
    • Use the Skipping Internal Number and Delete that Skipping Internal Number from “Y” Table after Use.
    • IF any Skipping Internal Number not available in “Y” Table with respective material type, then how to retrieve one Current Sequential Number ranges with respective material type.

Screen Shot# 3

Getting One Material Master Internal Number Range using "BAPI_STDMATERIAL_GETINTNUMBER' with Respective Material Type and Industry Sector

Screen Shot# 4

  • External Number Range. (Screen Shot# 5)
    • Check any Skipping External Number is available in “Y” Table for Respective Material Type , Here I am using Material Type = ‘ERSA’ .
    • Use the Skipping External Number and Delete that Skipping External Number from “Y” Table after Use.
    • IF any Skipping External Number not available in “Y” Table with respective material type, then pass the External Material Number to Material Header Structure.

                   i.e.  DATA:  MHEADER LIKE BAPIMATHEAD .

  MOVE  I_MATNR TO MHEADER-MATERIAL.

Screen Shot# 5


Step #3 :

Finally Pass all Respective field value into "BAPI_MATERIAL_SAVEDATA" .

Screen Shot# 6

Using " BAPI_TRANSACTION_COMMIT " Save the Data in to SAP

Screen Shot# 7


Step #4:

Re-Execute your Function Module with Correct data; here the correct data is “Base Unit of Measure” which is wrong previously, Instead of “EA” wrongly transfer “EAA”, Check below Screen Shots # 8 and 9.

Screen Shot# 8

Now you can Re-Use your Skip Number which is earlier Skip due to wrong data for the respective material type

Screen Shot# 9

Now you run your daily report you never find any skip number to the respective material type and industry sector .

Note : Source Code Available in wiki SAP Community Network Wiki - Code Gallery - How to Re use Material Master Skipping numbers using ...

Regard's

Smruti


3 Comments