forked from consultingwerk/CCS_Samples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget-customer-by-abstract-query.p
92 lines (70 loc) · 4.24 KB
/
get-customer-by-abstract-query.p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**********************************************************************
* Copyright (C) 2006-2016 by Consultingwerk Ltd. ("CW") - *
* www.consultingwerk.de and other contributors as listed *
* below. All Rights Reserved. *
* *
* Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY *
* KIND, either express or implied. *
* *
* Contributors: *
* *
**********************************************************************/
/*------------------------------------------------------------------------
File : get-customer-by-abstract-query.p
Purpose : fetches customer records by query string
Syntax :
Description :
Author(s) :
Created : Wed Jun 22 02:45:08 CEST 2016
Notes :
----------------------------------------------------------------------*/
/* *************************** Definitions ************************** */
BLOCK-LEVEL ON ERROR UNDO, THROW.
USING Ccs.BusinessLogic.* FROM PROPATH.
USING Ccs.Common.* FROM PROPATH.
USING Consultingwerk.CcsSamples.BusinessEntity.* FROM PROPATH.
USING Consultingwerk.CcsSamples.Framework.BusinessLogic.* FROM PROPATH.
DEFINE VARIABLE oCustomerEntity AS IBusinessEntity NO-UNDO .
DEFINE VARIABLE i AS INTEGER NO-UNDO .
DEFINE VARIABLE oRequest AS GetDataRequest NO-UNDO .
{Consultingwerk/CcsSamples/BusinessEntity/Customer/dsCustomer.i}
/* *************************** Main Block *************************** */
RUN Consultingwerk/CcsSamples/boot.p .
oCustomerEntity = CAST (Application:ServiceManager:getService(GET-CLASS (IBusinessEntity),
BusinessEntities:Customer:ToString()),
IBusinessEntity) .
/*// SalesRep = "BBB" AND Country = "USA" */
/*oRequest = NEW GetDataRequest (NEW GetDataTableRequest("eCustomer", */
/* QueryEntry:Array(NEW QueryPredicate("SalesRep", QueryOperatorEnum:Eq, "BBB"), */
/* NEW QueryPredicate(JoinEnum:And, "Country", QueryOperatorEnum:Eq, "USA")))) .*/
// SalesRep = "BBB" AND Country = "USA" AND NOT (City BEGINS "B" OR City BEGINS "C"
oRequest = NEW GetDataRequest (NEW GetDataTableRequest("eCustomer",
QueryEntry:Array(NEW QueryPredicate ("SalesRep", QueryOperatorEnum:Eq, "BBB"),
NEW QueryPredicate (JoinEnum:And, "Country", QueryOperatorEnum:Eq, "USA"),
NEW QueryGroup (JoinEnum:AndNot,
QueryEntry:Array(NEW QueryPredicate("City", QueryOperatorEnum:Begins, "B"),
NEW QueryPredicate(JoinEnum:Or, "City", QueryOperatorEnum:Begins, "C")))))) .
oCustomerEntity:getData (oRequest,
OUTPUT DATASET dsCustomer) .
FOR EACH eCustomer:
i = i + 1 .
END.
MESSAGE "results:" i
VIEW-AS ALERT-BOX.
FOR EACH eCustomer:
DISPLAY eCustomer.CustNum
eCustomer.Name
eCustomer.SalesRep WITH DOWN .
END.
// Error handling
CATCH apperr AS Progress.Lang.AppError :
MESSAGE apperr:GetMessage(1) SKIP
apperr:ReturnValue SKIP (2)
apperr:CallStack
VIEW-AS ALERT-BOX.
END CATCH.
CATCH err AS Progress.Lang.Error :
MESSAGE err:GetMessage(1) SKIP (2)
err:CallStack
VIEW-AS ALERT-BOX.
END CATCH.