====== GroupByExSorted ====== The mapping function GroupByExSorted() sorts the grouped result by (Key's). There are up to 6 key fields possible. ==== Syntax: ==== GroupByExSorted('Node', 'Key1', 'Key2', 'Key3', ..., 'Key6') GroupByExSorted('Node', 'Attribut1', 'Attribut2', 'Attribut3') ==== Notes ==== * The 'Key' values are treated internally as character strings. What is relevant when sorting by numeric or date values and a explicit formatting as a character string makes sense, e.g.: GroupByExSorted('//IndustryItems', 'FormatNumber(@PosNumber, "0000000")'). * It is possible to group attributes that are located in different depths of the node levels. To do this, however, the node must point to the lowest level. The hierarchically higher-ordered attributes must then be added by a "... /" reference. * If XPATH filters are required, make sure to use double and single quotation marks correctly.(See examples) ==== Samples ==== - Grouped and sorted under /InventoryReport/Items by @EanGroupByExSorted(/InventoryReport/Items, "@Ean") - Returns a list of all //LIN nodes//, grouped by the DE_7140 attributes whose DE_7143 attribute contains the value' GU'.GroupByExSorted(//LIN, "../PIA/*[@DE_7143='GU']/@DE_7140") - Returns a list of all //SG_33 nodes//, grouped by the DE_7140 attributes whose DE_7143 attribute contains the value' GU'.GroupByExSorted(//SG_33, "PIA/*[@DE_7143='GU']/@DE_7140") - Returns a list of all //LIN nodes//, grouped by the article details color attributes whose EAN is equal to the value in the DE_7140 attribute.Returns a list of all //LIN nodes//, grouped by the article details color attributes whose EAN is equal to the value in the DE_7140 attribute.GroupByExSorted(//LIN, "GetArticleDetailsByEAN(DG_212/@DE_7140)/Detail/@Color") - Group SLSRPT groups whose CustomItem key is =' EK_Department':GroupByExSorted(//Groups,"CustomItem[@Key='EK_Department']/@Value") - Groups the sales report according to the ID specified under PIA[@DE_4347=' 1']/DG_C212[@DE_7143=' LN']/@DE_7140 ((This is, for example, the purchasing department)).GroupByExSorted(//SG_7,"PIA[@DE_4347='1']/DG_C212[@DE_7143='LN']/@DE_7140") -Groups the sales report by location, SalesDate, and then by PIA[@DE_4347=' 1']/DG_C212[@DE_7143=' LN']/@DE_7140, in which case it is noteworthy that the group keys are located in different segments. This means that the grouping must be routed to the lowest node ((PIA is here under "SG_5/SG_7") and switched up for the higher-level segments with "... /" accordingly ((As specified:"... /LOC/DG_C517/@DE_3225" and "... /DTM/DG_C507[@DE_2005=' 356' and @DE_2379='102']/@DE_2380",)).GroupByExSorted(//SG_5/SG_7,"../LOC/DG_C517/@DE_3225","../DTM/DG_C507[@DE_2005='356' and @DE_2379='102']/@DE_2380","PIA[@DE_4347='1']/DG_C212[@DE_7143='LN']/@DE_7140")The keys therefore contain: - @Key1 = Location - @Key2 = SalesDate - @Key3 = e. g. ID of a purchasing department (e. g. at Breuninger)\\ \\ - Groups the sales report by location, SalesDate and then by RFF/DG_C506[@DE_1153 =' SB']/@DE_1154. It should also be noted here that the group keys are located in different segments. This means that the grouping must be routed to the lowest node ((RFF is here under "SG_5/SG_7"))(analogue to the previous example) and switched up for the higher-level segments with "... /".((As specified:"... /LOC/DG_C517/@DE_3225" and "... /DTM/DG_C507[@DE_2005=' 356' and @DE_2379=' 102']/@DE_2380",)).GroupByExSorted(//SG_5/SG_7,"../LOC/DG_C517/@DE_3225","../DTM/DG_C507[@DE_2005='356' and @DE_2379='102']/@DE_2380","RFF/DG_C506[@DE_1153 = 'SB']/@DE_1154")The keys therefore contain: - @Key1 = Location - @Key2 = SalesDate - @Key3 = e. g. an original location (e. g. near DeBijenkorf) ===== Nesting ===== In special cases it may be necessary to sort ((on a data element within the desired grouping)) before the actual grouping. This can be done by nesting the function. Note that the path **/Items** is appended to the nested grouping function ((which is used for pre-sorting at a lower level)). ==== Nesting sample ==== GroupByExSorted(GroupByExSorted(/TradeItemDocument/TradeItems,' @ArticleNo',' @Color',' @Size')/Items,' @ArticleNo',' @Color') In this example, the incoming items are sorted and grouped according to article number, color and size, and then only sorted and grouped according to article number and color, so that the sizes within a target record can be iterated in ascending order. === unsorted result: === === sorted result: ===