forked from sapmentors/SAPlink-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CLAS_ZSAPLINK_FUNCTIONGROUP.slnk
2638 lines (2284 loc) · 106 KB
/
CLAS_ZSAPLINK_FUNCTIONGROUP.slnk
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
<?xml version="1.0" encoding="utf-8"?>
<CLAS CLSNAME="ZSAPLINK_FUNCTIONGROUP" VERSION="1" LANGU="E" DESCRIPT="SAPlink - Function Groups" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" CLSFINAL="X" CLSCCINCL="X" FIXPT="X" UNICODE="X" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 " REFCLSNAME="ZSAPLINK">
<localImplementation>*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes</localImplementation>
<localTypes>*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature</localTypes>
<localMacros>*"* use this source file for any macro definitions you need
*"* in the implementation part of the class</localMacros>
<inheritance CLSNAME="ZSAPLINK_FUNCTIONGROUP" REFCLSNAME="ZSAPLINK" VERSION="1" STATE="1">
<redefinition CLSNAME="ZSAPLINK_FUNCTIONGROUP" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="CHECKEXISTS" EXPOSURE="0"/>
<redefinition CLSNAME="ZSAPLINK_FUNCTIONGROUP" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="CREATEIXMLDOCFROMOBJECT" EXPOSURE="0"/>
<redefinition CLSNAME="ZSAPLINK_FUNCTIONGROUP" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="CREATEOBJECTFROMIXMLDOC" EXPOSURE="0"/>
<redefinition CLSNAME="ZSAPLINK_FUNCTIONGROUP" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="DELETEOBJECT" EXPOSURE="0"/>
<redefinition CLSNAME="ZSAPLINK_FUNCTIONGROUP" REFCLSNAME="ZSAPLINK" VERSION="1" MTDNAME="GETOBJECTTYPE" EXPOSURE="0"/>
</inheritance>
<method CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="ACTUALIZE_OBJECT_TREE" VERSION="1" LANGU="E" DESCRIPT="Refresh Object Tree" EXPOSURE="0" STATE="1" EDITORDER="1 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>method ACTUALIZE_OBJECT_TREE.
*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| The code of this project is provided to you under the current |
*| version of the SAP Code Exchange Terms of Use. You can find the |
*| text on the SAP Code Exchange webpage at http://www.sdn.sap.com |
*| |
*| SAPlink is provided to you AS IS with no guarantee, warranty or |
*| support. |
*\---------------------------------------------------------------------/
DATA: l_offset TYPE i.
DATA: l_tree_string TYPE string.
CONCATENATE 'PG_' 'SAPL' objname INTO l_tree_string.
* If we supported namespaces, the following code would be required
* FIND ALL OCCURRENCES OF '/' IN objname MATCH OFFSET l_offset.
* IF sy-subrc = 0.
* l_tree_string = objname.
* REPLACE SECTION OFFSET l_offset LENGTH 1 OF l_tree_string WITH '/SAPL'.
* CONCATENATE 'PG_' l_tree_string INTO l_tree_string.
* ELSE.
* CONCATENATE 'PG_' 'SAPL' objname INTO l_tree_string.
* ENDIF.
CALL FUNCTION 'WB_TREE_ACTUALIZE'
EXPORTING
tree_name = l_tree_string.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CHECKEXISTS" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>method CHECKEXISTS.
*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| The code of this project is provided to you under the current |
*| version of the SAP Code Exchange Terms of Use. You can find the |
*| text on the SAP Code Exchange webpage at http://www.sdn.sap.com |
*| |
*| SAPlink is provided to you AS IS with no guarantee, warranty or |
*| support. |
*\---------------------------------------------------------------------/
select single area from tlibg into objname where area = objname.
if sy-subrc = 0.
exists = 'X'.
endif.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CREATEIXMLDOCFROMOBJECT" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>method CREATEIXMLDOCFROMOBJECT.
*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| The code of this project is provided to you under the current |
*| version of the SAP Code Exchange Terms of Use. You can find the |
*| text on the SAP Code Exchange webpage at http://www.sdn.sap.com |
*| |
*| SAPlink is provided to you AS IS with no guarantee, warranty or |
*| support. |
*\---------------------------------------------------------------------/
* Plugin created by:
* Rich Heilman
types: begin of t_tlibt,
area type tlibt-area,
spras type tlibt-spras,
areat type tlibt-areat,
end of t_tlibt.
data rootnode type ref to if_ixml_element.
data mainprognode type ref to if_ixml_element.
data includesnode type ref to if_ixml_element.
data functgroupnode type ref to if_ixml_element.
data functionmodulesnode type ref to if_ixml_element.
data docNode type ref to if_ixml_element.
data textpoolnode type ref to if_ixml_element.
data dynpronode type ref to if_ixml_element.
data statusnode type ref to if_ixml_element.
data sourcenode type ref to if_ixml_element.
data fmdocumenation type ref to if_ixml_element.
data rc type sysubrc.
data progattribs type trdir.
data progsource type rswsourcet.
data _objname(30) type c.
data sourcestring type string.
data _objtype type string.
data functiongroupname type tlibg-area.
data mainfgprogname type sy-repid.
DATA l_offset TYPE i.
data xtlibt type t_tlibt.
_objtype = getobjecttype( ).
rootnode = xmldoc->create_element( _objtype ).
* function groups in reserved namespace, not supported.
IF objname(1) = '/'.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING
textid = zcx_saplink=>error_message
msg = 'Function Groups in / namespace are not supported'.
ENDIF.
* create main program name. Other namespaces are not supported
CONCATENATE 'SAPL' objname INTO mainfgprogname.
* If we did support namespaces, this is how we would
* build the main program name
* FIND ALL OCCURRENCES OF '/' IN objname MATCH OFFSET l_offset.
* IF sy-subrc = 0.
* mainfgprogname = objname.
* REPLACE SECTION OFFSET l_offset LENGTH 1 OF mainfgprogname WITH '/SAPL'.
* ELSE.
* CONCATENATE 'SAPL' objname INTO mainfgprogname.
* ENDIF.
* Set function group name
functiongroupname = objname.
* Get main program attributes
select single * from trdir
into progattribs
where name = mainfgprogname.
if sy-subrc <> 0.
clear ixmldocument.
RAISE EXCEPTION type zcx_saplink
EXPORTING
textid = zcx_saplink=>not_found.
endif.
* Get Function group attributes
clear xtlibt.
select single * from tlibt
into corresponding fields of xtlibt
where spras = sy-langu
and area = functiongroupname.
if sy-subrc <> 0.
RAISE EXCEPTION type zcx_saplink
EXPORTING
textid = zcx_saplink=>not_found.
endif.
setattributesfromstructure( node = rootnode
structure = xtlibt ).
_objname = objname.
objname = mainfgprogname. " Main program is object
* Write main program for function group.
mainprognode = xmldoc->create_element( 'mainprogram' ).
setattributesfromstructure( node = mainprognode
structure = progattribs ).
sourcenode = xmldoc->create_element( 'source' ).
read report mainfgprogname into progsource.
sourcestring = buildsourcestring( sourcetable = progsource ).
rc = sourcenode->if_ixml_node~set_value( sourcestring ).
textpoolnode = get_textpool( ).
rc = mainprognode->append_child( textpoolnode ).
docNode = get_documentation( ).
rc = rootNOde->append_child( docNode ).
dynpronode = get_dynpro( ).
rc = mainprognode->append_child( dynpronode ).
statusnode = get_pfstatus( ).
rc = mainprognode->append_child( statusnode ).
rc = mainprognode->append_child( sourcenode ).
rc = rootnode->append_child( mainprognode ).
* Get the includes
includesnode = get_includes( main_prog = mainfgprogname
fct_group = functiongroupname ).
rc = rootnode->append_child( includesnode ).
* Get function modules data.
functionmodulesnode = get_function_modules( functiongroupname ).
rc = rootnode->append_child( functionmodulesnode ).
rc = xmldoc->append_child( rootnode ).
ixmldocument = xmldoc.
objname = _objname.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CREATEOBJECTFROMIXMLDOC" VERSION="0" EXPOSURE="0" STATE="0" EDITORDER="0 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<source>method CREATEOBJECTFROMIXMLDOC.
*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| The code of this project is provided to you under the current |
*| version of the SAP Code Exchange Terms of Use. You can find the |
*| text on the SAP Code Exchange webpage at http://www.sdn.sap.com |
*| |
*| SAPlink is provided to you AS IS with no guarantee, warranty or |
*| support. |
*\---------------------------------------------------------------------/
* Plugin created by:
* Rich Heilman
TYPES: BEGIN OF t_tlibt,
area TYPE tlibt-area,
spras TYPE tlibt-spras,
areat TYPE tlibt-areat,
END OF t_tlibt.
DATA rootnode TYPE REF TO if_ixml_element.
DATA sourcenode TYPE REF TO if_ixml_element.
DATA textnode TYPE REF TO if_ixml_element.
DATA docnode TYPE REF TO if_ixml_element.
DATA dynpnode TYPE REF TO if_ixml_element.
DATA statnode TYPE REF TO if_ixml_element.
DATA mainprog_node TYPE REF TO if_ixml_element.
DATA functionmodule_node TYPE REF TO if_ixml_element.
DATA functionmodules_node TYPE REF TO if_ixml_element.
DATA includes_node TYPE REF TO if_ixml_element.
DATA fmdoc_node TYPE REF TO if_ixml_element.
DATA progattribs TYPE trdir.
DATA source TYPE string.
DATA sourcetable TYPE table_of_strings.
DATA _objname(30) TYPE c.
DATA _objtype TYPE string.
DATA checkexists TYPE flag.
DATA xtlibt TYPE t_tlibt.
DATA xstext TYPE tftit-stext.
DATA functiongroupname TYPE tlibg-area.
_objtype = getobjecttype( ).
xmldoc = ixmldocument.
rootnode = xmldoc->find_from_name( _objtype ).
_objname = objname.
getstructurefromattributes(
EXPORTING
node = rootnode
CHANGING
structure = xtlibt ).
functiongroupname = xtlibt-area.
* function groups in reserved namespace, not supported.
IF functiongroupname(1) = '/'.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING
textid = zcx_saplink=>error_message
msg = 'Function Groups in / namespace are not supported'.
ENDIF.
objname = functiongroupname.
checkexists = checkexists( ).
IF checkexists IS NOT INITIAL.
IF overwrite IS INITIAL.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING
textid = zcx_saplink=>existing.
ELSE.
* delete object for new install
deleteobject( ).
ENDIF.
ENDIF.
* Insert the function group
xstext = xtlibt-areat.
CALL FUNCTION 'RS_FUNCTION_POOL_INSERT'
EXPORTING
function_pool = xtlibt-area
short_text = xstext
devclass = devclass
EXCEPTIONS
name_already_exists = 1
name_not_correct = 2
function_already_exists = 3
invalid_function_pool = 4
invalid_name = 5
too_many_functions = 6
no_modify_permission = 7
no_show_permission = 8
enqueue_system_failure = 9
canceled_in_corr = 10
undefined_error = 11
OTHERS = 12.
* Create the function modules
functionmodules_node = rootnode->find_from_name( 'functionmodules' ).
create_function_modules( fm_node = functionmodules_node
fct_group = functiongroupname ).
* Create Includes
includes_node = rootnode->find_from_name( 'includeprograms' ).
create_includes( devclass = devclass
incl_node = includes_node ).
* Update main program..... with include statements, dynpros, gui status
mainprog_node = rootnode->find_from_name( 'mainprogram' ).
getstructurefromattributes(
EXPORTING
node = mainprog_node
CHANGING
structure = progattribs ).
objname = progattribs-name. " Main Program Name is now the object
* Update the main program
enqueue_abap( ).
transport_copy( author = progattribs-cnam
devclass = devclass ).
* Source
sourcenode = mainprog_node->find_from_name( 'source' ).
source = sourcenode->get_value( ).
sourcetable = buildtablefromstring( source ).
create_source( source = sourcetable
attribs = progattribs ).
* Documentation
docnode = rootnode->find_from_name( 'functionGroupDocumentation' ).
create_documentation( docnode ).
* text pool
textnode = mainprog_node->find_from_name( 'textPool' ).
create_textpool( textnode ).
* Dynpros
dynpnode = mainprog_node->find_from_name( 'dynpros' ).
create_dynpro( dynpnode ).
* Gui status, titles
statnode = mainprog_node->find_from_name( 'pfstatus' ).
create_pfstatus( statnode ).
dequeue_abap( ).
* Rebuild tree structure for SE80
actualize_object_tree( ).
* successful install
objname = functiongroupname.
name = objname.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_DOCUMENTATION" VERSION="1" LANGU="E" DESCRIPT="Create Documentation" EXPOSURE="0" STATE="1" EDITORDER="4 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_DOCUMENTATION" SCONAME="DOCNODE" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_ELEMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<source>method CREATE_DOCUMENTATION.
*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| The code of this project is provided to you under the current |
*| version of the SAP Code Exchange Terms of Use. You can find the |
*| text on the SAP Code Exchange webpage at http://www.sdn.sap.com |
*| |
*| SAPlink is provided to you AS IS with no guarantee, warranty or |
*| support. |
*\---------------------------------------------------------------------/
DATA txtline_node TYPE REF TO if_ixml_element.
DATA txtline_filter TYPE REF TO if_ixml_node_filter.
DATA txtline_iterator TYPE REF TO if_ixml_node_iterator.
DATA lang_node TYPE REF TO if_ixml_element.
DATA lang_filter TYPE REF TO if_ixml_node_filter.
DATA lang_iterator TYPE REF TO if_ixml_node_iterator.
data obj_name type DOKHL-OBJECT.
data prog_name type string.
data language type string.
data obj_langu type DOKHL-LANGU.
data lv_str type string.
data rc type sy-subrc.
DATA lt_lines TYPE TABLE OF tline.
FIELD-SYMBOLS: <ls_lines> LIKE LINE OF lt_lines.
if docnode is not bound.
return.
endif.
prog_name = docNode->get_attribute( name = 'OBJECT' ).
obj_name = prog_name.
* If no prog name, then there was no program documenation, just return.
if prog_name is initial.
return.
endif.
* Get languages from XML
FREE: lang_filter, lang_iterator, lang_node.
lang_filter = docNode->create_filter_name( `language` ).
lang_iterator = docNode->create_iterator_filtered( lang_filter ).
lang_node ?= lang_iterator->get_next( ).
WHILE lang_node IS NOT INITIAL.
refresh lt_lines.
language = lang_node->get_attribute( name = 'SPRAS' ).
obj_langu = language.
* Get TextLines from XML
FREE: txtline_filter, txtline_iterator, txtline_node.
txtline_filter = lang_node->create_filter_name( `textLine` ).
txtline_iterator = lang_node->create_iterator_filtered( txtline_filter ).
txtline_node ?= txtline_iterator->get_next( ).
WHILE txtline_node IS NOT INITIAL.
APPEND INITIAL LINE TO lt_lines ASSIGNING <ls_lines>.
me->getstructurefromattributes(
EXPORTING node = txtline_node
CHANGING structure = <ls_lines> ).
txtline_node ?= txtline_iterator->get_next( ).
ENDWHILE.
* Delete any documentation that may currently exist.
CALL FUNCTION 'DOCU_DEL'
EXPORTING
id = 'RE' "<-- Report/program documentation
langu = obj_langu
object = obj_name
typ = 'E'
EXCEPTIONS
ret_code = 1
OTHERS = 2.
* Now update with new documentation text
CALL FUNCTION 'DOCU_UPD'
EXPORTING
id = 'RE'
langu = obj_langu
object = obj_name
typ = 'E'
TABLES
line = lt_lines
EXCEPTIONS
ret_code = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING
textid = zcx_saplink=>error_message
msg = `Program Documentation object import failed`.
ENDIF.
lang_node ?= lang_iterator->get_next( ).
ENDWHILE.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_DYNPRO" VERSION="1" LANGU="E" DESCRIPT="Create Dynpro" EXPOSURE="0" STATE="1" EDITORDER="17 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_DYNPRO" SCONAME="DYNP_NODE" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_ELEMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<source>method CREATE_DYNPRO.
*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| The code of this project is provided to you under the current |
*| version of the SAP Code Exchange Terms of Use. You can find the |
*| text on the SAP Code Exchange webpage at http://www.sdn.sap.com |
*| |
*| SAPlink is provided to you AS IS with no guarantee, warranty or |
*| support. |
*\---------------------------------------------------------------------/
types: begin of tdyn_head_temp.
include type d020s.
types: dtext type d020t-dtxt.
types: end of tdyn_head_temp.
data: idyn_fldl type table of d021s,
idyn_flow type table of d022s,
idyn_mcod type table of d023s.
data: xdyn_head type d020s,
xdyn_fldl type d021s,
xdyn_flow type d022s,
xdyn_mcod type d023s.
data: xdyn_text_string type string.
data: xdyn_text type d020t-dtxt .
data: xdyn_head_temp type tdyn_head_temp.
data _objname type trobj_name.
data dynpros_node type ref to if_ixml_element.
data dynpros_filter type ref to if_ixml_node_filter.
data dynpros_iterator type ref to if_ixml_node_iterator.
data dynpro_node type ref to if_ixml_element.
data dynpro_filter type ref to if_ixml_node_filter.
data dynpro_iterator type ref to if_ixml_node_iterator.
data dynfldl_node type ref to if_ixml_element.
data dynfldl_filter type ref to if_ixml_node_filter.
data dynfldl_iterator type ref to if_ixml_node_iterator.
data dynmcod_node type ref to if_ixml_element.
data dynmcod_filter type ref to if_ixml_node_filter.
data dynmcod_iterator type ref to if_ixml_node_iterator.
data dynflow_node type ref to if_ixml_element.
data xdynpro_flow_source type string.
data idynpro_flow_source type table_of_strings.
_objname = objname.
dynpros_node = dynp_node.
check dynpros_node is not initial.
free: dynpro_filter, dynpro_iterator, dynpro_node.
dynpro_filter = dynpros_node->create_filter_name( 'dynpro' ).
dynpro_iterator =
dynpros_node->create_iterator_filtered( dynpro_filter ).
dynpro_node ?= dynpro_iterator->get_next( ).
while dynpro_node is not initial.
clear: xdyn_head, xdyn_fldl, xdyn_flow, xdyn_mcod.
refresh: idyn_fldl, idyn_flow, idyn_mcod.
* Get the header data for the screen.
call method getstructurefromattributes
exporting
node = dynpro_node
changing
structure = xdyn_head_temp.
xdyn_head = xdyn_head_temp.
xdyn_text = xdyn_head_temp-dtext.
* Retrieve field list
free: dynfldl_filter, dynfldl_iterator, dynfldl_node.
dynfldl_filter = dynpro_node->create_filter_name( 'dynprofield' ).
dynfldl_iterator =
dynpro_node->create_iterator_filtered( dynfldl_filter ).
dynfldl_node ?= dynfldl_iterator->get_next( ).
while dynfldl_node is not initial.
call method getstructurefromattributes
exporting
node = dynfldl_node
changing
structure = xdyn_fldl.
append xdyn_fldl to idyn_fldl.
dynfldl_node ?= dynfldl_iterator->get_next( ).
endwhile.
* Retrieve matchcode data.
free: dynmcod_filter, dynmcod_iterator, dynmcod_node.
dynmcod_filter = dynpro_node->create_filter_name( 'dynprofield' ).
dynmcod_iterator =
dynpro_node->create_iterator_filtered( dynmcod_filter ).
dynmcod_node ?= dynmcod_iterator->get_next( ).
while dynmcod_node is not initial.
call method getstructurefromattributes
exporting
node = dynmcod_node
changing
structure = xdyn_mcod.
append xdyn_mcod to idyn_mcod.
dynmcod_node ?= dynmcod_iterator->get_next( ).
endwhile.
* retieve flow logic source.
clear xdynpro_flow_source. refresh idynpro_flow_source.
clear xdyn_flow. refresh idyn_flow.
free dynflow_node.
dynflow_node = dynpro_node->find_from_name( 'dynproflowsource' ).
xdynpro_flow_source = dynflow_node->get_value( ).
idynpro_flow_source = buildtablefromstring( xdynpro_flow_source ).
loop at idynpro_flow_source into xdyn_flow.
append xdyn_flow to idyn_flow.
endloop.
* Build dynpro from data
call function 'RPY_DYNPRO_INSERT_NATIVE'
exporting
* suppress_corr_checks = ' '
* CORRNUM = ' '
header = xdyn_head
dynprotext = xdyn_text
* SUPPRESS_EXIST_CHECKS = ' '
* USE_CORRNUM_IMMEDIATEDLY = ' '
* SUPPRESS_COMMIT_WORK = ' '
tables
fieldlist = idyn_fldl
flowlogic = idyn_flow
params = idyn_mcod
exceptions
cancelled = 1
already_exists = 2
program_not_exists = 3
not_executed = 4
others = 5.
if sy-subrc <> 0.
raise exception type zcx_saplink
exporting textid = zcx_saplink=>system_error.
endif.
dynpro_node ?= dynpro_iterator->get_next( ).
endwhile.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_FM_DOCUMENTATION" VERSION="1" LANGU="E" DESCRIPT="Create FM Documentation" EXPOSURE="0" STATE="1" EDITORDER="5 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_FM_DOCUMENTATION" SCONAME="DOCNODE" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_ELEMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<source>method CREATE_FM_DOCUMENTATION.
*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| The code of this project is provided to you under the current |
*| version of the SAP Code Exchange Terms of Use. You can find the |
*| text on the SAP Code Exchange webpage at http://www.sdn.sap.com |
*| |
*| SAPlink is provided to you AS IS with no guarantee, warranty or |
*| support. |
*\---------------------------------------------------------------------/
DATA txtline_node TYPE REF TO if_ixml_element.
DATA txtline_filter TYPE REF TO if_ixml_node_filter.
DATA txtline_iterator TYPE REF TO if_ixml_node_iterator.
DATA lang_node TYPE REF TO if_ixml_element.
DATA lang_filter TYPE REF TO if_ixml_node_filter.
DATA lang_iterator TYPE REF TO if_ixml_node_iterator.
data obj_name type DOKHL-OBJECT.
data fm_parm_name type string.
data language type string.
data obj_langu type DOKHL-LANGU.
data lv_str type string.
data rc type sy-subrc.
DATA lt_lines TYPE TABLE OF tline.
FIELD-SYMBOLS: <ls_lines> LIKE LINE OF lt_lines.
if docnode is not bound.
return.
endif.
fm_parm_name = docNode->get_attribute( name = 'OBJECT' ).
obj_name = fm_parm_name.
* If no fm_parm_name, then there was no documenation, just return.
if fm_parm_name is initial.
return.
endif.
* Get languages from XML
FREE: lang_filter, lang_iterator, lang_node.
lang_filter = docNode->create_filter_name( `language` ).
lang_iterator = docNode->create_iterator_filtered( lang_filter ).
lang_node ?= lang_iterator->get_next( ).
WHILE lang_node IS NOT INITIAL.
refresh lt_lines.
language = lang_node->get_attribute( name = 'SPRAS' ).
obj_langu = language.
* Get TextLines from XML
FREE: txtline_filter, txtline_iterator, txtline_node.
txtline_filter = lang_node->create_filter_name( `textLine` ).
txtline_iterator = lang_node->create_iterator_filtered( txtline_filter ).
txtline_node ?= txtline_iterator->get_next( ).
WHILE txtline_node IS NOT INITIAL.
APPEND INITIAL LINE TO lt_lines ASSIGNING <ls_lines>.
me->getstructurefromattributes(
EXPORTING node = txtline_node
CHANGING structure = <ls_lines> ).
txtline_node ?= txtline_iterator->get_next( ).
ENDWHILE.
* Delete any documentation that may currently exist.
CALL FUNCTION 'DOCU_DEL'
EXPORTING
id = 'FU' "<-- function module documentation
langu = obj_langu
object = obj_name
typ = 'T'
EXCEPTIONS
ret_code = 1
OTHERS = 2.
* Now update with new documentation text
CALL FUNCTION 'DOCU_UPD'
EXPORTING
id = 'FU'
langu = obj_langu
object = obj_name
typ = 'T'
TABLES
line = lt_lines
EXCEPTIONS
ret_code = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING
textid = zcx_saplink=>error_message
msg = `Program Documentation object import failed`.
ENDIF.
lang_node ?= lang_iterator->get_next( ).
ENDWHILE.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_FUNCTION_MODULES" VERSION="1" LANGU="E" DESCRIPT="Create Function Modules" EXPOSURE="0" STATE="1" EDITORDER="3 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="0" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_FUNCTION_MODULES" SCONAME="FM_NODE" VERSION="1" LANGU="E" DESCRIPT="IF_IXML_ELEMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZSAPLINK_FUNCTIONGROUP" CMPNAME="CREATE_FUNCTION_MODULES" SCONAME="FCT_GROUP" VERSION="1" LANGU="E" DESCRIPT="Function group, to which the function module belongs" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="TLIBG-AREA"/>
<source>method CREATE_FUNCTION_MODULES.
*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| The code of this project is provided to you under the current |
*| version of the SAP Code Exchange Terms of Use. You can find the |
*| text on the SAP Code Exchange webpage at http://www.sdn.sap.com |
*| |
*| SAPlink is provided to you AS IS with no guarantee, warranty or |
*| support. |
*\---------------------------------------------------------------------/
TYPES: BEGIN OF tfunct_head,
name TYPE rs38l-name,
global TYPE rs38l-global,
remote TYPE rs38l-remote,
utask TYPE rs38l-utask,
stext TYPE tftit-stext,
area TYPE rs38l-area,
END OF tfunct_head.
DATA functionmodules_node TYPE REF TO if_ixml_element.
DATA source TYPE string.
DATA sourcetable TYPE table_of_strings.
DATA functiongroupname TYPE tlibg-area.
DATA mainfgprogname TYPE trdir-name.
DATA xfunct_head TYPE tfunct_head.
DATA iimport TYPE TABLE OF rsimp.
DATA ichange TYPE TABLE OF rscha.
DATA iexport TYPE TABLE OF rsexp.
DATA itables TYPE TABLE OF rstbl.
DATA iexcepl TYPE TABLE OF rsexc.
DATA idocume TYPE TABLE OF rsfdo.
DATA isource TYPE TABLE OF rssource.
DATA isource_new TYPE rsfb_source.
DATA ximport TYPE rsimp.
DATA xchange TYPE rscha.
DATA xexport TYPE rsexp.
DATA xtables TYPE rstbl.
DATA xexcepl TYPE rsexc.
DATA xdocume TYPE rsfdo.
DATA xsource TYPE rssource.
DATA xsource_new LIKE LINE OF isource_new.
DATA node TYPE REF TO if_ixml_element.
DATA filter TYPE REF TO if_ixml_node_filter.
DATA iterator TYPE REF TO if_ixml_node_iterator.
DATA im_node TYPE REF TO if_ixml_element.
DATA im_filter TYPE REF TO if_ixml_node_filter.
DATA im_iterator TYPE REF TO if_ixml_node_iterator.
DATA ex_node TYPE REF TO if_ixml_element.
DATA ex_filter TYPE REF TO if_ixml_node_filter.
DATA ex_iterator TYPE REF TO if_ixml_node_iterator.
DATA ch_node TYPE REF TO if_ixml_element.
DATA ch_filter TYPE REF TO if_ixml_node_filter.
DATA ch_iterator TYPE REF TO if_ixml_node_iterator.
DATA ta_node TYPE REF TO if_ixml_element.
DATA ta_filter TYPE REF TO if_ixml_node_filter.
DATA ta_iterator TYPE REF TO if_ixml_node_iterator.
DATA el_node TYPE REF TO if_ixml_element.
DATA el_filter TYPE REF TO if_ixml_node_filter.
DATA el_iterator TYPE REF TO if_ixml_node_iterator.
DATA dm_node TYPE REF TO if_ixml_element.
DATA dm_filter TYPE REF TO if_ixml_node_filter.
DATA dm_iterator TYPE REF TO if_ixml_node_iterator.
DATA sc_node TYPE REF TO if_ixml_element.
DATA sc_filter TYPE REF TO if_ixml_node_filter.
DATA sc_iterator TYPE REF TO if_ixml_node_iterator.
DATA scn_node TYPE REF TO if_ixml_element.
DATA scn_filter TYPE REF TO if_ixml_node_filter.
DATA scn_iterator TYPE REF TO if_ixml_node_iterator.
DATA fmdoc_node TYPE REF TO if_ixml_element.
functionmodules_node = fm_node.
functiongroupname = fct_group.
IF functionmodules_node IS NOT INITIAL.
FREE: filter, iterator, node.
filter =
functionmodules_node->create_filter_name( 'functionmodule' ).
iterator = functionmodules_node->create_iterator_filtered( filter ).
node ?= iterator->get_next( ).
WHILE node IS NOT INITIAL.
CALL METHOD getstructurefromattributes
EXPORTING
node = node
CHANGING
structure = xfunct_head.
REFRESH: iimport, ichange, iexport,
itables, iexcepl, idocume, isource, isource_new.
* Get importing
FREE: im_filter, im_iterator, im_node.
im_filter = node->create_filter_name( 'importing' ).
im_iterator = node->create_iterator_filtered( im_filter ).
im_node ?= im_iterator->get_next( ).
WHILE im_node IS NOT INITIAL.
CALL METHOD getstructurefromattributes
EXPORTING
node = im_node
CHANGING
structure = ximport.
APPEND ximport TO iimport.
im_node ?= im_iterator->get_next( ).
ENDWHILE.
* Get exporting
FREE: ex_filter, ex_iterator, ex_node.
ex_filter = node->create_filter_name( 'exporting' ).
ex_iterator = node->create_iterator_filtered( ex_filter ).
ex_node ?= ex_iterator->get_next( ).
WHILE ex_node IS NOT INITIAL.
CALL METHOD getstructurefromattributes
EXPORTING
node = ex_node
CHANGING
structure = xexport.
APPEND xexport TO iexport.
ex_node ?= ex_iterator->get_next( ).
ENDWHILE.
* Get changing
FREE: ch_filter, ch_iterator, ch_node.
ch_filter = node->create_filter_name( 'changing' ).
ch_iterator = node->create_iterator_filtered( ch_filter ).
ch_node ?= ch_iterator->get_next( ).
WHILE ch_node IS NOT INITIAL.
CALL METHOD getstructurefromattributes
EXPORTING
node = ch_node
CHANGING
structure = xchange.
APPEND xchange TO ichange.
ch_node ?= ch_iterator->get_next( ).
ENDWHILE.
* Get tables
FREE: ta_filter, ta_iterator, ta_node.
ta_filter = node->create_filter_name( 'tables' ).
ta_iterator = node->create_iterator_filtered( ta_filter ).
ta_node ?= ta_iterator->get_next( ).
WHILE ta_node IS NOT INITIAL.
CALL METHOD getstructurefromattributes
EXPORTING
node = ta_node
CHANGING
structure = xtables.
APPEND xtables TO itables.
ta_node ?= ta_iterator->get_next( ).
ENDWHILE.
* Get exception list
FREE: el_filter, el_iterator, el_node.
el_filter = node->create_filter_name( 'exceptions' ).
el_iterator = node->create_iterator_filtered( el_filter ).
el_node ?= el_iterator->get_next( ).
WHILE el_node IS NOT INITIAL.
CALL METHOD getstructurefromattributes
EXPORTING
node = el_node
CHANGING
structure = xexcepl.
APPEND xexcepl TO iexcepl.
el_node ?= el_iterator->get_next( ).
ENDWHILE.
* Get documentation
FREE: dm_filter, dm_iterator, dm_node.
dm_filter = node->create_filter_name( 'documentation' ).
dm_iterator = node->create_iterator_filtered( dm_filter ).
dm_node ?= dm_iterator->get_next( ).
WHILE dm_node IS NOT INITIAL.
CALL METHOD getstructurefromattributes
EXPORTING
node = dm_node
CHANGING
structure = xdocume.
APPEND xdocume TO idocume.
dm_node ?= dm_iterator->get_next( ).
ENDWHILE.
* Get fm source
FREE: sc_filter, sc_iterator, sc_node.
sc_filter = node->create_filter_name( 'fm_source' ).
sc_iterator = node->create_iterator_filtered( sc_filter ).
sc_node ?= sc_iterator->get_next( ).
WHILE sc_node IS NOT INITIAL.
source = sc_node->get_value( ).
sourcetable = buildtablefromstring( source ).
LOOP AT sourcetable INTO xsource.
APPEND xsource TO isource.
ENDLOOP.
sc_node ?= sc_iterator->get_next( ).
ENDWHILE.
* Get fm source new
FREE: scn_filter, scn_iterator, scn_node.
scn_filter = node->create_filter_name( 'fm_source_new' ).
scn_iterator = node->create_iterator_filtered( scn_filter ).
scn_node ?= scn_iterator->get_next( ).
WHILE scn_node IS NOT INITIAL.
source = scn_node->get_value( ).
sourcetable = buildtablefromstring( source ).
LOOP AT sourcetable INTO xsource_new.
APPEND xsource_new TO isource_new.
ENDLOOP.
scn_node ?= scn_iterator->get_next( ).
ENDWHILE.
* INsert the function module
CALL FUNCTION 'RS_FUNCTIONMODULE_INSERT'
EXPORTING
funcname = xfunct_head-name
function_pool = functiongroupname
interface_global = xfunct_head-global
remote_call = xfunct_head-remote
update_task = xfunct_head-utask
short_text = xfunct_head-stext
save_active = ' ' "<-- Need to set inactive
new_source = isource_new
TABLES
import_parameter = iimport
export_parameter = iexport
tables_parameter = itables
changing_parameter = ichange
exception_list = iexcepl
parameter_docu = idocume
source = isource
EXCEPTIONS
double_task = 1
error_message = 2
function_already_exists = 3
invalid_function_pool = 4
invalid_name = 5
too_many_functions = 6
no_modify_permission = 7
no_show_permission = 8
enqueue_system_failure = 9
canceled_in_corr = 10