Index: src/org/openbravo/erpCommon/businessUtility/TabAttachments.java
===================================================================
--- src/org/openbravo/erpCommon/businessUtility/TabAttachments.java	(revision 15133)
+++ src/org/openbravo/erpCommon/businessUtility/TabAttachments.java	(working copy)
@@ -186,7 +186,7 @@
       TabAttachmentsData.insert(conn, this, strFileReference, vars.getClient(), vars.getOrg(), vars.getUser(), tableId, key, strDataType, strText, strName);
       try {
 				// FIXME: Get the directory separator from Java runtime
-        File uploadedDir = new File(globalParameters.strFTPDirectory+"/"+tableId+"-"+key);
+        File uploadedDir = new File(globalParameters.strFTPDirectory+"/"+tableId+"/"+ FileUtility.splitPath(key));
         if (!uploadedDir.exists()) uploadedDir.mkdirs();
         File uploadedFile = new File(uploadedDir, strName);
         file.write(uploadedFile);
@@ -368,11 +368,17 @@
   void printPageFile(HttpServletResponse response, VariablesSecureApp vars, String strFileReference) throws IOException, ServletException {
     TabAttachmentsData[] data = TabAttachmentsData.selectEdit(this, strFileReference);
     if (data==null || data.length==0) throw new ServletException("Missing file");
-    FileUtility f = new FileUtility();
+    FileUtility f = null;
 		// FIXME: Get the directory separator from Java runtime
-    File file = new File(globalParameters.strFTPDirectory+"/"+data[0].adTableId+"-"+data[0].adRecordId, data[0].name);
-    if (file.exists()) f = new FileUtility(globalParameters.strFTPDirectory+"/"+data[0].adTableId+"-"+data[0].adRecordId, data[0].name, false, true);
-    else f = new FileUtility(globalParameters.strFTPDirectory, strFileReference, false, true);
+    File file1 = new File(globalParameters.strFTPDirectory+"/"+data[0].adTableId+"/"+ FileUtility.splitPath(data[0].adRecordId), data[0].name);
+    if (file1.exists()){
+    	f = new FileUtility(globalParameters.strFTPDirectory+"/"+data[0].adTableId+"/"+ FileUtility.splitPath(data[0].adRecordId), data[0].name, false, true);
+    }
+    else {
+    	File file = new File(globalParameters.strFTPDirectory+"/"+data[0].adTableId+"-"+data[0].adRecordId, data[0].name);
+    	if (file.exists()) f = new FileUtility(globalParameters.strFTPDirectory+"/"+data[0].adTableId+"-"+data[0].adRecordId, data[0].name, false, true);
+    	else f = new FileUtility(globalParameters.strFTPDirectory, strFileReference, false, true);
+    }
     if (data[0].datatypeContent.equals("")) response.setContentType("application/txt");
     else response.setContentType(data[0].datatypeContent);
     response.setHeader("Content-Disposition","attachment; filename=" + data[0].name );
Index: src/nl/bmomentum/reporting/ReportManager.java
===================================================================
--- src/nl/bmomentum/reporting/ReportManager.java	(revision 15133)
+++ src/nl/bmomentum/reporting/ReportManager.java	(working copy)
@@ -43,6 +43,7 @@
 import org.openbravo.erpCommon.utility.JRFormatFactory;
 import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.utils.FileUtility;
 import org.openbravo.utils.Replace;
 
 public class ReportManager
@@ -175,7 +176,7 @@
 		if( report.isAttached() )
 			throw new ReportingException( "Attachment is already created." );
 		
-		String destination = tableId + "-" + report.getDocumentId();
+		String destination = tableId + "/" + FileUtility.splitPath(report.getDocumentId());
 		
 		// First move the file to the correct destination
         File destinationFolder = new File( _strAttachmentPath + "/" + destination );
Index: src-core/src/org/openbravo/utils/FileUtility.java
===================================================================
--- src-core/src/org/openbravo/utils/FileUtility.java	(revision 15133)
+++ src-core/src/org/openbravo/utils/FileUtility.java	(working copy)
@@ -166,4 +166,20 @@
     File f = new File(dir, filename);
     return f.exists();
   }
+  /**
+   * Splits the path name component so that the resulting path name is 3 characters long sub directories.
+   * For example 12345 is splitted to 123/45
+   * @param origname Original name
+   * @return splitted name.
+   */
+  public static String splitPath(final String origname) {
+		String newname = "";
+		for (int i = 0; i < origname.length(); i += 3) {
+			if (i != 0)
+				newname += "/";
+			newname += origname
+					.substring(i, Math.min(i + 3, origname.length()));
+		}
+		return newname;
+  }
 }
