&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI ADM2 &ANALYZE-RESUME /* Connected Databases anadat PROGRESS */ &Scoped-define WINDOW-NAME CURRENT-WINDOW {adecomm/appserv.i} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS dTables /*------------------------------------------------------------------------ File: Description: from DATA.W - Template For SmartData objects in the ADM Input Parameters: Output Parameters: Modified: February 24, 1999 ------------------------------------------------------------------------*/ /* This .W file was created with the Progress AppBuilder. */ /*----------------------------------------------------------------------*/ /* Create an unnamed pool to store all the widgets created by this procedure. This is a good default which assures that this procedure's triggers and internal procedures will execute in this procedure's storage, and that proper cleanup will occur on deletion of the procedure. */ CREATE WIDGET-POOL. /* *************************** Definitions ************************** */ /* Parameters Definitions --- */ /* Local Variable Definitions --- */ DEF VAR SteuAkt AS INT NO-UNDO. DEF VAR AktGrp AS INT NO-UNDO. &SCOPED-DEFINE Tabelle AktPreis &SCOPED-DEFINE TabWhere /* USE-INDEX Benutzer-k1 ~ WHERE {&Tabelle}.Benutzer = tRowObject.Benutzer */ { incl/datdefinition.i } /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK /* ******************** Preprocessor Definitions ******************** */ &Global-define DATA-LOGIC-PROCEDURE .p &Scoped-define PROCEDURE-TYPE SmartDataObject &Scoped-define DB-AWARE yes &Scoped-define ADM-SUPPORTED-LINKS Data-Source,Data-Target,Navigation-Target,Update-Target,Commit-Target,Filter-Target /* Db-Required definitions. */ &IF DEFINED(DB-REQUIRED) = 0 &THEN &GLOBAL-DEFINE DB-REQUIRED TRUE &ENDIF &GLOBAL-DEFINE DB-REQUIRED-START &IF {&DB-REQUIRED} &THEN &GLOBAL-DEFINE DB-REQUIRED-END &ENDIF &Scoped-define QUERY-NAME Query-Main /* Internal Tables (found by Frame, Query & Browse Queries) */ &Scoped-define INTERNAL-TABLES AktPreis /* Definitions for QUERY Query-Main */ &Scoped-Define ENABLED-FIELDS Firma Artnr Inhalt Jahr Grp Ab_Datum Bis_Datum Art Wert Aktion Bemerkung~ Gruppe VK_Netto VK_Brutto Marge VK_Normal &Scoped-define ENABLED-FIELDS-IN-AktPreis Firma Artnr Inhalt Jahr Grp ~ Ab_Datum Bis_Datum Art Wert Aktion Bemerkung &Scoped-Define DATA-FIELDS Firma Artnr Inhalt Jahr Grp Ab_Datum Bis_Datum Art Wert Aktion Bemerkung~ Gruppe VK_Netto VK_Brutto Marge VK_Normal &Scoped-define DATA-FIELDS-IN-AktPreis Firma Artnr Inhalt Jahr Grp Ab_Datum ~ Bis_Datum Art Wert Aktion Bemerkung &Scoped-Define MANDATORY-FIELDS Firma &Scoped-Define APPLICATION-SERVICE &Scoped-Define ASSIGN-LIST &Scoped-Define DATA-FIELD-DEFS "d-aktpreis.i" &Scoped-Define DATA-TABLE-NO-UNDO NO-UNDO &Scoped-define QUERY-STRING-Query-Main FOR EACH AktPreis NO-LOCK INDEXED-REPOSITION {&DB-REQUIRED-START} &Scoped-define OPEN-QUERY-Query-Main OPEN QUERY Query-Main FOR EACH AktPreis NO-LOCK INDEXED-REPOSITION. {&DB-REQUIRED-END} &Scoped-define TABLES-IN-QUERY-Query-Main AktPreis &Scoped-define FIRST-TABLE-IN-QUERY-Query-Main AktPreis /* Custom List Definitions */ /* List-1,List-2,List-3,List-4,List-5,List-6 */ /* _UIB-PREPROCESSOR-BLOCK-END */ &ANALYZE-RESUME /* ************************ Function Prototypes ********************** */ {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getPreise dTables _DB-REQUIRED FUNCTION getPreise RETURNS DECIMAL ( ipArtnr AS INT, ipInhalt AS INT, ipJahr AS INT, ipAktGrp AS INT, ipDatum AS DATE ) FORWARD. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getQueryBuffer dTables _DB-REQUIRED FUNCTION getQueryBuffer RETURNS HANDLE ( /* parameter-definitions */ ) FORWARD. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD openQuery dTables _DB-REQUIRED FUNCTION openQuery RETURNS LOGICAL ( /* parameter-definitions */ ) FORWARD. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} /* *********************** Control Definitions ********************** */ {&DB-REQUIRED-START} /* Query definitions */ &ANALYZE-SUSPEND DEFINE QUERY Query-Main FOR AktPreis SCROLLING. &ANALYZE-RESUME {&DB-REQUIRED-END} /* ************************ Frame Definitions *********************** */ /* *********************** Procedure Settings ************************ */ &ANALYZE-SUSPEND _PROCEDURE-SETTINGS /* Settings for THIS-PROCEDURE Type: SmartDataObject Allow: Query Frames: 0 Add Fields to: Neither Other Settings: PERSISTENT-ONLY COMPILE APPSERVER DB-AWARE */ /* This procedure should always be RUN PERSISTENT. Report the error, */ /* then cleanup and return. */ IF NOT THIS-PROCEDURE:PERSISTENT THEN DO: MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT.":U VIEW-AS ALERT-BOX ERROR BUTTONS OK. RETURN. END. &ANALYZE-RESUME _END-PROCEDURE-SETTINGS /* ************************* Create Window ************************** */ &ANALYZE-SUSPEND _CREATE-WINDOW /* DESIGN Window definition (used by the UIB) CREATE WINDOW dTables ASSIGN HEIGHT = 1.62 WIDTH = 46.6. /* END WINDOW DEFINITION */ */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB dTables /* ************************* Included-Libraries *********************** */ {src/adm2/data.i} /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* *********** Runtime Attributes and AppBuilder Settings *********** */ &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES /* SETTINGS FOR WINDOW dTables VISIBLE,,RUN-PERSISTENT */ /* _RUN-TIME-ATTRIBUTES-END */ &ANALYZE-RESUME /* Setting information for Queries and Browse Widgets fields */ &ANALYZE-SUSPEND _QUERY-BLOCK QUERY Query-Main /* Query rebuild information for SmartDataObject Query-Main _TblList = "AnaDat.AktPreis" _Options = "NO-LOCK INDEXED-REPOSITION" _FldNameList[1] > AnaDat.AktPreis.Firma "Firma" "Firma" ? ? "character" ? ? ? ? ? ? yes ? yes 8 yes ? _FldNameList[2] > AnaDat.AktPreis.Artnr "Artnr" "Artnr" ? ? "integer" ? ? ? ? ? ? yes ? no 7.2 yes ? _FldNameList[3] > AnaDat.AktPreis.Inhalt "Inhalt" "Inhalt" ? ? "integer" ? ? ? ? ? ? yes ? no 5.2 yes ? _FldNameList[4] > AnaDat.AktPreis.Jahr "Jahr" "Jahr" ? ? "integer" ? ? ? ? ? ? yes ? no 4.8 yes ? _FldNameList[5] > AnaDat.AktPreis.Grp "Grp" "Grp" ? ? "integer" ? ? ? ? ? ? yes ? no 3.4 yes ? _FldNameList[6] > AnaDat.AktPreis.Ab_Datum "Ab_Datum" "Ab_Datum" ? ? "date" ? ? ? ? ? ? yes ? no 10.8 yes ? _FldNameList[7] > AnaDat.AktPreis.Bis_Datum "Bis_Datum" "Bis_Datum" ? ? "date" ? ? ? ? ? ? yes ? no 10.8 yes ? _FldNameList[8] > AnaDat.AktPreis.Art "Art" "Art" ? ? "integer" ? ? ? ? ? ? yes ? no 2.6 yes ? _FldNameList[9] > AnaDat.AktPreis.Wert "Wert" "Wert" ? ? "decimal" ? ? ? ? ? ? yes ? no 9.2 yes ? _FldNameList[10] > AnaDat.AktPreis.Aktion "Aktion" "Aktion" ? ? "character" ? ? ? ? ? ? yes ? no 20 yes ? _FldNameList[11] > AnaDat.AktPreis.Bemerkung "Bemerkung" "Bemerkung" ? ? "character" ? ? ? ? ? ? yes ? no 30 yes ? _FldNameList[12] > "_" "DYNAMIC-FUNCTION('getAktPreisGruppe':U, RowObject.Grp)" "Gruppe" "Gruppe" "x(30)" "character" ? ? ? ? ? ? yes ? no 30 no ? _FldNameList[13] > "_" "0" "VK_Netto" "Netto (exkl)" "->>,>>9.9999" "Decimal" ? ? ? ? ? ? yes ? no 12.6 no ? _FldNameList[14] > "_" "0" "VK_Brutto" "Brutto (inkl)" "->>,>>9.9999" "Decimal" ? ? ? ? ? ? yes ? no 12.6 no ? _FldNameList[15] > "_" "0" "Marge" "Marge" "->>,>>9.9999" "Decimal" ? ? ? ? ? ? yes ? no 12.6 no ? _FldNameList[16] > "_" "DYNAMIC-FUNCTION('getPreise':U IN THIS-PROCEDURE, RowObject.Artnr, RowObject.Inhalt,RowObject.Jahr, RowObject.Grp, RowObject.Ab_Datum )" "VK_Normal" "Normalpreis" "->>,>>9.9999" "Decimal" ? ? ? ? ? ? yes ? no 12.6 no ? _Design-Parent is WINDOW dTables @ ( 1.14 , 2.6 ) */ /* QUERY Query-Main */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK dTables /* *************************** Main Block *************************** */ { incl/datmainblock.i } FIND Steuer NO-LOCK USE-INDEX Steuer-k1 WHERE Steuer.Firma = Firma NO-ERROR. IF AVAILABLE Steuer THEN SteuAkt = Steuer.Aktionspreise. &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN RUN initializeObject. &ENDIF /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ********************** Internal Procedures *********************** */ {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE DATA.CALCULATE dTables DATA.CALCULATE _DB-REQUIRED PROCEDURE DATA.CALCULATE : /*------------------------------------------------------------------------------ Purpose: Calculate all the Calculated Expressions found in the SmartDataObject. Parameters: ------------------------------------------------------------------------------*/ ASSIGN rowObject.Gruppe = (DYNAMIC-FUNCTION('getAktPreisGruppe':U, RowObject.Grp)) rowObject.Marge = (0) rowObject.VK_Brutto = (0) rowObject.VK_Netto = (0) rowObject.VK_Normal = (DYNAMIC-FUNCTION('getPreise':U IN THIS-PROCEDURE, RowObject.Artnr, RowObject.Inhalt,RowObject.Jahr, RowObject.Grp, RowObject.Ab_Datum )) . END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE dataAvailable dTables _DB-REQUIRED PROCEDURE dataAvailable : /*------------------------------------------------------------------------------ Purpose: Super Override Parameters: Notes: ------------------------------------------------------------------------------*/ { incl/datdataavailable.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI dTables _DEFAULT-DISABLE PROCEDURE disable_UI : /*------------------------------------------------------------------------------ Purpose: DISABLE the User Interface Parameters: Notes: Here we clean-up the user-interface by deleting dynamic widgets we have created and/or hide frames. This procedure is usually called when we are ready to "clean-up" after running. ------------------------------------------------------------------------------*/ /* Hide all frames. */ IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE INAKTIVIEREN dTables _DB-REQUIRED PROCEDURE INAKTIVIEREN : /*------------------------------------------------------------------------------ Purpose: Parameters: Notes: ------------------------------------------------------------------------------*/ { incl/datinaktivieren.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initializeObject dTables _DB-REQUIRED PROCEDURE initializeObject : /*------------------------------------------------------------------------------ Purpose: Super Override Parameters: Notes: ------------------------------------------------------------------------------*/ { incl/datinitialize.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE REAKTIVIEREN dTables _DB-REQUIRED PROCEDURE REAKTIVIEREN : /*------------------------------------------------------------------------------ Purpose: Parameters: Notes: ------------------------------------------------------------------------------*/ { incl/datreaktivieren.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE REPOS_TABELLE dTables _DB-REQUIRED PROCEDURE REPOS_TABELLE : /*------------------------------------------------------------------------------ Purpose: Parameters: Notes: ------------------------------------------------------------------------------*/ { incl/datrepos.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_FILTER dTables _DB-REQUIRED PROCEDURE SET_FILTER : /*------------------------------------------------------------------------------ Purpose: Parameters: Notes: ------------------------------------------------------------------------------*/ { incl/datsetfilter.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_OPENFLAG dTables _DB-REQUIRED PROCEDURE SET_OPENFLAG : /*------------------------------------------------------------------------------ Purpose: Parameters: Notes: ------------------------------------------------------------------------------*/ { incl/datsetopenflag.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_SORT dTables _DB-REQUIRED PROCEDURE SET_SORT : /*------------------------------------------------------------------------------ Purpose: Parameters: Notes: ------------------------------------------------------------------------------*/ { incl/datsetsort.i } END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} /* ************************ Function Implementations ***************** */ {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getPreise dTables _DB-REQUIRED FUNCTION getPreise RETURNS DECIMAL ( ipArtnr AS INT, ipInhalt AS INT, ipJahr AS INT, ipAktGrp AS INT, ipDatum AS DATE ) : /*------------------------------------------------------------------------------ Purpose: Notes: ------------------------------------------------------------------------------*/ DEF VAR cString AS CHAR NO-UNDO. DEF VAR lBrutto AS LOG NO-UNDO. DEF VAR VK_Normal AS DEC DECIMALS 4 NO-UNDO. DEF VAR VK_Netto AS DEC DECIMALS 4 NO-UNDO. DEF VAR VK_Brutto AS DEC DECIMALS 4 NO-UNDO. DEF VAR Ansatz AS DEC DECIMALS 4 NO-UNDO. DEF VAR Marge AS DEC DECIMALS 4 NO-UNDO. DEF VAR EP AS DEC DECIMALS 4 NO-UNDO. IF SteuAkt = 0 THEN AktGrp = ipAktGrp. ELSE DO: RUN FIND_KUNDENGRUPPE ( INPUT ipAktGrp, OUTPUT cString ). IF cString <> '' THEN AktGrp = INTEGER(ENTRY(3, cString, CHR(01))). END. RUN FIND_PREISGRUPPE ( INPUT AktGrp, OUTPUT cString ). IF INTEGER(ENTRY(3, cString, CHR(01))) = 1 THEN lBrutto = TRUE. ELSE lBrutto = FALSE. FIND LAST ArtPreis NO-LOCK USE-INDEX ArtPreis-k1 WHERE ArtPreis.Firma = Firma AND ArtPreis.Artnr = ipArtnr AND ArtPreis.Inhalt = ipInhalt AND ArtPreis.Jahr = ipJahr AND ArtPreis.Preis_Grp = ipAktGrp AND ArtPreis.Aktion = FALSE AND ArtPreis.Ab_Datum <= ipDatum NO-ERROR. DO WHILE TRUE: IF NOT AVAILABLE ArtPreis THEN LEAVE. Ansatz = (ArtPreis.VK_Brutto * 100 / ArtPreis.VK_Netto) - 100. IF lBrutto THEN VK_Normal = Artpreis.VK_Brutto. ELSE VK_Normal = Artpreis.VK_Netto. CASE rowObject.Art: WHEN 0 THEN DO: IF lBrutto THEN DO: VK_Brutto = ArtPreis.VK_Brutto - rowObject.Wert. RUN RUNDEN ( INPUT 1, INPUT-OUTPUT VK_Brutto ). VK_Netto = VK_Brutto / (100 + Ansatz) * 100. END. ELSE DO: VK_Netto = ArtPreis.VK_Netto - rowObject.Wert. VK_Brutto = VK_Netto * (100 + Ansatz) / 100. END. END. WHEN 1 THEN DO: IF lBrutto THEN DO: VK_Brutto = ArtPreis.VK_Brutto * (100 - rowObject.Wert) / 100. RUN RUNDEN ( INPUT 1, INPUT-OUTPUT VK_Brutto ). VK_Netto = VK_Brutto / (100 + Ansatz) * 100. END. ELSE DO: VK_Netto = ArtPreis.VK_Netto * (100 - rowObject.Wert) / 100. VK_Brutto = VK_Netto * (100 + Ansatz) / 100. END. END. END CASE. LEAVE. END. EP = 0. Marge = 0. FIND Artst NO-LOCK USE-INDEX Artst-k1 WHERE Artst.Firma = Firma AND Artst.Artnr = ipArtnr AND Artst.Inhalt = ipInhalt AND Artst.Jahr = ipJahr NO-ERROR. EP = Artst.Listen_EP. IF EP = 0 THEN EP = Artst.LEP. IF EP = 0 THEN EP = Artst.DEP. IF EP <> 0 AND VK_Netto <> 0 THEN Marge = 100 - (EP * 100 / VK_Netto). rowObject.VK_Brutto = VK_Brutto. rowObject.VK_Netto = VK_Netto . rowObject.Marge = Marge. RETURN VK_Normal. END FUNCTION. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getQueryBuffer dTables _DB-REQUIRED FUNCTION getQueryBuffer RETURNS HANDLE ( /* parameter-definitions */ ) : /*------------------------------------------------------------------------------ Purpose: Notes: ------------------------------------------------------------------------------*/ RETURN BUFFER rowObject:HANDLE. END FUNCTION. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END} {&DB-REQUIRED-START} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION openQuery dTables _DB-REQUIRED FUNCTION openQuery RETURNS LOGICAL ( /* parameter-definitions */ ) : /*------------------------------------------------------------------------------ Purpose: Super Override Notes: ------------------------------------------------------------------------------*/ DEF VAR Felder AS CHAR NO-UNDO. DEF VAR Inhalt AS CHAR NO-UNDO. DEF VAR ix AS INT NO-UNDO. DEF VAR cFeld AS CHAR NO-UNDO. /* IF NOT fOpen THEN RETURN FALSE. */ xWhere = ''. xSort = ''. xString = ''. Felder = DYNAMIC-FUNCTION('getForeignFields':U) NO-ERROR. Inhalt = DYNAMIC-FUNCTION('getForeignValues':U) NO-ERROR. /* ix = LOOKUP('Feld', Felder, ',') / 2. */ /* cFeld = ENTRY (ix , Inhalt, CHR(01)). */ /* xWhere = 'Aufko.Firma = ' + QUOTER(Firma) + ' AND ' */ /* + 'Aufko.Auf_Sta = ' + STRING(Auf_Sta) + ' '. */ /* xString = 'FOR EACH Debop ' + xSort + 'WHERE ' */ /* + 'Debop.Firma = "' + Firma + '" AND ' */ /* + 'Debop.Knr = ' + STRING(Knr) + ' ' */ /* + 'NO-LOCK BY Debop.FakDat DESCENDING INDEXED-REPOSITION '. */ { incl/datopenquery.i } IF xWhere <> '' THEN DYNAMIC-FUNCTION('setQueryWhere':U , INPUT xWhere ). IF xString <> '' THEN DYNAMIC-FUNCTION('setQueryString':U, INPUT xString). IF xSort <> '' THEN DYNAMIC-FUNCTION('setQuerySort':U , INPUT xSort ). RETURN SUPER( ). END FUNCTION. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME {&DB-REQUIRED-END}