Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XPP 2.61 KB | None | 0 0
  1. static void searchAcrossTables(Args _args)
  2. {
  3.     UtilIdElements  utilIdElements;
  4.     DictTable       dictTable;
  5.     DictField       dictField;
  6.  
  7.     str             selectStr;
  8.    
  9.     CommaIO         commaIO;
  10.     container       buffer;
  11.     int             k;
  12.    
  13.     str             filename = "V:\\Data\\itemId.csv";
  14.     ;
  15.  
  16.     commaIO = new CommaIO(filename, 'W');
  17.  
  18.     while select utilIdElements
  19.         where utilIdElements.recordType == UtilElementType::TableField &&
  20.               utilIdElements.name       like "*ItemId*" &&
  21.             !(utilIdElements.name       like "*mbsItemId*") &&
  22.             !(utilIdElements.name       like "*EmplItemId*") &&
  23.             !(utilIdElements.name       like "*ExternalItem*")
  24.     {
  25.         dictTable = new DictTable(utilIdElements.parentId);
  26.         if (!dictTable.isMap() &&
  27.             dictTable.name() != "KinUtItemRenameLog" &&
  28.             dictTable.name() != "CustInvoiceTrans" &&
  29.             dictTable.name() != "InventTable")
  30.         {
  31.             dictField = new DictField(utilIdElements.parentId, utilIdElements.id);
  32.             if (dictField.baseType() == Types::String &&
  33.                !(dictTable.name() == "mbsProductReferenceTable" && dictField.name() == "RefItemId"))
  34.             {
  35.                 print (dictTable.name() + "." + dictField.name());
  36.  
  37.                 selectStr = strfmt(@'container runBufJob()
  38.                                     {
  39.                                         %1 %1;
  40.                                         InventTable    inventTable;
  41.                                         container      values;
  42.                                         ;
  43.  
  44.                                         while select %1
  45.                                             where %1.%2 != ""
  46.                                             notexists join inventTable
  47.                                             where inventTable.ItemId == %1.%2
  48.                                         {
  49.                                             values += [["%1.%2", %1.%2, int642str(%1.RecId)]];
  50.                                         }
  51.                                        
  52.                                         return values;
  53.                                     }',
  54.                                      tableid2name(utilIdElements.parentId),
  55.                                      utilIdElements.name);
  56.  
  57.                 buffer = runbuf(selectStr);
  58.                
  59.                 for (k = 1; k <= conlen(buffer); k++)
  60.                 {
  61.                     commaIO.write(conpeek(buffer, k));
  62.                 }
  63.             }
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement