使用方法CL_SALV_EX_UTIL=>FACTORY_RESULT_DATA_TABLE以及CL_SALV_BS_TT_UTIL=>IF_SALV_BS_TT_UTIL~TRANSFORM可以将ALV展示的内表转换成XML格式,熟悉ABAP开发的各位朋友应该对传入的参数都不陌生,其中FIELDCATLG和DATA属于必输项,其他内容按需填入即可。这边推荐使用函数LVC_FIELDCATALOG_MERGE获取结构的FIELDCATLOG。
代码语言:javascript复制 LR_RESULT_DATA = CL_SALV_EX_UTIL=>FACTORY_RESULT_DATA_TABLE(
T_SELECTED_ROWS = LT_SEL_ROWS
T_SELECTED_COLUMNS = LT_SEL_COLS
T_SELECTED_CELLS = LT_SEL_CELLS
R_DATA = LR_DATA
S_LAYOUT = LS_LAYOUT
T_FIELDCATALOG = IT_FIELDCATELOG[]
T_SORT = LT_SORT
T_FILTER = LT_FILTER
T_HYPERLINKS = LT_HYPERLINKS
S_CURRENT_CELL = LS_CURRENT_CELL
HYPERLINK_ENTRY_COLUMN = HYPERLINK_ENTRY_COLUMN
DROPDOWN_ENTRY_COLUMN = DROPDOWN_ENTRY_COLUMN
R_TOP_OF_LIST = LR_TOP_OF_LIST
R_END_OF_LIST = LR_END_OF_LIST
T_DROPDOWN_VALUES = LT_DROPDOWN_VALUES ).
CASE CL_SALV_BS_A_XML_BASE=>GET_VERSION( ).
WHEN IF_SALV_BS_XML=>VERSION_25.
L_VERSION = IF_SALV_BS_XML=>VERSION_25.
WHEN IF_SALV_BS_XML=>VERSION_26.
L_VERSION = IF_SALV_BS_XML=>VERSION_26.
ENDCASE.
XML_FLAVOUR = IF_SALV_BS_C_TT=>C_TT_XML_FLAVOUR_EXPORT.
LS_XML_CHOICE-XML_TYPE = '04'.
CALL METHOD CL_SALV_BS_TT_UTIL=>IF_SALV_BS_TT_UTIL~TRANSFORM
EXPORTING
XML_TYPE = LS_XML_CHOICE-XML_TYPE
XML_VERSION = L_VERSION
R_RESULT_DATA = LR_RESULT_DATA
XML_FLAVOUR = XML_FLAVOUR
GUI_TYPE = IF_SALV_BS_XML=>C_GUI_TYPE_GUI
IMPORTING
XML = XML.
获取之后可以使用函数组SCMS_CONV内的转换函数转成各种其他格式