ABAP顾问
分类:
2008-04-25 16:51:46
REPORT z_barry_test_selection .
DATA: tabfield TYPE rstabfield ,
itab_bukrs TYPE RANGE OF bukrs WITH HEADER LINE .
START-OF-SELECTION.
tabfield-tablename = 'T001' .
tabfield-fieldname = 'BUKRS' .
CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG'
EXPORTING
text = '公司代码'(001)
tab_and_field = tabfield
TABLES
range = itab_bukrs[]
EXCEPTIONS
no_range_tab = 1
cancelled = 2
internal_error = 3
invalid_fieldname = 4
OTHERS = 5.
LOOP AT itab_bukrs.
PERFORM write_wa USING itab_bukrs 'XXXX' 'X'.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form write_wa
*&---------------------------------------------------------------------*
FORM write_wa USING wa fieldmask newline.
DATA: str TYPE string ,
str_idx TYPE string ,
f_index TYPE i ,
f_len TYPE i .
FIELD-SYMBOLS:
f_len = STRLEN( fieldmask ).
IF newline = 'X'. WRITE / ''.ENDIF.
POSITION 1 .
DO .
ASSIGN COMPONENT sy-index OF STRUCTURE wa TO
IF sy-subrc <> 0 OR sy-index > f_len.
EXIT.
ELSE.
str_idx = sy-index .
CONDENSE str_idx.
f_index = sy-index - 1.
IF fieldmask+f_index(1) = 'X'.
str =
WRITE str.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "write_wa