OBS/Makros und Scripting/Developer/Beispiele/UC Positionen

Aus OBS Wiki
Zur Navigation springen Zur Suche springen


Script Library

Durch den Prefix "AU" werden diese Scripte nur von Auftragsvorgängen genutzt.
"AU" ist der DMS-Typ von Auftrag. Eine Liste mit dem DMS-Typen finden Sie hier.
Generell können die Vorgänge "Angebot", "Aufträge", Rechnungen", "Einkauf", "Einkauflieferschein", "Bestellung" und "Reparaturauftrag" diese Methoden nutzen, brauchen aber dementsprechend ihren DMS-Typ als Prefix.

AU_VORGANG (Positionserfassung)

Zusatzinfo

Die Methode "VORGANG_ZUSATZINFO_START" gibt einen Headertext für die Positionserfassung zurück. Die Methode "StartProc" ist für Nachträgliche Datenänderungen nach Abschluss eines Vorganges.

HINWEIS: Die Methoden "VORGANG_ZUSATZINFO_START" und "StartProc" müssen vorhanden sein.
function VORGANG_ZUSATZINFO_START(cVorgang:String):String;
begin
    Result := ''; //'Result:='+cVorgang;
end;

function StartProc(cVorgang:String):String;
begin
    Result := ''; //'Result:='+cVorgang;
end;

Positionen Prüfen (Start und Ende)

Beim öffnen und Schließen der Positionserfassung können zum Beispiel Daten geprüfen oder manipulieren werden.

//beim Öffnen
procedure StartProc(cVorgang:String);
begin

end;

//Beim Schließen
function CloseProc(cVorgang:String):Boolean;
var lESC: Boolean;
begin
     GetMemoShort('F2  = Weiter' + CRLF +
                  'ESC = Abbrechen',
                  'Titel', lESC, 600);

    Result := lESC;
end;

AU_VORGANG_STDOK (Einzelen Position)

Die Methoden "BeforeSave" und "AfterSave" werden jeweils vor und nach dem Aufruf der Standard Speicherroutine aufgerufen.

Beispiel: Diese Methode kann verwendet werden, um Materialien nach dem Speichern der Positionen zu verändern.

Mit "BeforeSave" können Werte direkt in UC_Position vor dem Speichern verändert werden.

Mit "AfterSave" können Werte nach dem Speichern geändert werden.
Bei zeitnaher Artikelpflege (PMode 526) ist das Material schon angelegt. Hiermit kann z.B. das Material nachträglich verändert werden.

HINWEIS: Die Methoden "BeforeSave" und "AfterSave" müssen vorhanden sein.
function _Boolean(lVal:Boolean):String;
begin
    Result := iif(lVal,'True','False');
end;

function _SaveMode(Val:TSaveMode):String;
begin
    if          (Val = DB_INSERT) then begin
        Result := 'INSERT';
    end else if (Val = DB_UPDATE) then begin
        Result := 'UPDATE';
    end else begin
        Result := 'NOCHANGE';
    end;
end;
        
procedure _ShowValues(cVorgang:String; oPos:TPosValue);
begin
    DebugLine('Vorgang   :' + cVorgang                     );
    DebugLine('Artikel-Nr:' + oPos.POS_ARTNR               );
    DebugLine('SHOW      :' + _Boolean(oPos.POS_SHOW)      );    
    
    //TSaveMode      = (DB_INSERT, DB_UPDATE, DB_NOCHANGE);
    
    DebugLine('UPDATE    :' + _SaveMode(oPos.POS_UPDATE)   );
    DebugLine('SYS_UID   :' + oPos.POS_SYS_UID             );
    DebugLine('TSORT     :' + oPos.POS_TSORT               );
    DebugLine('NR        :' + oPos.POS_NR                  );
    DebugLine('KNR       :' + oPos.POS_KNR                 );
    DebugLine('POSNR     :' + oPos.POS_POSNR               );
    DebugLine('POSNR2    :' + oPos.POS_POSNR2              );
    DebugLine('POSKAS    :' + oPos.POS_POSKAS              );
    DebugLine('POSLFD    :' + oPos.POS_POSLFD              );
    
    (*               
    TPosType  = (ShowStd,
                 ShowMemo,
                 ShowEmpty,
                 ShowZwSum,
                 ShowTitSum,
                 ShowEndSum,
                 ShowTitel,
                 ShowAngTitel,
                 ShowGewerk,
                 ShowHeader,
                 ShowFooter,
                 ShowFootAbschl,
                 ShowFF,
                 EditStd,
                 EditMemo,
                 EditAngTitel,
                 EditGewerk,
                 ShowNewPage,
                 EditTitSum,
                 ShowBmp,
                 EditBmp,
                 EditZWSum,
                 ShowScriptResult,
                 Undefined)
    *)                 
    
    DebugLine('TYP       :' + IntToStr(oPos.POS_TYP)       );
    DebugLine('ARTNR     :' + oPos.POS_ARTNR               );
    DebugLine('ARTNR_SHOW:' + oPos.POS_ARTNR_SHOW          );
    DebugLine('LNR       :' + oPos.POS_LNR                 );
    DebugLine('MEMORTF   :' + oPos.POS_MEMO                );
    DebugLine('MEMOANSI  :' + oPos.POS_MEMOANSI            );
    DebugLine('MEMODRUCK :' + oPos.POS_MEMODRUCK           );
    DebugLine('BEZ1      :' + oPos.POS_BEZ1                );
    DebugLine('BEZ2      :' + oPos.POS_BEZ2                );
    DebugLine('MENGE     :' + axStr(oPos.POS_MENGE)        );
    DebugLine('URMENGE   :' + axStr(oPos.POS_URMENGE)      );
    DebugLine('EINHEIT   :' + oPos.POS_EINHEIT             );
    DebugLine('EINHNAME  :' + oPos.POS_EINHNAME            );
    DebugLine('MENGEIN   :' + axStr(oPos.POS_MENGEIN)      );
    DebugLine('MENGEINFAK:' + axStr(oPos.POS_MENGEINFAK)   );
    DebugLine('_EPREIS   :' + axStr(oPos.fPOS_EPREIS)      );
    DebugLine('_BEPREIS  :' + axStr(oPos.fPOS_BEPREIS)     );
    DebugLine('_BGPREIS  :' + axStr(oPos.fPOS_BGPREIS)     );
    DebugLine('_EKPREIS  :' + axStr(oPos.fPOS_EKPREIS)     );
    DebugLine('URPREIS   :' + axStr(oPos.POS_URPREIS)      );
    DebugLine('URPREISEK :' + axStr(oPos.POS_URPREISEK)    );
    DebugLine('MANPREIS  :' + oPos.POS_MANPREIS            );
    
    DebugLine('_GPREIS   :' + axStr(oPos.fPOS_GPREIS)      );
    DebugLine('GRABATT   :' + axStr(oPos.POS_GRABATT)      );
    DebugLine('RABATT    :' + axStr(oPos.POS_RABATT)       );
    DebugLine('RABART1   :' + oPos.POS_RABART1             );
    DebugLine('RABATT1   :' + axStr(oPos.POS_RABATT1)      );
    DebugLine('RABART2   :' + oPos.POS_RABART2             );
    DebugLine('RABATT2   :' + axStr(oPos.POS_RABATT2)      );
    DebugLine('RABART3   :' + oPos.POS_RABART3             );
    DebugLine('RABATT3   :' + axStr(oPos.POS_RABATT3)      );
    DebugLine('RABART4   :' + oPos.POS_RABART4             );
    DebugLine('RABATT4   :' + axStr(oPos.POS_RABATT4)      );
    DebugLine('RABART5   :' + oPos.POS_RABART5             );
    DebugLine('RABATT5   :' + axStr(oPos.POS_RABATT5)      );
    DebugLine('ADDSUB    :' + axStr(oPos.POS_ADDSUB)       );
    
    DebugLine('_MWSTSCH  :' + oPos.fPOS_MWSTSCH            );
    DebugLine('_MWSTSATZ :' + axStr(oPos.fPOS_MWSTSATZ)    );
    DebugLine('KONTO     :' + oPos.POS_KONTO               );
    DebugLine('LAGNR     :' + oPos.POS_LAGNR               );
    DebugLine('LAGONR    :' + oPos.POS_LAGONR              );
    DebugLine('SKFJN     :' + oPos.POS_SKFJN               );
    DebugLine('BILDUID   :' + oPos.POS_BILDUID             );
    
    DebugLine('AUSDRUCKJN:' + oPos.POS_AUSDRUCKJN );
    DebugLine('VERK      :' + oPos.POS_VERK                );
    DebugLine('STATUS    :' + oPos.POS_STATUS              );
    DebugLine('ANGNR     :' + oPos.POS_ANGNR               );
    DebugLine('COLNR     :' + IntToStr(oPos.POS_COLNR)     );
    DebugLine('UID       :' + oPos.POS_UID                 );
    DebugLine('MUID      :' + oPos.POS_MUID                );
    DebugLine('MENGEG    :' + axStr(oPos.POS_MENGEG)       );
    DebugLine('VERPACK   :' + oPos.POS_VERPACK             );
    DebugLine('KOLLI     :' + axStr(oPos.POS_KOLLI)        );
    DebugLine('INHALT    :' + axStr(oPos.POS_INHALT)       );
    DebugLine('EKSPREIS  :' + axStr(oPos.POS_EKSPREIS)     );
    DebugLine('OBPREIS   :' + axStr(oPos.POS_OBPREIS)      );
    
    DebugLine('AUFNR     :' + oPos.POS_AUFNR               );
    DebugLine('LIENR     :' + oPos.POS_LIENR               );
    DebugLine('XUID1     :' + oPos.POS_XUID1               );
    DebugLine('XUID2     :' + oPos.POS_XUID2               );
    DebugLine('XUID3     :' + oPos.POS_XUID3               );
    DebugLine('XUID4     :' + oPos.POS_XUID4               );
    DebugLine('PROV      :' + axStr(oPos.POS_PROV)         );
    DebugLine('LIEFKZ    :' + IntToStr(oPos.POS_LIEFKZ)    );
    DebugLine('KOSTST    :' + oPos.POS_KOSTST              );
    DebugLine('PRODGR    :' + oPos.POS_PRODGR              );
    DebugLine('FRACHTV   :' + axStr(oPos.POS_FRACHTV)      );
    DebugLine('MATEUID   :' + oPos.POS_MATEUID             );
    DebugLine('EILIUID   :' + oPos.POS_EILIUID             );
    
    DebugLine('BESTUID   :' + oPos.POS_BESTUID             );
    DebugLine('BESTNR    :' + oPos.POS_BESTNR              );
    DebugLine('POSTEXT   :' + oPos.POS_POSTEXT             );
    DebugLine('POSZUSATZ :' + oPos.POS_POSZUSATZ           );
    DebugLine('DIFFPREIS :' + axStr(oPos.POS_DIFFPREIS)    );
    DebugLine('LPROJNR   :' + oPos.POS_LPROJNR             );
    DebugLine('LSNR      :' + oPos.POS_LSNR                );
    DebugLine('LSDAT     :' + DToC(oPos.POS_LSDAT)         );
    DebugLine('EKHERKUNFT:' + oPos.POS_EKHERKUNFT          );
    DebugLine('POSART    :' + IntToStr(oPos.POS_POSART)    );
    DebugLine('URLAND    :' + oPos.POS_URLAND              );
    DebugLine('AUFSCHLAG :' + IntToStr(oPos.POS_AUFSCHLAG) );
    DebugLine('AUFSCHUID :' + oPos.POS_AUFSCHUID           );
    DebugLine('LIEFNR    :' + oPos.POS_LIEFNR              );
    DebugLine('LAGSTRECK :' + oPos.POS_LAGSTRECK           );
    DebugLine('MBANZAHL  :' + axStr(oPos.POS_MBANZAHL)     );
    DebugLine('MBEZMENGE :' + axStr(oPos.POS_MBEZMENGE)    );
    DebugLine('MBGEWICHT :' + axStr(oPos.POS_MBGEWICHT)    );
    DebugLine('MBGGEWICHT:' + axStr(oPos.POS_MBGGEWICHT)   );
    DebugLine('MBILAENGE :' + axStr(oPos.POS_MBILAENGE)    );
    DebugLine('MBSLAENGE :' + axStr(oPos.POS_MBSLAENGE)    );
    DebugLine('MBIBREITE :' + axStr(oPos.POS_MBIBREITE)    );
    DebugLine('MBSBREITE :' + axStr(oPos.POS_MBSBREITE)    );
    DebugLine('MBIHOEHE  :' + axStr(oPos.POS_MBIHOEHE)     );
    DebugLine('MBSHOEHE  :' + axStr(oPos.POS_MBSHOEHE)     );
    DebugLine('MBKZMENGE :' + oPos.POS_MBKZMENGE           );
    DebugLine('MBUID     :' + oPos.POS_MBUID               );
    DebugLine('RVUID     :' + oPos.POS_RVUID               );
    DebugLine('MBSYS_UID :' + oPos.POS_MBSYS_UID           );
    
    DebugLine('VPCALCMENG:' + axStr(oPos.POS_VPCALCMENGE)  );
    DebugLine('VPANZAHL1 :' + axStr(oPos.POS_VPANZAHL1)    );
    DebugLine('VPANZAHL2 :' + axStr(oPos.POS_VPANZAHL2)    );
    DebugLine('VPANZAHL3 :' + axStr(oPos.POS_VPANZAHL3)    );
    DebugLine('VPANZAHL4 :' + axStr(oPos.POS_VPANZAHL4)    );
    DebugLine('VPLFD1    :' + oPos.POS_VPLFD1              );
    DebugLine('VPLFD2    :' + oPos.POS_VPLFD2              );
    DebugLine('VPLFD3    :' + oPos.POS_VPLFD3              );
    DebugLine('VPLFD4    :' + oPos.POS_VPLFD4              );
    DebugLine('VPUID     :' + oPos.POS_VPUID               );
    DebugLine('VPSYS_UID :' + oPos.POS_VPSYS_UID           );
    DebugLine('IsInfo    :' + IntToStr(oPos.POS_IsInfo)    );

    DebugLine('KOMMENT   :' + oPos.POS_KOMMENT             );
    DebugLine('ERWARTIKEL:' + oPos.POS_ERWARTIKEL          );
    DebugLine('ERWARTIKEL:' + oPos.POS_ERWARTIKEL          );
    
    DebugLine('MWSTSATZ  :' + axStr(oPos.POS_MWSTSATZ)     );
    DebugLine('MWSTSCH   :' + oPos.POS_MWSTSCH             );
    
    DebugLine('EPREIS    :' + axStr(oPos.POS_EPREIS)       );
    DebugLine('EKPREIS   :' + axStr(oPos.POS_EKPREIS)      );
    DebugLine('BEPREIS   :' + axStr(oPos.POS_BEPREIS)      );
    DebugLine('BGPREIS   :' + axStr(oPos.POS_BGPREIS)      );
    DebugLine('GPREIS    :' + axStr(oPos.POS_GPREIS)       );
    
    DebugLine('--------------------------------------');
end;

procedure BeforeSave(cVorgang:String; oPos:TPosValue);
begin
    //DebugLine('BeforSave');
    //_ShowValues(cVorgang, oPos);
end;

procedure AfterSave(cVorgang:String; oPos:TPosValue);
begin
    //DebugLine('BeforSave');
    //_ShowValues(cVorgang, oPos);
end;

Ändern der Positionsframe-Komponenten

Aufruf im Scripter:

 procedure InitEdit(cVorgang:String; oFrame:TFrame);

Hier können Komponenten aus der geöffneten Position verändert werden. Dazu müssen die Komponenten mit oFrame.FindComponent ermittelt werden.

Beispiel:

procedure InitEdit(cVorgang:String; oFrame:TFrame);
var oEditPreis : TNumericEdit; // Komponente mit Typ deklarieren
begin
    DebugLine('InitEdit');
    // Komponente finden
    oEditPreis := TNumericEdit(oFrame.FindComponent('numed_epreis'));

    // Wenn Komponente vorhanden ist, Änderungen ausführen
    if (Assigned(oEditPreis)) then begin
        oEditPreis.Enabled := False;
    end;
end;

Alle verfügbaren Komponenten mit Typ (Je nach Einstellungen können einige deaktiviert sein):

       stred_bez2: TStringEdit;
       stred_bez1: TStringEdit;
       numed_menge: TNumericEdit;
       numed_rabatt: TNumericEdit;
       numed_epreis: TNumericEdit;
       cbl_db_artnr: TCombiListe;
       cbl_db_lnr: TCombiListe;
       cbl_db_konto: TCombiListe;
       cbl_db_lagnr: TCombiListe;
       cbl_db_mwst: TCombiListe;
       cbl_db_posken: TCombiListe;
       cbl_db_einheit: TCombiListe;
       numed_prov: TNumericEdit;
       numed_ekpreis: TNumericEdit;
       stred_posnr: TMaskEdit;
       Btn_weiter: TButton;
       stred_lsnr: TStringEdit;
       Datev_lsdat: TDateValEdit;
       comed_db_posart: xTComboedit;
       numed_anzahl: TNumericEdit;
       numed_inhalt: TNumericEdit;
       cbl_db_verp: TCombiListe;
       lab_inhalt: TLabel;
       stred_bestnr: TStringEdit;
       comed_db_aufschlag: xTComboedit;
       cbx_db_skfjn: TxCheckbox;
       numed_db_ggewicht: TNumericEdit;
       numed_db_gewicht: TNumericEdit;
       numed_db_ezmenge: TNumericEdit;
       numed_db_slaenge: TNumericEdit;
       numed_db_ilaenge: TNumericEdit;
       numed_db_sbreite: TNumericEdit;
       numed_db_ibreite: TNumericEdit;
       numed_db_ihoehe: TNumericEdit;
       numed_db_shoehe: TNumericEdit;
       stred_db_kzmenge: TStringEdit;
       numed_db_anzahl: TNumericEdit;
       cbl_db_prodgr: TCombiListe;
       numed_db_calcmenge: TNumericEdit;
       numed_db_anzahl1: TNumericEdit;
       numed_db_anzahl2: TNumericEdit;
       numed_db_anzahl3: TNumericEdit;
       numed_db_anzahl4: TNumericEdit;
       numed_db_inhalt1: TNumericEdit;
       numed_db_inhalt2: TNumericEdit;
       numed_db_inhalt3: TNumericEdit;
       numed_db_inhalt4: TNumericEdit;
       numed_gesamt1: TNumericEdit;
       numed_gesamt2: TNumericEdit;
       numed_gesamt3: TNumericEdit;
       numed_gesamt4: TNumericEdit;
       stred_einheit1: TStringEdit;
       stred_einheit2: TStringEdit;
       stred_einheit3: TStringEdit;
       stred_einheit4: TStringEdit;
       comed_db_liefkz: xTComboedit;
       cbl_db_kostst: TCombiListe;
       stred_posnr2: TMaskEdit;
       cbx_db_ausdruckjn: TxCheckbox;
       cbx_db_aufstrecke: TxCheckBox;
       cbx_db_manpreis: TxCheckBox;
       numed_obpreis: TNumericEdit;
       cbl_db_lagonr: TCombiListe;
       numed_addsub: TNumericEdit;
       riced_postext: TTextRichEdit;
       comed_db_druckposmemo: xTComboEdit;