Strategies for Working with the Link Server
Use
Remember that when you work with the link server, it is entered in the list of services in Windows. Since all services must be unique, you cannot insert the link server twice with the same name.
This leads to the following problem:
When you generate an instance of a link server (method start_link_server), the system checks whether a link server with the same name is already registered. If this is the case, the call fails, and the system returns an error message.
This means that problems can arise with the link server if a user is using several transactions at once that use SAP Desktop Office Integration (and hence the link server).
Solution 1
If you call method start_link_server, use parameter link_server_mode = link_server->link_server_custname, and assign an application-dependent parameter <server_name_suffix>.
CALL METHOD link_server->START_LINK_SERVER EXPORTING LINK_SERVER_MODE = link_server>link_server_custname SERVER_NAME_SUFFIX = 'FI' RECEIVING RETCODE = retcode.
This means that that the links from the document must have the following format:
{ LINK SAP.OLELinkServer.ItemObject.<n> "SAPOLELinkServerFI" "<field>" \<format>}.
This solution has the restriction that the user cannot run the same transaction twice simultaneously, since in this case, the same name would be assigned to the memory area twice.
Solution 2
If you call method start_link_server, always use parameter link_server_mode = link_server->link_server_custname, and assign a unique name (for example, GUID or ID of the document in the central repository) to parameter server_name_suffix.
This solution has the disadvantage that existing links in an initial document must be adapted:
{ LINK SAP.OLELinkServer.ItemObject.<n> "SAPOLELinkServer " "<field>" \<format>}.
The unique name must also be saved with the document, since the same suffix must be used when you subsequently restart the link server to display the document again.