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 read equipment addresses.
This is the third 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 and maintaining
On y va!
Reading an address
Once you have an address number, reading an address is quite straightforward. We will start assuming you have the address number, and explore further below how we might start if we don’t have the number.
The approach to reading is as follows:
data selection type addr1_sel. data result type addr1_val. selection-addrnumber = '1212345678' . " Your address number * Get the address and load into management tables call function 'ADDR_GET' exporting address_selection = selection importing address_value = result exceptions others = 0. * Do something with the information * Clear the local memory call function 'ADDR_MEMORY_CLEAR' exceptions others = 0 .
Note well the clearing of the memory of address management at the end. Ensures the state of address memory is completely reset.
If you need to read many addresses, then exchange ADDR_GET with ADDR_GET_ARRAY. As above, don’t forget to clear the local memory.
call function 'ADDR_GET_ARRAY' .. call function 'ADDR_MEMORY_CLEAR'
Finding the address number via equipment
If you have the equipment number, but don’t have the address number, then the database view EQUI_ADDR is your friend. The view will provide you the address number and some address details also.
DATABASE VIEW EQUI_ADDR
This view is provides a selection across tables EQUZ, ILOA and ADRC .
If you only need the details that this view provides, it is a lighter approach than going via business address services.
Finding the equipment address over Business Address Services
If you have the equipment number, but don’t have the address number, then you can alternatively determine the address number over the Business Address Services address where used.
DATABASE TABLE ADRV SELECT * FROM ADRV WHERE APPL_TABLE = 'EQUI' AND APPL_FIELD = 'EQUNR' AND APPL_KEY = <CLIENT> + <EQUIPMENT NUMBER WITH LEADING ZEROS>
I don’t recommend this approach – it results in a full table scan of the address where used table ADRV. In productive systems, this table can be very large. The usage in ADRV should match up with the details provided by EQUI_ADDR.
Who is using an address?
If you have an address number, and would like to know whether it is shared between equipment, functional locations or indeed other business objects, then the address where used of Business Address Services is again helpful.
DATABASE TABLE ADRV SELECT * FROM ADRV WHERE ADDRNUMBER = 'ADDRESS NUMBER'
This will provide you the details of all objects using the address.
Search for equipment using address details
You have some address details and you wish to find the equipment. Often a sufficient approach is to use the database view EQUI_ADDR. The view starts with ADRC and then joins to ILOA to EQUZ to reach the equipment.
DATABASE VIEW EQUI_ADDR
Searching for addresses using address details
If you need to search addresses, then the search function of Business Address Services may well be useful. It provides more details of the address than the view EQUI_ADDR provides.
data selection type addr1_find. data results type standard table of addr1_val. data groups type standard table of adagroups. " Search for addresses in Riverstone NSW selection-city1 = 'Riverstone'. selection-region = 'NSW'. " To restrict to addresses used in PM, insert " group = 'PM01' into groups CALL FUNCTION 'ADDR_SEARCH' importing SEARCH_FOR = selection tables ADDRESS_GROUPS = groups SEARCH_RESULT = results exceptions ...
Phew! Lots of little snippets of code – more like a cook-book to look up than a novel to read!
From this third blog post, you should now have a better understanding of how to read and search for addresses of equipment, either using Business Application Services or via equipment specific application tables.
In the next and final blog post, we will look at what we can do to create and maintain addresses of equipment from customer developed programs.