TABLES: kna1.标签:输出,gt,rab,land1,ENDIF,kna1,range,实例,name1 From: https://blog.51cto.com/u_15903986/5916069
data: begin of gt_kna1 occurs 0,
name1 type kna1-name1,
land1 type kna1-land1,
end of gt_kna1.
DATA: rab TYPE RANGE OF kna1-name1 WITH HEADER LINE,
line LIKE LINE OF rab.
PARAMETERS: s_desc RADIOBUTTON GROUP gr1,
s_asc RADIOBUTTON GROUP gr1,
gmn AS CHECKBOX DEFAULT 'X',
brt AS CHECKBOX DEFAULT 'X',
amc AS CHECKBOX DEFAULT 'X'.
AT SELECTION-SCREEN.
IF gmn <> 'X' AND brt <> 'X' AND amc <> 'X'.
MESSAGE e001(00) WITH text-001.
ENDIF.
DEFINE build_range.
rab-sign = 'I'.
rab-option = 'EQ'.
rab-low = &1.
append rab.
END-OF-DEFINITION.
IF gmn EQ 'X'.
build_range 'DE'.
ENDIF.
IF brt EQ 'X'.
build_range 'GB'.
ENDIF.
IF amc EQ 'X'.
build_range 'US'.
ENDIF.
START-OF-SELECTION.
PERFORM F_GET_data tables gt_kna1 rab.
perform f_display_data tables gt_kna1 using s_desc s_asc.
end-of-selection.
form F_GET_DATA tables p_kna1 structure gt_kna1
"Insert correct name for <...>
p_rab structure rab.
select name1 land1
into corresponding fields of table p_kna1
from kna1
where land1 in p_rab.
IF sy-subrc <> 0.
message i002(00) with text-002.
stop.
ENDIF.
endform. " F_GET_DATA
form F_DISPLAY_DATA tables p_gt_kna1 structure gt_kna1
"Insert correct name for <...>
using p_s_desc
p_s_asc.
IF p_s_desc eq 'X'.
sort p_gt_kna1 by name1 descending.
else.
sort p_gt_kna1 by name1 ascending.
ENDIF.
LOOP AT p_gt_kna1.
write:/ p_gt_kna1-name1, p_gt_kna1-land1.
ENDLOOP.
endform. " F_DISPLAY_DATA