如何動態地呼叫沒有引用的其他程式的記憶體變數資料的樣例?
本文ATP的增強(EXIT_SAPLATPC_002)會在訂單,出庫單的程式中被呼叫,我們可能希望讀取這些程式的變數的資料,我們就可以通過FIELD-SYMBOLS來完成,具體參見下面的程式碼樣例:
TABLES: y0000ca_userexit. "allready declaredDATA: c_programm LIKE y0000ca_userexit-yprogramm.
DATA: c_funcname LIKE y0000ca_userexit-yfuncname.
DATA: w_programm LIKE y0000ca_userexit-yprogramm.
DATA: w_funcname LIKE y0000ca_userexit-yfuncname.
DATA: w_active LIKE y0000ca_userexit-yactive.
DATA: w_subrc LIKE sy-subrc.
DATA: w_mandt LIKE sy-mandt.
DATA: function_name LIKE y0000ca_userexit-yfuncname.
DATA: wt_unit_params LIKE y0000ca_exit_params OCCURS 0.
DATA: wa_unit_params LIKE y0000ca_exit_params.
DATA: w_subp(30) TYPE c.
DATA: w_prog TYPE sy-repid VALUE 'ZXATPU02'.
DATA: lv_kunnr TYPE kna1-kunnr.
DATA: lv_vkorg TYPE tvko-vkorg.
DATA: lv_vtweg TYPE tvtw-vtweg.
DATA: lt_xvbpa TYPE vbpavb_tab.
FIELD-SYMBOLS:
<fs_vbak> TYPE vbak,
<fs_likp> TYPE likp,
<fs_lips> TYPE lips,
<fs_xvbpa> TYPE vbpavb_tab.
*** ATTENTION:
*** THIS exit is also called from purchasing
*** (e.g. in stock transfer orders - doc type UB)
*** However, there (SAPMV45A)VBAK is not defined ...
*** and consequently the assign was not sucessful -->
*** THIS implementation only works when coming from
*** sales order processing / delivery processing.
CASE t_atpcsx-vbtyp.
WHEN 'C' OR 'I'. "standard order / FoC
ASSIGN ('(SAPMV45A)VBAK') TO <fs_vbak>.
IF <fs_vbak> IS ASSIGNED.
lv_vkorg = <fs_vbak>-vkorg.
lv_vtweg = <fs_vbak>-vtweg.
lv_kunnr = <fs_vbak>-kunnr.
UNASSIGN <fs_vbak>.
ENDIF.
*** get partners and transfer to local table.
ASSIGN ('(SAPMV45A)XVBPA[]') TO <fs_xvbpa>.
IF <fs_xvbpa> IS ASSIGNED.
lt_xvbpa = <fs_xvbpa>.
UNASSIGN <fs_xvbpa>.
ENDIF.
WHEN 'J'. "Delivery
ASSIGN ('(SAPMV50A)VBAK') TO <fs_vbak>.
IF <fs_vbak> IS ASSIGNED.
lv_vkorg = <fs_vbak>-vkorg.
lv_vtweg = <fs_vbak>-vtweg.
lv_kunnr = <fs_vbak>-kunnr.
UNASSIGN <fs_vbak>.
ENDIF.
*** second attempt:
IF lv_vkorg IS INITIAL.
ASSIGN ('(SAPMV50S)VBAK') TO <fs_vbak>.
IF <fs_vbak> IS ASSIGNED.
lv_vkorg = <fs_vbak>-vkorg.
lv_vtweg = <fs_vbak>-vtweg.
lv_kunnr = <fs_vbak>-kunnr.
UNASSIGN <fs_vbak>.
ENDIF.
ENDIF.
*** third attempt:
IF lv_vkorg IS INITIAL.
ASSIGN ('(SAPMV50A)LIKP') TO <fs_likp>.
IF <fs_likp> IS ASSIGNED.
lv_vkorg = <fs_likp>-vkorg.
lv_kunnr = <fs_likp>-kunag.
UNASSIGN <fs_likp>.
ENDIF.
ENDIF.
*** fourth attempt:
IF lv_vkorg IS INITIAL.
ASSIGN ('(SAPMV50S)LIKP') TO <fs_likp>.
IF <fs_likp> IS ASSIGNED.
lv_vkorg = <fs_likp>-vkorg.
lv_kunnr = <fs_likp>-kunag.
UNASSIGN <fs_likp>.
ENDIF.
ENDIF.
*** Also check VTWEG:
IF lv_vtweg IS INITIAL.
ASSIGN ('(SAPMV50A)LIPS') TO <fs_lips>.
IF <fs_lips> IS ASSIGNED.
lv_vtweg = <fs_lips>-vtweg.
UNASSIGN <fs_lips>.
ENDIF.
ENDIF.
*** still check... VTWEG
IF lv_vtweg IS INITIAL.
ASSIGN ('(SAPMV50S)LIPS') TO <fs_lips>.
IF <fs_lips> IS ASSIGNED.
lv_vtweg = <fs_lips>-vtweg.
UNASSIGN <fs_lips>.
ENDIF.
ENDIF.
*** get partners and transfer to local table.
*** First attempt - online (SAPMV50A)
ASSIGN ('(SAPMV50A)XVBPA[]') TO <fs_xvbpa>.
IF <fs_xvbpa> IS ASSIGNED.
lt_xvbpa = <fs_xvbpa>.
UNASSIGN <fs_xvbpa>.
ENDIF.
*** Second attempt - Background (SAPMV50S)
IF lt_xvbpa[] IS INITIAL.
ASSIGN ('(SAPMV50S)XVBPA[]') TO <fs_xvbpa>.
IF <fs_xvbpa> IS ASSIGNED.
lt_xvbpa = <fs_xvbpa>.
UNASSIGN <fs_xvbpa>.
ENDIF.
ENDIF.
ENDCASE.
IF lv_vkorg IS NOT INITIALAND lv_vtweg IS NOT INITIAL.
*** This is only executed when field symbol assigned !!
** 1. step generally activated ?
c_programm = 'ZXATPU02'.
c_funcname = 'EXIT_SAPLATPC_002'.
*** check whether the user exit is activated for this client:
CALL FUNCTION 'Y_0000CA_CHECK_USEREXIT'
EXPORTING
pi_programm = c_programm
pi_funcname = c_funcname
IMPORTING
pe_programm = w_programm
pe_funcname = w_funcname
pe_active = w_active
pe_subrc = w_subrc.
*** if userexit is active execute it.
IF ( w_active <> ' ' ) AND ( w_subrc = 0 ).
w_mandt = sy-mandt. w_mandt+2(1) = '0'.
** 2. Step
*----------------------------------------------------------------------*
* new: fill parameter table for organizational units
*----------------------------------------------------------------------*
function_name = 'EXIT_SAPLATPC_002'.
CLEAR wt_unit_params. REFRESH wt_unit_params.
wa_unit_params-unit = 'VKORG'.
wa_unit_params-value = lv_vkorg.
APPEND wa_unit_params TO wt_unit_params.
*----------------------------------------------------------------------*
* read table Y0000CA_EXIT_EXT extended exit control
*----------------------------------------------------------------------*
CALL FUNCTION 'Y_0000CA_CHECK_EXIT_EXT'
EXPORTING
pi_funcname = function_name
IMPORTING
pe_programm = w_programm
pe_funcname = w_funcname
pe_active = w_active
pe_subrc = w_subrc
TABLES
pt_unit_params = wt_unit_params.
*----------------------------------------------------------------------*
* if userexit is active execute it
*----------------------------------------------------------------------*
IF ( w_subrc = 0 ) AND ( w_active <> ' ' ).
CONCATENATE: 'Y0000SD_' w_programm '_BMENG_ROUNDING' INTO w_subp,
'Y0000SD_' w_programm '_ZXATPU02' INTO w_prog.
PERFORM (w_subp) IN PROGRAM (w_prog) IF FOUND
TABLES
t_atpcsx " STRUCTURE ATPCS
t_mdvex " STRUCTURE MDVE
USING
lv_vkorg " TYPE tvko-vkorg
lv_vtweg " TYPE tvtw-vtweg
lv_kunnr " TYPE knvv-kunnr
CHANGING
p_atpcc " TYPE ATPCC OPTIONAL
lt_xvbpa. " TYPE vbpavb_tab
ENDIF.
ENDIF.
ENDIF.
相關文章
- python中的變數怎樣開闢記憶體Python變數記憶體
- 有沒有動態建立資料表的輪子?
- JavaScript變數,資料和記憶體的相關問題JavaScript變數記憶體
- 【Rust學習】記憶體安全探秘:變數的所有權、引用與借用Rust記憶體變數
- 動態代理的記憶體分析記憶體
- block沒那麼難(二):block和變數的記憶體管理BloC變數記憶體
- 物件呼叫動態變數物件變數
- 利用ipcrm清除資料庫crash後沒有釋放的記憶體段資料庫記憶體
- JS高階(2)—— 資料 變數 記憶體JS變數記憶體
- 如何檢測有沒有記憶體溢位或資源佔用記憶體溢位
- 指標:存放記憶體地址的變數指標記憶體變數
- 如何製作地圖?有沒有什麼超好用的地圖軟體?地圖
- Transact-SQL 示例 - 如何在拼接的動態sql內呼叫外部變數SQL變數
- 【CDB】怎樣修改PDB的記憶體引數記憶體
- 簡單理解動態記憶體分配和靜態記憶體分配的區別記憶體
- 變數沒有宣告的錯誤變數
- CPU和記憶體如何互動的記憶體
- 沒有記憶體,怎麼還能跑程式呢記憶體
- 程式程式碼,常量,區域性變數,全域性變數在記憶體中的儲存位置變數記憶體
- 動態記憶體管理記憶體
- 動態記憶體分配記憶體
- Day30--如何引用其他的類
- 有沒有support這樣的開源軟體
- RealVNC,除了RealVNC,有沒有其他好用的VNC軟體VNC
- 資料庫物件比如表放入記憶體,行發生改變不會自動同步到記憶體的總結資料庫物件記憶體
- javascript判斷變數的資料型別程式碼例項JavaScript變數資料型別
- 鏈式呼叫 | 我的程式碼沒有else
- shell特定變數和Makefile中自動化變數的對比記憶變數
- 如何配置oracle資料庫伺服器的記憶體Oracle資料庫伺服器記憶體
- 記憶體資料庫如何發揮記憶體優勢?記憶體資料庫
- ABAP Memory Inspector 裡對動態記憶體物件的記憶體消耗度量方式記憶體物件
- C和C++的動態記憶體管理的區別C++記憶體
- hadoop 存到hdfs的資料沒有同步到其他機器上Hadoop
- 動態修改 NodeJS 程式中的變數值NodeJS變數
- 如何觀察程式的記憶體佔用情況記憶體
- project中的堆疊記憶體,記憶體地址引用,gc相關問題Project記憶體GC
- 記憶體中的資料儲存記憶體
- 基本資料型別與引用資料型別,及記憶體分配資料型別記憶體