2017-08-23 38 views

回答

1

它看起來像一個function import使用情況給我。

首先,你必須定義一個ABAP結構返回的數據,如低於

@EndUserText.label : 'ENQUEUEGETSTAT' 
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE 
define structure zza_enqueuegetstat { 
    entries_total : abap.int4; 
    entries_peak : abap.int4; 
    entries_actual : abap.int4; 
} 

在你SEGW項目,創建ENQUEUEGETSTAT實體類型映射到這個結構。

enter image description here

然後,創建一個函數導入ENQUEUEGETSTAT

enter image description here

轉到您的DPC_EXT類,並重新定義方法/IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION

method /iwbep/if_mgw_appl_srv_runtime~execute_action. 

    data ls_enqueuegetstat type zza_enqueuegetstat. 

    if iv_action_name = 'ENQUEUEGETSTAT'. 
     call function 'ENQUEUEGETSTAT' 
     importing 
      entries_total = ls_enqueuegetstat-entries_actual 
      entries_peak = ls_enqueuegetstat-entries_peak 
      entries_actual = ls_enqueuegetstat-entries_total. 

     copy_data_to_ref(
      exporting 
      is_data = ls_enqueuegetstat 
      changing 
      cr_data = er_data 
    ). 
    endif. 
endmethod. 

保存並激活一切。那麼你應該能夠訪問你的函數進口/sap/opu/odata/sap/**YOUR_SERVICE**/ENQUEUEGETSTAT?$format=json

{ 
    "d": { 
     "EntriesTotal": 382, 
     "EntriesPeak": 43189, 
     "EntriesActual": 500000 
    } 
} 

希望它能幫助。