Codeblock Onlinehilfe

TBeCbStateOfConstructionResolving

TBeCbStateOfConstructionResolving

(Aktuellen) Bauzustand aus Dab740 auslesen.

Eigenschaften

Eigenschaft

Beschreibung

ArtNo:C

Artikel Nummer für welche der Bauzustand aufgelöst werden soll

BatchNo:C

Serien Nummer für welche der Bauzustand aufgelöst werden soll

DataModule:O

Gibt das intern verwendete DatenModul zurück

LegacyMode:L


Name:C


Tag:N


Methoden

Methode

Beschreibung

CreateMemtable():O

Leere Memtable erzeugen die an die Execute Funktion übergeben werden kann

Execute(aResultMemTable:O, aCurrentStateOnly:L):L

Bauzustand Auflösung durchführen, Rückgabe True wenn Bauzustand Daten vorhanden sind

Beispiel

|oProdResLegacy, oProdRes, oMemResLegacy, oMemRes, aFieldsToCompare, cSQL |

//******************************************************************************
function LegacyStateOfConstruction(cArtNo, cBatchNo)
   Result := True,
   startseq,
      oProdResLegacy.ArtNo   := cArtNo,
      oProdResLegacy.BatchNo := cBatchNo,
      oMemResLegacy.CbEmptyTable(),
      oProdResLegacy.Execute(),
      oProdResLegacy.TransferResult(oMemResLegacy, False, True, True),
      oMemResLegacy.OrderBy := 'Ebene;Parent_ARTNR;Parent_KOMMISS;ArtNr;Kommiss;Datum;D720_ID',
   onerror,
      WriteLn(GetErrorText()),
      Result := False,
   stopseq,
end,

//******************************************************************************
function StateOfConstruction(cArtNo, cBatchNo)
   Result := False,
   oProdRes.ArtNo   := cArtNo,
   oProdRes.BatchNo := cBatchNo,
   oMemRes.CbEmptyTable(),
   Result := oProdRes.Execute(oMemRes, false),
   oMemRes.CbOrderBy('Ebene;ArtNr_BG;Kommiss_BG;ArtNr;Kommiss;Datum;D740_ID'),
end,

//******************************************************************************
function ValidateMigration(cArtNo, cBatchNo)
   |i, bContinue|

   Result := True,
   if LegacyStateOfConstruction(cArtNo, cBatchNo) and StateOfConstruction(cArtNo, cBatchNo) then
      // browse(,oMemResLegacy),
      // browse(,oMemRes),
      if oMemResLegacy.CbRecordCount = oMemRes.CbRecordCount then
         DbGoTop(oMemResLegacy),
         oMemRes.CbFirst(),
         bContinue := true,

         while not oMemRes.CbEof and bContinue do
            for i := 1 to ALen(aFieldsToCompare) do
               if bContinue then
                  if Alltrim(AsString(aFieldsToCompare[1,i], oMemResLegacy)) <> Alltrim(AsString(aFieldsToCompare[2,i], oMemRes)) then
                     WriteLn(Space(0) + 'Werte unterschiedlich Feld: <' + aFieldsToCompare[1,i] + '> Wert: ' + AsString(aFieldsToCompare[1,i], oMemResLegacy) + ' !=' +  AsString(aFieldsToCompare[2,i], oMemRes)),
                     Writeln(Space(0) + 'Alt', oMemResLegacy.RecAsArray),
                     Writeln(Space(0) + 'Neu', oMemRes.CbGetRecAsArray()),
                     bContinue := false,
                     Result := False,
                  endif,
               endif,
            next,

            oMemRes.CbNext(),
            DBSkip(oMemResLegacy),
         end,
      else
         WriteLn(Space(10) + 'Anzahl der Datensätze unterschiedlich (Alt/Neu)', oMemResLegacy.CbRecordCount, oMemRes.CbRecordCount),
         Result := False,
      endif,
   else
      WriteLn(Space(10) + 'Auflösung nicht möglich'),
      Result := False,
   endif,

//   if not Result then
//     WriteLn('ARTNR/KOMMISS',cArtNo, cBatchNo),
//     WriteLn('********************************************************************************************************************************'),
//   endif,
end,

//******************************************************************************
//
//******************************************************************************
function ValidateBySQL(cSQL)
   |oQuery|

   startseq
      oQuery := CreateObject('TBeAdsQuery', 'QUERY'),
      oQuery.SQL := cSQL,
      oQuery.CbExecSQL(),
      oQuery.Active := true,
      oQuery.CbFirst(),

      WriteLn('********************************************************************************************************************************'),
      while not oQuery.CbEof do
         startseq,
            if not ValidateMigration(AllTrim(oQuery:ARTNR), AllTrim(oQuery:KOMMISS)) then
               WriteLn('ARTNR/KOMMISS', AllTrim(oQuery:ARTNR), AllTrim(oQuery:KOMMISS)),
               WriteLn('*******************************************************************************************************************************<h3>'),
            endif,
         onerror,
            WriteLn(GetErrorText()),
         stopseq,
         oQuery.CbNext(),                 
      end,
   always
      DestroyObject(oQuery),
   stopseq,
end,

aFieldsToCompare := {{'Parent_ARTNR','Parent_KOMMISS','ArtNr','Kommiss','Opt_Ansicht','Opt_ArtNr','Opt_Kommiss','Typ','Ebene','ProdAuftr','BelegNr','Lager','Datum','Menge','PersNr','Standort','B_Pos_Lfd','BUVORG','BUART','APNUMMER','BESTPOSNR','IsNeutralized','IsUnambiguous'}, // Legacy
                     {'ArtNr_BG','Kommiss_BG','ArtNr','Kommiss','Opt_Ansicht','Opt_ArtNr','Opt_Kommiss','Typ','Ebene','ProdAuftr','BelegNr','Lager','Datum','Menge','PersNr','Standort','B_Pos_Lfd','BUVORG','BUART','APNUMMER','BESTPOSNR','IsNeutralized','IsUnambiguous'}},

startseq,
   oProdResLegacy := CreateObject('TBeCbProductResolving'),
   oProdResLegacy.CalcOnlySerialNoArticles       := False,
   oProdResLegacy.CalcUnambiguousSerialNoBooking := True,
   oMemResLegacy := oProdResLegacy.CreateMemView_Extended(oProdResLegacy),

   oProdRes := CreateObject('TBeCbStateOfConstructionResolving'),
   oProdRes.LegacyMode := True,
   oMemRes := oProdRes.CreateMemtable(),

   // Validierung per SQL
   // cSQL := 'SELECT ARTNR, KOMMISS FROM "DAB730.ADT" DAB730 WHERE KOMMISS IS NOT NULL AND ARTNR IN (SELECT ARTNR FROM "DAB010.ADT" WHERE  PLATZ_VER IN ( ''S'' )) ORDER BY ARTNR,KOMMISS',
   // ValidateBySQL(cSQL),

   // Einzelne ARTNR/KOMISS validieren
   WriteLn(ValidateMigration('ARTNR', 'KOMMISS')),
always,
   DestroyObject(oProdResLegacy),
   DestroyObject(oProdRes),
stopseq,

Weitere Verknüpfungen