ABAP中的F4帮助怎么用
生活随笔
收集整理的這篇文章主要介紹了
ABAP中的F4帮助怎么用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ABAP中的F4幫助怎么用??
當我們在sap的界面上,焦點放到一個字段上的時候,按F4,會出現選擇或者搜索的界面,這就是abap中的f4幫助。?
?
有多種實現f4幫助的方法,現在就把我指導的一點點說出來:?
?
1?,?固定值。?我們在Domain?中可以定義?value?range?,在?value?range?中定義的值,就可以出現在f4幫助中。這是最簡單的實現f4幫助的方法。?
?
2?,數據類型關聯。?加入我們在選擇屏幕上定義一個?dats?類型的?參數,她就自動調用了日期類型的f4幫助。?
?
3,?se11?創建?f4幫助。?
(?
將se11創建的搜索幫助掛到表上的時候,又可以分為以下三種類型:?
?
用檢查表實現輸入幫助?
字段的外部搜索幫助附件?
數據元素的明確搜索幫助附件?
?
她們之間有啥區別,我也不知道。等我知道了再補充。?
)?
?
用?se11?創建?的?f4?幫助?可以分為兩類:?
?
基本搜索幫助?
集中搜索幫助?
?
基本搜索幫助是搜索幫助的最小單元,集中搜索幫助還可以包括集中搜索幫助,也可以包括基本搜索幫助。?
?
在基本搜索幫助中?可以定義?數據來源,但是集中搜索幫助不可以定義數據來源。?
?
無論是基本搜素偶幫助還是集中搜索幫助都包含輸出輸出字段定義,并可以定義搜索幫助exit,用于調用一個遠程的?function?module?來對數據進行?過濾和處理。?
?
?
如果將這些搜索幫助與表掛上之后,我們在使用的時候就會自動出現該搜索幫助。?
?
在?synpro?程序中。也可以通過屬性(屬性名叫?搜索幫助)為字段?重新指定自定義的搜索幫助?
?
?
也可以在?選擇屏幕或者?screen?中重新指定搜索幫助,下面舉幾個例子來說明使用的方法?
?
一,?根據搜索幫助的名字?來指定搜索幫助?
1?選擇屏幕?
?
REPORT?z_ljc_078?LINE-SIZE?200.?
parameters:?mama(18)?type?c.?
INITIALIZATION.?
AT?SELECTION-SCREEN?on?value-request?for?mama.?
DATA:v_mama?LIKE?help_info-dynprofld.?
v_mama?=?'MAMA'.?
CALL?FUNCTION?'F4IF_FIELD_VALUE_REQUEST'?
EXPORTING?
tabname?=?''?
fieldname?=?''?
SEARCHHELP?=?'ZFI_CRC_001'?
DYNPPROG?=?SY-REPID?
DYNPNR?=?SY-DYNNR?
DYNPROFIELD?=?v_mama?
.?
start-OF-SELECTION.?
write?mama.?
?
2?dynpro?screen?
?
流邏輯:?
?
PROCESS?BEFORE?OUTPUT.?
MODULE?INIT.?
PROCESS?AFTER?INPUT.?
PROCESS?ON?VALUE-REQUEST.?
FIELD?matnr?MODULE?VALUE_matnr.?
?
report?:?
MODULE?init?OUTPUT.?
progname?=?sy-repid.?
dynnum?=?sy-dynnr.?
ENDMODULE.?
?
?
MODULE?value_matnr?INPUT.?
CALL?FUNCTION?'F4IF_FIELD_VALUE_REQUEST'?
EXPORTING?
tabname?=?''?
fieldname?=?''?
SEARCHHELP?=?'MAT1'?
DYNPPROG?=?SY-REPID?
DYNPNR?=?SY-DYNNR?
DYNPROFIELD?=?'MATNR'?
ENDMODULE.?
?
?
無論是在選擇屏幕或者是dynpro中,如果指定了searchhelp?屬性,則?tabname?和?fieldname?屬性就不起作用了。?
當不指定?searchhelp?屬性,而制定?了?tabname?和?fieldname?屬性,則會調用?tabname-fieldname?掛接的搜素偶幫助。?
?
CALL?FUNCTION?'F4IF_FIELD_VALUE_REQUEST'?
EXPORTING?
tabname?=?'mara'?
fieldname?=?'matnr'?
*?SEARCHHELP?=?''?
DYNPPROG?=?SY-REPID?
DYNPNR?=?SY-DYNNR?
DYNPROFIELD?=?'MATNR'?
?
?
?
二,?用內表生成f4幫助?
?
1?選擇屏幕?
TYPES:?BEGIN?OF?ty_aenr,?
aennr?type?aenr-aennr,?
datuv?type?aenr-datuv,?
aenam?type?aenr-aenam,?
aegru?type?aenr-aegru,?
ccart?type?aenr-ccart,?
aetxt?type?aenr-aetxt,?
END?OF?ty_aenr.?
?
DATA:?gt_aenr?TYPE?TABLE?OF?ty_aenr,?
gs_aenr?TYPE?ty_aenr.?
?
INITIALIZATION.?
PERFORM?frm_read_aenr.?
?
?
*?獲得圖幅的f4幫助?
AT?SELECTION-SCREEN?ON?VALUE-REQUEST?FOR?so_aennr-low.?
PERFORM?frm_search_help_file.?
?
?
?
?
FORM?frm_read_aenr?.?
DATA?l_objnr?TYPE?jest-objnr.?
DATA?l_line?TYPE?bsvx-sttxt.?"?訂單狀態?
SELECT?a~aennr?a~datuv?a~aenam?a~aegru?a~ccart?a~aetxt?
INTO?TABLE?gt_aenr?
FROM?aenr?as?a?
inner?join?USGRP_USER?as?c?
on?a~annam?=?c~bname?
where?c~usergroup?=?'CCCAR'.?
loop?at?gt_aenr?into?gs_aenr.?
CLEAR:l_objnr,l_line.?
***組建更改編號對象號?
CONCATENATE?'CD'?gs_aenr-aennr?INTO?l_objnr.?
***獲得系統狀態,調用函數?
CALL?FUNCTION?'STATUS_TEXT_EDIT'?
EXPORTING?
objnr?=?l_objnr?
spras?=?sy-langu?
IMPORTING?
line?=?l_line?
EXCEPTIONS?
object_not_found?=?1?
OTHERS?=?2.?
***判斷該更改單是否批準?
IF?sy-subrc?=?0.?
SEARCH?l_line?FOR?'ECOR'.?
IF?sy-subrc?<>?0.?
DELETE?gt_aenr.?"沒有下達的就刪掉?
ENDIF.?
ENDIF.?
endloop.?
.?
ENDFORM.?"?frm_read_proj?
?
?
FORM?frm_search_help_file?.?
DATA:v_aennr?LIKE?help_info-dynprofld.?
v_aennr?=?'SO_aennr'.?
CALL?FUNCTION?'F4IF_INT_TABLE_VALUE_REQUEST'?
EXPORTING?
retfield?=?'AENNR'?
value_org?=?'S'?
dynprofield?=?v_aennr?
dynpprog?=?sy-repid?
dynpnr?=?sy-dynnr?
TABLES?
value_tab?=?gt_aenr?
EXCEPTIONS?
parameter_error?=?1?
no_values_found?=?2?
OTHERS?=?3.?
*?IF?sy-subrc?<>?0.?
*?WRITE:?'error'.?
*?ENDIF.?
ENDFORM.?"?frm_search_help_file?
?
2?dynpro?screen:?
?
流邏輯:?
?
PROCESS?BEFORE?OUTPUT.?
MODULE?INIT.?
PROCESS?AFTER?INPUT.?
PROCESS?ON?VALUE-REQUEST.?
FIELD?aenam?MODULE?VALUE_aenam.?
?
?
report?:?
?
TYPES:?BEGIN?OF?values,?
aenam?TYPE?mara-aenam,?
matnr?TYPE?mara-matnr,?
END?OF?values.?
DATA:?matnr(18)?TYPE?c,?
aenam(12)?TYPE?c.?
DATA:?progname?TYPE?sy-repid,?
dynnum?TYPE?sy-dynnr?
.?
CALL?SCREEN?100.?
MODULE?init?OUTPUT.?
progname?=?sy-repid.?
dynnum?=?sy-dynnr.?
ENDMODULE.?
MODULE?value_aenam?INPUT.?
select?aenam?matnr?into?table?values_tab?from?mara?where?matnr?BETWEEN?'000000000000001199'?and?'000000000000001250'.?
CALL?FUNCTION?'F4IF_INT_TABLE_VALUE_REQUEST'?
EXPORTING?
retfield?=?'AENAM'?
dynpprog?=?progname?
dynpnr?=?dynnum?
dynprofield?=?'AENAM'?
value_org?=?'S'?
TABLES?
value_tab?=?values_tab.?
ENDMODULE.?
?
當然,也可以根據一個?字段的選擇?過濾另一個字段的f4幫助的?數據。下面給出一個在?dynpro?screen?中的例子。?
在選擇屏幕上就不給出例子了。實現的方法都差不多。甚至更簡單。?
?
?
流邏輯:?
?
PROCESS?BEFORE?OUTPUT.?
*?MODULE?STATUS_0100.?
*?
MODULE?INIT.?
PROCESS?AFTER?INPUT.?
*?MODULE?USER_COMMAND_0100.?
MODULE?CANCEL?AT?EXIT-COMMAND.?
PROCESS?ON?VALUE-REQUEST.?
FIELD?matnr?MODULE?VALUE_matnr.?
FIELD?aenam?MODULE?VALUE_aenam.?
?
?
report?:?
?
*&?
TYPES:?BEGIN?OF?values,?
aenam?TYPE?mara-aenam,?
matnr?TYPE?mara-matnr,?
END?OF?values.?
DATA:?matnr(18)?TYPE?c,?
aenam(12)?TYPE?c.?
DATA:?progname?TYPE?sy-repid,?
dynnum?TYPE?sy-dynnr,?
dynpro_values?TYPE?TABLE?OF?dynpread,?
field_value?LIKE?LINE?OF?dynpro_values,?
values_tab?TYPE?TABLE?OF?values.?
CALL?SCREEN?100.?
MODULE?init?OUTPUT.?
progname?=?sy-repid.?
dynnum?=?sy-dynnr.?
CLEAR:?field_value,?dynpro_values.?
field_value-fieldname?=?'AENAM'.?
APPEND?field_value?TO?dynpro_values.?
ENDMODULE.?
MODULE?cancel?INPUT.?
LEAVE?PROGRAM.?
ENDMODULE.?
MODULE?value_aenam?INPUT.?
select?aenam?matnr?into?table?values_tab?from?mara?where?matnr?BETWEEN?'000000000000001199'?and?'000000000000001250'.?
CALL?FUNCTION?'F4IF_INT_TABLE_VALUE_REQUEST'?
EXPORTING?
retfield?=?'AENAM'?
dynpprog?=?progname?
dynpnr?=?dynnum?
dynprofield?=?'AENAM'?
value_org?=?'S'?
TABLES?
value_tab?=?values_tab.?
ENDMODULE.?
MODULE?value_matnr?INPUT.?
CALL?FUNCTION?'DYNP_VALUES_READ'?
EXPORTING?
dyname?=?progname?
dynumb?=?dynnum?
translate_to_upper?=?'X'?
TABLES?
dynpfields?=?dynpro_values.?
READ?TABLE?dynpro_values?INDEX?1?INTO?field_value.?
SELECT?AENAM?MATNR?
FROM?MARA?
INTO?CORRESPONDING?FIELDS?OF?TABLE?values_tab?
WHERE?AENAM?=?field_value-fieldvalue.?
CALL?FUNCTION?'F4IF_INT_TABLE_VALUE_REQUEST'?
EXPORTING?
retfield?=?'AENAM'?
dynpprog?=?progname?
dynpnr?=?dynnum?
dynprofield?=?'MATNR'?
value_org?=?'S'?
TABLES?
value_tab?=?values_tab.?
ENDMODULE.?
?
當我們在sap的界面上,焦點放到一個字段上的時候,按F4,會出現選擇或者搜索的界面,這就是abap中的f4幫助。?
?
有多種實現f4幫助的方法,現在就把我指導的一點點說出來:?
?
1?,?固定值。?我們在Domain?中可以定義?value?range?,在?value?range?中定義的值,就可以出現在f4幫助中。這是最簡單的實現f4幫助的方法。?
?
2?,數據類型關聯。?加入我們在選擇屏幕上定義一個?dats?類型的?參數,她就自動調用了日期類型的f4幫助。?
?
3,?se11?創建?f4幫助。?
(?
將se11創建的搜索幫助掛到表上的時候,又可以分為以下三種類型:?
?
用檢查表實現輸入幫助?
字段的外部搜索幫助附件?
數據元素的明確搜索幫助附件?
?
她們之間有啥區別,我也不知道。等我知道了再補充。?
)?
?
用?se11?創建?的?f4?幫助?可以分為兩類:?
?
基本搜索幫助?
集中搜索幫助?
?
基本搜索幫助是搜索幫助的最小單元,集中搜索幫助還可以包括集中搜索幫助,也可以包括基本搜索幫助。?
?
在基本搜索幫助中?可以定義?數據來源,但是集中搜索幫助不可以定義數據來源。?
?
無論是基本搜素偶幫助還是集中搜索幫助都包含輸出輸出字段定義,并可以定義搜索幫助exit,用于調用一個遠程的?function?module?來對數據進行?過濾和處理。?
?
?
如果將這些搜索幫助與表掛上之后,我們在使用的時候就會自動出現該搜索幫助。?
?
在?synpro?程序中。也可以通過屬性(屬性名叫?搜索幫助)為字段?重新指定自定義的搜索幫助?
?
?
也可以在?選擇屏幕或者?screen?中重新指定搜索幫助,下面舉幾個例子來說明使用的方法?
?
一,?根據搜索幫助的名字?來指定搜索幫助?
1?選擇屏幕?
?
REPORT?z_ljc_078?LINE-SIZE?200.?
parameters:?mama(18)?type?c.?
INITIALIZATION.?
AT?SELECTION-SCREEN?on?value-request?for?mama.?
DATA:v_mama?LIKE?help_info-dynprofld.?
v_mama?=?'MAMA'.?
CALL?FUNCTION?'F4IF_FIELD_VALUE_REQUEST'?
EXPORTING?
tabname?=?''?
fieldname?=?''?
SEARCHHELP?=?'ZFI_CRC_001'?
DYNPPROG?=?SY-REPID?
DYNPNR?=?SY-DYNNR?
DYNPROFIELD?=?v_mama?
.?
start-OF-SELECTION.?
write?mama.?
?
2?dynpro?screen?
?
流邏輯:?
?
PROCESS?BEFORE?OUTPUT.?
MODULE?INIT.?
PROCESS?AFTER?INPUT.?
PROCESS?ON?VALUE-REQUEST.?
FIELD?matnr?MODULE?VALUE_matnr.?
?
report?:?
MODULE?init?OUTPUT.?
progname?=?sy-repid.?
dynnum?=?sy-dynnr.?
ENDMODULE.?
?
?
MODULE?value_matnr?INPUT.?
CALL?FUNCTION?'F4IF_FIELD_VALUE_REQUEST'?
EXPORTING?
tabname?=?''?
fieldname?=?''?
SEARCHHELP?=?'MAT1'?
DYNPPROG?=?SY-REPID?
DYNPNR?=?SY-DYNNR?
DYNPROFIELD?=?'MATNR'?
ENDMODULE.?
?
?
無論是在選擇屏幕或者是dynpro中,如果指定了searchhelp?屬性,則?tabname?和?fieldname?屬性就不起作用了。?
當不指定?searchhelp?屬性,而制定?了?tabname?和?fieldname?屬性,則會調用?tabname-fieldname?掛接的搜素偶幫助。?
?
CALL?FUNCTION?'F4IF_FIELD_VALUE_REQUEST'?
EXPORTING?
tabname?=?'mara'?
fieldname?=?'matnr'?
*?SEARCHHELP?=?''?
DYNPPROG?=?SY-REPID?
DYNPNR?=?SY-DYNNR?
DYNPROFIELD?=?'MATNR'?
?
?
?
二,?用內表生成f4幫助?
?
1?選擇屏幕?
TYPES:?BEGIN?OF?ty_aenr,?
aennr?type?aenr-aennr,?
datuv?type?aenr-datuv,?
aenam?type?aenr-aenam,?
aegru?type?aenr-aegru,?
ccart?type?aenr-ccart,?
aetxt?type?aenr-aetxt,?
END?OF?ty_aenr.?
?
DATA:?gt_aenr?TYPE?TABLE?OF?ty_aenr,?
gs_aenr?TYPE?ty_aenr.?
?
INITIALIZATION.?
PERFORM?frm_read_aenr.?
?
?
*?獲得圖幅的f4幫助?
AT?SELECTION-SCREEN?ON?VALUE-REQUEST?FOR?so_aennr-low.?
PERFORM?frm_search_help_file.?
?
?
?
?
FORM?frm_read_aenr?.?
DATA?l_objnr?TYPE?jest-objnr.?
DATA?l_line?TYPE?bsvx-sttxt.?"?訂單狀態?
SELECT?a~aennr?a~datuv?a~aenam?a~aegru?a~ccart?a~aetxt?
INTO?TABLE?gt_aenr?
FROM?aenr?as?a?
inner?join?USGRP_USER?as?c?
on?a~annam?=?c~bname?
where?c~usergroup?=?'CCCAR'.?
loop?at?gt_aenr?into?gs_aenr.?
CLEAR:l_objnr,l_line.?
***組建更改編號對象號?
CONCATENATE?'CD'?gs_aenr-aennr?INTO?l_objnr.?
***獲得系統狀態,調用函數?
CALL?FUNCTION?'STATUS_TEXT_EDIT'?
EXPORTING?
objnr?=?l_objnr?
spras?=?sy-langu?
IMPORTING?
line?=?l_line?
EXCEPTIONS?
object_not_found?=?1?
OTHERS?=?2.?
***判斷該更改單是否批準?
IF?sy-subrc?=?0.?
SEARCH?l_line?FOR?'ECOR'.?
IF?sy-subrc?<>?0.?
DELETE?gt_aenr.?"沒有下達的就刪掉?
ENDIF.?
ENDIF.?
endloop.?
.?
ENDFORM.?"?frm_read_proj?
?
?
FORM?frm_search_help_file?.?
DATA:v_aennr?LIKE?help_info-dynprofld.?
v_aennr?=?'SO_aennr'.?
CALL?FUNCTION?'F4IF_INT_TABLE_VALUE_REQUEST'?
EXPORTING?
retfield?=?'AENNR'?
value_org?=?'S'?
dynprofield?=?v_aennr?
dynpprog?=?sy-repid?
dynpnr?=?sy-dynnr?
TABLES?
value_tab?=?gt_aenr?
EXCEPTIONS?
parameter_error?=?1?
no_values_found?=?2?
OTHERS?=?3.?
*?IF?sy-subrc?<>?0.?
*?WRITE:?'error'.?
*?ENDIF.?
ENDFORM.?"?frm_search_help_file?
?
2?dynpro?screen:?
?
流邏輯:?
?
PROCESS?BEFORE?OUTPUT.?
MODULE?INIT.?
PROCESS?AFTER?INPUT.?
PROCESS?ON?VALUE-REQUEST.?
FIELD?aenam?MODULE?VALUE_aenam.?
?
?
report?:?
?
TYPES:?BEGIN?OF?values,?
aenam?TYPE?mara-aenam,?
matnr?TYPE?mara-matnr,?
END?OF?values.?
DATA:?matnr(18)?TYPE?c,?
aenam(12)?TYPE?c.?
DATA:?progname?TYPE?sy-repid,?
dynnum?TYPE?sy-dynnr?
.?
CALL?SCREEN?100.?
MODULE?init?OUTPUT.?
progname?=?sy-repid.?
dynnum?=?sy-dynnr.?
ENDMODULE.?
MODULE?value_aenam?INPUT.?
select?aenam?matnr?into?table?values_tab?from?mara?where?matnr?BETWEEN?'000000000000001199'?and?'000000000000001250'.?
CALL?FUNCTION?'F4IF_INT_TABLE_VALUE_REQUEST'?
EXPORTING?
retfield?=?'AENAM'?
dynpprog?=?progname?
dynpnr?=?dynnum?
dynprofield?=?'AENAM'?
value_org?=?'S'?
TABLES?
value_tab?=?values_tab.?
ENDMODULE.?
?
當然,也可以根據一個?字段的選擇?過濾另一個字段的f4幫助的?數據。下面給出一個在?dynpro?screen?中的例子。?
在選擇屏幕上就不給出例子了。實現的方法都差不多。甚至更簡單。?
?
?
流邏輯:?
?
PROCESS?BEFORE?OUTPUT.?
*?MODULE?STATUS_0100.?
*?
MODULE?INIT.?
PROCESS?AFTER?INPUT.?
*?MODULE?USER_COMMAND_0100.?
MODULE?CANCEL?AT?EXIT-COMMAND.?
PROCESS?ON?VALUE-REQUEST.?
FIELD?matnr?MODULE?VALUE_matnr.?
FIELD?aenam?MODULE?VALUE_aenam.?
?
?
report?:?
?
*&?
TYPES:?BEGIN?OF?values,?
aenam?TYPE?mara-aenam,?
matnr?TYPE?mara-matnr,?
END?OF?values.?
DATA:?matnr(18)?TYPE?c,?
aenam(12)?TYPE?c.?
DATA:?progname?TYPE?sy-repid,?
dynnum?TYPE?sy-dynnr,?
dynpro_values?TYPE?TABLE?OF?dynpread,?
field_value?LIKE?LINE?OF?dynpro_values,?
values_tab?TYPE?TABLE?OF?values.?
CALL?SCREEN?100.?
MODULE?init?OUTPUT.?
progname?=?sy-repid.?
dynnum?=?sy-dynnr.?
CLEAR:?field_value,?dynpro_values.?
field_value-fieldname?=?'AENAM'.?
APPEND?field_value?TO?dynpro_values.?
ENDMODULE.?
MODULE?cancel?INPUT.?
LEAVE?PROGRAM.?
ENDMODULE.?
MODULE?value_aenam?INPUT.?
select?aenam?matnr?into?table?values_tab?from?mara?where?matnr?BETWEEN?'000000000000001199'?and?'000000000000001250'.?
CALL?FUNCTION?'F4IF_INT_TABLE_VALUE_REQUEST'?
EXPORTING?
retfield?=?'AENAM'?
dynpprog?=?progname?
dynpnr?=?dynnum?
dynprofield?=?'AENAM'?
value_org?=?'S'?
TABLES?
value_tab?=?values_tab.?
ENDMODULE.?
MODULE?value_matnr?INPUT.?
CALL?FUNCTION?'DYNP_VALUES_READ'?
EXPORTING?
dyname?=?progname?
dynumb?=?dynnum?
translate_to_upper?=?'X'?
TABLES?
dynpfields?=?dynpro_values.?
READ?TABLE?dynpro_values?INDEX?1?INTO?field_value.?
SELECT?AENAM?MATNR?
FROM?MARA?
INTO?CORRESPONDING?FIELDS?OF?TABLE?values_tab?
WHERE?AENAM?=?field_value-fieldvalue.?
CALL?FUNCTION?'F4IF_INT_TABLE_VALUE_REQUEST'?
EXPORTING?
retfield?=?'AENAM'?
dynpprog?=?progname?
dynpnr?=?dynnum?
dynprofield?=?'MATNR'?
value_org?=?'S'?
TABLES?
value_tab?=?values_tab.?
ENDMODULE.?
?
總結
以上是生活随笔為你收集整理的ABAP中的F4帮助怎么用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java并发编程(04):线程间通信,等
- 下一篇: 2008年第四季度开发者Top 100