Equipment Address Management – Creating an address for equipment
The purpose of this little series of blog posts is to provide an orientation to working with equipment addresses in customer developed programs. In prior blog posts, we looked at how addresses are managed. Now in this blog post, we look at how to create an address suitable for a piece of equipment.
This is the fifth blog post in the series, which has the following structure.
- Equipment Address Management – introduction
- Equipment Address Management – a closer look
- Equipment Address Management – reading and searching for addresses
- Equipment Address Management – creating Equipment with an address
- Equipment Address Management – creating an address for equipment
Similar to the prior blog posts, we will continue with a generous sprinkling of code snippets.
What are we seeking to achieve?
In blog post 4, we went through the details of creating the equipment and assigning the address. We
didn’t however spend any time looking at how to create the address. In this blog post, we will look more closely at the steps to create an address for the equipment; particularly how to use the functions below.
CALL FUNCTION 'ADDR_INSERT' CALL FUNCTION 'ADDR_NUMBER_GET' CALL FUNCTION 'ADDR_MEMORY_SAVE'
The purpose of ADDR_INSERT is to insert an address without dialog. If successful, the address is created, but not persistently saved. The interface of the function has three obligatory parameters:
We will look at each in turn.
This structured parameter contains the address details, such as city, suburb etc.
This structured parameter defines the address group to which the address belongs. Every address is assigned to at least one address group. The address group is defined by the application that uses the address. In the case of equipment, the expected address group is PM01, representing addresses of maintenance objects. As an aside, for customer developed applications, a customer can define their own address group.
This structured parameters defines a temporary handle by which the address can be referenced.
The exchange of the temporary handle for an address number occurs when ADDR_NUMBER_GET is called. See blow.
The purpose of ADDR_NUMBER_GET is to exchange the temporary handle with an address number. The interface of the function has two obligatory importing parameters:
and returns an address number. Let’s look at the importing parameters.
The temporary handle we supplied when the address was inserted – a means to reference our temporary address.
A reference used to identify who uses the address and who owns (has responsibility) for changing or deleting the address.
The address reference contains structured content, which point back to the application object using the address. It contains the application TABLE, the name of the key FIELD in the table, a KEY, an address group and an indicator of ownership.
Here is what I use for the ADDRESS_REFERENCE and HANDLE for a piece of equipment.
"a simple structured type for the appl_key in the address reference ADREF_KEY-MANDT = SY-MANDT. ADREF_KEY-EQUNR = equipment number in internal format " the address reference for ADDR_NUMBER_GET ADREF-APPL_TABLE = 'EQUI'. ADREF-APPL_FIELD = 'EQUNR'. ADREF-APPL_KEY = ADREF_KEY. ADREF-ADDR_GROUP = 'PM01'. ADREF-OWNER = abap_true. " temporary handle - just use the address reference HANDLE = ADREF.
And that’s is about all there is to it.
Phew! Again lots of little snippets of code – and not much story, but I hope nevertheless that for someone it will be exactly what they are looking for.
Of course, this little series has not been comprehensive. If you are working with addresses, the documentation of the function group SZA0 is very helpful.
And that basically wraps it up. If you have come on the complete journey or only for parts of it, I thank you for reading.