求助:Web Dynpro for ABAP的Table如何得到被选中的多行
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了求助:Web Dynpro for ABAP的Table如何得到被选中的多行相关的知识,希望对你有一定的参考价值。
对于Web Dynpro for ABAP的Table UI Element,现在允许用户选中多行,那么怎么样才能知道哪些行是被选中的呢,请高手指教。
一般情况下,在Web Dynpro for ABAP的Table中,不推荐使用行多选,因为Web Dynpro for ABAP的Table于abap中alv的mark选择方式不同。
alv无论单选还是多选,只要判断mark就是选择的行。
但是在Web Dynpro for ABAP的Table中单选个多选的获取方式不一样,
你如果注意看的话,单选跟多选的颜色有点不一样。
所以无论是业务上还是程序上,会导致无法正确判断用是是否是 多选+单选 选择了数据,
还是只选择 多选的。
建议该用checkbox。
最后解答你的问题。。
多选的时候Web Dynpro for ABAP的Table是以elements形式存到一个内表中的。。
上面的兄弟说的对。。
IF_WD_CONTEXT_NODE 中有method:GET_SELECTED_ELEMENTS
但是不包括单选的行。。
如果想取数据,就得循环了。。
loop at <ELEMENTS> into <ELEMENT>
ELEMENT->get_static_attributes(
... ...
).
endloop. 参考技术A 两种常用方法,只提供思路,具体代码就不多说了。
1:此TABLE的第一个项目绝大多数情况下是‘选择行’,LOOP当前TABLE,HEAD中此项目为'X'的行,就是选中的行。
2:调用METHOD,获取当前选择行数。 参考技术B 一种方法:node节点selection设置为0~n,选择的时候按ctrl点击,可以选中多行,另一种方法加checkbox,这个更简单。 参考技术C 接口:IF_WD_CONTEXT_NODE 中有method:GET_SELECTED_ELEMENTS
1.获取相应的context node
2.调用上面的方法,接收的参数就是选中的context element
ABAP EWM PRDI交货单过账
/n/scwm/prdi 交货单过账
DATA: lo_sp_inb TYPE REF TO /scwm/cl_sp_prd_inb,
lo_adapter_handler TYPE REF TO /scwm/cl_dlv_handler_adapter,
ls_details TYPE /scmb/s_default_values_det,
ls_dynpro_data TYPE /scmb/s_dynpro_data,
ls_default_values TYPE /scmb/s_default_values,
lv_rejected TYPE boole_d,
lt_return_codes TYPE /scdl/t_sp_return_code,
ls_k_hu TYPE /scwm/s_sp_k_hu,
lt_k_hu TYPE /scwm/t_sp_k_hu,
lt_a_hu TYPE /scwm/t_sp_a_hu,
ls_docid TYPE /scwm/s_docid,
lt_docid TYPE /scwm/tt_docid,
ls_k_head TYPE /scdl/s_sp_k_head,
lt_k_head TYPE /scdl/t_sp_k_head,
ls_a_head TYPE /scdl/s_sp_a_head,
ls_q_head TYPE /scwm/s_sp_q_head,
lt_h_prdi TYPE /scwm/t_sp_a_head_prdi,
lv_return TYPE xsdboolean.
FREE: lt_k_head.
CLEAR ls_k_head.
FREE: lt_k_hu.
ls_k_hu-docid = gs_gr_01-docid .
ls_k_hu-huid = ps_gr_02-guid_hu.
APPEND ls_k_hu TO lt_k_hu.
ls_k_head-docid = gs_gr_01-docid .
APPEND ls_k_head TO lt_k_head.
ls_q_head-docno_id = gs_gr_01-docno.
TRY.
CREATE OBJECT lo_adapter_handler.
CREATE OBJECT lo_sp_inb
EXPORTING
iv_mode = /scdl/cl_sp=>sc_mode_classic
io_attribute_handler = lo_adapter_handler
io_message_handler = lo_adapter_handler.
ENDTRY.
ls_details-v_fieldname = 'LGNUM'.
ls_details-v_mandatory = abap_true.
ls_details-v_memoryid = '/SCWM/LGN'.
ls_details-v_no_dropdown = 'X'.
APPEND ls_details TO ls_default_values-t_details.
CLEAR ls_details.
ls_details-v_fieldname = 'RECEIVING_OFFICE'.
ls_details-v_no_dropdown = 'X'.
APPEND ls_details TO ls_default_values-t_details.
ls_details-v_fieldname = 'ENTITLED'.
ls_details-v_no_dropdown = 'X'.
APPEND ls_details TO ls_default_values-t_details.
ls_details-v_fieldname = 'HU_DISPLAY'.
APPEND ls_details TO ls_default_values-t_details.
ls_default_values-v_identifier = '/SCWM/PRDI'.
ls_default_values-v_values_structure = '/SCWM/S_SP_DEFAULT'.
ls_default_values-v_extended = abap_true.
SET PARAMETER ID '/SCWM/LGN' FIELD gs_rsrc-lgnum.
/scmb/cl_base=>set_process_data( io_attribute_handler = lo_adapter_handler->mo_attr_handler
io_service_provider = lo_sp_inb
io_message_handler = lo_adapter_handler->mo_msg_handler
is_dynpro_data = ls_dynpro_data
is_default_values = ls_default_values
iv_disable_standard_save = abap_true ).
CALL METHOD /scmb/cl_base=>end_of_initialization.
/scwm/cl_tm=>set_lgnum( gs_rsrc-lgnum ).
CALL METHOD lo_sp_inb->lock
EXPORTING
inkeys = lt_k_head
lockmode = /scdl/if_sp1_locking=>sc_exclusive_lock
aspect = /scwm/if_sp_c=>sc_asp_head
IMPORTING
rejected = lv_rejected
return_codes = lt_return_codes.
READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.
IF sy-subrc = 0 OR lv_rejected = abap_true.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
CALL METHOD lo_sp_inb->/scmb/if_sp_query~execute
EXPORTING
inparam = ls_q_head
query = '/SCDL/QRY_HEAD'
IMPORTING
outrecords = lt_h_prdi
rejected = lv_rejected.
IF lv_rejected = abap_true.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
CALL METHOD lo_sp_inb->execute
EXPORTING
aspect = /scwm/if_sp_c=>sc_asp_hu
inkeys = lt_k_hu
action = /scwm/if_sp_c=>sc_act_hu_post_gm
relation = /scwm/if_sp_c=>sc_rel_head_to_hu
relation_inkey = ls_k_head
IMPORTING
outrecords = lt_a_hu
relation_outrecord = ls_a_head
rejected = lv_rejected
return_codes = lt_return_codes.
READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.
IF sy-subrc = 0 OR lv_rejected = abap_true.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
CALL METHOD lo_sp_inb->/scmb/if_sp_transaction~save
IMPORTING
rejected = lv_rejected.
IF lv_rejected = abap_false.
COMMIT WORK AND WAIT.
CALL METHOD lo_sp_inb->/scmb/if_sp_transaction~cleanup
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_commit.
CALL METHOD /scwm/cl_tm=>cleanup( ).
*******清空
CLEAR ps_gr_02.
" PERFORM disp_message USING 'ZEWM01' 'S' '000' '过账成功' '' '' ''.
ELSE.
ROLLBACK WORK.
CALL METHOD lo_sp_inb->/scmb/if_sp_transaction~cleanup
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_end.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
以上是关于求助:Web Dynpro for ABAP的Table如何得到被选中的多行的主要内容,如果未能解决你的问题,请参考以下文章