Skip to main content
Skip table of contents

Import-Programm mit Excel-File zum Importieren


JS
| oDM, oTable, oMemExcel, oDlg, oFile, nRecordCount, i |

startseq
   oDM                         := BeCreateTransactionDM(nil, 'IMPORTDM'),
   oTable                      := DBGetTable(oDM, waDAB010),                    // WORKAREA + INDEX anpassen!!
   oTable.CbIndexname          := 'DAB011',
   oTable.Writeprotocol        := true,

   startseq
      Beginsuspend(oTable),
      startseq
         oDlg                     := OpenDlg('Bitte die Excel-Datei für den Import auswählen.','',''),
         oDlg.Active              := true,
         if oDlg.selected then
            BeStartTransaction(oDM),
            startseq
               oMemExcel               := CreateObject('TbeMemTable', 'IMPORTMEMTABLE', oDM),
               oFile                   := oDlg.FileName,
               ImportExcelFile(oMemExcel, oFile),
               nRecordCount            := oMemExcel.CbRecordCount,
               i                       := 1,
               startseq
                  ProgressBarShow('Import von XY','Import von XY',true),        // Beschreibung anpassen!!
                  while not oMemExcel.CbEof do
                     if oTable.CbFindKey({Alltrim(oMemExcel:A)}) then
                           oTable.CbEdit(),
                           oTable:X_FELD := 'X_FELD INHALT AUS oMemExcel:XYZ',        // Feld(er) anpassen!!
                           oTable.CbPost(),
                     endif,
                     ProgressBarUpdate(100/nRecordCount*i, 'Datensatz' + Str(i) + ' von ' + Str(nRecordCount), false),
                     i++,
                     oMemExcel.CbNext(),
                  end,
               always
                  ProgressBarHide(),
               stopseq,
               BeCommitTransaction(oDM),
            onerror
               BeRollbackTransaction(oDM),
               Raise(),
            stopseq,
         endif,
      always
         Endsuspend(oTable),
      stopseq,
   always
      Destroyobject(oDM),
   stopseq,
onerror
   GU_ShowStdErrorMessage(GetErrorText(), GetErrorObj()),
stopseq,


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.