One Friday afternoon the infrastructure team moved the file server to new storage, faster and with automatic backup, and by Monday morning not a single user could open one supporting document from SAP Business One: the attachments were still listed on every invoice, with their name, their extension and their date, but on double click the system demanded a folder that no longer existed. Nobody checked beforehand. The file was on the new disk. The path was not.
In SAP Business One, attachments and documents live in separate worlds. The ERP copies the file to a folder in the operating system and in the database it records only the full path to that file. Therefore, anything that alters that path (a migration, a different drive letter, a user attaching from their desktop) leaves the link dangling. Below you will see how to get the folder configured once and for all and, above all, how to audit what is already loaded with queries that run on both SQL Server and SAP HANA.
Why SAP Business One attachments break so easily
The mechanics are simple, and that is exactly where the problem starts. When someone attaches a PDF to an invoice, SAP Business One copies the file to the configured target folder and writes a row in the ATC1 table with three fields that matter: the name, the extension and the full target path. That path stays frozen in the database. It is never recalculated.
SAP chose to store the whole folder in every row instead of storing only the file name and resolving the location on the fly against the current setup. It is a design decision I still cannot explain to myself, and it turns a server change into a mass data update. Besides, the path is written exactly as the client that uploaded the file saw it: if that machine had the folder mapped as Z:\, that is what gets written, and on a colleague machine the same letter points somewhere else or does not exist at all.

Why you need to govern attachments in SAP Business One
The cost does not show up in the accounts, it shows up in people time. IDC put a number on that vague feeling that everything is hard to find: those who create or edit documents spend up to 2.5 hours a day looking for what they need. Gartner, in turn, estimates an average of 18 minutes to locate a single document. Multiply that by a collections team that needs the signed proof of delivery for every dispatch note.
There is a second cost, less obvious. When the attachment does not show up, people stop trusting the ERP and build their own parallel archive: a folder in OneDrive or an email forwarded to themselves. As a result, business information fragments and next year audit turns into an excavation. A shared drive without rules is not up to the job as a document manager. One with rules, and with an audit that somebody actually runs, solves most cases in a mid-sized company.
And then there is the regulatory side. If the tax authority asks you for the supporting document of an invoice from three years ago, the broken link is not an operational nuisance. It is an audit finding.
Prerequisites before touching anything
- A user with the superuser profile in SAP Business One. General settings are not edited by just anyone.
- A network folder visible from every machine that uses the ERP, with read and write permissions for the users and for the license server service account.
- Query access to the company database, through Query Manager or through a SQL client. Every query in this article is read-only.
- A recent database backup. If you are going to update paths, this is not optional.
- A maintenance window if you already have volume loaded: the button that updates paths runs through every record.
How to configure the attachments folder in SAP Business One step by step
Step 1: create the shared folder and note its UNC path
Create the folder on the file server and share it. Write down the path in UNC format, never as a mapped drive. That is, \\FILE-SERVER\SAPB1\Attachments and why not Z:\Attachments. The drive letter depends on how each computer is configured; the UNC path means the same thing on all of them.
Step 2: assign the right permissions
You need modify permissions at the share level and at the NTFS level for the ERP user group. Add as well the service account that runs the SAP Business One license server, because the web client and some server processes read the folder on their own and not with the end user credentials. This detail you only learn by using it: in installations with the web client, attachments work in the desktop client and fail in the browser for exactly this reason.
Step 3: define the folder in general settings
Go Administration > System Initialization > General Settings and open the Path. In the field Attachments Folder paste the UNC path from step 1. Save and close the window. From that moment on, every new file will be copied to that folder.
Step 4: update the paths of existing documents
Changing the folder does not move what is already there. On that same Path tab you will find the option to update the path of attachments already loaded, which rewrites the trgtPath field of the existing records. Before using it, copy the physical files to the new folder and check that they are there. In 9.3, if memory serves, that option did not exist yet and the update had to be done straight in the database, with everything that implies.
Step 5: review the user defaults
In Administration > Setup > General > User Defaults, tab Path, each user template can have its own attachments folder. If somebody left a local path there three years ago, that path wins over the general settings for the users assigned to that template. Review them all before calling the job finished.
Step 6: test from two different machines
Attach a file from computer A and open it from computer B. Then do it the other way around. If both open the file, the setup is consistent; if one fails, it is almost always permissions or a mapped path that survived in the user defaults.

Where attachments live: OATC, ATC1 and the AtcEntry field
Before the first query it helps to understand the model, which is just three pieces:
OATC: the attachment header. Its key isAbsEntry.ATC1: the lines, one file per row. It carriesFileName,FileExt,srcPath(where the user took it from),trgtPath(where it ended up stored) andDate.AtcEntry: the field that appears on the business object (OINV,OPOR,OCRD,OITMand several more) and that points to theAbsEntrytheOATC.
That is all you need. An object with no attachments has AtcEntry at zero or null, and one with attachments points to a header that groups all of its lines. This way, any audit boils down to walking through ATC1 and checking that the pointers still line up. One practical warning: Date is a reserved word, so in SQL Server it goes in square brackets and in SAP HANA in double quotes.
SQL queries to audit SAP Business One attachments
The four queries below answer, in order, the questions that matter: what is loaded, across how many different folders it ended up scattered, which files are not on the network and which documents point at nothing. Each one comes in a SQL Server version and a SAP HANA version. They modify nothing, so you can run them in production without ceremony.
Query 1: attachment inventory by object type
First, the map. This query counts how many objects have attachments and how many files they add up to, broken down by document type. It is the starting point for knowing where the volume is concentrated.
SQL Server
-- Attachment inventory by object type
SELECT 'Factura de cliente' AS Objeto,
COUNT(DISTINCT T0.DocEntry) AS Objetos,
COUNT(T1.Line) AS Archivos
FROM OINV T0
INNER JOIN ATC1 T1 ON T1.AbsEntry = T0.AtcEntry
UNION ALL
SELECT 'Orden de compra', COUNT(DISTINCT T0.DocEntry), COUNT(T1.Line)
FROM OPOR T0
INNER JOIN ATC1 T1 ON T1.AbsEntry = T0.AtcEntry
UNION ALL
SELECT 'Entrega', COUNT(DISTINCT T0.DocEntry), COUNT(T1.Line)
FROM ODLN T0
INNER JOIN ATC1 T1 ON T1.AbsEntry = T0.AtcEntry
UNION ALL
SELECT 'Socio de negocio', COUNT(DISTINCT T0.CardCode), COUNT(T1.Line)
FROM OCRD T0
INNER JOIN ATC1 T1 ON T1.AbsEntry = T0.AtcEntry
UNION ALL
SELECT 'Artículo', COUNT(DISTINCT T0.ItemCode), COUNT(T1.Line)
FROM OITM T0
INNER JOIN ATC1 T1 ON T1.AbsEntry = T0.AtcEntry
ORDER BY 3 DESC;
SAP HANA
-- Attachment inventory by object type
SELECT 'Factura de cliente' AS "Objeto",
COUNT(DISTINCT T0."DocEntry") AS "Objetos",
COUNT(T1."Line") AS "Archivos"
FROM OINV T0
INNER JOIN ATC1 T1 ON T1."AbsEntry" = T0."AtcEntry"
UNION ALL
SELECT 'Orden de compra', COUNT(DISTINCT T0."DocEntry"), COUNT(T1."Line")
FROM OPOR T0
INNER JOIN ATC1 T1 ON T1."AbsEntry" = T0."AtcEntry"
UNION ALL
SELECT 'Entrega', COUNT(DISTINCT T0."DocEntry"), COUNT(T1."Line")
FROM ODLN T0
INNER JOIN ATC1 T1 ON T1."AbsEntry" = T0."AtcEntry"
UNION ALL
SELECT 'Socio de negocio', COUNT(DISTINCT T0."CardCode"), COUNT(T1."Line")
FROM OCRD T0
INNER JOIN ATC1 T1 ON T1."AbsEntry" = T0."AtcEntry"
UNION ALL
SELECT 'Artículo', COUNT(DISTINCT T0."ItemCode"), COUNT(T1."Line")
FROM OITM T0
INNER JOIN ATC1 T1 ON T1."AbsEntry" = T0."AtcEntry"
ORDER BY 3 DESC;
Query 2: how many different target folders coexist
This is the diagnosis that surprises management most. If the setup were clean, the result would be a single row. In practice, in an installation with several years behind it, it is common to see ten or more different paths, including the desktops of users who no longer work at the company.
SQL Server
-- Target folder fragmentation
SELECT T0.trgtPath AS CarpetaDestino,
COUNT(*) AS Archivos,
COUNT(DISTINCT T0.AbsEntry) AS Objetos,
MIN(T0.[Date]) AS PrimerArchivo,
MAX(T0.[Date]) AS UltimoArchivo
FROM ATC1 T0
GROUP BY T0.trgtPath
ORDER BY 2 DESC;
SAP HANA
-- Target folder fragmentation
SELECT T0."trgtPath" AS "CarpetaDestino",
COUNT(*) AS "Archivos",
COUNT(DISTINCT T0."AbsEntry") AS "Objetos",
MIN(T0."Date") AS "PrimerArchivo",
MAX(T0."Date") AS "UltimoArchivo"
FROM ATC1 T0
GROUP BY T0."trgtPath"
ORDER BY 2 DESC;
Query 3: files that ended up off the network
A target path that does not start with a double backslash is not a network path: it is a local folder or a mapped drive. In both cases the file exists on one computer only. This query brings them to light, sorted from newest to oldest so you can recover first whatever is still salvageable.
SQL Server
-- Attachments whose target is not a UNC network path
SELECT T0.AbsEntry,
T0.Line,
T0.FileName + '.' + T0.FileExt AS Archivo,
T0.trgtPath AS CarpetaDestino,
T0.srcPath AS CarpetaOrigen,
T0.[Date] AS FechaAdjunto
FROM ATC1 T0
WHERE T0.trgtPath NOT LIKE '\\%'
ORDER BY T0.[Date] DESC;
SAP HANA
-- Attachments whose target is not a UNC network path
SELECT T0."AbsEntry",
T0."Line",
T0."FileName" || '.' || T0."FileExt" AS "Archivo",
T0."trgtPath" AS "CarpetaDestino",
T0."srcPath" AS "CarpetaOrigen",
T0."Date" AS "FechaAdjunto"
FROM ATC1 T0
WHERE T0."trgtPath" NOT LIKE '\\%'
ORDER BY "FechaAdjunto" DESC;
Query 4: documents pointing to an attachment that does not exist
The reverse case, and the quieter one. The document has AtcEntry with a value, but the matching header is no longer in OATC. The user sees the clip, clicks and nothing happens. However, nobody raises a ticket for this: they simply attach the file again and move on.
SQL Server
-- Broken references: the document points to an attachment that does not exist
SELECT 'Factura de cliente' AS Objeto, T0.DocNum AS Numero,
T0.DocDate AS Fecha, T0.CardCode AS Socio, T0.AtcEntry
FROM OINV T0
LEFT JOIN OATC T1 ON T1.AbsEntry = T0.AtcEntry
WHERE T0.AtcEntry > 0 AND T1.AbsEntry IS NULL
UNION ALL
SELECT 'Orden de compra', T0.DocNum, T0.DocDate, T0.CardCode, T0.AtcEntry
FROM OPOR T0
LEFT JOIN OATC T1 ON T1.AbsEntry = T0.AtcEntry
WHERE T0.AtcEntry > 0 AND T1.AbsEntry IS NULL
UNION ALL
SELECT 'Entrega', T0.DocNum, T0.DocDate, T0.CardCode, T0.AtcEntry
FROM ODLN T0
LEFT JOIN OATC T1 ON T1.AbsEntry = T0.AtcEntry
WHERE T0.AtcEntry > 0 AND T1.AbsEntry IS NULL
ORDER BY 3 DESC;
SAP HANA
-- Broken references: the document points to an attachment that does not exist
SELECT 'Factura de cliente' AS "Objeto", T0."DocNum" AS "Numero",
T0."DocDate" AS "Fecha", T0."CardCode" AS "Socio", T0."AtcEntry"
FROM OINV T0
LEFT JOIN OATC T1 ON T1."AbsEntry" = T0."AtcEntry"
WHERE T0."AtcEntry" > 0 AND T1."AbsEntry" IS NULL
UNION ALL
SELECT 'Orden de compra', T0."DocNum", T0."DocDate", T0."CardCode", T0."AtcEntry"
FROM OPOR T0
LEFT JOIN OATC T1 ON T1."AbsEntry" = T0."AtcEntry"
WHERE T0."AtcEntry" > 0 AND T1."AbsEntry" IS NULL
UNION ALL
SELECT 'Entrega', T0."DocNum", T0."DocDate", T0."CardCode", T0."AtcEntry"
FROM ODLN T0
LEFT JOIN OATC T1 ON T1."AbsEntry" = T0."AtcEntry"
WHERE T0."AtcEntry" > 0 AND T1."AbsEntry" IS NULL
ORDER BY 3 DESC;
Variations and use cases
The same structure serves quite different questions. For example, if what worries you is the growth of the folder, group by year and extension instead of by path, and you will see straight away whether the volume comes from backup PDFs or from 8-megapixel photos somebody uploads from a phone without compressing.
Another frequent use is spotting duplicates. The same file uploaded twenty times across twenty different documents breaks nothing, but it inflates the disk and usually gives away a badly designed process: somebody attaches the same quality certificate to every dispatch note instead of keeping it on the item master.
SQL Server
-- Repeated files by name
SELECT T0.FileName AS Archivo,
T0.FileExt AS Extension,
COUNT(*) AS Veces,
COUNT(DISTINCT T0.AbsEntry) AS ObjetosDistintos
FROM ATC1 T0
GROUP BY T0.FileName, T0.FileExt
HAVING COUNT(*) > 1
ORDER BY 3 DESC;
SAP HANA
-- Repeated files by name
SELECT T0."FileName" AS "Archivo",
T0."FileExt" AS "Extension",
COUNT(*) AS "Veces",
COUNT(DISTINCT T0."AbsEntry") AS "ObjetosDistintos"
FROM ATC1 T0
GROUP BY T0."FileName", T0."FileExt"
HAVING COUNT(*) > 1
ORDER BY 3 DESC;
A third variation: set up Query 3 as an internal alert in SAP Business One, scheduled once a week, so the administrator receives the list of files saved off the network while they can still be recovered. As a result, you stop auditing by hand and the control becomes part of the operation.

Best practices and common mistakes
Always use a UNC path. It is the rule that avoids 80% of the problems. A mapped drive works until a new computer does not have it, and then the one left holding the bag is Accounting.
One single folder, with subfolders by year. SAP Business One stores everything flat in the folder you point it at, so after five years you will have tens of thousands of files in a single directory. Windows handles it; opening that folder from Explorer, not so much. If your volume is high, it is worth rotating the target folder every year and leaving the previous ones accessible in read-only mode.
Watch out for the length of the path. Between the network folder, the year and file names people write as if they were thesis titles, it is easy to go past the 260 characters Windows allows by default. When that happens the attachment uploads and then will not open, which is the worst possible combination.
Back up the folder together with the database. This has cost me dearly more than once: the database backup was flawless, the attachments folder was not in the backup plan, and the supporting document for the invoice was, of course, on the desktop of whoever uploaded it. The database and the files are one single set. Separate them and you have half a backup.
Do not delete ATC1 rows by hand. A classic temptation when you see junk piling up. However, the document still points to that header and the result is precisely the broken reference you were trying to eliminate. If you need to clean up, do it from the interface or with the DI API.
How often should you run this audit? Once a month is enough in most companies, and it is worth making it mandatory after any server migration, domain change or mass onboarding of users.
Official SAP Resources
- How to Manage Attachments in SAP Business One, the full functional guide in PDF.
- Setting Up an Attachment Folder, in the administration guide.
- Setting and Updating Default Folder for Attachments, on updating existing paths.
- SDK Database Tables Reference, to review the fields of OADM, OATC and ATC1.
Conclusion: the archive nobody looks at until it fails
The attachments folder is one of those settings defined on day one of the implementation, written down in a document nobody opens again, and working for years without asking for attention. Then comes a migration, a domain change or a new computer, and suddenly it turns out the document traceability of the whole company depended on a path nobody was watching.
Run Query 2 this week. If it returns a single row, close the tab and relax. If it returns five, you know what your next job is and, more importantly, you have the exact list of what to review and in what order.
The complete tutorials, with the SQL code ready to paste into Query Manager in both versions, are available to members of the Círculo Estratégico at hectorpincheira.com. If you administer SAP Business One and want to stop putting out configuration fires, that is the place.




