-
Notifications
You must be signed in to change notification settings - Fork 0
/
zbackup4abap_ecc.abap
5941 lines (5031 loc) · 197 KB
/
zbackup4abap_ecc.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*&---------------------------------------------------------------------*
*& Report ZBACKUP4ABAP_ECC
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zbackup4abap_ecc.
" 需创建 demo_indx_table 表
*&----------------------------------------------------------------------
* Type-Pools
*&----------------------------------------------------------------------
TYPE-POOLS: seop.
*&----------------------------------------------------------------------
* Tables
*&----------------------------------------------------------------------
TABLES: tadir.
*&----------------------------------------------------------------------
* Types
*&----------------------------------------------------------------------
TYPES: BEGIN OF ty_folder,
tag TYPE char10,
folder TYPE char10,
END OF ty_folder.
TYPES: BEGIN OF ty_function,
functionname LIKE tfdir-funcname,
functiongroup LIKE enlfdir-area,
includenumber LIKE tfdir-include,
functionmaininclude LIKE tfdir-funcname,
functiontitle LIKE tftit-stext,
progname LIKE tfdir-pname,
END OF ty_function.
TYPES: BEGIN OF ty_log_list,
main TYPE text30,
uname TYPE text12,
datum TYPE datum,
uzeit TYPE uzeit,
END OF ty_log_list.
TYPES: tt_log_list TYPE STANDARD TABLE OF ty_log_list WITH DEFAULT KEY.
TYPES: BEGIN OF ty_log_flow,
type TYPE text30,
info TYPE tt_log_list,
END OF ty_log_flow.
TYPES: BEGIN OF ty_delt_log,
object TYPE trobjtype, " 对象类型
ddate TYPE datum, " 增量日期
dtime TYPE uzeit, " 增量时间
END OF ty_delt_log.
CLASS lcl_export_ddldict DEFINITION DEFERRED.
CLASS lcl_progress_bar DEFINITION DEFERRED.
CLASS lcl_pretty_json DEFINITION DEFERRED.
CLASS lcl_ui2_json DEFINITION DEFERRED.
*&----------------------------------------------------------------------
* Variables
*&----------------------------------------------------------------------
DATA: gr_zip TYPE REF TO cl_abap_zip, " abap 压缩类
gr_cover_out TYPE REF TO cl_abap_conv_out_ce. " abap 编码转换类
DATA: gv_parent_folder TYPE string.
DATA: gt_folder TYPE TABLE OF ty_folder.
DATA: gc_extension_name TYPE string VALUE 'abap'.
DATA: gv_export_fullpath TYPE string.
DATA: gt_map_file TYPE TABLE OF string.
DATA: gt_log_flow TYPE TABLE OF ty_log_flow.
DATA: gt_range_devclass TYPE RANGE OF tadir-devclass.
"CONSTANTS: gc_newline type ABAP_CHAR1 VALUE CL_ABAP_CHAR_UTILITIES=>NEWLINE.
CONSTANTS: gc_newline TYPE abap_cr_lf VALUE cl_abap_char_utilities=>cr_lf.
DATA: gt_range_append_class TYPE RANGE OF vseoclass-clsname.
DATA: gt_delt_log TYPE TABLE OF ty_delt_log.
*&----------------------------------------------------------------------
* Select Screen
*&----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK blck1 WITH FRAME.
" 代码相关
" report
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_prog FOR FIELD p_prog.
PARAMETERS: p_prog AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
" function
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_func FOR FIELD p_func.
PARAMETERS: p_func AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
" Class
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_clas FOR FIELD p_clas.
PARAMETERS: p_clas AS CHECKBOX DEFAULT ''.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blck1.
SELECTION-SCREEN BEGIN OF BLOCK blck2 WITH FRAME.
" 表相关
" Table
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_tabl FOR FIELD p_tabl.
PARAMETERS: p_tabl AS CHECKBOX DEFAULT 'X' USER-COMMAND tab.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 15(10) t_txml MODIF ID gp1 FOR FIELD p_txml.
PARAMETERS: p_txml TYPE c RADIOBUTTON GROUP gp1 USER-COMMAND gp1 MODIF ID gp1.
SELECTION-SCREEN COMMENT 35(10) t_tddl MODIF ID gp1 FOR FIELD p_tddl.
PARAMETERS: p_tddl TYPE c RADIOBUTTON GROUP gp1 MODIF ID gp1 DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN COMMENT 5(70) t_dddl MODIF ID gp1.
" DDL
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_cdsv FOR FIELD p_cdsv.
PARAMETERS: p_cdsv AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
" Domain
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_doma FOR FIELD p_doma.
PARAMETERS: p_doma AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
" Element
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_dtel FOR FIELD p_dtel.
PARAMETERS: p_dtel AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
" table type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_ttyp FOR FIELD p_ttyp.
PARAMETERS: p_ttyp AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blck2.
SELECTION-SCREEN BEGIN OF BLOCK blck3 WITH FRAME.
" 其他
" Smw0
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_smw0 FOR FIELD p_smw0.
PARAMETERS: p_smw0 AS CHECKBOX DEFAULT ''.
SELECTION-SCREEN END OF LINE.
" Tcode
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_tran FOR FIELD p_tran.
PARAMETERS: p_tran AS CHECKBOX DEFAULT ''.
SELECTION-SCREEN END OF LINE.
" Strans
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_xslt FOR FIELD p_xslt.
PARAMETERS: p_xslt AS CHECKBOX DEFAULT ''.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blck3.
SELECTION-SCREEN BEGIN OF BLOCK blck4 WITH FRAME.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_pack FOR FIELD s_pack.
SELECT-OPTIONS: s_pack FOR tadir-devclass.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blck4.
SELECTION-SCREEN BEGIN OF BLOCK blck5 WITH FRAME.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(23) t_delt FOR FIELD p_delt.
PARAMETERS: p_delt TYPE c AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blck5.
" 标识用于 接口获取内容
SELECTION-SCREEN BEGIN OF BLOCK brun WITH FRAME.
" __ 借用 blob 表存储 xstring 数据,读取后删除
" 同时为返回的文件名
PARAMETERS: p_brun TYPE char30 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK brun.
*&----------------------------------------------------------------------
* Initialization
*&----------------------------------------------------------------------
INITIALIZATION.
PERFORM frm_init_text.
*&----------------------------------------------------------------------
* At Selection-Screen Output
*&----------------------------------------------------------------------
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'GP1' AND p_tabl = ''.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
" 功能未有,此处暂时不可显示
IF screen-name = 'P_TXML'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*&----------------------------------------------------------------------
* Start-Of-Selection
*&----------------------------------------------------------------------
AT SELECTION-SCREEN.
*&----------------------------------------------------------------------
* At Selection-Screen
*&----------------------------------------------------------------------
START-OF-SELECTION.
IF s_pack[] IS NOT INITIAL.
gt_range_devclass = s_pack[].
ENDIF.
PERFORM frm_check.
PERFORM frm_get_more.
PERFORM frm_init_variables.
IF p_brun IS INITIAL.
" 不获取文件路径
PERFORM frm_get_path.
ENDIF.
PERFORM frm_get_code.
PERFORM frm_get_ddic.
PERFORM frm_get_others.
PERFORM frm_export_zip.
*----------------------------------------------------------------------*
* CLASS lcl_progress_bar DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_progress_bar DEFINITION.
PUBLIC SECTION.
DATA: count TYPE i,
base_desc TYPE string,
curr TYPE i.
METHODS constructor IMPORTING i_count TYPE i OPTIONAL
i_base_desc TYPE string OPTIONAL.
METHODS add IMPORTING i_add TYPE i DEFAULT 1
i_desc TYPE data OPTIONAL.
PRIVATE SECTION.
DATA: percent TYPE p DECIMALS 2 LENGTH 5.
METHODS display IMPORTING desc TYPE data.
ENDCLASS.
*&---------------------------------------------------------------------*
*& Form frm_init_text
*&---------------------------------------------------------------------*
*& 文本初始化
*&---------------------------------------------------------------------*
FORM frm_init_text .
" 类限制
" GT_RANGE_DEVCLASS = VALUE #( ).
REFRESH gt_range_devclass.
t_prog = '报表程序'.
t_func = '函数程序'.
t_tabl = '表内容'.
t_txml = '导出 XML'.
t_tddl = '导出 DDL'.
t_clas = '类程序'.
t_cdsv = 'CDS视图'.
t_doma = '数据域'.
t_dtel = '数据元素'.
t_ttyp = '表类型'.
t_smw0 = 'SMW0(Z*)附件'.
t_tran = '事务码'.
t_xslt = '转换'.
t_pack = '开发类(包)'.
t_delt = '增量获取(不跨client)'.
t_dddl = '导出DDL文件, 用于 SAP NetWeaver AS for ABAP 7.52 SP00 以上版本 ADT'.
ENDFORM. "frm_init_text
*&---------------------------------------------------------------------*
*& Form frm_check
*&---------------------------------------------------------------------*
*& 检查输入
*&---------------------------------------------------------------------*
FORM frm_check .
" 指定包后 不在进行增量获取
IF s_pack[] IS NOT INITIAL.
p_delt = ''.
ENDIF.
ENDFORM. "frm_check
*&---------------------------------------------------------------------*
*& Form frm_init_variables
*&---------------------------------------------------------------------*
*& 初始化压缩相关类
*&---------------------------------------------------------------------*
FORM frm_init_variables .
" 压缩对象
CREATE OBJECT gr_zip.
" 编码转换
gr_cover_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
" 文件目录
DATA: ls_folder LIKE LINE OF gt_folder.
DEFINE zappend.
ls_folder-tag = &1.
ls_folder-folder = &2.
APPEND ls_folder TO gt_folder.
CLEAR ls_folder.
END-OF-DEFINITION.
zappend 'MM' ''.
zappend 'PP' ''.
zappend 'SD' ''.
zappend 'FI' ''.
zappend 'FICO' 'FI'.
zappend 'HD' ''. " 汉得包
zappend 'TX' ''. " 推送测试平台类
zappend 'API' ''. " 接口处理
zappend 'JOB' ''. " job 处理
zappend 'JO' 'JOB'. " job 处理
zappend 'FILE' ''. " 文件处理
SORT gt_folder BY tag.
" 增量数据获取
IF p_delt = 'X'.
IMPORT gt_delt_log FROM DATABASE demo_indx_table(zd) ID 'DeltaDownload'.
SORT gt_delt_log BY object.
FIELD-SYMBOLS: <ls_delt_log> LIKE LINE OF gt_delt_log.
" 时间减3s
LOOP AT gt_delt_log ASSIGNING <ls_delt_log>.
<ls_delt_log>-dtime = <ls_delt_log>-dtime - 3.
ENDLOOP.
ENDIF.
ENDFORM. "frm_init_variables
*&---------------------------------------------------------------------*
*& Form frm_get_code
*&---------------------------------------------------------------------*
*& 获取代码数据
*&---------------------------------------------------------------------*
FORM frm_get_code .
IF p_prog = abap_true.
PERFORM frm_set_parent_folder USING `SE38/`.
PERFORM frm_get_report.
ENDIF.
IF p_func = abap_true.
PERFORM frm_set_parent_folder USING `SE37/`.
PERFORM frm_get_function.
ENDIF.
IF p_clas = abap_true.
PERFORM frm_set_parent_folder USING `SE24/`.
PERFORM frm_get_class.
ENDIF.
ENDFORM. "frm_get_code
*&---------------------------------------------------------------------*
*& Form frm_get_DDIC
*&---------------------------------------------------------------------*
*& 获取表相关内容
*&---------------------------------------------------------------------*
FORM frm_get_ddic .
IF p_tabl = abap_true.
"PERFORM frm_set_parent_folder USING `SE11/`.
IF p_txml = abap_true.
" no realization
ELSE.
PERFORM frm_get_tables_ddl USING gr_zip gr_cover_out `SE11/DDL/TABLE/`.
PERFORM frm_get_structs_ddl USING gr_zip gr_cover_out `SE11/DDL/STRUCT/`.
ENDIF.
ENDIF.
IF p_cdsv = abap_true.
PERFORM frm_set_parent_folder USING `DDL/`.
PERFORM frm_get_ddl.
ENDIF.
IF p_doma = abap_true.
PERFORM frm_set_parent_folder USING `SE11/field/Domain/`.
PERFORM frm_get_domain.
ENDIF.
IF p_dtel = abap_true.
PERFORM frm_set_parent_folder USING `SE11/field/Element/`.
PERFORM frm_get_element.
ENDIF.
IF p_ttyp = abap_true.
PERFORM frm_set_parent_folder USING `SE11/TABLETYPE/`.
PERFORM frm_get_tabletypes.
ENDIF.
ENDFORM. "frm_get_ddic
*&---------------------------------------------------------------------*
*& Form frm_get_report
*&---------------------------------------------------------------------*
*& 获取报表数据
*&---------------------------------------------------------------------*
FORM frm_get_report .
" D010SINF REPOSRC 视图(INF 部分) => REPOSRC 程序含代码
" D010TINF REPOTEXT 视图(INF 部分)=> REPOTEXT 程序文本
" trdirt 标题文本
TYPES: BEGIN OF ty_list,
progname TYPE reposrc-progname,
r3state TYPE reposrc-r3state,
subc TYPE reposrc-subc,
unam TYPE reposrc-unam,
udat TYPE reposrc-udat,
utime TYPE reposrc-utime,
text TYPE trdirt-text,
END OF ty_list.
DATA: lv_filename TYPE string.
DATA: lt_source TYPE TABLE OF text1000 WITH DEFAULT KEY,
lv_source TYPE string,
lv_xstring TYPE xstring.
DATA: lv_c_flag TYPE char2.
DATA: lv_folder TYPE char10,
lv_max TYPE i.
DATA: lt_list TYPE TABLE OF ty_list,
ls_list TYPE ty_list.
DATA: lr_pb TYPE REF TO lcl_progress_bar.
CREATE OBJECT lr_pb.
" 读取 报表
SELECT
rep~progname
rep~r3state
rep~subc
rep~unam " 修改人
rep~udat
rep~utime
des~text
FROM reposrc AS rep
INNER JOIN tadir AS tad ON tad~obj_name = rep~progname AND tad~object = 'PROG'
LEFT JOIN trdirt AS des ON des~name = rep~progname AND des~sprsl = sy-langu
INTO TABLE lt_list
WHERE (
( rep~progname LIKE 'Z%' AND rep~subc = '1' )
OR ( rep~progname LIKE 'Z%' AND rep~subc = 'I' AND rep~rload = '1' )
OR ( rep~progname LIKE 'Z%' AND rep~subc = 'M' )
OR ( rep~progname LIKE 'Z%' AND rep~subc = 'T' ) )
AND rep~r3state = 'A'
AND tad~devclass IN gt_range_devclass.
SORT lt_list BY progname.
DATA: ls_delt_log LIKE LINE OF gt_delt_log.
FIELD-SYMBOLS: <ls_delt_log> LIKE LINE OF gt_delt_log.
READ TABLE gt_delt_log ASSIGNING <ls_delt_log> WITH KEY object = 'PROG' BINARY SEARCH.
IF sy-subrc <> 0.
ls_delt_log-object = 'PROG'.
ls_delt_log-ddate = sy-datum.
ls_delt_log-dtime = sy-uzeit.
APPEND ls_delt_log TO gt_delt_log.
CLEAR ls_delt_log.
ELSE.
ls_delt_log = <ls_delt_log>.
<ls_delt_log>-ddate = sy-datum.
<ls_delt_log>-dtime = sy-uzeit.
ENDIF.
DESCRIBE TABLE lt_list LINES lr_pb->count.
lr_pb->base_desc = 'Process Report & '.
LOOP AT lt_list INTO ls_list.
lr_pb->add( i_desc = ls_list-progname ).
" 忽略当前程序
IF ls_list-progname = sy-cprog.
CONTINUE.
ENDIF.
" 文件夹匹配 -> 文件名
CONCATENATE 'R' ls_list-subc INTO lv_c_flag.
PERFORM frm_get_folder_name USING lv_c_flag ls_list-progname lv_folder.
IF ls_list-subc = 'I'.
IF lv_folder+0(1) = 'X'.
" 特殊
CONCATENATE 'CMOD/' ls_list-progname '.' gc_extension_name INTO lv_filename.
ELSE.
IF lv_folder IS NOT INITIAL.
CONCATENATE lv_filename lv_folder '/' INTO lv_filename.
ENDIF.
CONCATENATE lv_filename 'INCLUDE/' ls_list-progname '.' gc_extension_name INTO lv_filename.
ENDIF.
ELSEIF ls_list-subc = '1'.
IF lv_folder IS NOT INITIAL.
CONCATENATE lv_filename lv_folder '/' INTO lv_filename.
ENDIF.
CONCATENATE lv_filename ls_list-progname '.' gc_extension_name INTO lv_filename.
ELSEIF ls_list-subc = 'M'.
CONCATENATE 'MODULEPOOLS/' lv_filename INTO lv_filename.
IF lv_folder IS NOT INITIAL.
CONCATENATE lv_filename lv_folder '/' INTO lv_filename.
ENDIF.
CONCATENATE lv_filename ls_list-progname '.' gc_extension_name INTO lv_filename.
ELSEIF ls_list-subc = 'T'.
CONCATENATE 'TYPEPOOLS/' lv_filename INTO lv_filename.
IF lv_folder IS NOT INITIAL.
CONCATENATE lv_filename lv_folder '/' INTO lv_filename.
ENDIF.
CONCATENATE lv_filename ls_list-progname '.' gc_extension_name INTO lv_filename.
ENDIF.
" map 文件路径
PERFORM frm_set_map_file USING lv_filename ls_list-text.
CONCATENATE gv_parent_folder lv_filename INTO lv_filename.
" 日志 生成
PERFORM frm_set_log_flow USING 'PROG' ls_list-progname ls_list-unam ls_list-udat ls_list-utime.
" 检查增量
IF p_delt = 'X'.
IF ls_delt_log-ddate > ls_list-udat
OR ( ls_delt_log-ddate = ls_list-udat AND ls_delt_log-dtime > ls_list-utime ).
REFRESH lt_source.
CLEAR: lv_filename, lv_xstring.
CONTINUE.
ENDIF.
ENDIF.
" 读取激活状态的代码
READ REPORT ls_list-progname INTO lt_source STATE 'A' MAXIMUM WIDTH INTO lv_max.
IF sy-subrc = 0.
" 内表转换为长字符串
CONCATENATE LINES OF lt_source INTO lv_source SEPARATED BY gc_newline.
" string -> xstring
gr_cover_out->convert(
EXPORTING data = lv_source
IMPORTING buffer = lv_xstring ).
ENDIF.
" 添加到压缩包
gr_zip->add( name = lv_filename
content = lv_xstring ).
" 清除缓存
REFRESH lt_source.
CLEAR: lv_filename, lv_xstring.
ENDLOOP.
" map 文件
PERFORM frm_add_map_file USING gv_parent_folder.
ENDFORM. "frm_get_report
*&---------------------------------------------------------------------*
*& Form frm_get_function
*&---------------------------------------------------------------------*
*& 获取函数
*&---------------------------------------------------------------------*
FORM frm_get_function .
" V_FDIR 查找功能模块的视图(函数名 函数组名)
" TFDIR 功能模块 (实际程序名)
" ENLFDIR 功能模块的附加属性(函数的函数组)
" TFTIT 功能模块描述信息
" TLIBV 负责功能组(函数组 函数组负责人)
" TADIR 资源对象库(不仅函数部分数据)(包 关联函数)
TYPES: BEGIN OF ty_tftit,
funcname TYPE tftit-funcname,
stext TYPE tftit-stext,
END OF ty_tftit.
TYPES: BEGIN OF ty_rep,
progname TYPE reposrc-progname,
unam TYPE reposrc-unam,
udat TYPE reposrc-udat,
utime TYPE reposrc-utime,
END OF ty_rep.
TYPES: BEGIN OF ty_list,
progname TYPE reposrc-progname,
r3state TYPE reposrc-r3state,
subc TYPE reposrc-subc,
unam TYPE reposrc-unam,
udat TYPE reposrc-udat,
utime TYPE reposrc-utime,
END OF ty_list.
DATA: lt_func TYPE TABLE OF ty_function.
DATA: lt_tftit TYPE TABLE OF ty_tftit.
DATA: lv_filename TYPE string.
DATA: lt_source TYPE TABLE OF text1000 WITH DEFAULT KEY,
lv_source TYPE string,
lv_xstring TYPE xstring.
DATA: lv_report_name TYPE char50.
DATA: lv_folder TYPE char10,
lv_max TYPE i.
DATA: lr_pb TYPE REF TO lcl_progress_bar.
CREATE OBJECT lr_pb.
" 此处获取所有的 Z* 函数组数据
SELECT
fu~funcname AS functionname
gr~area AS functiongroup
fu~pname AS progname
fu~include AS includenumber
FROM enlfdir AS gr
INNER JOIN tfdir AS fu ON fu~funcname = gr~funcname
INNER JOIN tadir AS tad ON tad~obj_name = gr~area
INTO CORRESPONDING FIELDS OF TABLE lt_func
WHERE gr~area LIKE 'Z%' " 会包含表维护
AND gr~funcname LIKE 'Z%'
AND tad~devclass IN gt_range_devclass.
IF lt_func IS NOT INITIAL.
SELECT
funcname
stext
FROM tftit
INTO TABLE lt_tftit
FOR ALL ENTRIES IN lt_func
WHERE spras = sy-langu
AND funcname = lt_func-functionname.
SORT lt_tftit BY funcname.
ENDIF.
SORT lt_func BY functionname.
FIELD-SYMBOLS: <ls_func_fixt> LIKE LINE OF lt_func.
DATA: ls_tftit LIKE LINE OF lt_tftit.
LOOP AT lt_func ASSIGNING <ls_func_fixt>.
READ TABLE lt_tftit INTO ls_tftit WITH KEY funcname = <ls_func_fixt>-functionname BINARY SEARCH.
IF sy-subrc = 0.
<ls_func_fixt>-functiontitle = ls_tftit-stext.
ENDIF.
ENDLOOP.
" 更新人获取
DATA: lt_rep TYPE TABLE OF ty_rep,
ls_rep TYPE ty_rep.
SELECT
progname
unam
udat
utime
FROM reposrc
INTO TABLE lt_rep
WHERE progname LIKE 'LZ%' AND appl = 'S'.
SORT lt_rep BY progname.
DATA: ls_delt_log LIKE LINE OF gt_delt_log.
FIELD-SYMBOLS: <ls_delt_log> LIKE LINE OF gt_delt_log.
READ TABLE gt_delt_log ASSIGNING <ls_delt_log> WITH KEY object = 'FUNC' BINARY SEARCH.
IF sy-subrc <> 0.
ls_delt_log-object = 'FUNC'.
ls_delt_log-ddate = sy-datum.
ls_delt_log-dtime = sy-uzeit.
APPEND ls_delt_log TO gt_delt_log.
CLEAR ls_delt_log.
ELSE.
ls_delt_log = <ls_delt_log>.
<ls_delt_log>-ddate = sy-datum.
<ls_delt_log>-dtime = sy-uzeit.
ENDIF.
DATA: ls_func LIKE LINE OF lt_func.
DESCRIBE TABLE lt_func LINES lr_pb->count.
lr_pb->base_desc = 'Process Function & '.
LOOP AT lt_func INTO ls_func.
lr_pb->add( i_desc = ls_func-functionname ).
PERFORM frm_get_folder_name USING 'F' ls_func-functionname lv_folder.
IF lv_folder IS NOT INITIAL.
CONCATENATE lv_folder '/' ls_func-functionname '.abap' INTO lv_filename.
ELSE.
CONCATENATE ls_func-functionname '.abap' INTO lv_filename.
ENDIF.
CONCATENATE 'L' ls_func-functiongroup 'U' ls_func-includenumber INTO lv_report_name.
" map 文件路径
PERFORM frm_set_map_file USING lv_filename ls_func-functiontitle.
CONCATENATE gv_parent_folder lv_filename INTO lv_filename.
" 日志 生成
READ TABLE lt_rep INTO ls_rep WITH KEY progname = lv_report_name BINARY SEARCH.
PERFORM frm_set_log_flow USING 'FUNC' ls_func-functionname ls_rep-unam ls_rep-udat ls_rep-utime.
" 检查增量
IF p_delt = 'X'.
IF ls_delt_log-ddate > ls_rep-udat
OR ( ls_delt_log-ddate = ls_rep-udat AND ls_delt_log-dtime > ls_rep-utime ).
REFRESH lt_source.
CLEAR: lv_filename, lv_xstring, lv_report_name.
CONTINUE.
ENDIF.
ENDIF.
CLEAR ls_rep.
" 读取激活状态的代码
READ REPORT lv_report_name INTO lt_source STATE 'A' MAXIMUM WIDTH INTO lv_max.
IF sy-subrc = 0.
" 内表转换为长字符串
CONCATENATE LINES OF lt_source INTO lv_source SEPARATED BY gc_newline.
" string -> xstring
gr_cover_out->convert(
EXPORTING data = lv_source
IMPORTING buffer = lv_xstring ).
ENDIF.
" 添加到压缩包
gr_zip->add( name = lv_filename
content = lv_xstring ).
" 清除缓存
REFRESH lt_source.
CLEAR: lv_filename, lv_xstring, lv_report_name.
ENDLOOP.
" --> more
" 读取 函数组其他信息
DATA: lt_list TYPE TABLE OF ty_list,
ls_list TYPE ty_list.
SELECT
rep~progname
rep~r3state
rep~subc
rep~unam " 修改人
rep~udat
rep~utime
FROM reposrc AS rep
INNER JOIN tadir AS tad ON tad~obj_name = rep~progname
INTO TABLE lt_list
WHERE ( " ( rep~progname LIKE 'LZ%' AND rep~subc = 'I' AND rep~appl = '' ) " 索引页
( rep~progname LIKE 'LZ%' AND rep~rstat = 'S' ) " 索引页 + RFC
OR ( rep~progname LIKE 'LZ%' AND rep~subc = 'I' AND rep~appl = 'S' AND rep~dbapl = '' ) " O/I/F
OR ( rep~progname LIKE 'LZ%TOP' AND rep~subc = 'I' AND rep~appl = 'S' ) ) " TOP
AND rep~r3state = 'A'
AND tad~devclass IN gt_range_devclass.
SORT lt_list BY progname.
DATA: lv_str_len TYPE i.
READ TABLE gt_delt_log ASSIGNING <ls_delt_log> WITH KEY object = 'FINC' BINARY SEARCH.
IF sy-subrc <> 0.
ls_delt_log-object = 'FINC'.
ls_delt_log-ddate = sy-datum.
ls_delt_log-dtime = sy-uzeit.
APPEND ls_delt_log TO gt_delt_log.
CLEAR ls_delt_log.
ELSE.
ls_delt_log = <ls_delt_log>.
<ls_delt_log>-ddate = sy-datum.
<ls_delt_log>-dtime = sy-uzeit.
ENDIF.
DESCRIBE TABLE lt_list LINES lr_pb->count.
lr_pb->base_desc = 'Process Function More & '.
lr_pb->curr = 0.
LOOP AT lt_list INTO ls_list.
lr_pb->add( i_desc = ls_list-progname ).
" 文件名
CONCATENATE ls_list-progname '.' gc_extension_name INTO lv_filename.
" map 文件路径
PERFORM frm_set_map_file USING lv_filename ''.
lv_str_len = strlen( ls_list-progname ) - 3.
CASE ls_list-progname+lv_str_len(1).
WHEN 'V'.
CONCATENATE gv_parent_folder `Rfc/` lv_filename INTO lv_filename.
WHEN '$'.
CONCATENATE gv_parent_folder `Rfc/Unit/` lv_filename INTO lv_filename.
WHEN OTHERS.
CONCATENATE gv_parent_folder `More/` lv_filename INTO lv_filename.
ENDCASE.
" 日志 生成
PERFORM frm_set_log_flow USING 'FINC' ls_list-progname ls_list-unam ls_list-udat ls_list-utime.
" 检查增量
IF p_delt = 'X'.
IF ls_delt_log-ddate > ls_list-udat
OR ( ls_delt_log-ddate = ls_list-udat AND ls_delt_log-dtime > ls_list-utime ).
REFRESH lt_source.
CLEAR: lv_filename, lv_xstring.
CONTINUE.
ENDIF.
ENDIF.
" 读取激活状态的代码
READ REPORT ls_list-progname INTO lt_source STATE 'A' MAXIMUM WIDTH INTO lv_max.
IF sy-subrc = 0.
" 内表转换为长字符串
CONCATENATE LINES OF lt_source INTO lv_source SEPARATED BY gc_newline.
" string -> xstring
gr_cover_out->convert(
EXPORTING data = lv_source
IMPORTING buffer = lv_xstring ).
ENDIF.
" 添加到压缩包
gr_zip->add( name = lv_filename
content = lv_xstring ).
" 清除缓存
REFRESH lt_source.
CLEAR: lv_filename, lv_xstring.
ENDLOOP.
" <--
" map 文件
PERFORM frm_add_map_file USING gv_parent_folder.
ENDFORM. "frm_get_function
*&---------------------------------------------------------------------*
*& Form frm_export_zip
*&---------------------------------------------------------------------*
*& 导出压缩文件
*&---------------------------------------------------------------------*
FORM frm_export_zip .
DATA: lv_zip_xstr TYPE xstring.
TYPES: ty_hex TYPE x LENGTH 200.
DATA: lt_xdata TYPE STANDARD TABLE OF ty_hex WITH DEFAULT KEY,
lv_xlen TYPE i.
" 压缩文件保存
lv_zip_xstr = gr_zip->save( ).
lv_xlen = xstrlen( lv_zip_xstr ).
" __接口获取时导入 blob表
IF p_brun IS INITIAL.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_zip_xstr
IMPORTING
output_length = lv_xlen
TABLES
binary_tab = lt_xdata.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_xlen
filename = gv_export_fullpath
filetype = 'BIN'
TABLES
data_tab = lt_xdata.
ELSE.
EXPORT xlen = lv_xlen
zip = lv_zip_xstr TO DATABASE demo_indx_table(zb) ID p_brun.
ENDIF.
ENDFORM. "frm_export_zip
*&---------------------------------------------------------------------*
*& Form frm_get_path
*&---------------------------------------------------------------------*
*& 获取存储路径
*&---------------------------------------------------------------------*
FORM frm_get_path .
DATA: lv_path TYPE string,
lv_fullpath TYPE string,
lv_filename TYPE string.
DATA: lv_default_file TYPE string.
CONCATENATE sy-datum sy-uzeit INTO lv_default_file.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'download zip'
default_extension = 'zip'
default_file_name = lv_default_file
file_filter = '(*.zip)|*.zip|'
CHANGING
filename = lv_filename
path = lv_path
fullpath = lv_fullpath
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0 OR lv_fullpath IS INITIAL.
MESSAGE '用户取消' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
ENDIF.
gv_export_fullpath = lv_fullpath.
ENDFORM. "frm_get_path
*&---------------------------------------------------------------------*
*& Form frm_set_map_file
*&---------------------------------------------------------------------*
*& 设置 map 文件内容
*&---------------------------------------------------------------------*
FORM frm_set_map_file USING VALUE(p_file_path)
VALUE(p_file_desc).
DATA: lv_map_file TYPE string.
CONCATENATE `<a href="./` p_file_path `">` p_file_desc `</a>` INTO lv_map_file.
APPEND lv_map_file TO gt_map_file.
ENDFORM. "frm_set_map_file
*&---------------------------------------------------------------------*
*& Form frm_add_map_file
*&---------------------------------------------------------------------*
*& 添加 map 文件到 zip
*&---------------------------------------------------------------------*
FORM frm_add_map_file USING VALUE(p_folder).
DATA: lv_source TYPE string,
lv_xstring TYPE xstring.
DATA: lv_name TYPE string.
CONCATENATE gv_parent_folder `map.html` INTO lv_name.
CONCATENATE LINES OF gt_map_file INTO lv_source SEPARATED BY gc_newline.
gr_cover_out->convert(
EXPORTING data = lv_source
IMPORTING buffer = lv_xstring ).
gr_zip->add( name = lv_name
content = lv_xstring ).
REFRESH gt_map_file.
ENDFORM. "frm_add_map_file
*&---------------------------------------------------------------------*
*& Form FRM_GET_CLASS
*&---------------------------------------------------------------------*
*& 获取类代码
*&---------------------------------------------------------------------*
FORM frm_get_class .
TYPES: BEGIN OF ty_class,
clsname TYPE vseoclass-clsname,
langu TYPE vseoclass-langu,
descript TYPE vseoclass-descript,
msg_id TYPE vseoclass-msg_id,
exposure TYPE vseoclass-exposure,
state TYPE vseoclass-state,
clsfinal TYPE vseoclass-clsfinal,
r3release TYPE vseoclass-r3release,
changedby TYPE vseoclass-changedby,
changedon TYPE vseoclass-changedon,
changetm TYPE uzeit,
END OF ty_class.
TYPES: BEGIN OF ty_progdir,