-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZ_TEST_DOCX.abap
90 lines (54 loc) · 1.82 KB
/
Z_TEST_DOCX.abap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
*&---------------------------------------------------------------------*
*& Report Z_TEST_DOCX
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_test_docx.
** òóò êëàññ
INCLUDE zcl_docx_class.
START-OF-SELECTION.
DATA
: lo_docx TYPE REF TO lcl_docx
, lr_data TYPE REF TO lcl_recursive_data
.
CREATE OBJECT lr_data.
lr_data->append_key_value( iv_key = 'name' iv_value = sy-uname ).
lr_data->append_key_value( iv_key = 'date' iv_value = |{ sy-datum DATE = ENVIRONMENT }| ).
lr_data->append_key_value( iv_key = 'time' iv_value = |{ sy-uzeit TIME = ENVIRONMENT }| ).
DATA
: lt_sflight TYPE TABLE OF sflight
.
SELECT *
INTO TABLE lt_sflight
UP TO 5 ROWS
FROM sflight.
lr_data->append_key_table( iv_key = 'line1' iv_table = lt_sflight ).
DATA
: lt_carrid TYPE TABLE OF s_carr_id
, lt_sflight1 TYPE TABLE OF sflight
, lr_doc TYPE REF TO lcl_recursive_data
.
SELECT DISTINCT carrid INTO TABLE lt_carrid
UP TO 5 ROWS
FROM sflight.
LOOP AT lt_carrid ASSIGNING FIELD-SYMBOL(<fs_carrid>).
REFRESH lt_sflight1.
SELECT * INTO TABLE lt_sflight1
FROM sflight
UP TO 5 ROWS
WHERE carrid = <fs_carrid>.
lr_doc = lr_data->create_document( 'DOC1' ).
lr_doc->append_key_value( iv_key = 'carrid1' iv_value = <fs_carrid> ).
lr_doc->append_key_table( iv_key = 'line2' iv_table = lt_sflight1 ).
ENDLOOP.
CREATE OBJECT lo_docx .
lo_docx->load_smw0( 'Z_TEST_DOCX' ).
lo_docx->map_data( EXPORTING ir_data = lr_data ).
CALL METHOD lo_docx->save
EXPORTING
on_desktop = 'X'
iv_folder = 'report'
iv_file_name = 'report.docx'
no_execute = ''.