SAP CDS How get GUID from /BOBF/UUID for ODATA Query

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
@AbapCatalog.sqlViewName: '/ZHM/CQIMAGEMAT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Consumption CDS for /ZHM/I_T_IMAGE_MAT'

@OData.publish: true

@Metadata.allowExtensions

@ObjectModel:{
    transactionalProcessingDelegated: true,
    compositionRoot: true,
    semanticKey: ['uuid'],
    representativeKey: 'uuid',
    createEnabled: true,
    updateEnabled: true,
    deleteEnabled: true
}

@UI.headerInfo: { typeName: 'Изображение ТМЦ',typeNamePlural: 'Изображения ТМЦ'}

@Search.searchable: true

define view /ZHM/C_IMAGE_MAT
  as select from /ZHM/I_T_IMAGE_MAT
{
  key uuid,
      ///ZHM/I_T_IMAGE_MAT
      @UI.lineItem: { label: 'Key', position: 10, importance: #HIGH }
      @UI.identification:{ label: 'Key', position: 10, importance: #HIGH }
      @Search.defaultSearchElement: true
      image_key,

      @UI.lineItem: { label: 'Material', position: 20, importance: #HIGH }
      @UI.identification:{ label: 'Material', position: 20, importance: #HIGH }
      @Search.defaultSearchElement: true
      matnr_ext,

      @UI.lineItem: { label: 'URL', position: 30, importance: #HIGH }
      @UI.identification:{ label: 'URL', position: 30, importance: #HIGH }
      @Search.defaultSearchElement: true
      image_url,


      @UI.lineItem: { label: 'URL', position: 40, importance: #HIGH }
      @UI.identification:{ label: 'URL', position: 40, importance: #HIGH }
      @ObjectModel.readOnly: true
      replace('/sap/opu/odata/ZHM/C_IMAGE_MAT_CDS/xZHMxC_IMAGE_MAT(guid''uuid'')','uuid',      
      LOWER(CONCAT(  //GET guid
          CONCAT(
              CONCAT(
                  CONCAT(LEFT(BINTOHEX( uuid ),8),'-'),
                  CONCAT(SUBSTRING(BINTOHEX( uuid ), 9, 4),'-')
                  ),
              CONCAT(
                  CONCAT(SUBSTRING(BINTOHEX( uuid ), 13, 4),'-'),
                  CONCAT(SUBSTRING(BINTOHEX( uuid ), 17, 4),'-')
                  )),             SUBSTRING(BINTOHEX( uuid ), 21, 12) ) )) as GetUrl
}

Добавить комментарий