拷贝/打包

一、程序下载

拷贝/打包
   1 *&---------------------------------------------------------------------*
   2 *& Report  ZEXPORT
   3 *&
   4 *&---------------------------------------------------------------------*
   5 *&TEDK900341
   6 *&
   7 *&---------------------------------------------------------------------*
   8 
   9 REPORT ZCHENKAI.
  10 
  11 
  12 
  13 
  14 *&---------------------------------------------------------------------*
  15 *& Report  ZTEST1111
  16 *&
  17 *&---------------------------------------------------------------------*
  18 *&
  19 *&
  20 *&---------------------------------------------------------------------*
  21 
  22 *&---------------------------------------------------------------------*
  23 *& Report  ZCQBTEST_1
  24 *&
  25 *&---------------------------------------------------------------------*
  26 *&
  27 *&
  28 *&------------------------------------------------------------------
  29 
  30 
  31 *REPORT zcqbtest_1.
  32 *======================================================================================================================
  33 *  Direct Download Enterprise version 1.3.1.
  34 *
  35 *  THIS SOFTWARE IS FOR PERSONAL USE ONLY.
  36 *  THIS PROGRAM IS FREEWARE AND IS PROVIDED ON AN AS-IS BASIS WITHOUT WARRANTY OF ANY KIND.
  37 *  THE PROVIDER SPECIFICALLY DISCLAIMS ANY OTHER WARRANTY, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY
  38 *  OR FITNESS FOR A PARTICULAR PURPOSE.
  39 *
  40 *  IN NO EVENT SHALL THE PROVIDER BE LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, SPECIAL OR INCIDENTAL DAMAGES, EVEN IF PROVIDER
  41 *  HAS BEEN ADVISED BY CLIENT OF THE POSSIBILITY OF SUCH POTENTIAL LOSS OR DAMAGE.
  42 *  CLIENT AGREES TO HOLD PROVIDER HARMLESS FROM AND AGAINST ANY AND ALL CLAIMS, LOSSES, LIABILITIES AND EXPENSES.  BY
  43 *  INSTALLING OR RUNNING THIS PROGRAM YOU ARE AGREEING TO THE TERMS AND CONDITONS STATED ABOVE.
  44 *
  45 *----------------------------------------------------------------------------------------------------------------------
  46 *  PROGRAM DESCRIPTION & USE
  47 *  Allows a user to download programs, Functions, DD definitions, etc to the presentation server.  This version searches
  48 *  recursively for nested includes and function modules, and allows you to download the resulting code as standard text
  49 *  or HTML web pages within a suitable directory structure.
  50 *
  51 *  You can either search by object name, using wildcards if you wish, or a combination of Author and object name.  If
  52 *  you want all objects returned for a particular author then select the author name and choose the most suitable
  53 *  radiobutton.  All objects will be returned if the fields to the right hand side of the radiobutton are left completely
  54 *  blank.
  55 *
  56 *  Compatible with R/3 Enterprise only, for older versions of SAP you will need Direct Download version 5.xx.
  57 *  This version removes the programming limitations imposed by developing across SAP releases 3 to 4.6.
  58 *
  59 *  In order to be able to download files to the SAP server you must first set up a logical filepath within transaction
  60 *  'FILE', or use an existing one.  You must also create a external operating system command in SM69 called ZMKDIR. This
  61 *  will then be used to create any directories needed on the SAP server
  62 
  63 *  This program is intended to allow a person to keep a visual representation of a program for backup purposes only as
  64 *  has not been designed to allow programs to be uploaded to SAP systems.
  65 *----------------------------------------------------------------------------------------------------------------------
  66 *
  67 * author          : E.G.Mellodew
  68 *
  69 *
  70 * program contact : direct@dalestech.com
  71 *                   www.dalestech.com
  72 *
  73 *----------------------------------------------------------------------------------------------------------------------
  74 
  75 *----------------------------------------------------------------------------------------------------------------------
  76 *  SAP Tables
  77 *----------------------------------------------------------------------------------------------------------------------
  78 TABLES: trdir, seoclass, tfdir, enlfdir, dd02l.
  79 
  80 *----------------------------------------------------------------------------------------------------------------------
  81 *  Types
  82 *----------------------------------------------------------------------------------------------------------------------
  83 * text element structure
  84 TYPES: ttexttable LIKE textpool.
  85 * GUI titles
  86 TYPES: tguititle LIKE d347t.
  87 
  88 * Message classes
  89 TYPES: BEGIN OF tmessage,
  90          arbgb LIKE t100-arbgb,
  91          stext LIKE t100a-stext,
  92          msgnr LIKE t100-msgnr,
  93          text  LIKE t100-text,
  94        END OF tmessage.
  95 
  96 * Screen flow.
  97 TYPES: BEGIN OF tscreenflow,
  98          screen LIKE d020s-dnum,
  99          code LIKE d022s-line,
 100        END OF tscreenflow.
 101 
 102 * Holds a table\structure definition
 103 TYPES: BEGIN OF tdicttablestructure,
 104          fieldname LIKE dd03l-fieldname,
 105          position  LIKE dd03l-position,
 106          keyflag   LIKE dd03l-keyflag,
 107          rollname  LIKE dd03l-rollname,
 108          domname   LIKE dd03l-domname,
 109          datatype  LIKE dd03l-datatype,
 110          leng      LIKE dd03l-leng,
 111          ddtext    LIKE dd04t-ddtext,
 112        END OF tdicttablestructure.
 113 
 114 * Holds a tables attributes + its definition
 115 TYPES: BEGIN OF tdicttable,
 116          tablename    LIKE dd03l-tabname,
 117          tabletitle   LIKE dd02t-ddtext,
 118          istructure TYPE tdicttablestructure OCCURS 0,
 119        END OF tdicttable.
 120 
 121 * Include program names
 122 TYPES: BEGIN OF tinclude,
 123          includename LIKE trdir-name,
 124          includetitle LIKE tftit-stext,
 125        END OF tinclude.
 126 
 127 * Exception class texts
 128 TYPES: BEGIN OF tconcept,
 129          constname TYPE string,
 130          concept TYPE sotr_conc,
 131        END OF tconcept.
 132 
 133 * Method
 134 TYPES: BEGIN OF tmethod,
 135          cmpname LIKE vseomethod-cmpname,
 136          descript LIKE vseomethod-descript,
 137          exposure LIKE vseomethod-exposure,
 138          methodkey TYPE string,
 139        END OF tmethod.
 140 
 141 * Class
 142 TYPES: BEGIN OF tclass,
 143          scanned(1),
 144          clsname LIKE vseoclass-clsname,
 145          descript LIKE vseoclass-descript,
 146          msg_id LIKE vseoclass-msg_id,
 147          exposure LIKE vseoclass-exposure,
 148          state LIKE vseoclass-state,
 149          clsfinal LIKE vseoclass-clsfinal,
 150          r3release LIKE vseoclass-r3release,
 151          imethods TYPE tmethod OCCURS 0,
 152          idictstruct TYPE tdicttable OCCURS 0,
 153          itextelements TYPE ttexttable OCCURS 0,
 154          imessages TYPE tmessage OCCURS 0,
 155          iconcepts TYPE tconcept OCCURS 0,
 156          textelementkey TYPE string,
 157          publicclasskey TYPE string,
 158          privateclasskey TYPE string,
 159          protectedclasskey TYPE string,
 160          typesclasskey TYPE string,
 161          exceptionclass TYPE i,
 162        END OF tclass.
 163 
 164 * function modules
 165 TYPES: BEGIN OF tfunction,
 166          functionname LIKE tfdir-funcname,
 167          functiongroup LIKE enlfdir-area,
 168          includenumber LIKE tfdir-include,
 169          functionmaininclude LIKE tfdir-funcname,
 170          functiontitle LIKE tftit-stext,
 171          topincludename LIKE tfdir-funcname,
 172          progname LIKE tfdir-pname,
 173          programlinkname LIKE tfdir-pname,
 174          messageclass LIKE t100-arbgb,
 175          itextelements TYPE ttexttable OCCURS 0,
 176          iselectiontexts TYPE ttexttable OCCURS 0,
 177          imessages TYPE tmessage OCCURS 0,
 178          iincludes TYPE tinclude OCCURS 0,
 179          idictstruct TYPE tdicttable OCCURS 0,
 180          iguititle TYPE tguititle OCCURS 0,
 181          iscreenflow TYPE tscreenflow OCCURS 0,
 182        END OF tfunction.
 183 
 184 TYPES: BEGIN OF tprogram,
 185          progname LIKE trdir-name,
 186          programtitle LIKE tftit-stext,
 187          subc LIKE trdir-subc,
 188          messageclass LIKE t100-arbgb,
 189          imessages TYPE tmessage OCCURS 0,
 190          itextelements TYPE ttexttable OCCURS 0,
 191          iselectiontexts TYPE ttexttable OCCURS 0,
 192          iguititle TYPE tguititle OCCURS 0,
 193          iscreenflow TYPE tscreenflow OCCURS 0,
 194          iincludes TYPE tinclude OCCURS 0,
 195          idictstruct TYPE tdicttable OCCURS 0,
 196        END OF tprogram.
 197 
 198 *----------------------------------------------------------------------------------------------------------------------
 199 *  Internal tables
 200 *----------------------------------------------------------------------------------------------------------------------
 201 *  Dictionary object
 202 DATA: idictionary TYPE STANDARD TABLE OF tdicttable WITH HEADER LINE.
 203 * Function modules.
 204 DATA: ifunctions TYPE STANDARD TABLE OF tfunction WITH HEADER LINE.
 205 * Tree display structure.
 206 DATA: itreedisplay TYPE STANDARD TABLE OF snodetext WITH HEADER LINE.
 207 * Message class data
 208 DATA: imessages TYPE STANDARD TABLE OF tmessage WITH HEADER LINE.
 209 * Holds a single message class an all of its messages
 210 DATA: isinglemessageclass TYPE STANDARD TABLE OF tmessage WITH HEADER LINE.
 211 * Holds program related data
 212 DATA: iprograms TYPE STANDARD TABLE OF tprogram WITH HEADER LINE.
 213 * Classes
 214 DATA: iclasses TYPE STANDARD TABLE OF tclass WITH HEADER LINE.
 215 * Table of paths created on the SAP server
 216 DATA: iserverpaths TYPE STANDARD TABLE OF string WITH HEADER LINE.
 217 
 218 *----------------------------------------------------------------------------------------------------------------------
 219 *  Table prototypes
 220 *----------------------------------------------------------------------------------------------------------------------
 221 DATA: dumidictstructure TYPE STANDARD TABLE OF tdicttablestructure.
 222 DATA: dumitexttab TYPE STANDARD TABLE OF ttexttable.
 223 DATA: dumiincludes TYPE STANDARD TABLE OF tinclude.
 224 DATA: dumihtml TYPE STANDARD TABLE OF string.
 225 DATA: dumiheader TYPE STANDARD TABLE OF string .
 226 DATA: dumiscreen TYPE STANDARD TABLE OF tscreenflow .
 227 DATA: dumiguititle TYPE STANDARD TABLE OF tguititle.
 228 DATA: dumimethods TYPE STANDARD TABLE OF tmethod.
 229 DATA: dumiconcepts TYPE STANDARD TABLE OF tconcept.
 230 
 231 *----------------------------------------------------------------------------------------------------------------------
 232 *   Global objects
 233 *----------------------------------------------------------------------------------------------------------------------
 234 DATA: objfile TYPE REF TO cl_gui_frontend_services.
 235 DATA: objruntimeerror TYPE REF TO cx_root.
 236 
 237 *----------------------------------------------------------------------------------------------------------------------
 238 *  Constants
 239 *----------------------------------------------------------------------------------------------------------------------
 240 CONSTANTS: versionno TYPE string VALUE '1.3.1'.
 241 CONSTANTS: tables TYPE string VALUE 'TABLES'.
 242 CONSTANTS: table TYPE string VALUE 'TABLE'.
 243 CONSTANTS: like TYPE string VALUE 'LIKE'.
 244 CONSTANTS: type TYPE string VALUE 'TYPE'.
 245 CONSTANTS: typerefto TYPE string VALUE 'TYPE REF TO'.
 246 CONSTANTS: structure TYPE string VALUE 'STRUCTURE'.
 247 CONSTANTS: lowstructure TYPE string VALUE 'structure'.
 248 CONSTANTS: occurs TYPE string VALUE 'OCCURS'.
 249 CONSTANTS: function TYPE string VALUE 'FUNCTION'.
 250 CONSTANTS: callfunction TYPE string VALUE ' CALL FUNCTION'.
 251 CONSTANTS: message TYPE string  VALUE 'MESSAGE'.
 252 CONSTANTS: include TYPE string VALUE 'INCLUDE'.
 253 CONSTANTS: lowinclude TYPE string VALUE 'include'.
 254 CONSTANTS: destination TYPE string VALUE 'DESTINATION'.
 255 CONSTANTS: is_table TYPE string VALUE 'T'.
 256 CONSTANTS: is_program TYPE string VALUE 'P'.
 257 CONSTANTS: is_screen TYPE string VALUE 'S'.
 258 CONSTANTS: is_guititle TYPE string VALUE 'G'.
 259 CONSTANTS: is_documentation TYPE string VALUE 'D'.
 260 CONSTANTS: is_messageclass TYPE string VALUE 'MC'.
 261 CONSTANTS: is_function TYPE string VALUE 'F'.
 262 CONSTANTS: is_class TYPE string VALUE 'C'.
 263 CONSTANTS: is_method TYPE string VALUE 'M'.
 264 CONSTANTS: asterix TYPE string VALUE '*'.
 265 CONSTANTS: comma TYPE string VALUE ','.
 266 CONSTANTS: period TYPE string VALUE '.'.
 267 CONSTANTS: dash TYPE string VALUE '-'.
 268 CONSTANTS: true TYPE i VALUE 1.
 269 CONSTANTS: false TYPE i VALUE 0.
 270 CONSTANTS: lt TYPE string VALUE '<'.
 271 CONSTANTS: gt TYPE string VALUE '>'.
 272 CONSTANTS: unix TYPE string VALUE 'UNIX'.
 273 CONSTANTS: non_unix TYPE string VALUE 'not UNIX'.
 274 CONSTANTS: background_colour TYPE string VALUE '#FFFFE0'.
 275 CONSTANTS: colour_white TYPE string VALUE '#FFFFFF'.
 276 CONSTANTS: colour_black TYPE string VALUE '#000000'.
 277 CONSTANTS: colour_yellow TYPE string VALUE '#FFFF00'.
 278 CONSTANTS: comment_colour TYPE string VALUE '#0000FF'.
 279 CONSTANTS: htmlextension TYPE string VALUE 'html'.
 280 CONSTANTS: textextension TYPE string VALUE 'txt'.
 281 
 282 *----------------------------------------------------------------------------------------------------------------------
 283 *  Global variables
 284 *----------------------------------------------------------------------------------------------------------------------
 285 DATA: statusbarmessage(100).
 286 DATA: forcedexit TYPE i VALUE 0.
 287 DATA: starttime LIKE sy-uzeit.
 288 DATA: runtime LIKE sy-uzeit.
 289 DATA: downloadfileextension TYPE string.
 290 DATA: downloadfolder TYPE string.
 291 DATA: serverslashseparator TYPE string.
 292 DATA: frontendslashseparator TYPE string.
 293 DATA: slashseparatortouse TYPE string.
 294 DATA: serverfilesystem TYPE filesys_d.
 295 DATA: serverfolder TYPE string.
 296 DATA: frontendopsystem TYPE string.
 297 DATA: serveropsystem TYPE string.
 298 DATA: customernamespace TYPE string.
 299 RANGES: soprogramname FOR trdir-name.
 300 RANGES: soauthor FOR usr02-bname.
 301 RANGES: sotablenames FOR dd02l-tabname.
 302 RANGES: sofunctionname  FOR tfdir-funcname.
 303 RANGES: soclassname FOR vseoclass-clsname.
 304 RANGES: sofunctiongroup FOR enlfdir-area.
 305 FIELD-SYMBOLS: <wadictstruct> TYPE tdicttable.
 306 
 307 *----------------------------------------------------------------------------------------------------------------------
 308 *  Selection screen declaration
 309 *----------------------------------------------------------------------------------------------------------------------
 310 * Author
 311 SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE tblock1.
 312 SELECTION-SCREEN BEGIN OF LINE.
 313 SELECTION-SCREEN COMMENT 5(23) tauth.
 314 PARAMETERS: pauth LIKE usr02-bname MEMORY ID mauth.
 315 SELECTION-SCREEN END OF LINE.
 316 
 317 SELECTION-SCREEN BEGIN OF LINE.
 318 SELECTION-SCREEN COMMENT 5(36) tpmod.
 319 PARAMETERS: pmod AS CHECKBOX.
 320 SELECTION-SCREEN END OF LINE.
 321 
 322 * Local objects
 323 SELECTION-SCREEN BEGIN OF LINE.
 324 SELECTION-SCREEN COMMENT 5(36) t$tmp.
 325 PARAMETERS: p$tmp AS CHECKBOX DEFAULT ''.
 326 SELECTION-SCREEN END OF LINE.
 327 SELECTION-SCREEN: END OF BLOCK b1.
 328 
 329 SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE tblock2.
 330 * Tables
 331 SELECTION-SCREEN BEGIN OF LINE.
 332 PARAMETERS: rtable RADIOBUTTON GROUP r1.
 333 SELECTION-SCREEN COMMENT 5(15) trtable.
 334 SELECTION-SCREEN END OF LINE.
 335 
 336 SELECTION-SCREEN BEGIN OF LINE.
 337 SELECTION-SCREEN COMMENT 10(15) tptable.
 338 SELECT-OPTIONS: sotable FOR dd02l-tabname.
 339 SELECTION-SCREEN END OF LINE.
 340 
 341 SELECTION-SCREEN BEGIN OF LINE.
 342 SELECTION-SCREEN COMMENT 10(79) ttnote.
 343 SELECTION-SCREEN END OF LINE.
 344 
 345 * Message classes
 346 SELECTION-SCREEN BEGIN OF LINE.
 347 PARAMETERS: rmess RADIOBUTTON GROUP r1.
 348 SELECTION-SCREEN COMMENT 5(18) tpmes.
 349 SELECTION-SCREEN END OF LINE.
 350 
 351 SELECTION-SCREEN BEGIN OF LINE.
 352 SELECTION-SCREEN COMMENT 10(18) tmname.
 353 PARAMETERS: pmname LIKE t100-arbgb MEMORY ID mmname.
 354 SELECTION-SCREEN END OF LINE.
 355 
 356 * Function modules
 357 SELECTION-SCREEN BEGIN OF LINE.
 358 PARAMETERS: rfunc RADIOBUTTON GROUP r1.
 359 SELECTION-SCREEN COMMENT 5(30) trfunc.
 360 SELECTION-SCREEN END OF LINE.
 361 
 362 SELECTION-SCREEN BEGIN OF LINE.
 363 SELECTION-SCREEN COMMENT 10(15) tpfname.
 364 SELECT-OPTIONS: sofname FOR tfdir-funcname.
 365 SELECTION-SCREEN END OF LINE.
 366 
 367 SELECTION-SCREEN BEGIN OF LINE.
 368 SELECTION-SCREEN COMMENT 10(15) tfgroup.
 369 SELECT-OPTIONS: sofgroup FOR enlfdir-area.
 370 SELECTION-SCREEN END OF LINE.
 371 
 372 * Classes
 373 SELECTION-SCREEN BEGIN OF LINE.
 374 PARAMETERS: rclass RADIOBUTTON GROUP r1.
 375 SELECTION-SCREEN COMMENT 5(30) trclass.
 376 SELECTION-SCREEN END OF LINE.
 377 
 378 SELECTION-SCREEN BEGIN OF LINE.
 379 SELECTION-SCREEN COMMENT 10(15) tpcname.
 380 SELECT-OPTIONS: soclass FOR seoclass-clsname.
 381 SELECTION-SCREEN END OF LINE.
 382 
 383 * Programs / includes
 384 SELECTION-SCREEN BEGIN OF LINE.
 385 PARAMETERS: rprog RADIOBUTTON GROUP r1 DEFAULT 'X'.
 386 SELECTION-SCREEN COMMENT 5(18) tprog.
 387 SELECTION-SCREEN END OF LINE.
 388 
 389 SELECTION-SCREEN BEGIN OF LINE.
 390 SELECTION-SCREEN COMMENT 10(15) trpname.
 391 SELECT-OPTIONS: soprog FOR trdir-name.
 392 SELECTION-SCREEN END OF LINE.
 393 
 394 SELECTION-SCREEN SKIP.
 395 * Language
 396 SELECTION-SCREEN BEGIN OF LINE.
 397 SELECTION-SCREEN COMMENT 1(18) tmlang.
 398 PARAMETERS: pmlang LIKE t100-sprsl DEFAULT 'EN'.
 399 SELECTION-SCREEN END OF LINE.
 400 
 401 * Package
 402 SELECTION-SCREEN BEGIN OF LINE.
 403 SELECTION-SCREEN COMMENT 1(18) tpack.
 404 PARAMETERS: ppack LIKE tadiv-devclass MEMORY ID mpack.
 405 SELECTION-SCREEN END OF LINE.
 406 
 407 * Customer objects
 408 SELECTION-SCREEN BEGIN OF LINE.
 409 SELECTION-SCREEN COMMENT 1(27) tcust.
 410 PARAMETERS: pcust AS CHECKBOX DEFAULT 'X'.
 411 SELECTION-SCREEN COMMENT 32(25) tnrange.
 412 PARAMETERS: pcname TYPE namespace MEMORY ID mnamespace.
 413 SELECTION-SCREEN END OF LINE.
 414 SELECTION-SCREEN: END OF BLOCK b2.
 415 
 416 * Additional things to download.
 417 SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE tblock3.
 418 SELECTION-SCREEN BEGIN OF LINE.
 419 SELECTION-SCREEN COMMENT 1(33) tptext.
 420 PARAMETERS: ptext AS CHECKBOX DEFAULT 'X' MEMORY ID mtext.
 421 SELECTION-SCREEN END OF LINE.
 422 
 423 SELECTION-SCREEN BEGIN OF LINE.
 424 SELECTION-SCREEN COMMENT 1(33) tmess.
 425 PARAMETERS: pmess AS CHECKBOX DEFAULT 'X' MEMORY ID mmess.
 426 SELECTION-SCREEN END OF LINE.
 427 
 428 SELECTION-SCREEN BEGIN OF LINE.
 429 SELECTION-SCREEN COMMENT 1(33) tpinc.
 430 PARAMETERS: pinc AS CHECKBOX DEFAULT 'X' MEMORY ID minc.
 431 SELECTION-SCREEN COMMENT 40(20) trecc.
 432 PARAMETERS: preci AS CHECKBOX DEFAULT 'X' MEMORY ID mreci.
 433 SELECTION-SCREEN END OF LINE.
 434 
 435 SELECTION-SCREEN BEGIN OF LINE.
 436 SELECTION-SCREEN COMMENT 1(33) tpfunc.
 437 PARAMETERS: pfunc AS CHECKBOX DEFAULT 'X' MEMORY ID mfunc.
 438 SELECTION-SCREEN COMMENT 40(20) trecf.
 439 PARAMETERS: precf AS CHECKBOX DEFAULT 'X' MEMORY ID mrecf.
 440 SELECTION-SCREEN END OF LINE.
 441 
 442 SELECTION-SCREEN BEGIN OF LINE.
 443 SELECTION-SCREEN COMMENT 1(33) tdoc.
 444 PARAMETERS: pdoc AS CHECKBOX DEFAULT 'X' MEMORY ID mdoc.
 445 SELECTION-SCREEN END OF LINE.
 446 
 447 SELECTION-SCREEN BEGIN OF LINE.
 448 SELECTION-SCREEN COMMENT 1(33) tpscr.
 449 PARAMETERS: pscr AS CHECKBOX DEFAULT 'X' MEMORY ID mscr.
 450 SELECTION-SCREEN END OF LINE.
 451 
 452 SELECTION-SCREEN BEGIN OF LINE.
 453 SELECTION-SCREEN COMMENT 1(33) tpdict.
 454 PARAMETERS: pdict AS CHECKBOX DEFAULT 'X' MEMORY ID mdict.
 455 SELECTION-SCREEN END OF LINE.
 456 
 457 SELECTION-SCREEN BEGIN OF LINE.
 458 SELECTION-SCREEN COMMENT 1(33) tsortt.
 459 PARAMETERS: psortt AS CHECKBOX DEFAULT ' ' MEMORY ID msortt.
 460 SELECTION-SCREEN END OF LINE.
 461 SELECTION-SCREEN: END OF BLOCK b3.
 462 
 463 * File details
 464 SELECTION-SCREEN: BEGIN OF BLOCK b4 WITH FRAME TITLE tblock4.
 465 SELECTION-SCREEN BEGIN OF LINE.
 466 SELECTION-SCREEN COMMENT 1(20) tphtml.
 467 PARAMETERS: phtml RADIOBUTTON GROUP g1 DEFAULT 'X'.
 468 SELECTION-SCREEN END OF LINE.
 469 
 470 SELECTION-SCREEN BEGIN OF LINE.
 471 SELECTION-SCREEN COMMENT 5(29) tcomm.
 472 PARAMETERS: pcomm AS CHECKBOX DEFAULT 'X'.
 473 SELECTION-SCREEN END OF LINE.
 474 
 475 SELECTION-SCREEN BEGIN OF LINE.
 476 SELECTION-SCREEN COMMENT 5(29) tback.
 477 PARAMETERS: pback AS CHECKBOX DEFAULT 'X'.
 478 SELECTION-SCREEN END OF LINE.
 479 
 480 SELECTION-SCREEN BEGIN OF LINE.
 481 SELECTION-SCREEN COMMENT 1(20) tptxt.
 482 PARAMETERS: ptxt RADIOBUTTON GROUP g1.
 483 SELECTION-SCREEN END OF LINE.
 484 
 485 SELECTION-SCREEN SKIP.
 486 
 487 * Download to SAP server
 488 SELECTION-SCREEN BEGIN OF LINE.
 489 SELECTION-SCREEN COMMENT 1(25) tserv.
 490 PARAMETERS: pserv RADIOBUTTON GROUP g2.
 491 SELECTION-SCREEN END OF LINE.
 492 SELECTION-SCREEN BEGIN OF LINE.
 493 SELECTION-SCREEN COMMENT 8(20) tspath.
 494 PARAMETERS: plogical LIKE filename-fileintern MEMORY ID mlogical.
 495 SELECTION-SCREEN END OF LINE.
 496 SELECTION-SCREEN COMMENT /28(60) tsdpath.
 497 
 498 * Download to PC
 499 SELECTION-SCREEN BEGIN OF LINE.
 500 SELECTION-SCREEN COMMENT 1(25) tpc.
 501 PARAMETERS: ppc RADIOBUTTON GROUP g2 DEFAULT 'X'.
 502 SELECTION-SCREEN END OF LINE.
 503 SELECTION-SCREEN BEGIN OF LINE.
 504 SELECTION-SCREEN COMMENT 8(20) tppath.
 505 PARAMETERS: pfolder LIKE rlgrap-filename MEMORY ID mfolder.
 506 SELECTION-SCREEN END OF LINE.
 507 SELECTION-SCREEN: END OF BLOCK b4.
 508 
 509 * Display options
 510 SELECTION-SCREEN: BEGIN OF BLOCK b5 WITH FRAME TITLE tblock5.
 511 * Display final report
 512 SELECTION-SCREEN BEGIN OF LINE.
 513 SELECTION-SCREEN COMMENT 1(33) trep.
 514 PARAMETERS: prep AS CHECKBOX DEFAULT 'X'.
 515 SELECTION-SCREEN END OF LINE.
 516 * Display progress messages
 517 SELECTION-SCREEN BEGIN OF LINE.
 518 SELECTION-SCREEN COMMENT 1(33) tpromess.
 519 PARAMETERS: ppromess AS CHECKBOX DEFAULT 'X'.
 520 SELECTION-SCREEN END OF LINE.
 521 SELECTION-SCREEN: END OF BLOCK b5.
 522 
 523 *----------------------------------------------------------------------------------------------------------------------
 524 * Display a directory picker window
 525 *----------------------------------------------------------------------------------------------------------------------
 526 AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfolder.
 527 
 528   DATA: objfile TYPE REF TO cl_gui_frontend_services.
 529   DATA: pickedfolder TYPE string.
 530   DATA: initialfolder TYPE string.
 531 
 532   IF sy-batch IS INITIAL.
 533     CREATE OBJECT objfile.
 534 
 535     IF NOT pfolder IS INITIAL.
 536       initialfolder = pfolder.
 537     ELSE.
 538       objfile->get_temp_directory( CHANGING temp_dir = initialfolder
 539                                    EXCEPTIONS cntl_error = 1
 540                                              error_no_gui = 2
 541                                              not_supported_by_gui = 3 ).
 542     ENDIF.
 543 
 544     objfile->directory_browse( EXPORTING initial_folder = initialfolder
 545                                CHANGING selected_folder = pickedfolder
 546                                EXCEPTIONS cntl_error = 1
 547                                           error_no_gui = 2
 548                                           not_supported_by_gui = 3 ).
 549 
 550     IF sy-subrc = 0.
 551       pfolder = pickedfolder.
 552     ELSE.
 553       WRITE: / 'An error has occured picking a folder'.
 554     ENDIF.
 555   ENDIF.
 556 
 557 *----------------------------------------------------------------------------------------------------------------------
 558 AT SELECTION-SCREEN.
 559 *----------------------------------------------------------------------------------------------------------------------
 560   CASE 'X'.
 561     WHEN ppc.
 562       IF pfolder IS INITIAL.
 563 *       User must enter a path to save to
 564         MESSAGE e000(oo) WITH 'You must enter a file path'.
 565       ENDIF.
 566 
 567     WHEN pserv.
 568       IF plogical IS INITIAL.
 569 *       User must enter a logical path to save to
 570         MESSAGE e000(oo) WITH 'You must enter a logical file name'.
 571       ENDIF.
 572   ENDCASE.
 573 
 574 *----------------------------------------------------------------------------------------------------------------------
 575 AT SELECTION-SCREEN ON plogical.
 576 *----------------------------------------------------------------------------------------------------------------------
 577 
 578   IF NOT pserv IS INITIAL.
 579     CALL FUNCTION 'FILE_GET_NAME'
 580       EXPORTING
 581         logical_filename = plogical
 582       IMPORTING
 583         file_name        = serverfolder
 584       EXCEPTIONS
 585         file_not_found   = 1
 586         OTHERS           = 2.
 587     IF sy-subrc = 0.
 588       IF serverfolder IS INITIAL.
 589         MESSAGE e000(oo) WITH 'No file path returned from logical filename'.
 590       ELSE.
 591 *       Path to display on the selection screen
 592         tsdpath = serverfolder.
 593 *       Remove the trailing slash off the path as the subroutine buildFilename will add an extra one
 594         SHIFT serverfolder RIGHT DELETING TRAILING serverslashseparator.
 595         SHIFT serverfolder LEFT DELETING LEADING space.
 596       ENDIF.
 597     ELSE.
 598       MESSAGE e000(oo) WITH 'Logical filename does not exist'.
 599     ENDIF.
 600   ENDIF.
 601 
 602 * ---------------------------------------------------------------------------------------------------------------------
 603 AT SELECTION-SCREEN ON VALUE-REQUEST FOR soprog-low.
 604 * ---------------------------------------------------------------------------------------------------------------------
 605   CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
 606     EXPORTING
 607       object_type           = 'PROG'
 608       object_name           = soprog-low
 609       suppress_selection    = 'X'
 610       use_alv_grid          = ''
 611       without_personal_list = ''
 612     IMPORTING
 613       object_name_selected  = soprog-low
 614     EXCEPTIONS
 615       cancel                = 1.
 616 
 617 * ---------------------------------------------------------------------------------------------------------------------
 618 AT SELECTION-SCREEN ON VALUE-REQUEST FOR soprog-high.
 619 * ---------------------------------------------------------------------------------------------------------------------
 620   CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
 621     EXPORTING
 622       object_type           = 'PROG'
 623       object_name           = soprog-high
 624       suppress_selection    = 'X'
 625       use_alv_grid          = ''
 626       without_personal_list = ''
 627     IMPORTING
 628       object_name_selected  = soprog-high
 629     EXCEPTIONS
 630       cancel                = 1.
 631 
 632 * ---------------------------------------------------------------------------------------------------------------------
 633 AT SELECTION-SCREEN ON VALUE-REQUEST FOR soclass-low.
 634 * ---------------------------------------------------------------------------------------------------------------------
 635   CALL FUNCTION 'F4_DD_ALLTYPES'
 636     EXPORTING
 637       object               = soclass-low
 638       suppress_selection   = 'X'
 639       display_only         = ''
 640       only_types_for_clifs = 'X'
 641     IMPORTING
 642       RESULT               = soclass-low.
 643 
 644 * ---------------------------------------------------------------------------------------------------------------------
 645 AT SELECTION-SCREEN ON VALUE-REQUEST FOR soclass-high.
 646 * ---------------------------------------------------------------------------------------------------------------------
 647   CALL FUNCTION 'F4_DD_ALLTYPES'
 648     EXPORTING
 649       object               = soclass-high
 650       suppress_selection   = 'X'
 651       display_only         = ''
 652       only_types_for_clifs = 'X'
 653     IMPORTING
 654       RESULT               = soclass-high.
 655 
 656 * ---------------------------------------------------------------------------------------------------------------------
 657 AT SELECTION-SCREEN ON VALUE-REQUEST FOR sofname-low.
 658 * ---------------------------------------------------------------------------------------------------------------------
 659   CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
 660     EXPORTING
 661       object_type           = 'FUNC'
 662       object_name           = sofname-low
 663       suppress_selection    = 'X'
 664       use_alv_grid          = ''
 665       without_personal_list = ''
 666     IMPORTING
 667       object_name_selected  = sofname-low
 668     EXCEPTIONS
 669       cancel                = 1.
 670 
 671 * ---------------------------------------------------------------------------------------------------------------------
 672 AT SELECTION-SCREEN ON VALUE-REQUEST FOR sofname-high.
 673 * ---------------------------------------------------------------------------------------------------------------------
 674   CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
 675     EXPORTING
 676       object_type           = 'FUNC'
 677       object_name           = sofname-high
 678       suppress_selection    = 'X'
 679       use_alv_grid          = ''
 680       without_personal_list = ''
 681     IMPORTING
 682       object_name_selected  = sofname-high
 683     EXCEPTIONS
 684       cancel                = 1.
 685 
 686 * ---------------------------------------------------------------------------------------------------------------------
 687 AT SELECTION-SCREEN ON VALUE-REQUEST FOR sofgroup-low.
 688 * ---------------------------------------------------------------------------------------------------------------------
 689   CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
 690     EXPORTING
 691       object_type           = 'FUGR'
 692       object_name           = sofgroup-low
 693       suppress_selection    = 'X'
 694       use_alv_grid          = ''
 695       without_personal_list = ''
 696     IMPORTING
 697       object_name_selected  = sofgroup-low
 698     EXCEPTIONS
 699       cancel                = 1.
 700 
 701 * ---------------------------------------------------------------------------------------------------------------------
 702 AT SELECTION-SCREEN ON VALUE-REQUEST FOR sofgroup-high.
 703 * ---------------------------------------------------------------------------------------------------------------------
 704   CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
 705     EXPORTING
 706       object_type           = 'FUGR'
 707       object_name           = sofgroup-high
 708       suppress_selection    = 'X'
 709       use_alv_grid          = ''
 710       without_personal_list = ''
 711     IMPORTING
 712       object_name_selected  = sofgroup-high
 713     EXCEPTIONS
 714       cancel                = 1.
 715 
 716 *----------------------------------------------------------------------------------------------------------------------
 717 * initialisation
 718 *----------------------------------------------------------------------------------------------------------------------
 719 INITIALIZATION.
 720 * Parameter screen texts.
 721   tblock1 = 'Author (Optional)'.
 722   t$tmp   = 'Programs only: include local objects'.
 723   tblock2 = 'Objects to download'.
 724   tblock3 = 'Additional downloads for programs, function modules and classes'.
 725   tblock4 = 'Download parameters'.
 726   tblock5 = 'Display options'.
 727   tauth   = 'Author name'.
 728   tpmod   = 'Include programs modified by author'.
 729   tcust   = 'Only customer objects'.
 730   tnrange = 'Alt customer name range'.
 731   trtable = 'Tables / Structures'.
 732   tptable = 'Table name'.
 733   ttnote  = 'Note: tables are stored under the username of the last person who modified them'.
 734   trfunc  = 'Function modules'.
 735   tpfname = 'Function name'.
 736   tfgroup = 'Function group'.
 737   trclass  = 'Classes'.
 738   tpcname = 'Class name'.
 739   tmess   = 'Message class'.
 740   tmname  = 'Class name'.
 741   tmlang  = 'Language'.
 742   tprog   = 'Programs'.
 743   trpname = 'Program name'.
 744   tpack   = 'Package'.
 745   tptxt   = 'Text document'.
 746   tphtml  = 'HTML document'.
 747   tcomm   = 'Highlight comments'.
 748   tback   = 'Include background colour'.
 749   tptext  = 'Text elements'.
 750   tpinc   = 'Include programs'.
 751   trecc   = 'Recursive search'.
 752   tppath  = 'File path'.
 753   tspath  = 'Logical file name'.
 754   tpmes   = 'Message classes'.
 755   tpfunc  = 'Function modules'.
 756   tdoc    = 'Function module documentation'.
 757   trecf   = 'Recursive search'.
 758   tpscr   = 'Screens'.
 759   tpdict  = 'Dictionary structures'.
 760   tsortt  = 'Sort table fields alphabetically'.
 761   tserv   = 'Download to server'.
 762   tpc     = 'Download to PC'.
 763   trep    = 'Display download report'.
 764   tpromess  = 'Display progress messages'.
 765 
 766 * Determine the frontend operating system type.
 767   IF sy-batch IS INITIAL.
 768     PERFORM determinefrontendopsystem USING frontendslashseparator frontendopsystem.
 769   ENDIF.
 770   PERFORM determineserveropsystem USING serverslashseparator serverfilesystem serveropsystem.
 771 
 772 * Determine if the external command exists.  If it doesn't then disable the server input field
 773   PERFORM findexternalcommand.
 774 
 775 *----------------------------------------------------------------------------------------------------------------------
 776 * start-of-selection.
 777 *----------------------------------------------------------------------------------------------------------------------
 778 START-OF-SELECTION.
 779 
 780   PERFORM checkcomboboxes.
 781   PERFORM fillselectionranges.
 782   starttime = sy-uzeit.
 783 
 784 * Don't display status messages if we are running in the background
 785   IF NOT sy-batch IS INITIAL.
 786     ppromess = ''.
 787   ENDIF.
 788 
 789 * Fool the HTML routines to stop them hyperlinking anything with a space in them
 790   IF pcname IS INITIAL.
 791     customernamespace  = '^'.
 792   ELSE.
 793     customernamespace = pcname.
 794   ENDIF.
 795 
 796 * Determine which operating slash and download directory to use
 797   CASE 'X'.
 798     WHEN ppc.
 799       slashseparatortouse = frontendslashseparator.
 800       downloadfolder = pfolder.
 801     WHEN pserv.
 802       slashseparatortouse = serverslashseparator.
 803       downloadfolder = serverfolder.
 804   ENDCASE.
 805 
 806 * Main program flow.
 807   CASE 'X'.
 808 *   Select tables
 809     WHEN rtable.
 810       PERFORM retrievetables USING idictionary[]
 811                                    sotablenames[]
 812                                    soauthor[].
 813 
 814 *   Select message classes tables
 815     WHEN rmess.
 816       PERFORM retrievemessageclass USING imessages[]
 817                                          soauthor[]      "Author
 818                                          pmname          "Message class name
 819                                          pmlang          "Message class language
 820                                          pmod.           "Modified by author
 821 
 822 *   Select function modules
 823     WHEN rfunc.
 824       PERFORM retrievefunctions USING sofunctionname[]   "Function name
 825                                       sofunctiongroup[]  "Function group
 826                                       ifunctions[]       "Found functions
 827                                       soauthor[]         "Author
 828                                       ptext              "Get text elements
 829                                       pscr               "Get screens
 830                                       pcust              "Customer data only
 831                                       customernamespace. "Customer name range
 832 
 833 
 834       LOOP AT ifunctions.
 835 *       Find Dict structures, messages, functions, includes etc.
 836         PERFORM scanforadditionalfuncstuff USING ifunctions[]
 837                                                  preci                   "Search for includes recursively
 838                                                  precf                   "Search for functions recursively
 839                                                  pinc                    "Search for includes
 840                                                  pfunc                   "Search for functions
 841                                                  pdict                   "search for dictionary objects
 842                                                  pmess                   "Search for messages
 843                                                  pcust                   "Customer data only
 844                                                  customernamespace.      "Customer name range
 845       ENDLOOP.
 846 
 847 *   Select Classes
 848     WHEN rclass.
 849       PERFORM retrieveclasses USING iclasses[]
 850                                     ifunctions[]
 851                                     soclassname[]       "Class name
 852                                     soauthor[]          "Author
 853                                     customernamespace   "Customer name range
 854                                     pmod                "Also modified by author
 855                                     pcust               "Customer object only
 856                                     pmess               "Find messages
 857                                     ptext               "Text Elements
 858                                     pdict               "Dictionary structures
 859                                     pfunc               "Get functions
 860                                     pinc                "Get includes
 861                                     precf               "Search recursively for functions
 862                                     preci               "Search recursively for includes
 863                                     'X'                 "Search recursively for classes
 864                                     pmlang.             "Language
 865 
 866       LOOP AT ifunctions.
 867 *       Find Dict structures, messages, functions, includes etc.
 868         PERFORM scanforadditionalfuncstuff USING ifunctions[]
 869                                                  preci                   "Search for includes recursively
 870                                                  precf                   "Search for functions recursively
 871                                                  pinc                    "Search for includes
 872                                                  pfunc                   "Search for functions
 873                                                  pdict                   "search for dictionary objects
 874                                                  pmess                   "Search for messages
 875                                                  pcust                   "Customer data only
 876                                                  customernamespace.      "Customer name range
 877       ENDLOOP.
 878 
 879 *   Select programs
 880     WHEN rprog.
 881       PERFORM retrieveprograms USING iprograms[]
 882                                      ifunctions[]
 883                                      soprogramname[]    "Program name
 884                                      soauthor[]         "Author
 885                                      customernamespace  "Customer name range
 886                                      pmod               "Also modified by author
 887                                      pcust              "Customer object only
 888                                      pmess              "Find messages
 889                                      ptext              "Text Elements
 890                                      pdict              "Dictionay structures
 891                                      pfunc              "Get functions
 892                                      pinc               "Get includes
 893                                      pscr               "Get screens
 894                                      precf              "Search recursively for functions
 895                                      preci              "Search recursively for includes
 896                                      p$tmp              "local objects
 897                                      ppack.             "Package
 898   ENDCASE.
 899 
 900 *----------------------------------------------------------------------------------------------------------------------
 901 * end-of-selection
 902 *----------------------------------------------------------------------------------------------------------------------
 903 END-OF-SELECTION.
 904 
 905   IF forcedexit = 0.
 906 *   Set the file extension and output type of the file
 907     IF ptxt IS INITIAL.
 908       downloadfileextension = htmlextension.
 909     ELSE.
 910       downloadfileextension = textextension.
 911     ENDIF.
 912 
 913 *   Decide what to download
 914     CASE 'X'.
 915 *     Download tables
 916       WHEN rtable.
 917         IF NOT ( idictionary[] IS INITIAL ).
 918           PERFORM downloadddstructures USING idictionary[]
 919                                              downloadfolder
 920                                              htmlextension
 921                                              space
 922                                              psortt
 923                                              slashseparatortouse
 924                                              pserv
 925                                              ppromess.
 926 
 927 *         Free up any memory used for caching HTML versions of tables
 928           LOOP AT idictionary.
 929             FREE MEMORY ID idictionary-tablename.
 930           ENDLOOP.
 931 
 932 *         Display donwload report
 933           IF NOT prep IS INITIAL.
 934             GET TIME.
 935             runtime = sy-uzeit - starttime.
 936             PERFORM filltreenodetables USING idictionary[]
 937                                              itreedisplay[]
 938                                              runtime.
 939           ENDIF.
 940 
 941           CLEAR idictionary[].
 942         ENDIF.
 943 
 944 *     Download message class
 945       WHEN rmess.
 946         IF NOT ( imessages[] IS INITIAL ).
 947           SORT imessages ASCENDING BY arbgb msgnr.
 948           LOOP AT imessages.
 949             APPEND imessages TO isinglemessageclass.
 950             AT END OF arbgb.
 951               PERFORM downloadmessageclass USING isinglemessageclass[]
 952                                                  imessages-arbgb
 953                                                  downloadfolder
 954                                                  downloadfileextension
 955                                                  phtml
 956                                                  space
 957                                                  pcomm
 958                                                  customernamespace
 959                                                  pinc
 960                                                  pdict
 961                                                  pmess
 962                                                  slashseparatortouse
 963                                                  pserv
 964                                                  ppromess.
 965               CLEAR isinglemessageclass[].
 966             ENDAT.
 967           ENDLOOP.
 968 
 969 *         Display download report
 970           IF NOT prep IS INITIAL.
 971             GET TIME.
 972             runtime = sy-uzeit - starttime.
 973             PERFORM filltreenodemessages USING imessages[]
 974                                                itreedisplay[]
 975                                                runtime.
 976           ENDIF.
 977 
 978           CLEAR imessages[].
 979         ENDIF.
 980 
 981 *     Download functions
 982       WHEN rfunc.
 983         IF NOT ( ifunctions[] IS INITIAL ).
 984           PERFORM downloadfunctions USING ifunctions[]
 985                                           downloadfolder
 986                                           downloadfileextension
 987                                           space
 988                                           pdoc
 989                                           phtml
 990                                           pcomm
 991                                           customernamespace
 992                                           pinc
 993                                           pdict
 994                                           textextension
 995                                           htmlextension
 996                                           psortt
 997                                           slashseparatortouse
 998                                           pserv
 999                                           ppromess.
1000 
1001 *         Free up any memory used for caching HTML versions of tables
1002           LOOP AT ifunctions.
1003             LOOP AT ifunctions-idictstruct ASSIGNING <wadictstruct>.
1004               FREE MEMORY ID <wadictstruct>-tablename.
1005             ENDLOOP.
1006           ENDLOOP.
1007 
1008 *         Display donwload report
1009           IF NOT prep IS INITIAL.
1010             GET TIME.
1011             runtime = sy-uzeit - starttime.
1012             PERFORM filltreenodefunctions USING ifunctions[]
1013                                                 itreedisplay[]
1014                                                 runtime.
1015           ENDIF.
1016 
1017           CLEAR ifunctions[].
1018         ENDIF.
1019 
1020 *     Download Classes
1021       WHEN rclass.
1022         IF NOT ( iclasses[] IS INITIAL ).
1023           PERFORM downloadclasses USING iclasses[]
1024                                         ifunctions[]
1025                                         downloadfolder
1026                                         downloadfileextension
1027                                         htmlextension
1028                                         textextension
1029                                         phtml
1030                                         pcomm
1031                                         customernamespace
1032                                         pinc
1033                                         pdict
1034                                         pdoc
1035                                         psortt
1036                                         slashseparatortouse
1037                                         pserv
1038                                         ppromess.
1039 
1040 *         Free up any memory used for caching HTML versions of tables
1041           LOOP AT ifunctions.
1042             LOOP AT ifunctions-idictstruct ASSIGNING <wadictstruct>.
1043               FREE MEMORY ID <wadictstruct>-tablename.
1044             ENDLOOP.
1045           ENDLOOP.
1046 
1047 *         Free up any memory used for caching HTML versions of tables
1048           LOOP AT iprograms.
1049             LOOP AT iprograms-idictstruct ASSIGNING <wadictstruct>.
1050               FREE MEMORY ID <wadictstruct>-tablename.
1051             ENDLOOP.
1052           ENDLOOP.
1053 
1054 *         Display donwload report
1055           IF NOT prep IS INITIAL.
1056             GET TIME.
1057             runtime = sy-uzeit - starttime.
1058             PERFORM filltreenodeclasses USING iclasses[]
1059                                               ifunctions[]
1060                                               itreedisplay[]
1061                                               runtime.
1062           ENDIF.
1063 
1064           CLEAR iclasses[].
1065           CLEAR ifunctions[].
1066         ENDIF.
1067 
1068 *     Download programs
1069       WHEN rprog.
1070         IF NOT ( iprograms[] IS INITIAL ).
1071           PERFORM downloadprograms USING iprograms[]
1072                                          ifunctions[]
1073                                          downloadfolder
1074                                          downloadfileextension
1075                                          htmlextension
1076                                          textextension
1077                                          phtml
1078                                          pcomm
1079                                          customernamespace
1080                                          pinc
1081                                          pdict
1082                                          pdoc
1083                                          psortt
1084                                          slashseparatortouse
1085                                          pserv
1086                                          ppromess.
1087 
1088 *         Free up any memory used for caching HTML versions of tables
1089           LOOP AT ifunctions.
1090             LOOP AT ifunctions-idictstruct ASSIGNING <wadictstruct>.
1091               FREE MEMORY ID <wadictstruct>-tablename.
1092             ENDLOOP.
1093           ENDLOOP.
1094 
1095 *         Free up any memory used for caching HTML versions of tables
1096           LOOP AT iprograms.
1097             LOOP AT iprograms-idictstruct ASSIGNING <wadictstruct>.
1098               FREE MEMORY ID <wadictstruct>-tablename.
1099             ENDLOOP.
1100           ENDLOOP.
1101 
1102 *         Display donwload report
1103           IF NOT prep IS INITIAL.
1104             GET TIME.
1105             runtime = sy-uzeit - starttime.
1106             PERFORM filltreenodeprograms USING iprograms[]
1107                                                ifunctions[]
1108                                                itreedisplay[]
1109                                                runtime.
1110           ENDIF.
1111 
1112           CLEAR iprograms[].
1113           CLEAR ifunctions[].
1114         ENDIF.
1115     ENDCASE.
1116 
1117     IF NOT prep IS INITIAL.
1118       IF NOT ( itreedisplay[] IS INITIAL ).
1119         PERFORM displaytree USING itreedisplay[].
1120       ELSE.
1121         statusbarmessage = 'No items found matching selection criteria'.
1122         PERFORM displaystatus USING statusbarmessage 2.
1123       ENDIF.
1124     ENDIF.
1125   ENDIF.
1126 
1127 *--- Memory IDs
1128 * User name
1129   SET PARAMETER ID 'MAUTH' FIELD pauth.
1130 * Message class
1131   SET PARAMETER ID 'MMNAME' FIELD pmname.
1132 * Customer namespace
1133   SET PARAMETER ID 'MNAMESPACE' FIELD pcname.
1134 * Folder
1135   SET PARAMETER ID 'MFOLDER' FIELD pfolder.
1136 * Logical filepath
1137   SET PARAMETER ID 'MLOGICAL' FIELD plogical.
1138 * Package
1139   SET PARAMETER ID 'MPACK' FIELD ppack.
1140 * Text element checkbox
1141   SET PARAMETER ID 'MTEXT' FIELD ptext.
1142 * Messages checkbox
1143   SET PARAMETER ID 'MMESS' FIELD pmess.
1144 * Includes checkbox
1145   SET PARAMETER ID 'MINC' FIELD pinc.
1146 * Recursive includes checkbox.
1147   SET PARAMETER ID 'MRECI' FIELD preci.
1148 * Functions checkbox
1149   SET PARAMETER ID 'MFUNC' FIELD pfunc.
1150 * Recursive functions checkbox
1151   SET PARAMETER ID 'MRECF' FIELD precf.
1152 * Function module documntation checkbox
1153   SET PARAMETER ID 'MDOC' FIELD pdoc.
1154 * Screens checkbox
1155   SET PARAMETER ID 'MSCR' FIELD pscr.
1156 * Dictionary checkbox
1157   SET PARAMETER ID 'MDICT' FIELD pdict.
1158 * Sort table ascending checkBox
1159   SET PARAMETER ID 'MSORTT' FIELD psortt.
1160 
1161 ***********************************************************************************************************************
1162 ***************************************************SUBROUTINES*********************************************************
1163 ***********************************************************************************************************************
1164 
1165 *----------------------------------------------------------------------------------------------------------------------
1166 *  checkComboBoxes...  Check input parameters
1167 *----------------------------------------------------------------------------------------------------------------------
1168 FORM checkcomboboxes.
1169 
1170   IF pauth IS INITIAL.
1171     CASE 'X'.
1172       WHEN rtable.
1173         IF sotable[] IS INITIAL.
1174           statusbarmessage = 'You must enter either a table name or author.'.
1175         ENDIF.
1176       WHEN rfunc.
1177         IF ( sofname[] IS INITIAL ) AND ( sofgroup[] IS INITIAL ).
1178           IF sofname[] IS INITIAL.
1179             statusbarmessage = 'You must enter either a function name or author.'.
1180           ELSE.
1181             IF sofgroup[] IS INITIAL.
1182               statusbarmessage = 'You must enter either a function group, or an author name.'.
1183             ENDIF.
1184           ENDIF.
1185         ENDIF.
1186       WHEN rprog.
1187         IF soprog[] IS INITIAL.
1188           statusbarmessage = 'You must enter either a program name or author name.'.
1189         ENDIF.
1190     ENDCASE.
1191   ELSE.
1192 *   Check the user name of the person objects are to be downloaded for
1193     IF pauth = 'SAP*' OR pauth = 'SAP'.
1194       statusbarmessage = 'Sorry cannot download all objects for SAP standard user'.
1195     ENDIF.
1196   ENDIF.
1197 
1198   IF NOT statusbarmessage IS INITIAL.
1199     PERFORM displaystatus USING statusbarmessage 3.
1200     forcedexit = 1.
1201     STOP.
1202   ENDIF.
1203 ENDFORM.                                                                                "checkComboBoxes
1204 
1205 *----------------------------------------------------------------------------------------------------------------------
1206 * fillSelectionRanges...      for selection routines
1207 *----------------------------------------------------------------------------------------------------------------------
1208 FORM fillselectionranges.
1209 
1210   DATA: strlength TYPE i.
1211 
1212   strlength = STRLEN( pcname ).
1213 
1214   IF NOT pauth IS INITIAL.
1215     soauthor-sign = 'I'.
1216     soauthor-option = 'EQ'.
1217     soauthor-low = pauth.
1218     APPEND soauthor.
1219   ENDIF.
1220 
1221 * Tables
1222   IF NOT sotable IS INITIAL.
1223     sotablenames[] = sotable[].
1224 *   Add in the customer namespace if we need to
1225     IF NOT pcname IS INITIAL.
1226       LOOP AT sotablenames.
1227         IF sotablenames-low+0(strlength) <> pcname.
1228           CONCATENATE pcname sotablenames-low INTO sotablenames-low.
1229         ENDIF.
1230 
1231         IF sotablenames-high+0(strlength) <> pcname.
1232           CONCATENATE pcname sotablenames-high INTO sotablenames-high.
1233         ENDIF.
1234 
1235         MODIFY sotablenames.
1236       ENDLOOP.
1237     ENDIF.
1238   ENDIF.
1239 
1240 * Function names
1241   IF NOT sofname IS INITIAL.
1242     sofunctionname[] = sofname[].
1243 *   Add in the customer namespace if we need to
1244     IF NOT pcname IS INITIAL.
1245       LOOP AT sofunctionname.
1246         IF sofunctionname-low+0(strlength) <> pcname.
1247           CONCATENATE pcname sofunctionname-low INTO sofunctionname-low.
1248         ENDIF.
1249 
1250         IF sofunctionname-high+0(strlength) <> pcname.
1251           CONCATENATE pcname sofunctionname-high INTO sofunctionname-high.
1252         ENDIF.
1253 
1254         MODIFY sofunctionname.
1255       ENDLOOP.
1256     ENDIF.
1257   ENDIF.
1258 
1259 * Function group
1260   IF NOT sofgroup IS INITIAL.
1261     sofunctiongroup[] = sofgroup[].
1262 *   Add in the customer namespace if we need to
1263     IF NOT pcname IS INITIAL.
1264       LOOP AT sofunctionname.
1265         IF sofunctiongroup-low+0(strlength) <> pcname.
1266           CONCATENATE pcname sofunctiongroup-low INTO sofunctiongroup-low.
1267         ENDIF.
1268 
1269         IF sofunctiongroup-high+0(strlength) <> pcname.
1270           CONCATENATE pcname sofunctiongroup-high INTO sofunctiongroup-high.
1271         ENDIF.
1272 
1273         MODIFY sofunctiongroup.
1274       ENDLOOP.
1275     ENDIF.
1276   ENDIF.
1277 
1278 * Class names
1279   IF NOT soclass IS INITIAL.
1280     soclassname[] = soclass[].
1281 *   Add in the customer namespace if we need to
1282     IF NOT pcname IS INITIAL.
1283       LOOP AT soclassname.
1284         IF soclassname-low+0(strlength) <> pcname.
1285           CONCATENATE pcname soclassname-low INTO soclassname-low.
1286         ENDIF.
1287 
1288         IF soclassname-high+0(strlength) <> pcname.
1289           CONCATENATE pcname soclassname-high INTO soclassname-high.
1290         ENDIF.
1291 
1292         MODIFY soclassname.
1293       ENDLOOP.
1294     ENDIF.
1295   ENDIF.
1296 
1297 * Program names
1298   IF NOT soprog IS INITIAL.
1299     soprogramname[] = soprog[].
1300 *   Add in the customer namespace if we need to
1301     IF NOT pcname IS INITIAL.
1302       LOOP AT soprogramname.
1303         IF soprogramname-low+0(strlength) <> pcname.
1304           CONCATENATE pcname soprogramname-low INTO soprogramname-low.
1305         ENDIF.
1306 
1307         IF soprogramname-high+0(strlength) <> pcname.
1308           CONCATENATE pcname soprogramname-high INTO soprogramname-high.
1309         ENDIF.
1310 
1311         MODIFY soprogramname.
1312       ENDLOOP.
1313     ENDIF.
1314   ENDIF.
1315 ENDFORM.                                                                                          " fillSelectionRanges
1316 
1317 *----------------------------------------------------------------------------------------------------------------------
1318 *  retrieveTables...             Search for tables in dictionary
1319 *----------------------------------------------------------------------------------------------------------------------
1320 FORM retrievetables USING ilocdictstructure LIKE idictionary[]
1321                           sotable LIKE sotable[]
1322                           soauthor LIKE soauthor[].
1323 
1324   DATA: wadictstructure TYPE tdicttable.
1325 
1326   SELECT tabname
1327          FROM dd02l
1328          INTO wadictstructure-tablename
1329          WHERE tabname IN sotable
1330            AND tabclass <> 'CLUSTER'
1331            AND tabclass <> 'POOL'
1332            AND tabclass <> 'VIEW'
1333            AND as4user IN soauthor
1334            AND as4local = 'A'.
1335 
1336     PERFORM findtabledescription USING wadictstructure-tablename
1337                                        wadictstructure-tabletitle.
1338 
1339     PERFORM findtabledefinition USING wadictstructure-tablename
1340                                       wadictstructure-istructure[].
1341 
1342     APPEND wadictstructure TO ilocdictstructure.
1343     CLEAR wadictstructure.
1344   ENDSELECT.
1345 ENDFORM.                                                                                                "retrieveTables
1346 
1347 *----------------------------------------------------------------------------------------------------------------------
1348 *  findTableDescription...  Search for table description in dictionary
1349 *----------------------------------------------------------------------------------------------------------------------
1350 FORM findtabledescription USING value(tablename)
1351                                       tabledescription.
1352 
1353   SELECT SINGLE ddtext
1354                 FROM dd02t
1355                 INTO tabledescription
1356                 WHERE tabname = tablename
1357                  AND ddlanguage = sy-langu.
1358 ENDFORM.                                                                                          "findTableDescription
1359 
1360 *----------------------------------------------------------------------------------------------------------------------
1361 *  findTableDefinition... Find the structure of a table from the SAP database.
1362 *----------------------------------------------------------------------------------------------------------------------
1363 FORM findtabledefinition USING value(tablename)
1364                                idictstruct LIKE dumidictstructure[].
1365 
1366   DATA gotstate LIKE dcobjif-gotstate.
1367   DATA: definition TYPE STANDARD TABLE OF dd03p WITH HEADER LINE.
1368   DATA: wadictstruct TYPE tdicttablestructure.
1369 
1370   CALL FUNCTION 'DDIF_TABL_GET'
1371     EXPORTING
1372       name          = tablename
1373       state         = 'A'
1374       langu         = sy-langu
1375     IMPORTING
1376       gotstate      = gotstate
1377     TABLES
1378       dd03p_tab     = definition
1379     EXCEPTIONS
1380       illegal_input = 1
1381       OTHERS        = 2.
1382 
1383   IF sy-subrc = 0 AND gotstate = 'A'.
1384     LOOP AT definition.
1385       MOVE-CORRESPONDING definition TO wadictstruct.
1386       PERFORM removeleadingzeros CHANGING wadictstruct-position.
1387       PERFORM removeleadingzeros CHANGING wadictstruct-leng.
1388       APPEND wadictstruct TO idictstruct.
1389     ENDLOOP.
1390   ENDIF.
1391 ENDFORM.                                                                                           "findTableDefinition
1392 
1393 *----------------------------------------------------------------------------------------------------------------------
1394 *  retrieveMessageClass...   Retrieve a message class from the SAP database
1395 *----------------------------------------------------------------------------------------------------------------------
1396 FORM retrievemessageclass USING ilocmessages LIKE imessages[]
1397                                 rangeauthor LIKE soauthor[]
1398                                 value(messageclassname)
1399                                 value(messageclasslang)
1400                                 value(modifiedby).
1401 
1402   DATA: wamessage TYPE tmessage.
1403 
1404   IF NOT messageclassname IS INITIAL.
1405     SELECT * FROM t100
1406              APPENDING CORRESPONDING FIELDS OF TABLE ilocmessages
1407              WHERE sprsl = messageclasslang
1408                AND arbgb = messageclassname.
1409 
1410     LOOP AT ilocmessages INTO wamessage.
1411       SELECT SINGLE stext
1412                     FROM t100a                         "#EC CI_BUFFJOIN
1413                     INTO wamessage-stext
1414                     WHERE arbgb = wamessage-arbgb.
1415       MODIFY ilocmessages FROM wamessage INDEX sy-tabix.
1416     ENDLOOP.
1417   ELSE.
1418     IF modifiedby IS INITIAL.
1419 *     Select by author
1420       SELECT t100~arbgb                                "#EC CI_BUFFJOIN
1421              t100~msgnr
1422              t100~text
1423              t100a~stext
1424              APPENDING CORRESPONDING FIELDS OF TABLE ilocmessages
1425              FROM t100
1426              INNER JOIN t100a ON t100a~arbgb = t100~arbgb
1427              WHERE t100a~masterlang = messageclasslang
1428                AND t100a~respuser IN rangeauthor[].
1429     ELSE.
1430 *     Select also by the last person who modified the message class
1431       SELECT t100~arbgb                                "#EC CI_BUFFJOIN
1432              t100~msgnr
1433              t100~text
1434              t100a~stext
1435              APPENDING CORRESPONDING FIELDS OF TABLE ilocmessages
1436              FROM t100
1437              INNER JOIN t100a ON t100a~arbgb = t100~arbgb
1438              WHERE t100a~masterlang = messageclasslang
1439                AND t100a~respuser IN rangeauthor[]
1440                AND t100a~lastuser IN rangeauthor[].
1441     ENDIF.
1442   ENDIF.
1443 ENDFORM.                                                                                          "retrieveMessageClass
1444 
1445 *----------------------------------------------------------------------------------------------------------------------
1446 *  retrieveFunctions...   Retrieve function modules from SAP DB.  May be called in one of two ways
1447 *----------------------------------------------------------------------------------------------------------------------
1448 FORM retrievefunctions USING sofname LIKE sofunctionname[]
1449                              sofgroup LIKE sofunctiongroup[]
1450                              ilocfunctionnames LIKE ifunctions[]
1451                              value(solocauthor) LIKE soauthor[]
1452                              value(gettextelements)
1453                              value(getscreens)
1454                              value(customeronly)
1455                              value(customernamerange).
1456 
1457   RANGES: rangefuncname  FOR tfdir-funcname.
1458   RANGES: rangefuncgroup FOR enlfdir-area.
1459   DATA: wafunctionname TYPE tfunction.
1460   DATA: nogroupsfound TYPE i VALUE true.
1461   DATA: previousfg TYPE v_fdir-area.
1462 
1463   rangefuncname[] = sofname[].
1464   rangefuncgroup[] = sofgroup[].
1465 
1466   IF NOT solocauthor[] IS INITIAL.
1467 *-- Need to select all function groups by author
1468     SELECT area
1469            FROM tlibv
1470            INTO rangefuncgroup-low
1471            WHERE uname IN solocauthor
1472              AND area IN sofgroup[].
1473 
1474       rangefuncgroup-sign = 'I'.
1475       rangefuncgroup-option = 'EQ'.
1476       APPEND rangefuncgroup.
1477       nogroupsfound = false.
1478     ENDSELECT.
1479   ELSE.
1480     nogroupsfound = false.
1481   ENDIF.
1482 
1483   IF nogroupsfound = false.
1484 *   select by function name and/or function group.
1485     SELECT funcname area
1486                     FROM v_fdir
1487                     INTO (wafunctionname-functionname,
1488                           wafunctionname-functiongroup)
1489                     WHERE funcname IN rangefuncname
1490                       AND area IN rangefuncgroup
1491                       AND generated = ''
1492                       ORDER BY area.
1493 
1494       APPEND wafunctionname TO ilocfunctionnames.
1495     ENDSELECT.
1496   ENDIF.
1497 
1498   LOOP AT ilocfunctionnames INTO wafunctionname.
1499     PERFORM retrievefunctiondetail USING wafunctionname-functionname
1500                                          wafunctionname-progname
1501                                          wafunctionname-includenumber
1502                                          wafunctionname-functiontitle.
1503 
1504     PERFORM findmainfunctioninclude USING wafunctionname-progname
1505                                           wafunctionname-includenumber
1506                                           wafunctionname-functionmaininclude.
1507 
1508     PERFORM findfunctiontopinclude USING wafunctionname-progname
1509                                          wafunctionname-topincludename.
1510 
1511 *   Find all user defined includes within the function group
1512     PERFORM scanforfunctionincludes USING wafunctionname-progname
1513                                           customeronly
1514                                           customernamerange
1515                                           wafunctionname-iincludes[].
1516 *   Find main message class
1517     PERFORM findmainmessageclass USING wafunctionname-progname
1518                                        wafunctionname-messageclass.
1519 
1520 *   Find any screens declared within the main include
1521     IF NOT getscreens IS INITIAL.
1522       IF previousfg IS INITIAL OR previousfg <> wafunctionname-functiongroup.
1523         PERFORM findfunctionscreenflow USING wafunctionname.
1524 
1525 *       Search for any GUI texts
1526         PERFORM retrieveguititles USING wafunctionname-iguititle[]
1527                                         wafunctionname-progname.
1528       ENDIF.
1529     ENDIF.
1530 
1531     IF NOT gettextelements IS INITIAL.
1532 *     Find the program texts from out of the database.
1533       PERFORM retrieveprogramtexts USING wafunctionname-iselectiontexts[]
1534                                          wafunctionname-itextelements[]
1535                                          wafunctionname-progname.
1536     ENDIF.
1537 
1538     previousfg = wafunctionname-functiongroup.
1539     MODIFY ilocfunctionnames FROM wafunctionname.
1540   ENDLOOP.
1541 ENDFORM.                                                                                             "retrieveFunctions
1542 
1543 *----------------------------------------------------------------------------------------------------------------------
1544 *  retrieveFunctionDetail...   Retrieve function module details from SAP DB.
1545 *----------------------------------------------------------------------------------------------------------------------
1546 FORM retrievefunctiondetail USING value(functionname)
1547                                         progname
1548                                         includename
1549                                         titletext.
1550 
1551   SELECT SINGLE pname
1552                 include
1553                 FROM tfdir
1554                 INTO (progname, includename)
1555                 WHERE funcname = functionname.
1556 
1557   IF sy-subrc = 0.
1558     SELECT SINGLE stext
1559                   FROM tftit
1560                   INTO titletext
1561                   WHERE spras = sy-langu
1562                     AND funcname = functionname.
1563   ENDIF.
1564 ENDFORM.                                                                                        "retrieveFunctionDetail
1565 
1566 *----------------------------------------------------------------------------------------------------------------------
1567 *  findMainFunctionInclude...  Find the main include that contains the source code
1568 *----------------------------------------------------------------------------------------------------------------------
1569 FORM findmainfunctioninclude USING value(programname)
1570                                    value(includeno)
1571                                          internalincludename.
1572   DATA: newincludenumber TYPE string.
1573 
1574   CONCATENATE '%U' includeno INTO newincludenumber.
1575   SELECT SINGLE include
1576                 FROM d010inc
1577                 INTO internalincludename
1578                 WHERE master = programname
1579                   AND include LIKE newincludenumber.
1580 ENDFORM.                                                                                       "findMainFunctionInclude
1581 
1582 *----------------------------------------------------------------------------------------------------------------------
1583 *  findFunctionTopInclude...  Find the top include for the function group
1584 *----------------------------------------------------------------------------------------------------------------------
1585 FORM findfunctiontopinclude USING value(programname)
1586                                         topincludename.
1587 
1588   SELECT SINGLE include
1589                 FROM d010inc
1590                 INTO topincludename
1591                 WHERE master = programname
1592                   AND include LIKE '%TOP'.
1593 ENDFORM.                                                                                        "findFunctionTopInclude
1594 
1595 *----------------------------------------------------------------------------------------------------------------------
1596 * scanForAdditionalFuncStuff... Search for additional things relating to functions
1597 *----------------------------------------------------------------------------------------------------------------------
1598 FORM scanforadditionalfuncstuff USING ilocfunctions LIKE ifunctions[]
1599                                       value(recursiveincludes)
1600                                       value(recursivefunctions)
1601                                       value(searchforincludes)
1602                                       value(searchforfunctions)
1603                                       value(searchfordictionary)
1604                                       value(searchformessages)
1605                                       value(customeronly)
1606                                       value(customernamerange).
1607 
1608   DATA: wafunction TYPE tfunction.
1609   DATA: wainclude TYPE tinclude.
1610 
1611   LOOP AT ilocfunctions INTO wafunction.
1612     IF NOT searchforincludes IS INITIAL.
1613 *     Search in the main include
1614       PERFORM scanforincludeprograms USING wafunction-functionmaininclude
1615                                            recursiveincludes
1616                                            customeronly
1617                                            customernamerange
1618                                            wafunction-iincludes[].
1619 
1620 *     Search in the top include
1621       PERFORM scanforincludeprograms USING wafunction-topincludename
1622                                            recursiveincludes
1623                                            customeronly
1624                                            customernamerange
1625                                            wafunction-iincludes[].
1626     ENDIF.
1627 
1628     IF NOT searchforfunctions IS INITIAL.
1629       PERFORM scanforfunctions USING wafunction-functionmaininclude
1630                                      wafunction-programlinkname
1631                                      recursiveincludes
1632                                      recursivefunctions
1633                                      customeronly
1634                                      customernamerange
1635                                      ilocfunctions[].
1636     ENDIF.
1637 
1638     MODIFY ilocfunctions FROM wafunction.
1639   ENDLOOP.
1640 
1641 * Now we have everthing perhaps we had better find all the dictionary structures
1642   IF NOT searchfordictionary IS INITIAL.
1643     LOOP AT ilocfunctions INTO wafunction.
1644       PERFORM scanfortables USING wafunction-progname
1645                                   customeronly
1646                                   customernamerange
1647                                   wafunction-idictstruct[].
1648 
1649       PERFORM scanforlikeortype USING wafunction-progname
1650                                       customeronly
1651                                       customernamerange
1652                                       wafunction-idictstruct[].
1653 
1654       LOOP AT wafunction-iincludes INTO wainclude.
1655         PERFORM scanfortables USING wainclude-includename
1656                                     customeronly
1657                                     customernamerange
1658                                     wafunction-idictstruct[].
1659 
1660         PERFORM scanforlikeortype USING wainclude-includename
1661                                         customeronly
1662                                         customernamerange
1663                                         wafunction-idictstruct[].
1664       ENDLOOP.
1665 
1666       MODIFY ilocfunctions FROM wafunction.
1667     ENDLOOP.
1668   ENDIF.
1669 
1670 * Now search for all messages
1671   IF NOT searchformessages IS INITIAL.
1672     LOOP AT ilocfunctions INTO wafunction.
1673       PERFORM scanformessages USING wafunction-progname
1674                                     wafunction-messageclass
1675                                     wafunction-imessages[].
1676       MODIFY ilocfunctions FROM wafunction.
1677     ENDLOOP.
1678   ENDIF.
1679 ENDFORM.                                                                                    "scanForAdditionalFuncStuff
1680 
1681 *----------------------------------------------------------------------------------------------------------------------
1682 * scanForClasses... Search each class or method for other classes
1683 *----------------------------------------------------------------------------------------------------------------------
1684 FORM scanforclasses USING value(classname)
1685                           value(classlinkname)
1686                           value(customeronly)
1687                           value(customernamerange)
1688                                 ilocclasses LIKE iclasses[].
1689 
1690   DATA ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
1691   DATA: head TYPE string.
1692   DATA: tail TYPE string.
1693   DATA: linelength TYPE i VALUE 0.
1694   DATA: waline TYPE string.
1695   DATA: waclass TYPE tclass.
1696   DATA: castclassname TYPE program.
1697   DATA: exceptioncustomernamerange TYPE string.
1698 
1699 * Build the name of the possible cusotmer exception classes
1700   CONCATENATE customernamerange 'CX_' INTO  exceptioncustomernamerange.
1701 
1702 * Read the program code from the textpool.
1703   castclassname = classname.
1704   READ REPORT castclassname INTO ilines.
1705 
1706   LOOP AT ilines INTO waline.
1707 *   Find custom tables.
1708     linelength = STRLEN( waline ).
1709     IF linelength > 0.
1710       IF waline(1) = asterix.
1711         CONTINUE.
1712       ENDIF.
1713 
1714       TRANSLATE waline TO UPPER CASE.
1715 
1716       FIND typerefto IN waline IGNORING CASE.
1717       IF sy-subrc = 0.
1718 *       Have found a reference to another class
1719         SPLIT waline AT type INTO head tail.
1720         SHIFT tail LEFT DELETING LEADING space.
1721         SPLIT tail AT 'REF' INTO head tail.
1722         SHIFT tail LEFT DELETING LEADING space.
1723         SPLIT tail AT 'TO' INTO head tail.
1724         SHIFT tail LEFT DELETING LEADING space.
1725         IF tail CS period.
1726           SPLIT tail AT period INTO head tail.
1727         ELSE.
1728           IF tail CS comma.
1729             SPLIT tail AT comma INTO head tail.
1730           ENDIF.
1731         ENDIF.
1732       ELSE.
1733 *       Try and find classes which are only referenced through static mehods
1734         FIND '=>' IN waline MATCH OFFSET sy-fdpos.
1735         IF sy-subrc = 0.
1736           head = waline+0(sy-fdpos).
1737           SHIFT head LEFT DELETING LEADING space.
1738           CONDENSE head.
1739           FIND 'call method' IN head IGNORING CASE.
1740           IF sy-subrc = 0.
1741             SHIFT head LEFT DELETING LEADING space.
1742             SPLIT head AT space INTO head tail.
1743             SPLIT tail AT space INTO head tail.
1744 *           Should have the class name here
1745             head = tail.
1746           ELSE.
1747 *           Still have a class name even though it does not have the words call method in front
1748             IF waline CS '='.
1749               SPLIT waline AT '=' INTO tail head.
1750               SHIFT head LEFT DELETING LEADING space.
1751               SPLIT head AT '=' INTO head tail.
1752             ENDIF.
1753             sy-subrc = 0.
1754           ENDIF.
1755         ENDIF.
1756       ENDIF.
1757 
1758       IF sy-subrc = 0.
1759         TRY.
1760             IF head+0(1) = 'Y' OR head+0(1) = 'Z' OR head CS customernamerange.
1761 *           We have found a class best append it to our class table if we do not already have it.
1762               READ TABLE ilocclasses INTO waclass WITH KEY clsname = head.
1763               IF sy-subrc <> 0.
1764                 IF head+0(3) = 'CX_'
1765                    OR head+0(4) = 'ZCX_'
1766                    OR head+0(4) = 'YCX_'
1767                    OR head CS exceptioncustomernamerange.
1768 
1769                   waclass-exceptionclass = true.
1770                 ENDIF.
1771 
1772                 waclass-clsname = head.
1773                 APPEND waclass TO ilocclasses.
1774               ENDIF.
1775             ENDIF.
1776           CATCH cx_sy_range_out_of_bounds.
1777         ENDTRY.
1778       ENDIF.
1779     ENDIF.
1780   ENDLOOP.
1781 ENDFORM.                                                                                                "scanForClasses
1782 
1783 *----------------------------------------------------------------------------------------------------------------------
1784 * scanForIncludePrograms... Search each program for include programs
1785 *----------------------------------------------------------------------------------------------------------------------
1786 FORM scanforincludeprograms USING value(programname)
1787                                   value(recursiveincludes)
1788                                   value(customeronly)
1789                                   value(customernamerange)
1790                                         ilocincludes LIKE dumiincludes[].
1791 
1792   DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
1793   DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
1794   DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
1795   DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
1796   DATA: watokens TYPE stokes.
1797   DATA: wainclude TYPE tinclude.
1798   DATA: waincludeexists TYPE tinclude.
1799   DATA: maxlines TYPE i.
1800   DATA: nextline TYPE i.
1801   DATA: castprogramname TYPE program.
1802 
1803 * Read the program code from the textpool.
1804   castprogramname = programname.
1805   READ REPORT castprogramname INTO iincludelines.
1806 
1807   APPEND include TO ikeywords.
1808   SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
1809 
1810   CLEAR iincludelines[].
1811 
1812   maxlines = LINES( itokens ).
1813   LOOP AT itokens WHERE str = include AND type = 'I'.
1814     nextline = sy-tabix + 1.
1815     IF nextline <= maxlines.
1816       READ TABLE itokens INDEX nextline INTO watokens.
1817 
1818 *      Are we only to find customer includes?
1819       IF NOT customeronly IS INITIAL.
1820         TRY.
1821             IF watokens-str+0(1) = 'Y' OR watokens-str+0(1) = 'Z' OR watokens-str CS customernamerange
1822                OR watokens-str+0(2) = 'MZ' OR watokens-str+0(2) = 'MY'.
1823 
1824             ELSE.
1825               CONTINUE.
1826             ENDIF.
1827           CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
1828         ENDTRY.
1829       ENDIF.
1830 
1831       wainclude-includename = watokens-str.
1832 
1833 *      Best find the program title text as well.
1834       PERFORM findprogramorincludetitle USING wainclude-includename
1835                                               wainclude-includetitle.
1836 
1837 *      Don't append the include if we already have it listed
1838       READ TABLE ilocincludes INTO waincludeexists WITH KEY includename = wainclude-includename.
1839       IF sy-subrc <> 0.
1840         APPEND wainclude TO ilocincludes.
1841 
1842         IF NOT recursiveincludes IS INITIAL.
1843 *          Do a recursive search for other includes
1844           PERFORM scanforincludeprograms USING wainclude-includename
1845                                                recursiveincludes
1846                                                customeronly
1847                                                customernamerange
1848                                                ilocincludes[].
1849         ENDIF.
1850       ENDIF.
1851     ENDIF.
1852   ENDLOOP.
1853 ENDFORM.                                                                                        "scanForIncludePrograms
1854 
1855 *----------------------------------------------------------------------------------------------------------------------
1856 * scanForFunctions... Search each program for function modules
1857 *----------------------------------------------------------------------------------------------------------------------
1858 FORM scanforfunctions USING value(programname)
1859                             value(programlinkname)
1860                             value(recursiveincludes)
1861                             value(recursivefunctions)
1862                             value(customeronly)
1863                             value(customernamerange)
1864                                   ilocfunctions LIKE ifunctions[].
1865 
1866   DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
1867   DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
1868   DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
1869   DATA: watokens TYPE stokes.
1870   DATA: wafunction TYPE tfunction.
1871   DATA: wafunctioncomparison TYPE tfunction.
1872   DATA: maxlines TYPE i.
1873   DATA: nextline TYPE i.
1874   DATA: castprogramname TYPE program.
1875   DATA: skipthisloop TYPE i.
1876 
1877 * Read the program code from the textpool.
1878   castprogramname = programname.
1879   READ REPORT castprogramname INTO iincludelines.
1880   SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements.
1881   CLEAR iincludelines[].
1882 
1883   maxlines = LINES( itokens ).
1884   LOOP AT itokens WHERE str = function AND type = 'I'.
1885 
1886     nextline = sy-tabix + 1.
1887     IF nextline <= maxlines.
1888       READ TABLE itokens INDEX nextline INTO watokens.
1889 
1890 *      Are we only to find customer functions
1891       skipthisloop = false.
1892       IF NOT customeronly IS INITIAL.
1893         TRY.
1894             IF watokens-str+1(1) = 'Y' OR watokens-str+1(1) = 'Z' OR watokens-str CS customernamerange.
1895             ELSE.
1896               skipthisloop = true.
1897             ENDIF.
1898           CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
1899           CLEANUP.
1900             skipthisloop = true.
1901         ENDTRY.
1902       ENDIF.
1903 
1904       IF skipthisloop = false.
1905         wafunction-functionname = watokens-str.
1906         REPLACE ALL OCCURRENCES OF '''' IN wafunction-functionname WITH ' '.
1907         CONDENSE wafunction-functionname.
1908 
1909 *        Don't add a function if we alread have it listed.
1910         READ TABLE ilocfunctions WITH KEY functionname = wafunction-functionname INTO wafunctioncomparison.
1911         IF sy-subrc <> 0.
1912 *          Add in the link name if the function is linked to a program
1913           wafunction-programlinkname = programlinkname.
1914 
1915 *          Don't download functions which are called through an RFC destination
1916           nextline = sy-tabix + 2.
1917           READ TABLE itokens INDEX nextline INTO watokens.
1918           IF watokens-str <> destination.
1919 
1920 *            Find the function group
1921             SELECT SINGLE area FROM v_fdir INTO wafunction-functiongroup WHERE funcname = wafunction-functionname.
1922 
1923             IF sy-subrc = 0.
1924 *              Best find the function number as well.
1925               PERFORM retrievefunctiondetail USING wafunction-functionname
1926                                                    wafunction-progname
1927                                                    wafunction-includenumber
1928                                                    wafunction-functiontitle.
1929 
1930               PERFORM findmainfunctioninclude USING wafunction-progname
1931                                                     wafunction-includenumber
1932                                                     wafunction-functionmaininclude.
1933 
1934               PERFORM findfunctiontopinclude USING wafunction-progname
1935                                                    wafunction-topincludename.
1936 
1937 *              Find main message class
1938               PERFORM findmainmessageclass USING wafunction-progname
1939                                                  wafunction-messageclass.
1940 
1941               APPEND wafunction TO ilocfunctions.
1942 
1943 *              Now lets search a little bit deeper and do a recursive search for other includes
1944               IF NOT recursiveincludes IS INITIAL.
1945                 PERFORM scanforincludeprograms USING wafunction-functionmaininclude
1946                                                      recursiveincludes
1947                                                      customeronly
1948                                                      customernamerange
1949                                                      wafunction-iincludes[].
1950               ENDIF.
1951 
1952 *              Now lets search a little bit deeper and do a recursive search for other functions
1953               IF NOT recursivefunctions IS INITIAL.
1954                 PERFORM scanforfunctions USING wafunction-functionmaininclude
1955                                                space
1956                                                recursiveincludes
1957                                                recursivefunctions
1958                                                customeronly
1959                                                customernamerange
1960                                                ilocfunctions[].
1961               ENDIF.
1962               CLEAR wafunction.
1963             ENDIF.
1964           ENDIF.
1965         ENDIF.
1966 
1967         CLEAR wafunction.
1968       ENDIF.
1969     ENDIF.
1970   ENDLOOP.
1971 ENDFORM.                                                                                              "scanForFunctions
1972 
1973 *----------------------------------------------------------------------------------------------------------------------
1974 *  scanForFunctionIncludes... Find all user defined includes within the function group
1975 *----------------------------------------------------------------------------------------------------------------------
1976 FORM scanforfunctionincludes USING poolname
1977                                    value(customeronly)
1978                                    value(customernamerange)
1979                                    ilocincludes LIKE dumiincludes[].
1980 
1981   DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
1982   DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
1983   DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
1984   DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
1985   DATA: watokens TYPE stokes.
1986   DATA: wainclude TYPE tinclude.
1987   DATA: waincludeexists TYPE tinclude.
1988   DATA: maxlines TYPE i.
1989   DATA: nextline TYPE i.
1990   DATA: castprogramname TYPE program.
1991 
1992 * Read the program code from the textpool.
1993   castprogramname = poolname.
1994   READ REPORT castprogramname INTO iincludelines.
1995 
1996   APPEND include TO ikeywords.
1997   SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
1998 
1999   CLEAR iincludelines[].
2000 
2001   maxlines = LINES( itokens ).
2002   LOOP AT itokens WHERE str = include AND type = 'I'.
2003     nextline = sy-tabix + 1.
2004     IF nextline <= maxlines.
2005       READ TABLE itokens INDEX nextline INTO watokens.
2006 
2007       IF watokens-str CP '*F++'.
2008 *        Are we only to find customer includes?
2009         IF NOT customeronly IS INITIAL.
2010           TRY.
2011               IF watokens-str+0(2) = 'LY' OR watokens-str+0(2) = 'LZ' OR watokens-str CS customernamerange.
2012               ELSE.
2013                 CONTINUE.
2014               ENDIF.
2015             CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
2016           ENDTRY.
2017         ENDIF.
2018 
2019         wainclude-includename = watokens-str.
2020 
2021 *        Best find the program title text as well.
2022         PERFORM findprogramorincludetitle USING wainclude-includename
2023                                                 wainclude-includetitle.
2024 
2025 *        Don't append the include if we already have it listed
2026         READ TABLE ilocincludes INTO waincludeexists WITH KEY includename = wainclude-includename.
2027         IF sy-subrc <> 0.
2028           APPEND wainclude TO ilocincludes.
2029         ENDIF.
2030       ENDIF.
2031     ENDIF.
2032   ENDLOOP.
2033 ENDFORM.                                                                                       "scanForFunctionIncludes
2034 
2035 *----------------------------------------------------------------------------------------------------------------------
2036 *  findProgramOrIncludeTitle...   Finds the title text of a program.
2037 *----------------------------------------------------------------------------------------------------------------------
2038 FORM findprogramorincludetitle USING value(programname)
2039                                            titletext.
2040 
2041   SELECT SINGLE text
2042                 FROM trdirt
2043                 INTO titletext
2044                 WHERE name = programname
2045                   AND sprsl = sy-langu.
2046 ENDFORM.                                                                                     "findProgramOrIncludeTitle
2047 
2048 *----------------------------------------------------------------------------------------------------------------------
2049 * retrievePrograms...    find programs and sub objects from SAP DB
2050 *----------------------------------------------------------------------------------------------------------------------
2051 FORM retrieveprograms USING ilocprogram LIKE iprograms[]
2052                             ilocfunctions LIKE ifunctions[]
2053                             rangeprogram LIKE soprogramname[]
2054                             rangeauthor LIKE soauthor[]
2055                             value(custnamerange)
2056                             value(alsomodifiedbyauthor)
2057                             value(customerprogsonly)
2058                             value(getmessages)
2059                             value(gettextelements)
2060                             value(getcustdictstructures)
2061                             value(getfunctions)
2062                             value(getincludes)
2063                             value(getscreens)
2064                             value(recursivefuncsearch)
2065                             value(recursiveincludesearch)
2066                             value(getlocalobjects)
2067                             value(package).
2068 
2069   DATA: warangeprogram LIKE LINE OF rangeprogram.
2070 
2071   IF rangeprogram[] IS INITIAL.
2072 *   We are finding all programs by an author
2073     PERFORM findallprogramsforauthor USING ilocprogram[]
2074                                            rangeprogram[]
2075                                            rangeauthor[]
2076                                            custnamerange
2077                                            alsomodifiedbyauthor
2078                                            customerprogsonly
2079                                            getlocalobjects
2080                                            package.
2081   ELSE.
2082     READ TABLE rangeprogram INDEX 1 INTO warangeprogram.
2083     IF warangeprogram-low CS asterix.
2084       PERFORM findprogramsbywildcard USING ilocprogram[]
2085                                            rangeprogram[]
2086                                            rangeauthor[]
2087                                            custnamerange
2088                                            customerprogsonly
2089                                            getlocalobjects
2090                                            package.
2091     ELSE.
2092       PERFORM checkprogramdoesexist USING ilocprogram[]
2093                                           rangeprogram[].
2094     ENDIF.
2095   ENDIF.
2096 
2097 * Find extra items
2098   PERFORM scanforadditionalprogstuff USING ilocprogram[]
2099                                            ilocfunctions[]
2100                                            gettextelements
2101                                            getmessages
2102                                            getscreens
2103                                            getcustdictstructures
2104                                            getfunctions
2105                                            getincludes
2106                                            customerprogsonly
2107                                            custnamerange
2108                                            recursiveincludesearch
2109                                            recursivefuncsearch.
2110 ENDFORM.                                                                               "retrievePrograms
2111 
2112 *-------------------------------------------------------------------------------------------------------
2113 *  scanForAdditionalProgStuff...
2114 *-------------------------------------------------------------------------------------------------------
2115 FORM scanforadditionalprogstuff USING ilocprogram LIKE iprograms[]
2116                                       ilocfunctions LIKE ifunctions[]
2117                                       value(gettextelements)
2118                                       value(getmessages)
2119                                       value(getscreens)
2120                                       value(getcustdictstructures)
2121                                       value(getfunctions)
2122                                       value(getincludes)
2123                                       value(customeronly)
2124                                       value(customernamerange)
2125                                       value(recursiveincludesearch)
2126                                       value(recursivefuncsearch).
2127 
2128   DATA: waprogram TYPE tprogram.
2129   DATA: wainclude TYPE tinclude.
2130   DATA: mytabix TYPE sytabix.
2131 
2132 * Best to find all the includes used in a program first
2133   IF NOT getincludes IS INITIAL.
2134     LOOP AT ilocprogram INTO waprogram.
2135       mytabix = sy-tabix.
2136       PERFORM scanforincludeprograms USING waprogram-progname
2137                                            recursiveincludesearch
2138                                            customeronly
2139                                            customernamerange
2140                                            waprogram-iincludes[].
2141 
2142       MODIFY ilocprogram FROM waprogram INDEX mytabix.
2143     ENDLOOP.
2144   ENDIF.
2145 
2146 * Once we have a list of all the includes we need to loop round them an select all the other objects
2147   LOOP AT ilocprogram INTO waprogram.
2148     mytabix = sy-tabix.
2149     PERFORM findprogramdetails USING waprogram-progname
2150                                      waprogram-subc
2151                                      waprogram-programtitle
2152                                      waprogram
2153                                      gettextelements
2154                                      getmessages
2155                                      getscreens
2156                                      getcustdictstructures
2157                                      customeronly
2158                                      customernamerange.
2159 
2160 *   Find any screens
2161     IF NOT getscreens IS INITIAL.
2162       PERFORM findprogramscreenflow USING waprogram.
2163     ENDIF.
2164 
2165     LOOP AT waprogram-iincludes INTO wainclude.
2166       PERFORM findprogramdetails USING wainclude-includename
2167                                        'I'
2168                                        wainclude-includetitle
2169                                        waprogram
2170                                        gettextelements
2171                                        getmessages
2172                                        getscreens
2173                                        getcustdictstructures
2174                                        customeronly
2175                                        customernamerange.
2176     ENDLOOP.
2177 
2178     MODIFY ilocprogram FROM waprogram INDEX mytabix.
2179   ENDLOOP.
2180 
2181 * Now we have all the program includes and details we need to find extra functions
2182   IF NOT getfunctions IS INITIAL.
2183     LOOP AT ilocprogram INTO waprogram.
2184 *     Find any functions defined in the code
2185       PERFORM scanforfunctions USING waprogram-progname
2186                                      waprogram-progname
2187                                      space
2188                                      space
2189                                      customeronly
2190                                      customernamerange
2191                                      ilocfunctions[].
2192     ENDLOOP.
2193   ENDIF.
2194 
2195 * We have a list of all the functions so lets go and find details and other function calls
2196   PERFORM scanforadditionalfuncstuff USING ilocfunctions[]
2197                                            recursiveincludesearch
2198                                            recursivefuncsearch
2199                                            getincludes
2200                                            getfunctions
2201                                            getcustdictstructures
2202                                            getmessages
2203                                            customeronly
2204                                            customernamerange.
2205 ENDFORM.                                                                     "scanForAdditionalProgStuff
2206 
2207 *-------------------------------------------------------------------------------------------------------
2208 *  findProgramDetails...
2209 *-------------------------------------------------------------------------------------------------------
2210 FORM findprogramdetails USING value(programname)
2211                               value(programtype)
2212                                     programtitle
2213                                     waprogram TYPE tprogram
2214                               value(gettextelements)
2215                               value(getmessages)
2216                               value(getscreens)
2217                               value(getcustdictstructures)
2218                               value(customeronly)
2219                               value(customernamerange).
2220 
2221   PERFORM findprogramorincludetitle USING programname
2222                                           programtitle.
2223 
2224   IF NOT gettextelements IS INITIAL.
2225 *   Find the program texts from out of the database.
2226     PERFORM retrieveprogramtexts USING waprogram-iselectiontexts[]
2227                                        waprogram-itextelements[]
2228                                        programname.
2229   ENDIF.
2230 
2231 * Search for any GUI texts
2232   IF NOT getscreens IS INITIAL AND ( programtype = 'M' OR programtype = '1' ).
2233     PERFORM retrieveguititles USING waprogram-iguititle[]
2234                                     programname.
2235   ENDIF.
2236 
2237 * Find individual messages
2238   IF NOT getmessages IS INITIAL.
2239     IF programtype = 'M' OR programtype = '1'.
2240       PERFORM findmainmessageclass USING programname
2241                                          waprogram-messageclass.
2242     ENDIF.
2243 
2244     PERFORM scanformessages USING programname
2245                                   waprogram-messageclass
2246                                   waprogram-imessages[].
2247   ENDIF.
2248 
2249   IF NOT getcustdictstructures IS INITIAL.
2250     PERFORM scanfortables USING programname
2251                                 customeronly
2252                                 customernamerange
2253                                 waprogram-idictstruct[].
2254 
2255     PERFORM scanforlikeortype USING programname
2256                                     customeronly
2257                                     customernamerange
2258                                     waprogram-idictstruct[].
2259   ENDIF.
2260 ENDFORM.                                                                             "findProgramDetails
2261 
2262 *-------------------------------------------------------------------------------------------------------
2263 *  findAllProgramsForAuthor...
2264 *-------------------------------------------------------------------------------------------------------
2265 FORM findallprogramsforauthor USING ilocprogram LIKE iprograms[]
2266                                     rangeprogram LIKE soprogramname[]
2267                                     rangeauthor LIKE soauthor[]
2268                                     value(custnamerange)
2269                                     value(alsomodifiedbyauthor)
2270                                     value(customerprogsonly)
2271                                     value(getlocalobjects)
2272                                     value(package).
2273 
2274   DATA: altcustomernamerange TYPE string.
2275   FIELD-SYMBOLS: <waprogram> TYPE tprogram.
2276   DATA: genflag TYPE genflag.
2277 
2278 * build up the customer name range used for select statements
2279   CONCATENATE custnamerange '%' INTO altcustomernamerange.
2280 
2281 * select by name and author
2282   IF NOT alsomodifiedbyauthor IS INITIAL.
2283 *   Programs modified by author
2284 *   Program to search for is an executable program
2285     IF customerprogsonly IS INITIAL.
2286 *     Select all programs
2287       SELECT progname
2288              subc
2289              FROM reposrc
2290              APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
2291              WHERE progname IN rangeprogram
2292                AND cnam IN rangeauthor
2293                AND ( subc = '1' OR subc = 'M' OR subc = 'S' ).
2294 
2295     ELSE.
2296 *     Select only customer specific programs
2297       SELECT progname
2298              subc
2299              FROM reposrc
2300              APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
2301              WHERE progname  IN rangeprogram
2302                AND ( progname LIKE altcustomernamerange
2303                      OR progname LIKE 'Z%'
2304                      OR progname LIKE 'Y%'
2305                      OR progname LIKE 'SAPMZ%'
2306                      OR progname LIKE 'SAPMY%')
2307                AND cnam IN rangeauthor
2308                AND ( subc = '1' OR subc = 'M' OR subc = 'S' ).
2309     ENDIF.
2310   ELSE.
2311 
2312 *   Programs created by author
2313     IF customerprogsonly IS INITIAL.
2314 *     Select all programs
2315       SELECT progname
2316              subc
2317              FROM reposrc
2318              APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
2319              WHERE progname IN rangeprogram
2320                AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
2321                AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
2322     ELSE.
2323 *     Select only customer specific programs
2324       SELECT progname
2325              subc
2326              FROM reposrc
2327              APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
2328              WHERE progname IN rangeprogram
2329                AND ( progname LIKE altcustomernamerange
2330                      OR progname LIKE 'Z%'
2331                      OR progname LIKE 'Y%'
2332                      OR progname LIKE 'SAPMZ%'
2333                      OR progname LIKE 'SAPMY%')
2334                AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
2335                AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
2336     ENDIF.
2337   ENDIF.
2338 
2339 * Delete any programs which are local objects
2340   IF getlocalobjects IS INITIAL.
2341     LOOP AT ilocprogram ASSIGNING <waprogram>.
2342       SELECT SINGLE genflag
2343                     FROM tadiv
2344                     INTO genflag
2345                     WHERE pgmid = 'R3TR'
2346                       AND object = 'PROG'
2347                       AND obj_name = <waprogram>-progname
2348                       AND devclass = '$TMP'.
2349       IF sy-subrc = 0.
2350         DELETE ilocprogram.
2351       ENDIF.
2352     ENDLOOP.
2353   ENDIF.
2354 
2355 * Delete any programs which are not in the specified package
2356   IF NOT package IS INITIAL.
2357     IF package CS '*'.
2358       TRANSLATE package USING '*%'.
2359     ENDIF.
2360 
2361     LOOP AT ilocprogram ASSIGNING <waprogram>.
2362       SELECT SINGLE genflag
2363                     FROM tadiv
2364                     INTO genflag
2365                     WHERE pgmid = 'R3TR'
2366                       AND object = 'PROG'
2367                       AND obj_name = <waprogram>-progname
2368                       AND devclass LIKE package.
2369       IF sy-subrc <> 0.
2370         DELETE ilocprogram.
2371       ENDIF.
2372     ENDLOOP.
2373   ENDIF.
2374 ENDFORM.                                                                       "findAllProgramsForAuthor
2375 
2376 *-------------------------------------------------------------------------------------------------------
2377 *  checkProgramDoesExist...
2378 *-------------------------------------------------------------------------------------------------------
2379 FORM checkprogramdoesexist USING ilocprogram LIKE iprograms[]
2380                                  rangeprogram LIKE soprogramname[].
2381 
2382   DATA: waprogram TYPE tprogram.
2383 
2384 *  Check to see if the program is an executable program
2385   SELECT SINGLE progname
2386                 subc
2387                 INTO (waprogram-progname, waprogram-subc)
2388                 FROM reposrc
2389                 WHERE progname IN rangeprogram
2390                   AND ( subc = '1' OR
2391                         subc = 'I' OR
2392                         subc = 'M' OR
2393                         subc = 'S' ).
2394 
2395   IF NOT waprogram-progname IS INITIAL.
2396     APPEND waprogram TO ilocprogram.
2397   ENDIF.
2398 ENDFORM.                                                                          "checkProgramDoesExist
2399 
2400 *-------------------------------------------------------------------------------------------------------
2401 *  findProgramsByWildcard.. Search in the system for programs
2402 *-------------------------------------------------------------------------------------------------------
2403 FORM findprogramsbywildcard USING ilocprogram LIKE iprograms[]
2404                                   value(rangeprogram) LIKE soprogramname[]
2405                                   value(rangeauthor) LIKE soauthor[]
2406                                   value(custnamerange)
2407                                   value(customerprogsonly)
2408                                   value(getlocalobjects)
2409                                   value(package).
2410 
2411   DATA: altcustomernamerange TYPE string.
2412   FIELD-SYMBOLS: <waprogram> TYPE tprogram.
2413   DATA: genflag TYPE genflag.
2414 
2415   IF customerprogsonly IS INITIAL.
2416 *   build up the customer name range used for select statements
2417     IF custnamerange <> '^'.
2418       CONCATENATE custnamerange '%' INTO altcustomernamerange.
2419 
2420       SELECT progname
2421              subc
2422              FROM reposrc
2423              APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
2424              WHERE progname  IN rangeprogram
2425                AND progname LIKE altcustomernamerange
2426                AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
2427                AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
2428     ELSE.
2429       SELECT progname
2430              subc
2431              FROM reposrc
2432              APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
2433              WHERE progname  IN rangeprogram
2434                AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
2435                AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
2436     ENDIF.
2437   ELSE.
2438 *   Only customer programs
2439     IF custnamerange <> '^'.
2440       CONCATENATE custnamerange '%' INTO altcustomernamerange.
2441 
2442       SELECT progname
2443              subc
2444              FROM reposrc
2445              APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
2446              WHERE progname  IN rangeprogram
2447                AND ( progname LIKE altcustomernamerange
2448                      OR progname LIKE 'Z%'
2449                      OR progname LIKE 'Y%'
2450                      OR progname LIKE 'SAPMZ%'
2451                      OR progname LIKE 'SAPMY%')
2452                AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
2453                AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
2454     ELSE.
2455       SELECT progname
2456              subc
2457              FROM reposrc
2458              APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
2459              WHERE progname  IN rangeprogram
2460              AND ( progname LIKE 'Z%'
2461                    OR progname LIKE 'Y%'
2462                    OR progname LIKE 'SAPMZ%'
2463                    OR progname LIKE 'SAPMY%')
2464              AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
2465              AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
2466     ENDIF.
2467   ENDIF.
2468 
2469 * Delete any programs which are local objects
2470   IF getlocalobjects IS INITIAL.
2471     LOOP AT ilocprogram ASSIGNING <waprogram>.
2472       SELECT SINGLE genflag
2473                     FROM tadiv
2474                     INTO genflag
2475                     WHERE pgmid = 'R3TR'
2476                       AND object = 'PROG'
2477                       AND obj_name = <waprogram>-progname
2478                       AND devclass = '$TMP'.
2479       IF sy-subrc = 0.
2480         DELETE ilocprogram.
2481       ENDIF.
2482     ENDLOOP.
2483   ENDIF.
2484 
2485 * Delete any programs which are not in the specified package
2486   IF NOT package IS INITIAL.
2487     LOOP AT ilocprogram ASSIGNING <waprogram>.
2488       SELECT SINGLE genflag
2489                     FROM tadiv
2490                     INTO genflag
2491                     WHERE pgmid = 'R3TR'
2492                       AND object = 'PROG'
2493                       AND obj_name = <waprogram>-progname
2494                       AND devclass <> package.
2495       IF sy-subrc = 0.
2496         DELETE ilocprogram.
2497       ENDIF.
2498     ENDLOOP.
2499   ENDIF.
2500 ENDFORM.                                                                         "findProgramsByWildcard
2501 
2502 *-------------------------------------------------------------------------------------------------------
2503 *  retrieveProgramTexts... Find the text elements and selection texts for a program
2504 *-------------------------------------------------------------------------------------------------------
2505 FORM retrieveprogramtexts USING ilocselectiontexts LIKE dumitexttab[]
2506                                 iloctextelements LIKE dumitexttab[]
2507                                 value(programname).
2508 
2509   DATA: itexttable TYPE STANDARD TABLE OF ttexttable WITH HEADER LINE.
2510   DATA: watexts TYPE ttexttable.
2511   DATA: castprogramname(50).
2512 
2513   MOVE programname TO castprogramname.
2514 
2515   READ TEXTPOOL castprogramname INTO itexttable LANGUAGE sy-langu.
2516   DELETE itexttable WHERE key = 'R'.
2517 
2518 * Selection texts.
2519   LOOP AT itexttable WHERE id = 'S'.
2520     MOVE itexttable-key TO watexts-key.
2521     MOVE itexttable-entry TO watexts-entry.
2522     APPEND watexts TO ilocselectiontexts.
2523     CLEAR watexts.
2524   ENDLOOP.
2525 
2526 * Text elements.
2527   DELETE itexttable WHERE key = 'S'.
2528   LOOP AT itexttable WHERE id = 'I'.
2529     MOVE itexttable-key TO watexts-key.
2530     MOVE itexttable-entry TO watexts-entry.
2531     APPEND watexts TO iloctextelements.
2532   ENDLOOP.
2533 ENDFORM.                                                                           "retrieveProgramTexts
2534 
2535 *-------------------------------------------------------------------------------------------------------
2536 *  retrieveGUITitles...  Search for any GUI texts
2537 *-------------------------------------------------------------------------------------------------------
2538 FORM retrieveguititles USING ilocguititle LIKE dumiguititle[]
2539                              value(programname).
2540 
2541   SELECT obj_code
2542          text
2543          FROM d347t
2544          APPENDING CORRESPONDING FIELDS OF TABLE ilocguititle
2545          WHERE progname = programname.
2546 ENDFORM.                                                                              "retrieveGUITitles
2547 
2548 *-------------------------------------------------------------------------------------------------------
2549 *   findMainMessageClass... find the message class stated at the top of  program.
2550 *-------------------------------------------------------------------------------------------------------
2551 FORM findmainmessageclass USING value(programname)
2552                                       messageclass.
2553 
2554   SELECT SINGLE msgid
2555                 FROM trdire INTO messageclass
2556                 WHERE report = programname.
2557 ENDFORM.                                                                           "findMainMessageClass
2558 
2559 *-------------------------------------------------------------------------------------------------------
2560 * retrieveClasses...    find classes and sub objects from SAP DB
2561 *-------------------------------------------------------------------------------------------------------
2562 FORM retrieveclasses USING ilocclasses LIKE iclasses[]
2563                            ilocfunctions LIKE ifunctions[]
2564                            rangeclass LIKE soclassname[]
2565                            rangeauthor LIKE soauthor[]
2566                            value(custnamerange)
2567                            value(alsomodifiedbyauthor)
2568                            value(customerprogsonly)
2569                            value(getmessages)
2570                            value(gettextelements)
2571                            value(getcustdictstructures)
2572                            value(getfunctions)
2573                            value(getincludes)
2574                            value(recursivefuncsearch)
2575                            value(recursiveincludesearch)
2576                            value(recursiveclasssearch)
2577                            value(language).
2578 
2579   DATA: warangeclass LIKE LINE OF rangeclass.
2580 
2581   IF rangeclass[] IS INITIAL.
2582 *   We are finding all programs by an author
2583     PERFORM findallclassesforauthor USING ilocclasses[]
2584                                            rangeclass[]
2585                                            rangeauthor[]
2586                                            custnamerange
2587                                            alsomodifiedbyauthor
2588                                            customerprogsonly
2589                                            language.
2590   ELSE.
2591     READ TABLE rangeclass INDEX 1 INTO warangeclass.
2592     IF warangeclass-low CS asterix.
2593       PERFORM findclassesbywildcard USING ilocclasses[]
2594                                           rangeclass[]
2595                                           rangeauthor[]
2596                                           custnamerange
2597                                           customerprogsonly
2598                                           language.
2599     ELSE.
2600       PERFORM checkclassdoesexist USING ilocclasses[]
2601                                         rangeclass[].
2602     ENDIF.
2603   ENDIF.
2604 
2605 * Find extra items
2606   IF NOT ilocclasses[] IS INITIAL.
2607     PERFORM scanforadditionalclassstuff USING ilocclasses[]
2608                                               ilocfunctions[]
2609                                               gettextelements
2610                                               getmessages
2611                                               getcustdictstructures
2612                                               getfunctions
2613                                               getincludes
2614                                               customerprogsonly
2615                                               custnamerange
2616                                               recursiveincludesearch
2617                                               recursivefuncsearch
2618                                               recursiveclasssearch.
2619   ENDIF.
2620 ENDFORM.                                                                                "retrieveClasses
2621 
2622 *-------------------------------------------------------------------------------------------------------
2623 *  findAllClassesForAuthor...
2624 *-------------------------------------------------------------------------------------------------------
2625 FORM findallclassesforauthor USING ilocclass LIKE iclasses[]
2626                                    rangeclass LIKE soclassname[]
2627                                    rangeauthor LIKE soauthor[]
2628                                    value(custnamerange)
2629                                    value(alsomodifiedbyauthor)
2630                                    value(customerclassesonly)
2631                                    value(language).
2632 
2633   DATA: altcustomernamerange(2).
2634 
2635 * build up the customer name range used for select statements
2636   CONCATENATE custnamerange '%' INTO altcustomernamerange.
2637 
2638 * select by name and author
2639   IF NOT alsomodifiedbyauthor IS INITIAL.
2640 *   Classes modified by author
2641     IF customerclassesonly IS INITIAL.
2642 *     Select all classes
2643       SELECT clsname descript msg_id
2644              FROM vseoclass
2645              APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2646              WHERE clsname IN rangeclass
2647                AND langu = language
2648                AND ( author IN rangeauthor OR changedby IN rangeauthor )
2649                AND version = '1'
2650                AND ( state = '0' OR state = '1' ).
2651 
2652       IF sy-subrc <> 0.
2653         SELECT clsname descript msg_id
2654                FROM vseoclass
2655                APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2656                WHERE clsname IN rangeclass
2657                AND langu = language
2658                  AND ( author IN rangeauthor OR changedby IN rangeauthor )
2659                  AND version = '0'
2660                  AND ( state = '0' OR state = '1' ).
2661       ENDIF.
2662     ELSE.
2663 *     Select only customer specific classes
2664       SELECT clsname descript msg_id
2665              FROM vseoclass
2666              APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2667              WHERE clsname IN rangeclass
2668                AND ( clsname LIKE altcustomernamerange
2669                      OR clsname LIKE 'Z%'
2670                      OR clsname LIKE 'Y%')
2671                AND langu = language
2672                AND ( author IN rangeauthor OR changedby IN rangeauthor )
2673                AND version = '1'
2674                AND ( state = '0' OR state = '1' ).
2675 
2676       IF sy-subrc <> 0.
2677         SELECT clsname descript msg_id
2678                FROM vseoclass
2679                APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2680                WHERE clsname IN rangeclass
2681                  AND ( clsname LIKE altcustomernamerange
2682                        OR clsname LIKE 'Z%'
2683                        OR clsname LIKE 'Y%')
2684                  AND langu = language
2685                  AND ( author IN rangeauthor OR changedby IN rangeauthor )
2686                  AND version = '0'
2687                  AND ( state = '0' OR state = '1' ).
2688       ENDIF.
2689     ENDIF.
2690   ELSE.
2691 *   Programs created by author
2692     IF customerclassesonly IS INITIAL.
2693 *     Select all classes
2694       SELECT clsname descript msg_id
2695              FROM vseoclass
2696              APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2697              WHERE clsname IN rangeclass
2698                AND langu = language
2699                AND author IN rangeauthor
2700                AND version = '1'
2701                AND ( state = '0' OR state = '1' ).
2702 
2703       IF sy-subrc <> 0.
2704         SELECT clsname descript msg_id
2705                FROM vseoclass
2706                APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2707                WHERE clsname IN rangeclass
2708                  AND langu = language
2709                  AND author IN rangeauthor
2710                  AND version = '0'
2711                  AND ( state = '0' OR state = '1' ).
2712       ENDIF.
2713     ELSE.
2714 *     Select only customer specific classes
2715       SELECT clsname descript msg_id
2716              FROM vseoclass
2717              APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2718              WHERE clsname IN rangeclass
2719                AND ( clsname LIKE altcustomernamerange
2720                      OR clsname LIKE 'Z%'
2721                      OR clsname LIKE 'Y%')
2722                AND langu = language
2723                AND author IN rangeauthor
2724                AND version = '1'
2725                AND ( state = '0' OR state = '1' ).
2726 
2727       IF sy-subrc <> 0.
2728         SELECT clsname descript msg_id
2729                FROM vseoclass
2730                APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2731                WHERE clsname IN rangeclass
2732                  AND ( clsname LIKE altcustomernamerange
2733                        OR clsname LIKE 'Z%'
2734                        OR clsname LIKE 'Y%')
2735                  AND langu = language
2736                  AND author IN rangeauthor
2737                  AND version = '0'
2738                  AND ( state = '0' OR state = '1' ).
2739       ENDIF.
2740     ENDIF.
2741   ENDIF.
2742 ENDFORM.                                                                        "findAllClassesForAuthor
2743 
2744 *-------------------------------------------------------------------------------------------------------
2745 *  findClassesByWildcard...  Find classes using a wildcard search
2746 *-------------------------------------------------------------------------------------------------------
2747 FORM findclassesbywildcard USING ilocclass LIKE iclasses[]
2748                                  rangeclass LIKE soclassname[]
2749                                  value(rangeauthor) LIKE soauthor[]
2750                                  value(custnamerange)
2751                                  value(customerclassesonly)
2752                                  value(language).
2753 
2754   DATA: altcustomernamerange(2).
2755 
2756   IF customerclassesonly IS INITIAL.
2757 *   Searching for customer and SAP classes
2758     IF custnamerange <> '^'.
2759 *     build up the customer name range used for select statements
2760       CONCATENATE custnamerange '%' INTO altcustomernamerange.
2761 
2762       SELECT clsname descript msg_id
2763              FROM vseoclass
2764              APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2765              WHERE clsname IN rangeclass
2766                AND clsname LIKE custnamerange
2767                AND langu = language
2768                AND ( author IN rangeauthor OR changedby IN rangeauthor )
2769                AND version = '1'
2770                AND ( state = '0' OR state = '1' ).
2771       IF sy-subrc <> 0.
2772         SELECT clsname descript msg_id
2773                FROM vseoclass
2774                APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2775                WHERE clsname IN rangeclass
2776                  AND clsname LIKE custnamerange
2777                  AND langu = language
2778                  AND ( author IN rangeauthor OR changedby IN rangeauthor )
2779                  AND version = '0'
2780                  AND ( state = '0' OR state = '1' ).
2781       ENDIF.
2782     ELSE.
2783 *     Searching using normal name ranges
2784       SELECT clsname descript msg_id
2785              FROM vseoclass
2786              APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2787              WHERE clsname IN rangeclass
2788                AND langu = language
2789                AND ( author IN rangeauthor OR changedby IN rangeauthor )
2790                AND version = '1'
2791                AND ( state = '0' OR state = '1' ).
2792       IF sy-subrc <> 0.
2793         SELECT clsname descript msg_id
2794                FROM vseoclass
2795                APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2796                WHERE clsname IN rangeclass
2797                  AND langu = language
2798                  AND ( author IN rangeauthor OR changedby IN rangeauthor )
2799                  AND version = '0'
2800                  AND ( state = '0' OR state = '1' ).
2801       ENDIF.
2802     ENDIF.
2803   ELSE.
2804 *   searching for only customer classes
2805     IF custnamerange <> '^'.
2806 *     build up the customer name range used for select statements
2807       CONCATENATE custnamerange '%' INTO altcustomernamerange.
2808 
2809       SELECT clsname descript msg_id
2810              FROM vseoclass
2811              APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2812              WHERE clsname IN rangeclass
2813                AND clsname LIKE custnamerange
2814                AND langu = language
2815                AND ( clsname LIKE 'ZC%' OR clsname LIKE 'YC%' )
2816                AND ( author IN rangeauthor OR changedby IN rangeauthor )
2817                AND version = '1'
2818                AND ( state = '0' OR state = '1' ).
2819       IF sy-subrc <> 0.
2820         SELECT clsname descript msg_id
2821                FROM vseoclass
2822                APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2823                WHERE clsname IN rangeclass
2824                  AND langu = language
2825                  AND ( clsname LIKE 'ZC%' OR clsname LIKE 'YC%' )
2826                  AND ( author IN rangeauthor OR changedby IN rangeauthor )
2827                  AND version = '0'
2828                  AND ( state = '0' OR state = '1' ).
2829       ENDIF.
2830     ELSE.
2831 *     Searching using normal name ranges
2832       SELECT clsname descript msg_id
2833              FROM vseoclass
2834              APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2835              WHERE clsname IN rangeclass
2836                AND ( clsname LIKE 'ZC%' OR clsname LIKE 'YC%' )
2837                AND ( author IN rangeauthor OR changedby IN rangeauthor )
2838                AND version = '1'
2839                AND ( state = '0' OR state = '1' ).
2840       IF sy-subrc <> 0.
2841         SELECT clsname descript msg_id
2842                FROM vseoclass
2843                APPENDING CORRESPONDING FIELDS OF TABLE ilocclass
2844                WHERE clsname IN rangeclass
2845                  AND ( clsname LIKE 'ZC%' OR clsname LIKE 'YC%' )
2846                  AND ( author IN rangeauthor OR changedby IN rangeauthor )
2847                  AND version = '0'
2848                  AND ( state = '0' OR state = '1' ).
2849       ENDIF.
2850     ENDIF.
2851   ENDIF.
2852 ENDFORM.                                                                          "findClassesByWildcard
2853 
2854 *-------------------------------------------------------------------------------------------------------
2855 *  checkClassDoesExist...
2856 *-------------------------------------------------------------------------------------------------------
2857 FORM checkclassdoesexist USING ilocclass LIKE iclasses[]
2858                                rangeclass LIKE soclassname[].
2859 
2860   DATA: waclass TYPE tclass.
2861 
2862   SELECT SINGLE clsname descript msg_id
2863          FROM vseoclass
2864          INTO CORRESPONDING FIELDS OF waclass
2865          WHERE clsname IN rangeclass
2866            AND version = '1'
2867            AND ( state = '0' OR state = '1' ).
2868 
2869   IF sy-subrc <> 0.
2870     SELECT SINGLE clsname descript msg_id
2871          FROM vseoclass
2872          INTO CORRESPONDING FIELDS OF waclass
2873          WHERE clsname IN rangeclass
2874            AND version = '0'
2875            AND ( state = '0' OR state = '1' ).
2876   ENDIF.
2877 
2878   IF NOT waclass-clsname IS INITIAL.
2879     APPEND waclass TO ilocclass.
2880   ENDIF.
2881 ENDFORM.                                                                            "checkClassDoesExist
2882 
2883 *-------------------------------------------------------------------------------------------------------
2884 *  scanForAdditionalClassStuff...
2885 *-------------------------------------------------------------------------------------------------------
2886 FORM scanforadditionalclassstuff USING ilocclasses LIKE iclasses[]
2887                                        ilocfunctions LIKE ifunctions[]
2888                                        value(gettextelements)
2889                                        value(getmessages)
2890                                        value(getcustdictstructures)
2891                                        value(getfunctions)
2892                                        value(getincludes)
2893                                        value(customeronly)
2894                                        value(customernamerange)
2895                                        value(recursiveincludesearch)
2896                                        value(recursivefuncsearch)
2897                                        value(recursiveclasssearch).
2898 
2899   DATA: waclass TYPE tclass.
2900   DATA: wamethod TYPE tmethod.
2901   DATA: mytabix TYPE sytabix.
2902   DATA: scanningforclasses TYPE i VALUE false.
2903   DATA: classnewlines TYPE i VALUE 0.
2904   DATA: classcurrentlines TYPE i VALUE 0.
2905 
2906   LOOP AT ilocclasses INTO waclass WHERE scanned IS INITIAL.
2907 *  Once we have a list of all the classes we need to loop round them an select all the other objects
2908     mytabix = sy-tabix.
2909     PERFORM findclassdetails USING waclass-clsname
2910                                    waclass
2911                                    ilocfunctions[]
2912                                    gettextelements
2913                                    getmessages
2914                                    getfunctions
2915                                    getcustdictstructures
2916                                    customeronly
2917                                    customernamerange.
2918 
2919 *   Set the scanned class so we do not check them again when running recursively.
2920     waclass-scanned = 'X'.
2921     MODIFY ilocclasses FROM waclass INDEX mytabix.
2922   ENDLOOP.
2923 
2924 * Now we have all the classes and details we need to find extra classes
2925   IF NOT recursiveclasssearch IS INITIAL.
2926     classcurrentlines = LINES( ilocclasses ).
2927     LOOP AT ilocclasses INTO waclass.
2928 *     Don't try and find any other details for an exception class
2929       IF ( waclass-clsname NS 'ZCX_' OR waclass-clsname NS 'CX_'  ).
2930 *       Find any classes defined in the main class definition
2931         PERFORM scanforclasses USING waclass-privateclasskey
2932                                      waclass-clsname
2933                                      customeronly
2934                                      customernamerange
2935                                      ilocclasses[].
2936 
2937         PERFORM scanforclasses USING waclass-publicclasskey
2938                                      waclass-clsname
2939                                      customeronly
2940                                      customernamerange
2941                                      ilocclasses[].
2942 
2943         PERFORM scanforclasses USING waclass-protectedclasskey
2944                                      waclass-clsname
2945                                      customeronly
2946                                      customernamerange
2947                                      ilocclasses[].
2948 
2949         LOOP AT waclass-imethods INTO wamethod.
2950 *         Find any classes defined in any of the methods
2951           PERFORM scanforclasses USING wamethod-methodkey
2952                                        waclass-clsname
2953                                        customeronly
2954                                        customernamerange
2955                                        ilocclasses[].
2956         ENDLOOP.
2957       ENDIF.
2958     ENDLOOP.
2959 
2960 *   We have a list of all the classes so lets go and find their details
2961     classnewlines = LINES( ilocclasses ).
2962     IF classnewlines > classcurrentlines.
2963       PERFORM scanforadditionalclassstuff USING ilocclasses[]
2964                                                 ilocfunctions[]
2965                                                 gettextelements
2966                                                 getmessages
2967                                                 getcustdictstructures
2968                                                 getfunctions
2969                                                 getincludes
2970                                                 customeronly
2971                                                 customernamerange
2972                                                 recursiveincludesearch
2973                                                 recursivefuncsearch
2974                                                 recursiveclasssearch.
2975     ENDIF.
2976   ENDIF.
2977 ENDFORM.                                                                   "scanForAdditionalClassStuff
2978 
2979 *-------------------------------------------------------------------------------------------------------
2980 *  findClassDetails...
2981 *-------------------------------------------------------------------------------------------------------
2982 FORM findclassdetails USING value(classname)
2983                                   waclass TYPE tclass
2984                               ilocfunctions LIKE ifunctions[]
2985                               value(gettextelements)
2986                               value(getmessages)
2987                               value(getfunctions)
2988                               value(getcustdictstructures)
2989                               value(customeronly)
2990                               value(customernamerange).
2991 
2992   DATA: iemptyselectiontexts TYPE STANDARD TABLE OF ttexttable.
2993   DATA: mytabix TYPE sytabix.
2994   DATA: wamethod TYPE tmethod.
2995 
2996 * Build up the keys we will use for finding data
2997   PERFORM buildclasskeys USING waclass.
2998 
2999   IF waclass-descript IS INITIAL.
3000     PERFORM findclassdescription USING classname
3001                                        waclass-descript.
3002   ENDIF.
3003 
3004 * Find the class attributes.
3005   SELECT SINGLE exposure msg_id state clsfinal r3release
3006                 FROM vseoclass
3007                 INTO (waclass-exposure, waclass-msg_id, waclass-state,
3008                       waclass-clsfinal, waclass-r3release)
3009                 WHERE clsname = waclass-clsname.
3010 
3011 * Don't try and find any other details for an exception class
3012   IF ( waclass-clsname CS 'ZCX_' OR waclass-clsname CS 'CX_'  ).
3013 *   Exception texts
3014     PERFORM findexceptiontexts USING waclass-publicclasskey
3015                                      waclass-iconcepts[].
3016     waclass-scanned = 'X'.
3017   ELSE.
3018     IF NOT gettextelements IS INITIAL.
3019 *     Find the class texts from out of the database.
3020       PERFORM retrieveprogramtexts USING iemptyselectiontexts[]
3021                                          waclass-itextelements[]
3022                                          waclass-textelementkey.
3023     ENDIF.
3024 
3025 *   Find any declared dictionary structures
3026     IF NOT getcustdictstructures IS INITIAL.
3027       PERFORM scanfortables USING waclass-privateclasskey
3028                                   customeronly
3029                                   customernamerange
3030                                   waclass-idictstruct[].
3031 
3032       PERFORM scanfortables USING waclass-publicclasskey
3033                                   customeronly
3034                                   customernamerange
3035                                   waclass-idictstruct[].
3036 
3037       PERFORM scanfortables USING waclass-protectedclasskey
3038                                   customeronly
3039                                   customernamerange
3040                                   waclass-idictstruct[].
3041 
3042       PERFORM scanfortables USING waclass-typesclasskey
3043                                   customeronly
3044                                   customernamerange
3045                                   waclass-idictstruct[].
3046 
3047       PERFORM scanforlikeortype USING waclass-privateclasskey
3048                                       customeronly
3049                                       customernamerange
3050                                       waclass-idictstruct[].
3051 
3052       PERFORM scanforlikeortype USING waclass-publicclasskey
3053                                       customeronly
3054                                       customernamerange
3055                                       waclass-idictstruct[].
3056 
3057       PERFORM scanforlikeortype USING waclass-protectedclasskey
3058                                       customeronly
3059                                       customernamerange
3060                                       waclass-idictstruct[].
3061 
3062       PERFORM scanforlikeortype USING waclass-typesclasskey
3063                                       customeronly
3064                                       customernamerange
3065                                       waclass-idictstruct[].
3066     ENDIF.
3067 
3068 
3069 *   Methods
3070 *   Find all the methods for this class
3071     PERFORM findclassmethods USING classname
3072                                    waclass-imethods[].
3073 
3074     LOOP AT waclass-imethods[] INTO wamethod.
3075       mytabix = sy-tabix.
3076 *     Find individual messages
3077       IF NOT getmessages IS INITIAL.
3078         PERFORM scanformessages USING wamethod-methodkey
3079                                       waclass-msg_id
3080                                       waclass-imessages[].
3081       ENDIF.
3082 
3083       IF NOT getcustdictstructures IS INITIAL.
3084 *       Find any declared dictionary structures
3085         PERFORM scanfortables USING wamethod-methodkey
3086                                     customeronly
3087                                     customernamerange
3088                                     waclass-idictstruct[].
3089 
3090         PERFORM scanforlikeortype USING wamethod-methodkey
3091                                         customeronly
3092                                         customernamerange
3093                                         waclass-idictstruct[].
3094       ENDIF.
3095 
3096       IF NOT getfunctions IS INITIAL.
3097         PERFORM scanforfunctions USING wamethod-methodkey
3098                                        waclass-clsname
3099                                        space
3100                                        space
3101                                        customeronly
3102                                        customernamerange
3103                                        ilocfunctions[].
3104       ENDIF.
3105 
3106       MODIFY waclass-imethods FROM wamethod INDEX mytabix.
3107     ENDLOOP.
3108   ENDIF.
3109 ENDFORM.                                                                               "findClassDetails
3110 
3111 *-------------------------------------------------------------------------------------------------------
3112 *  buildClassKeys...   Finds the title text of a class.
3113 *-------------------------------------------------------------------------------------------------------
3114 FORM buildclasskeys USING waclass TYPE tclass.
3115 
3116   DATA: classnamelength TYPE i.
3117   DATA: loops TYPE i.
3118 
3119   classnamelength = STRLEN( waclass-clsname ).
3120 
3121   cl_oo_classname_service=>get_pubsec_name( EXPORTING clsname = waclass-clsname
3122                                             RECEIVING result = waclass-publicclasskey ).
3123 
3124   cl_oo_classname_service=>get_prisec_name( EXPORTING clsname = waclass-clsname
3125                                             RECEIVING result = waclass-privateclasskey ).
3126 
3127   cl_oo_classname_service=>get_prosec_name( EXPORTING clsname = waclass-clsname
3128                                             RECEIVING result = waclass-protectedclasskey ).
3129 
3130 
3131 * Text element key - length of text element key has to be 32 characters.
3132   loops = 30 - classnamelength.
3133   waclass-textelementkey = waclass-clsname.
3134   DO loops TIMES.
3135     CONCATENATE waclass-textelementkey '=' INTO waclass-textelementkey.
3136   ENDDO.
3137 * Save this for later.
3138   CONCATENATE waclass-textelementkey 'CP' INTO waclass-textelementkey.
3139 
3140 * Types Class key - length of class name has to be 32 characters.
3141   loops = 30 - classnamelength.
3142   waclass-typesclasskey = waclass-clsname.
3143   DO loops TIMES.
3144     CONCATENATE waclass-typesclasskey '=' INTO waclass-typesclasskey.
3145   ENDDO.
3146 * Save this for later
3147   CONCATENATE waclass-typesclasskey 'CT' INTO waclass-typesclasskey.
3148 ENDFORM.                                                                                 "buildClassKeys
3149 
3150 *-------------------------------------------------------------------------------------------------------
3151 *  findClassDescription...   Finds the title text of a class.
3152 *-------------------------------------------------------------------------------------------------------
3153 FORM findclassdescription USING value(classname)
3154                                       titletext.
3155 
3156   SELECT SINGLE descript
3157                 FROM vseoclass
3158                 INTO titletext
3159                 WHERE clsname = classname
3160                   AND langu = sy-langu.
3161   IF sy-subrc <> 0.
3162     SELECT SINGLE descript
3163                   FROM vseoclass
3164                   INTO titletext
3165                   WHERE clsname = classname.
3166   ENDIF.
3167 ENDFORM.                                                                           "findClassDescription
3168 
3169 *-------------------------------------------------------------------------------------------------------
3170 *  findExceptionTexts...   Fiond the texts of an exception class.
3171 *-------------------------------------------------------------------------------------------------------
3172 FORM findexceptiontexts USING publicclasskey
3173                               iconcepts LIKE dumiconcepts[].
3174 
3175   DATA: castclassname TYPE program.
3176   DATA: itemplines TYPE STANDARD TABLE OF string WITH HEADER LINE.
3177   DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
3178   DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
3179   DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
3180   DATA: watokens TYPE stokes.
3181   DATA: wacurrenttoken TYPE stokes.
3182   DATA: waconcept LIKE LINE OF iconcepts.
3183   DATA: tokenlength TYPE i.
3184   DATA: myrow TYPE i.
3185 
3186   castclassname = publicclasskey.
3187   READ REPORT castclassname INTO itemplines.
3188 
3189   APPEND 'CONSTANTS' TO ikeywords.
3190   SCAN ABAP-SOURCE itemplines TOKENS INTO itokens STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
3191 
3192   DELETE itokens WHERE str = 'CONSTANTS'.
3193   DELETE itokens WHERE str = 'VALUE'.
3194   DELETE itokens WHERE str = 'TYPE'.
3195 
3196   LOOP AT itokens INTO watokens WHERE str = 'SOTR_CONC'.
3197 *   The loop before holds the constant name
3198     myrow = sy-tabix - 1.
3199     READ TABLE itokens INDEX myrow INTO wacurrenttoken.
3200     waconcept-constname = wacurrenttoken-str.
3201 
3202 *   The loop after holds the constant name
3203     myrow = myrow + 2.
3204     READ TABLE itokens INDEX myrow INTO wacurrenttoken.
3205     tokenlength = STRLEN( wacurrenttoken-str ).
3206     IF tokenlength = 34.
3207 *     Most likely an exception text.
3208       REPLACE ALL OCCURRENCES OF '''' IN wacurrenttoken-str WITH ' ' .
3209       waconcept-concept = wacurrenttoken-str.
3210       APPEND waconcept TO iconcepts.
3211     ENDIF.
3212   ENDLOOP.
3213 ENDFORM.                    "findExceptionTexts
3214 
3215 *-------------------------------------------------------------------------------------------------------
3216 *  findClassMethods...   Finds the methods of a class.
3217 *-------------------------------------------------------------------------------------------------------
3218 FORM findclassmethods USING value(classname)
3219                             ilocmethods LIKE dumimethods[].
3220 
3221   DATA: imethods TYPE STANDARD TABLE OF tmethod WITH HEADER LINE.
3222 
3223   SELECT cmpname descript exposure
3224          FROM vseomethod
3225          INTO CORRESPONDING FIELDS OF TABLE imethods
3226            WHERE clsname = classname
3227              AND version = '1'
3228              AND langu = sy-langu
3229              AND ( state = '0' OR state = '1' ).
3230 
3231   IF sy-subrc <> 0.
3232     SELECT cmpname descript exposure
3233            FROM vseomethod
3234            INTO CORRESPONDING FIELDS OF TABLE imethods
3235            WHERE clsname = classname
3236              AND version = '0'
3237              AND langu = sy-langu
3238              AND ( state = '0' OR state = '1' ).
3239   ENDIF.
3240 
3241 * Find the method key so that we can acces the source code later
3242   LOOP AT imethods.
3243     PERFORM findmethodkey USING classname
3244                                 imethods-cmpname
3245                                 imethods-methodkey.
3246     MODIFY imethods.
3247   ENDLOOP.
3248 
3249   ilocmethods[] = imethods[].
3250 ENDFORM.                                                                               "findClassMethods
3251 
3252 *-------------------------------------------------------------------------------------------------------
3253 * findMethodKey... find the unique key which identifes this method
3254 *-------------------------------------------------------------------------------------------------------
3255 FORM findmethodkey USING value(classname)
3256                          value(methodname)
3257                                methodkey.
3258 
3259   DATA: methodid TYPE seocpdkey.
3260   DATA: locmethodkey TYPE program.
3261 
3262   methodid-clsname = classname.
3263   methodid-cpdname = methodname.
3264 
3265   cl_oo_classname_service=>get_method_include( EXPORTING mtdkey = methodid
3266                                                RECEIVING result = locmethodkey
3267                                                EXCEPTIONS class_not_existing = 1
3268                                                           method_not_existing = 2 ).
3269 
3270   methodkey = locmethodkey.
3271 ENDFORM.                                                                                  "findMethodKey
3272 
3273 *-------------------------------------------------------------------------------------------------------
3274 * scanForMessages... Search each program for messages
3275 *-------------------------------------------------------------------------------------------------------
3276 FORM scanformessages USING value(programname)
3277                            value(mainmessageclass)
3278                                  ilocmessages LIKE imessages[].
3279 
3280   DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
3281   DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
3282   DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
3283   DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
3284   DATA: wamessage TYPE tmessage.
3285   DATA: wamessagecomparison TYPE tmessage.
3286   DATA: watokens TYPE stokes.
3287   DATA: nextline TYPE i.
3288   DATA: stringlength TYPE i VALUE 0.
3289   DATA: workingonmessage TYPE i VALUE false.
3290   DATA: castprogramname TYPE program.
3291 
3292 * Read the program code from the textpool.
3293   castprogramname = programname.
3294   READ REPORT castprogramname INTO iincludelines.
3295 
3296   APPEND message TO ikeywords.
3297   SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
3298 
3299   CLEAR iincludelines[].
3300 
3301   LOOP AT itokens.
3302     IF itokens-str = message.
3303       workingonmessage = true.
3304       CONTINUE.
3305     ENDIF.
3306 
3307     IF workingonmessage = true.
3308       stringlength = STRLEN( itokens-str ).
3309 
3310 *     Message declaration 1
3311       IF stringlength = 4 AND itokens-str+0(1) CA sy-abcde.
3312         wamessage-msgnr = itokens-str+1(3).
3313         wamessage-arbgb = mainmessageclass.
3314       ELSE.
3315         IF itokens-str CS '''' OR itokens-str CS '`'.
3316 *         Message declaration 2
3317           TRANSLATE itokens-str USING ''' '.
3318           TRANSLATE itokens-str USING '` '.
3319           CONDENSE itokens-str.
3320           SHIFT itokens-str LEFT DELETING LEADING space.
3321           wamessage-text = itokens-str.
3322           wamessage-arbgb = 'Hard coded'.
3323         ELSE.
3324           IF itokens-str = 'ID'.
3325 *           Message declaration 3
3326             nextline = sy-tabix + 1.
3327             READ TABLE itokens INDEX nextline INTO watokens.
3328             TRANSLATE watokens-str USING ''' '.
3329             CONDENSE itokens-str.
3330             SHIFT watokens-str LEFT DELETING LEADING space.
3331             IF NOT watokens-str = 'SY-MSGID'.
3332               wamessage-arbgb = watokens-str.
3333 
3334               nextline = nextline + 4.
3335               READ TABLE itokens INDEX nextline INTO watokens.
3336               TRANSLATE watokens-str USING ''' '.
3337               CONDENSE watokens-str.
3338               SHIFT watokens-str LEFT DELETING LEADING space.
3339               wamessage-msgnr = watokens-str.
3340             ELSE.
3341               workingonmessage = false.
3342             ENDIF.
3343           ELSE.
3344             IF stringlength >= 5 AND itokens-str+4(1) = '('.
3345 *              Message declaration 4
3346               wamessage-msgnr = itokens-str+1(3).
3347               SHIFT itokens-str LEFT UP TO '('.
3348               REPLACE '(' INTO itokens-str WITH space.
3349               REPLACE ')' INTO itokens-str WITH space.
3350               CONDENSE itokens-str.
3351               wamessage-arbgb = itokens-str.
3352             ENDIF.
3353           ENDIF.
3354         ENDIF.
3355       ENDIF.
3356 
3357 *      find the message text
3358       IF NOT wamessage-arbgb IS INITIAL AND NOT wamessage-msgnr IS INITIAL AND wamessage-text IS INITIAL.
3359         SELECT SINGLE text
3360                       FROM t100
3361                       INTO wamessage-text
3362                       WHERE sprsl = sy-langu
3363                         AND arbgb = wamessage-arbgb
3364                         AND msgnr = wamessage-msgnr.
3365       ENDIF.
3366 
3367 *      Append the message
3368       IF NOT wamessage IS INITIAL.
3369 *        Don't append the message if we already have it listed
3370         READ TABLE ilocmessages WITH KEY arbgb = wamessage-arbgb
3371                                          msgnr = wamessage-msgnr
3372                                          INTO wamessagecomparison.
3373         IF sy-subrc <> 0.
3374           APPEND wamessage TO ilocmessages.
3375         ENDIF.
3376         CLEAR wamessage.
3377         workingonmessage = false.
3378       ENDIF.
3379     ENDIF.
3380   ENDLOOP.
3381 ENDFORM.                                                                                 "scanForMessages
3382 
3383 *-------------------------------------------------------------------------------------------------------
3384 * scanForTables... Search each program for dictionary tables
3385 *-------------------------------------------------------------------------------------------------------
3386 FORM scanfortables USING value(programname)
3387                          value(customeronly)
3388                          value(customernamerange)
3389                                ilocdictionary LIKE idictionary[].
3390 
3391   DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
3392   DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
3393   DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
3394   DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
3395   DATA: wadictionary TYPE tdicttable.
3396   DATA: wadictionarycomparison TYPE tdicttable.
3397   DATA: castprogramname TYPE program.
3398 
3399 * Read the program code from the textpool.
3400   castprogramname = programname.
3401   READ REPORT castprogramname INTO iincludelines.
3402 
3403   APPEND tables TO ikeywords.
3404 
3405   SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
3406   CLEAR iincludelines[].
3407 
3408   SORT itokens ASCENDING BY str.
3409   DELETE itokens WHERE str = tables.
3410 
3411   LOOP AT itokens.
3412     IF NOT customeronly IS INITIAL.
3413       TRY.
3414           IF ( itokens-str+0(1) <> 'Y' OR itokens-str+0(1) <> 'Z' OR itokens-str NS customernamerange ).
3415             CONTINUE.
3416           ENDIF.
3417         CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
3418       ENDTRY.
3419     ENDIF.
3420 
3421     wadictionary-tablename = itokens-str.
3422 *   Don't append the object if we already have it listed
3423     READ TABLE ilocdictionary INTO wadictionarycomparison WITH KEY tablename = wadictionary-tablename.
3424     IF sy-subrc <> 0.
3425       PERFORM findtabledescription USING wadictionary-tablename
3426                                          wadictionary-tabletitle.
3427 
3428       PERFORM findtabledefinition USING wadictionary-tablename
3429                                         wadictionary-istructure[].
3430 
3431       APPEND wadictionary TO ilocdictionary.
3432     ENDIF.
3433   ENDLOOP.
3434 ENDFORM.                                                                                 "scanForTables
3435 
3436 *-------------------------------------------------------------------------------------------------------
3437 *  findProgramScreenFlow...
3438 *-------------------------------------------------------------------------------------------------------
3439 FORM findprogramscreenflow USING waprogram TYPE tprogram.
3440 
3441   DATA: iflow TYPE STANDARD TABLE OF tscreenflow WITH HEADER LINE.
3442 
3443   CALL FUNCTION 'DYNPRO_PROCESSINGLOGIC'
3444     EXPORTING
3445       rep_name  = waprogram-progname
3446     TABLES
3447       scr_logic = iflow.
3448 
3449   SORT iflow ASCENDING BY screen.
3450   DELETE ADJACENT DUPLICATES FROM iflow COMPARING screen.
3451   IF waprogram-subc <> 'M'.
3452     DELETE iflow WHERE screen >= '1000' AND screen <= '1099'.
3453   ENDIF.
3454 
3455   LOOP AT iflow.
3456     APPEND iflow TO waprogram-iscreenflow.
3457   ENDLOOP.
3458 ENDFORM.                                                                          "findProgramScreenFlow
3459 
3460 *-------------------------------------------------------------------------------------------------------
3461 *  findFunctionScreenFlow...
3462 *-------------------------------------------------------------------------------------------------------
3463 FORM findfunctionscreenflow USING wafunction TYPE tfunction.
3464 
3465   DATA: iflow TYPE STANDARD TABLE OF tscreenflow WITH HEADER LINE.
3466 
3467   CALL FUNCTION 'DYNPRO_PROCESSINGLOGIC'
3468     EXPORTING
3469       rep_name  = wafunction-progname
3470     TABLES
3471       scr_logic = iflow.
3472 
3473   SORT iflow ASCENDING BY screen.
3474   DELETE ADJACENT DUPLICATES FROM iflow COMPARING screen.
3475 
3476   LOOP AT iflow.
3477     APPEND iflow TO wafunction-iscreenflow.
3478   ENDLOOP.
3479 ENDFORM.                                                                          "findFunctionScreenFlow
3480 
3481 *-------------------------------------------------------------------------------------------------------
3482 * scanForLikeOrType... Look for any dictionary objects referenced by a like or type statement
3483 *-------------------------------------------------------------------------------------------------------
3484 FORM scanforlikeortype USING value(programname)
3485                              value(customeronly)
3486                              value(customernamerange)
3487                              ilocdictionary LIKE idictionary[].
3488 
3489   DATA ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
3490   DATA: head TYPE string.
3491   DATA: tail TYPE string.
3492   DATA: junk TYPE string.
3493   DATA: linetype TYPE string.
3494   DATA: linelength TYPE i VALUE 0.
3495   DATA: endofline TYPE i VALUE true.
3496   DATA: wadictionary TYPE tdicttable.
3497   DATA: wadictionarycomparison TYPE tdicttable.
3498   DATA: waline TYPE string.
3499   DATA: castprogramname TYPE program.
3500 
3501 * Read the program code from the textpool.
3502   castprogramname = programname.
3503   READ REPORT castprogramname INTO ilines.
3504 
3505   LOOP AT ilines INTO waline.
3506 *   Find custom tables.
3507     linelength = STRLEN( waline ).
3508     IF linelength > 0.
3509       IF waline(1) = asterix.
3510         CONTINUE.
3511       ENDIF.
3512 
3513       TRANSLATE waline TO UPPER CASE.
3514 
3515 *   Determine the lineType.
3516       IF endofline = true.
3517         SHIFT waline UP TO like.
3518         IF sy-subrc = 0.
3519           linetype = like.
3520         ELSE.
3521           SHIFT waline UP TO type.
3522           IF sy-subrc = 0.
3523             FIND 'BEGIN OF' IN waline.
3524             IF sy-subrc <> 0.
3525               FIND 'END OF' IN waline.
3526               IF sy-subrc <> 0.
3527                 FIND 'VALUE' IN waline.
3528                 IF sy-subrc <> 0.
3529                   linetype = type.
3530                 ENDIF.
3531               ENDIF.
3532             ENDIF.
3533           ELSE.
3534             SHIFT waline UP TO include.
3535             IF sy-subrc = 0.
3536               SPLIT waline AT space INTO junk ilines.
3537             ENDIF.
3538 
3539             SHIFT waline UP TO structure.
3540             IF sy-subrc = 0.
3541               linetype = structure.
3542             ELSE.
3543               CONTINUE.
3544             ENDIF.
3545           ENDIF.
3546         ENDIF.
3547       ELSE.
3548         linetype = comma.
3549       ENDIF.
3550 
3551       CASE linetype.
3552         WHEN like OR type OR structure.
3553 *         Work on the appropriate lineType
3554           SHIFT waline UP TO space.
3555           SHIFT waline LEFT DELETING LEADING space.
3556           IF waline CS table.
3557             SPLIT waline AT table INTO head tail.
3558             SPLIT tail AT 'OF' INTO head tail.
3559             waline = tail.
3560             SHIFT waline LEFT DELETING LEADING space.
3561           ENDIF.
3562 
3563 *         Are we only to download SAP dictionary structures.
3564           IF NOT customeronly IS INITIAL.
3565             TRY.
3566                 IF waline+0(1) = 'Y' OR waline+0(1) = 'Z' OR waline CS customernamerange.
3567                 ELSE.
3568                   linetype = ''.
3569                   CONTINUE.
3570                 ENDIF.
3571               CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
3572             ENDTRY.
3573           ENDIF.
3574 
3575           IF waline CS comma.
3576             SPLIT waline AT comma INTO head tail.
3577             IF waline CS dash.
3578               SPLIT head AT dash INTO head tail.
3579             ENDIF.
3580             IF waline CS occurs.
3581               SPLIT waline AT space INTO head tail.
3582             ENDIF.
3583           ELSE.
3584             IF waline CS period.
3585               SPLIT waline AT period INTO head tail.
3586               IF waline CS dash.
3587                 SPLIT head AT dash INTO head tail.
3588               ENDIF.
3589               IF waline CS occurs.
3590                 SPLIT waline AT space INTO head tail.
3591               ENDIF.
3592             ELSE.
3593               SPLIT waline AT space INTO head tail.
3594               IF waline CS dash.
3595                 SPLIT head AT dash INTO head tail.
3596               ENDIF.
3597             ENDIF.
3598           ENDIF.
3599 
3600           IF NOT head IS INITIAL.
3601             wadictionary-tablename = head.
3602 *           Don't append the object if we already have it listed
3603             READ TABLE ilocdictionary INTO wadictionarycomparison
3604                                       WITH KEY tablename = wadictionary-tablename.
3605             IF sy-subrc <> 0.
3606               PERFORM findtabledescription USING wadictionary-tablename
3607                                                  wadictionary-tabletitle.
3608 
3609               PERFORM findtabledefinition USING wadictionary-tablename
3610                                                 wadictionary-istructure[].
3611 
3612 *             Only append if the item is a table and not a structure or data element
3613               IF NOT wadictionary-istructure[] IS INITIAL.
3614                 APPEND wadictionary TO ilocdictionary.
3615               ENDIF.
3616             ENDIF.
3617             CLEAR wadictionary.
3618           ENDIF.
3619 
3620           linetype = ''.
3621       ENDCASE.
3622     ENDIF.
3623   ENDLOOP.
3624 ENDFORM.                                                                              "scanForLikeOrType
3625 
3626 *-------------------------------------------------------------------------------------------------------
3627 *  displayStatus...
3628 *-------------------------------------------------------------------------------------------------------
3629 FORM displaystatus USING value(message)
3630                          value(delay).
3631 
3632   CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
3633     EXPORTING
3634       percentage = 0
3635       text       = message
3636     EXCEPTIONS
3637       OTHERS     = 1.
3638 
3639   IF delay > 0.
3640     WAIT UP TO delay SECONDS.
3641   ENDIF.
3642 ENDFORM.                                                                                  "displayStatus
3643 
3644 *-------------------------------------------------------------------------------------------------------
3645 *  removeLeadingZeros...
3646 *-------------------------------------------------------------------------------------------------------
3647 FORM removeleadingzeros CHANGING myvalue.
3648 
3649   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
3650     EXPORTING
3651       input  = myvalue
3652     IMPORTING
3653       output = myvalue
3654     EXCEPTIONS
3655       OTHERS = 1.
3656 ENDFORM.                                                                             "removeLeadingZeros
3657 
3658 *-------------------------------------------------------------------------------------------------------
3659 * determineFrontendOPSystem.... Determine the frontend operating system type.
3660 *-------------------------------------------------------------------------------------------------------
3661 FORM determinefrontendopsystem USING separator
3662                                      operatingsystem.
3663 
3664   DATA: platformid TYPE i VALUE 0.
3665 
3666   CREATE OBJECT objfile.
3667 
3668   CALL METHOD objfile->get_platform
3669     RECEIVING
3670       platform             = platformid
3671     EXCEPTIONS
3672       cntl_error           = 1
3673       error_no_gui         = 2
3674       not_supported_by_gui = 3.
3675   CASE platformid.
3676     WHEN objfile->platform_windows95
3677          OR objfile->platform_windows98
3678          OR objfile->platform_nt351
3679          OR objfile->platform_nt40
3680          OR objfile->platform_nt50
3681          OR objfile->platform_mac
3682          OR objfile->platform_os2
3683          OR 14.      "XP
3684       separator = '\'.
3685       operatingsystem = non_unix.
3686     WHEN OTHERS.
3687       separator = '/'.
3688       operatingsystem = unix.
3689   ENDCASE.
3690 ENDFORM.                                                                      "determineFrontendOpSystem
3691 
3692 *-------------------------------------------------------------------------------------------------------
3693 * determineServerOPSystem.... Determine the server operating system type.
3694 *-------------------------------------------------------------------------------------------------------
3695 FORM determineserveropsystem USING separator
3696                                    serverfilesystem
3697                                    serveropsystem.
3698 
3699 * Find the file system
3700   SELECT SINGLE filesys
3701                 FROM opsystem
3702                 INTO serverfilesystem
3703                 WHERE opsys = sy-opsys.
3704 
3705   FIND 'WINDOWS' IN serverfilesystem IGNORING CASE.
3706   IF sy-subrc = 0.
3707     separator = '\'.
3708     serveropsystem = non_unix.
3709   ELSE.
3710     FIND 'DOS' IN serverfilesystem IGNORING CASE.
3711     IF sy-subrc = 0.
3712       separator = '\'.
3713       serveropsystem = non_unix.
3714     ELSE.
3715       separator = '/'.
3716       serveropsystem = unix.
3717     ENDIF.
3718   ENDIF.
3719 ENDFORM.                                                                        "determineServerOpSystem
3720 
3721 *-------------------------------------------------------------------------------------------------------
3722 * findExternalCommand.... Determine if the external command exists.  If it doesn't then disable the
3723 *                         server input field
3724 *-------------------------------------------------------------------------------------------------------
3725 FORM findexternalcommand.
3726 
3727   CALL FUNCTION 'SXPG_COMMAND_CHECK'
3728     EXPORTING
3729       commandname       = 'ZMKDIR'
3730       operatingsystem   = sy-opsys
3731     EXCEPTIONS
3732       command_not_found = 1
3733       OTHERS            = 0.
3734 
3735   IF sy-subrc <> 0.
3736     LOOP AT SCREEN.
3737       IF screen-name = 'PLOGICAL'.
3738         screen-input = 0.
3739         MODIFY SCREEN.
3740       ENDIF.
3741 
3742       IF screen-name = 'PSERV'.
3743         screen-input = 0.
3744         MODIFY SCREEN.
3745       ENDIF.
3746 
3747       IF screen-name = 'PPC'.
3748         screen-input = 0.
3749         MODIFY SCREEN.
3750       ENDIF.
3751     ENDLOOP.
3752 
3753     MESSAGE s000(oo) WITH 'Download to server disabled,' 'external command ZMKDIR not defined.'.
3754   ENDIF.
3755 ENDFORM.                    "findExternalCommand
3756 
3757 ********************************************************************************************************
3758 *****************************************DOWNLOAD ROUTINES**********************************************
3759 ********************************************************************************************************
3760 
3761 *-------------------------------------------------------------------------------------------------------
3762 * downloadDDStructures... download database objects to file
3763 *-------------------------------------------------------------------------------------------------------
3764 FORM downloadddstructures USING ilocdictionary LIKE idictionary[]
3765                                 value(pathname)
3766                                 value(htmlfileextension)
3767                                 value(subdir)
3768                                 value(sorttablesasc)
3769                                 value(slashseparator)
3770                                 value(savetoserver)
3771                                 value(displayprogressmessage).
3772 
3773   FIELD-SYMBOLS: <wadictionary> TYPE tdicttable.
3774   DATA: tablefilename TYPE string.
3775   DATA: tablefilenamewithpath TYPE string.
3776   DATA: ihtmltable TYPE STANDARD TABLE OF string WITH HEADER LINE.
3777   DATA: newsubdirectory TYPE string.
3778   DATA: completesavepath TYPE string.
3779 
3780   LOOP AT ilocdictionary ASSIGNING <wadictionary>.
3781     PERFORM buildfilename USING pathname
3782                                 subdir
3783                                 <wadictionary>-tablename
3784                                 space
3785                                 space
3786                                 htmlfileextension
3787                                 is_table
3788                                 savetoserver
3789                                 slashseparator
3790                                 tablefilenamewithpath
3791                                 tablefilename
3792                                 newsubdirectory
3793                                 completesavepath.
3794 
3795 *   Try and import a converted table to memory as it will be much quicker than converting it again
3796     IMPORT ihtmltable FROM MEMORY ID <wadictionary>-tablename.
3797     IF sy-subrc <> 0.
3798       CONCATENATE 'Converting table' <wadictionary>-tablename 'to html' INTO statusbarmessage SEPARATED BY space.
3799       PERFORM displaystatus USING statusbarmessage 0.
3800 
3801       PERFORM convertddtohtml USING <wadictionary>-istructure[]
3802                                     ihtmltable[]
3803                                     <wadictionary>-tablename
3804                                     <wadictionary>-tabletitle
3805                                     sorttablesasc.
3806 
3807       EXPORT ihtmltable TO MEMORY ID <wadictionary>-tablename.
3808     ENDIF.
3809 
3810     IF savetoserver IS INITIAL.
3811       PERFORM savefiletopc USING ihtmltable[]
3812                                  tablefilenamewithpath
3813                                  tablefilename
3814                                  space
3815                                  space
3816                                  displayprogressmessage.
3817     ELSE.
3818       PERFORM savefiletoserver USING ihtmltable[]
3819                                      tablefilenamewithpath
3820                                      tablefilename
3821                                      completesavepath
3822                                      displayprogressmessage.
3823     ENDIF.
3824 
3825     CLEAR ihtmltable[].
3826   ENDLOOP.
3827 ENDFORM.                                                                           "downloadDDStructures
3828 
3829 *-------------------------------------------------------------------------------------------------------
3830 * downloadMessageClass...
3831 *-------------------------------------------------------------------------------------------------------
3832 FORM downloadmessageclass USING ilocmessages LIKE imessages[]
3833                                 value(messageclassname)
3834                                 value(userfilepath)
3835                                 value(fileextension)
3836                                 value(htmlfileflag)
3837                                       subdir
3838                                 value(syntaxhighlightcomments)
3839                                 value(customernamerange)
3840                                 value(getincludes)
3841                                 value(getdictstructures)
3842                                 value(userhasselectedmessageclasses)
3843                                 value(slashseparator)
3844                                 value(savetoserver)
3845                                 value(displayprogressmessage).
3846 
3847   DATA: htmlpagename TYPE string.
3848   DATA: newfilenameonly TYPE string.
3849   DATA: newfilenamewithpath TYPE string.
3850   DATA: ihtmltable TYPE STANDARD TABLE OF string WITH HEADER LINE.
3851   DATA: newsubdirectory TYPE string.
3852   DATA: completesavepath TYPE string.
3853 
3854   PERFORM appendmessagestofile USING ilocmessages[]
3855                                      ihtmltable[]
3856                                      userhasselectedmessageclasses.
3857 
3858 
3859   CONCATENATE `message class ` messageclassname INTO htmlpagename.
3860 
3861   IF htmlfileflag IS INITIAL.
3862     APPEND '' TO ihtmltable.
3863     APPEND  '----------------------------------------------------------------------------------' TO ihtmltable.
3864 
3865     PERFORM buildfootermessage USING 'TEXT'
3866                                      ihtmltable.
3867     APPEND ihtmltable.
3868   ELSE.
3869     PERFORM convertcodetohtml USING ihtmltable[]
3870                                     htmlpagename
3871                                     space
3872                                     is_messageclass
3873                                     ''
3874                                     false
3875                                     syntaxhighlightcomments
3876                                     fileextension
3877                                     customernamerange
3878                                     getincludes
3879                                     getdictstructures.
3880   ENDIF.
3881 
3882   PERFORM buildfilename USING userfilepath
3883                               subdir
3884                               messageclassname
3885                               space
3886                               space
3887                               fileextension
3888                               is_messageclass
3889                               savetoserver
3890                               slashseparator
3891                               newfilenamewithpath
3892                               newfilenameonly
3893                               newsubdirectory
3894                               completesavepath.
3895 
3896   IF savetoserver IS INITIAL.
3897     PERFORM savefiletopc USING ihtmltable[]
3898                                newfilenamewithpath
3899                                newfilenameonly
3900                                space
3901                                space
3902                                displayprogressmessage.
3903   ELSE.
3904 *     Save the file to the SAP server
3905     PERFORM savefiletoserver USING ihtmltable[]
3906                                    newfilenamewithpath
3907                                    newfilenameonly
3908                                    completesavepath
3909                                    displayprogressmessage.
3910   ENDIF.
3911 ENDFORM.                                                                          "downloadMessageClass
3912 
3913 *-------------------------------------------------------------------------------------------------------
3914 *  appendMessagesToFile
3915 *-------------------------------------------------------------------------------------------------------
3916 FORM appendmessagestofile USING ilocmessages LIKE imessages[]
3917                                 ilochtml LIKE dumihtml[]
3918                                 value(userhasselectedmessageclasses).
3919 
3920   DATA: previousmessageid LIKE imessages-arbgb.
3921   FIELD-SYMBOLS: <wamessage> TYPE tmessage.
3922   DATA: wahtml TYPE string.
3923 
3924   SORT ilocmessages ASCENDING BY arbgb msgnr.
3925 
3926   IF NOT ilocmessages[] IS INITIAL.
3927     IF userhasselectedmessageclasses IS INITIAL.
3928 *     Only add these extra lines if we are actually appending them to the end of some program code
3929       APPEND wahtml TO ilochtml.
3930       APPEND wahtml TO ilochtml.
3931 
3932       APPEND '*Messages' TO ilochtml.
3933       APPEND '*----------------------------------------------------------' TO ilochtml.
3934     ENDIF.
3935 
3936     LOOP AT ilocmessages ASSIGNING <wamessage>.
3937       IF ( <wamessage>-arbgb <> previousmessageid ).
3938 
3939         IF userhasselectedmessageclasses IS INITIAL.
3940 *         Only add this extra lines if we are actually appending them to the end of some program code
3941           APPEND '*' TO ilochtml.
3942           CONCATENATE `* Message class: ` <wamessage>-arbgb INTO wahtml.
3943           APPEND wahtml TO ilochtml.
3944         ENDIF.
3945 
3946         previousmessageid = <wamessage>-arbgb.
3947         CLEAR wahtml.
3948       ENDIF.
3949 
3950       IF userhasselectedmessageclasses IS INITIAL.
3951 *       Only add this extra lines if we are actually appending them to the end of some program code
3952         CONCATENATE '*' <wamessage>-msgnr `   ` <wamessage>-text INTO wahtml.
3953       ELSE.
3954         CONCATENATE <wamessage>-msgnr `   ` <wamessage>-text INTO wahtml.
3955       ENDIF.
3956 
3957       APPEND wahtml TO ilochtml.
3958     ENDLOOP.
3959   ENDIF.
3960 ENDFORM.                                                                           "appendMessagesToFile
3961 
3962 *-------------------------------------------------------------------------------------------------------
3963 *  downloadFunctions...       Download function modules to file.
3964 *-------------------------------------------------------------------------------------------------------
3965 FORM downloadfunctions USING ilocfunctions LIKE ifunctions[]
3966                              value(userfilepath)
3967                              value(fileextension)
3968                              value(subdir)
3969                              value(downloaddocumentation)
3970                              value(converttohtml)
3971                              value(syntaxhighlightcomments)
3972                              value(customernamerange)
3973                              value(getincludes)
3974                              value(getdictstruct)
3975                              value(textfileextension)
3976                              value(htmlfileextension)
3977                              value(sorttablesasc)
3978                              value(slashseparator)
3979                              value(savetoserver)
3980                              value(displayprogressmessage).
3981 
3982   DATA: mainsubdir TYPE string.
3983   DATA: incsubdir TYPE string.
3984   FIELD-SYMBOLS: <wafunction> TYPE tfunction.
3985   FIELD-SYMBOLS: <wainclude> TYPE tinclude.
3986   DATA: iemptytextelements TYPE STANDARD TABLE OF ttexttable.
3987   DATA: iemptyselectiontexts TYPE STANDARD TABLE OF ttexttable.
3988   DATA: iemptymessages TYPE STANDARD TABLE OF tmessage.
3989   DATA: iemptyguititles TYPE STANDARD TABLE OF tguititle.
3990   DATA: functiondocumentationexists TYPE i VALUE false.
3991 
3992   LOOP AT ilocfunctions ASSIGNING <wafunction>.
3993     IF subdir IS INITIAL.
3994       incsubdir = <wafunction>-functionname.
3995       mainsubdir = ''.
3996     ELSE.
3997       CONCATENATE subdir <wafunction>-functionname INTO incsubdir SEPARATED BY slashseparator.
3998       mainsubdir = subdir.
3999     ENDIF.
4000 
4001     IF NOT downloaddocumentation IS INITIAL.
4002       PERFORM downloadfunctiondocs USING <wafunction>-functionname
4003                                          <wafunction>-functiontitle
4004                                          userfilepath
4005                                          fileextension
4006                                          converttohtml
4007                                          slashseparator
4008                                          savetoserver
4009                                          displayprogressmessage
4010                                          mainsubdir
4011                                          functiondocumentationexists.
4012     ENDIF.
4013 
4014 *   Download main source code
4015     PERFORM readfunctionanddownload USING <wafunction>-itextelements[]
4016                                           <wafunction>-iselectiontexts[]
4017                                           <wafunction>-imessages[]
4018                                           <wafunction>-functionname
4019                                           <wafunction>-functionmaininclude
4020                                           <wafunction>-functiontitle
4021                                           userfilepath
4022                                           fileextension
4023                                           mainsubdir
4024                                           converttohtml
4025                                           functiondocumentationexists
4026                                           syntaxhighlightcomments
4027                                           customernamerange
4028                                           getincludes
4029                                           getdictstruct
4030                                           slashseparator
4031                                           savetoserver
4032                                           displayprogressmessage.
4033 
4034 *   Download top include
4035     PERFORM readincludeanddownload USING iemptytextelements[]
4036                                          iemptyselectiontexts[]
4037                                          iemptymessages[]
4038                                          iemptyguititles[]
4039                                          <wafunction>-topincludename
4040                                          <wafunction>-functionname
4041                                          <wafunction>-functiontitle
4042                                          is_function
4043                                          userfilepath
4044                                          fileextension
4045                                          mainsubdir
4046                                          converttohtml
4047                                          syntaxhighlightcomments
4048                                          customernamerange
4049                                          getincludes
4050                                          getdictstruct
4051                                          slashseparator
4052                                          savetoserver
4053                                          displayprogressmessage.
4054 
4055 *   Download screens.
4056     IF NOT <wafunction>-iscreenflow[] IS INITIAL.
4057       PERFORM downloadscreens USING <wafunction>-iscreenflow[]
4058                                     <wafunction>-progname
4059                                     userfilepath
4060                                     textfileextension
4061                                     mainsubdir
4062                                     slashseparator
4063                                     savetoserver
4064                                     displayprogressmessage.
4065     ENDIF.
4066 
4067 *   Download GUI titles
4068     IF NOT <wafunction>-iguititle[] IS INITIAL.
4069       PERFORM downloadguititles USING <wafunction>-iguititle
4070                                       userfilepath
4071                                       textfileextension
4072                                       mainsubdir
4073                                       slashseparator
4074                                       savetoserver
4075                                       displayprogressmessage.
4076     ENDIF.
4077 
4078 *   Download all other includes
4079     LOOP AT <wafunction>-iincludes ASSIGNING <wainclude>.
4080       PERFORM readincludeanddownload USING iemptytextelements[]
4081                                            iemptyselectiontexts[]
4082                                            iemptymessages[]
4083                                            iemptyguititles[]
4084                                            <wainclude>-includename
4085                                            space
4086                                            <wainclude>-includetitle
4087                                            is_program
4088                                            userfilepath
4089                                            fileextension
4090                                            incsubdir
4091                                            converttohtml
4092                                            syntaxhighlightcomments
4093                                            customernamerange
4094                                            getincludes
4095                                            getdictstruct
4096                                            slashseparator
4097                                            savetoserver
4098                                            displayprogressmessage.
4099 
4100     ENDLOOP.
4101 
4102 *   Download all dictionary structures
4103     IF NOT <wafunction>-idictstruct[] IS INITIAL.
4104       PERFORM downloadddstructures USING <wafunction>-idictstruct[]
4105                                          userfilepath
4106                                          htmlfileextension
4107                                          incsubdir
4108                                          sorttablesasc
4109                                          slashseparator
4110                                          savetoserver
4111                                          displayprogressmessage.
4112     ENDIF.
4113   ENDLOOP.
4114 ENDFORM.                                                                              "downloadFunctions
4115 
4116 *-------------------------------------------------------------------------------------------------------
4117 *   readIcludeAndDownload...
4118 *-------------------------------------------------------------------------------------------------------
4119 FORM readincludeanddownload USING iloctextelements LIKE dumitexttab[]
4120                                   ilocselectiontexts LIKE dumitexttab[]
4121                                   ilocmessages LIKE imessages[]
4122                                   ilocguititles LIKE dumiguititle[]
4123                                   value(programname)
4124                                   value(functionname)
4125                                   value(shorttext)
4126                                   value(overideprogtype)
4127                                   value(userfilepath)
4128                                   value(fileextension)
4129                                   value(additionalsubdir)
4130                                   value(converttohtml)
4131                                   value(syntaxhighlightcomments)
4132                                   value(customernamerange)
4133                                   value(getincludes)
4134                                   value(getdictstructures)
4135                                   value(slashseparator)
4136                                   value(savetoserver)
4137                                   value(displayprogressmessage).
4138 
4139   DATA: ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
4140   DATA: localfilenamewithpath TYPE string.
4141   DATA: localfilenameonly TYPE string.
4142   DATA: newsubdirectory TYPE string.
4143   DATA: objectname TYPE string.
4144   DATA: completesavepath TYPE string.
4145 
4146   READ REPORT programname INTO ilines.
4147 
4148 * Download GUI titles for main program
4149   IF NOT ilocguititles[] IS INITIAL.
4150     PERFORM appendguititles USING ilocguititles[]
4151                                   ilines[].
4152   ENDIF.
4153 
4154 * Download text elements for main program
4155   IF NOT iloctextelements[] IS INITIAL.
4156     PERFORM appendtextelements USING iloctextelements[]
4157                                      ilines[].
4158   ENDIF.
4159 
4160 * Download selection texts for main program
4161   IF NOT ilocselectiontexts[] IS INITIAL.
4162     PERFORM appendselectiontexts USING ilocselectiontexts[]
4163                                        ilines[].
4164   ENDIF.
4165 
4166 * Download messages classes for main program.
4167   IF NOT ilocmessages[] IS INITIAL.
4168     PERFORM appendmessagestofile USING ilocmessages[]
4169                                        ilines[]
4170                                        space.
4171   ENDIF.
4172 
4173   IF converttohtml IS INITIAL.
4174     APPEND '' TO ilines.
4175     APPEND '----------------------------------------------------------------------------------' TO ilines.
4176     PERFORM buildfootermessage USING 'TEXT'
4177                                      ilines.
4178     APPEND ilines.
4179   ELSE.
4180     PERFORM convertcodetohtml USING ilines[]
4181                                     programname
4182                                     shorttext
4183                                     overideprogtype
4184                                     space
4185                                     space
4186                                     syntaxhighlightcomments
4187                                     fileextension
4188                                     customernamerange
4189                                     getincludes
4190                                     getdictstructures.
4191   ENDIF.
4192 
4193   IF functionname IS INITIAL.
4194     objectname = programname.
4195   ELSE.
4196     objectname = functionname.
4197   ENDIF.
4198 
4199   PERFORM buildfilename USING userfilepath
4200                               additionalsubdir
4201                               objectname
4202                               space
4203                               programname
4204                               fileextension
4205                               overideprogtype
4206                               savetoserver
4207                               slashseparator
4208                               localfilenamewithpath
4209                               localfilenameonly
4210                               newsubdirectory
4211                               completesavepath.
4212 
4213   IF savetoserver IS INITIAL.
4214     PERFORM savefiletopc USING ilines[]
4215                                localfilenamewithpath
4216                                localfilenameonly
4217                                space
4218                                space
4219                                displayprogressmessage.
4220   ELSE.
4221     PERFORM savefiletoserver USING ilines[]
4222                                    localfilenamewithpath
4223                                    localfilenameonly
4224                                    completesavepath
4225                                    displayprogressmessage.
4226   ENDIF.
4227 ENDFORM.                                                                         "readIncludeAndDownload
4228 
4229 *-------------------------------------------------------------------------------------------------------
4230 *   readClassAndDownload...
4231 *-------------------------------------------------------------------------------------------------------
4232 FORM readclassanddownload USING walocclass TYPE tclass
4233                                 value(classname)
4234                                 value(functionname)
4235                                 value(overideprogtype)
4236                                 value(userfilepath)
4237                                 value(fileextension)
4238                                 value(additionalsubdir)
4239                                 value(converttohtml)
4240                                 value(syntaxhighlightcomments)
4241                                 value(customernamerange)
4242                                 value(getincludes)
4243                                 value(getdictstructures)
4244                                 value(slashseparator)
4245                                 value(savetoserver)
4246                                 value(displayprogressmessage).
4247 
4248   DATA: itemplines TYPE STANDARD TABLE OF string WITH HEADER LINE.
4249   DATA: ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
4250   DATA: localfilenamewithpath TYPE string.
4251   DATA: localfilenameonly TYPE string.
4252   DATA: newsubdirectory TYPE string.
4253   DATA: objectname TYPE string.
4254   DATA: castclassname TYPE program.
4255   DATA: completesavepath TYPE string.
4256 
4257 * Build up attribute comments
4258   APPEND '**************************************************************************' TO ilines.
4259   APPEND '*   Class attributes.                                                    *' TO ilines.
4260   APPEND '**************************************************************************' TO ilines.
4261   CASE walocclass-exposure.
4262     WHEN 0.
4263       APPEND `Instantiation: Private` TO ilines.
4264     WHEN 1.
4265       APPEND `Instantiation: Protected` TO ilines.
4266     WHEN 2.
4267       APPEND `Instantiation: Public` TO ilines.
4268   ENDCASE.
4269   CONCATENATE `Message class: ` walocclass-msg_id INTO ilines.
4270   APPEND ilines.
4271   CASE walocclass-state.
4272     WHEN 0.
4273       APPEND `State: Only Modelled` TO ilines.
4274     WHEN 1.
4275       APPEND `State: Implemented` TO ilines.
4276   ENDCASE.
4277   CONCATENATE `Final Indicator: ` walocclass-clsfinal INTO ilines.
4278   APPEND ilines.
4279   CONCATENATE `R/3 Release: ` walocclass-r3release INTO ilines.
4280   APPEND ilines.
4281   CLEAR ilines.
4282   APPEND ilines.
4283 
4284   castclassname = walocclass-publicclasskey.
4285   READ REPORT castclassname INTO itemplines.
4286   IF sy-subrc = 0.
4287     PERFORM reformatclasscode USING itemplines[].
4288 
4289     APPEND '**************************************************************************' TO ilines.
4290     APPEND '*   Public section of class.                                             *' TO ilines.
4291     APPEND '**************************************************************************' TO ilines.
4292     LOOP AT itemplines.
4293       APPEND itemplines TO ilines.
4294     ENDLOOP.
4295   ENDIF.
4296 
4297   castclassname = walocclass-privateclasskey.
4298   READ REPORT castclassname INTO itemplines.
4299   IF sy-subrc = 0.
4300     PERFORM reformatclasscode USING itemplines[].
4301 
4302     APPEND ilines.
4303     APPEND '**************************************************************************' TO ilines.
4304     APPEND '*   Private section of class.                                            *' TO ilines.
4305     APPEND '**************************************************************************' TO ilines.
4306     LOOP AT itemplines.
4307       APPEND itemplines TO ilines.
4308     ENDLOOP.
4309   ENDIF.
4310 
4311   castclassname = walocclass-protectedclasskey.
4312   READ REPORT castclassname INTO itemplines.
4313   IF sy-subrc = 0.
4314     PERFORM reformatclasscode USING itemplines[].
4315 
4316     APPEND ilines.
4317     APPEND '**************************************************************************' TO ilines.
4318     APPEND '*   Protected section of class.                                          *' TO ilines.
4319     APPEND '**************************************************************************' TO ilines.
4320     LOOP AT itemplines.
4321       APPEND itemplines TO ilines.
4322     ENDLOOP.
4323   ENDIF.
4324 
4325   castclassname = walocclass-typesclasskey.
4326   READ REPORT castclassname INTO itemplines.
4327   IF sy-subrc = 0.
4328     APPEND ilines.
4329     APPEND '**************************************************************************' TO ilines.
4330     APPEND '*   Types section of class.                                              *' TO ilines.
4331     APPEND '**************************************************************************' TO ilines.
4332     LOOP AT itemplines.
4333       APPEND itemplines TO ilines.
4334     ENDLOOP.
4335   ENDIF.
4336 
4337 * Download text elements for this class
4338   IF NOT walocclass-itextelements[] IS INITIAL.
4339     PERFORM appendtextelements USING walocclass-itextelements[]
4340                                      ilines[].
4341   ENDIF.
4342 
4343 * Download messages classes for this class.
4344   IF NOT walocclass-imessages[] IS INITIAL.
4345     PERFORM appendmessagestofile USING walocclass-imessages[]
4346                                        ilines[]
4347                                        space.
4348   ENDIF.
4349 
4350 * Download exception texts for this class
4351   IF NOT walocclass-iconcepts[] IS INITIAL.
4352     PERFORM appendexceptiontexts USING walocclass-iconcepts[]
4353                                        ilines[].
4354   ENDIF.
4355 
4356 
4357   IF converttohtml IS INITIAL.
4358     APPEND '' TO ilines.
4359     APPEND '----------------------------------------------------------------------------------' TO ilines.
4360     PERFORM buildfootermessage USING 'TEXT'
4361                                      ilines.
4362     APPEND ilines.
4363   ELSE.
4364     PERFORM convertclasstohtml USING ilines[]
4365                                     classname
4366                                     walocclass-descript
4367                                     overideprogtype
4368                                     syntaxhighlightcomments
4369                                     fileextension
4370                                     customernamerange
4371                                     getdictstructures.
4372   ENDIF.
4373 
4374   IF functionname IS INITIAL.
4375     objectname = classname.
4376   ELSE.
4377     objectname = functionname.
4378   ENDIF.
4379 
4380   PERFORM buildfilename USING userfilepath
4381                               additionalsubdir
4382                               objectname
4383                               space
4384                               classname
4385                               fileextension
4386                               overideprogtype
4387                               savetoserver
4388                               slashseparator
4389                               localfilenamewithpath
4390                               localfilenameonly
4391                               newsubdirectory
4392                               completesavepath.
4393 
4394   IF savetoserver IS INITIAL.
4395     PERFORM savefiletopc USING ilines[]
4396                                localfilenamewithpath
4397                                localfilenameonly
4398                                space
4399                                space
4400                                displayprogressmessage.
4401   ELSE.
4402     PERFORM savefiletoserver USING ilines[]
4403                                    localfilenamewithpath
4404                                    localfilenameonly
4405                                    completesavepath
4406                                    displayprogressmessage.
4407   ENDIF.
4408 ENDFORM.                                                                           "readClassAndDownload
4409 
4410 *-------------------------------------------------------------------------------------------------------
4411 *   readMethodAndDownload...
4412 *-------------------------------------------------------------------------------------------------------
4413 FORM readmethodanddownload USING walocmethod TYPE tmethod
4414                                 value(methodname)
4415                                 value(methodkey)
4416                                 value(functionname)
4417                                 value(overideprogtype)
4418                                 value(userfilepath)
4419                                 value(fileextension)
4420                                 value(additionalsubdir)
4421                                 value(converttohtml)
4422                                 value(syntaxhighlightcomments)
4423                                 value(customernamerange)
4424                                 value(getincludes)
4425                                 value(getdictstructures)
4426                                 value(slashseparator)
4427                                 value(savetoserver)
4428                                 value(displayprogressmessage).
4429 
4430   DATA: ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
4431   DATA: itemplines TYPE STANDARD TABLE OF string WITH HEADER LINE.
4432   DATA: localfilenamewithpath TYPE string.
4433   DATA: localfilenameonly TYPE string.
4434   DATA: newsubdirectory TYPE string.
4435   DATA: objectname TYPE string.
4436   DATA: castmethodkey TYPE program.
4437   DATA: completesavepath TYPE string.
4438 
4439 * Add the method scope to the downloaded file
4440   APPEND '**************************************************************************' TO ilines.
4441   APPEND '*   Method attributes.                                                   *' TO ilines.
4442   APPEND '**************************************************************************' TO ilines.
4443   CASE walocmethod-exposure.
4444     WHEN 0.
4445       APPEND `Instantiation: Private` TO ilines.
4446     WHEN 1.
4447       APPEND `Instantiation: Protected` TO ilines.
4448     WHEN 2.
4449       APPEND `Instantiation: Public` TO ilines.
4450   ENDCASE.
4451   APPEND '**************************************************************************' TO ilines.
4452   APPEND '' TO ilines.
4453 
4454   castmethodkey = walocmethod-methodkey.
4455   READ REPORT castmethodkey INTO itemplines.
4456   LOOP AT itemplines.
4457     APPEND itemplines TO ilines.
4458   ENDLOOP.
4459 
4460   IF converttohtml IS INITIAL.
4461     APPEND '' TO ilines.
4462     APPEND '----------------------------------------------------------------------------------' TO ilines.
4463     PERFORM buildfootermessage USING 'TEXT'
4464                                      ilines.
4465     APPEND ilines.
4466   ELSE.
4467     PERFORM convertcodetohtml USING ilines[]
4468                                     methodname
4469                                     walocmethod-descript
4470                                     overideprogtype
4471                                     space
4472                                     space
4473                                     syntaxhighlightcomments
4474                                     fileextension
4475                                     customernamerange
4476                                     getincludes
4477 
4478                                     getdictstructures.
4479   ENDIF.
4480 
4481   IF functionname IS INITIAL.
4482     objectname = methodname.
4483   ELSE.
4484     objectname = functionname.
4485   ENDIF.
4486 
4487   PERFORM buildfilename USING userfilepath
4488                               additionalsubdir
4489                               objectname
4490                               space
4491                               methodname
4492                               fileextension
4493                               overideprogtype
4494                               savetoserver
4495                               slashseparator
4496                               localfilenamewithpath
4497                               localfilenameonly
4498                               newsubdirectory
4499                               completesavepath.
4500 
4501   IF savetoserver IS INITIAL.
4502     PERFORM savefiletopc USING ilines[]
4503                                localfilenamewithpath
4504                                localfilenameonly
4505                                space
4506                                space
4507                                displayprogressmessage.
4508   ELSE.
4509     PERFORM savefiletoserver USING ilines[]
4510                                    localfilenamewithpath
4511                                    localfilenameonly
4512                                    completesavepath
4513                                    displayprogressmessage.
4514   ENDIF.
4515 ENDFORM.                                                                          "readMethodAndDownload
4516 
4517 *-------------------------------------------------------------------------------------------------------
4518 *   readFunctionAndDownload...
4519 *-------------------------------------------------------------------------------------------------------
4520 FORM readfunctionanddownload USING iloctextelements LIKE dumitexttab[]
4521                                    ilocselectiontexts LIKE dumitexttab[]
4522                                    ilocmessages LIKE imessages[]
4523                                    value(functionname)
4524                                    value(functioninternalname)
4525                                    value(shorttext)
4526                                    value(userfilepath)
4527                                    value(fileextension)
4528                                    value(subdir)
4529                                    value(converttohtml)
4530                                    value(functiondocumentationexists)
4531                                    value(syntaxhighlightcomments)
4532                                    value(customernamerange)
4533                                    value(getincludes)
4534                                    value(getdictstructures)
4535                                    value(slashseparator)
4536                                    value(savetoserver)
4537                                    value(displayprogressmessage).
4538 
4539   DATA: ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
4540   DATA: localfilenamewithpath TYPE string.
4541   DATA: localfilenameonly TYPE string.
4542   DATA: newsubdirectory TYPE string.
4543   DATA: completesavepath TYPE string.
4544 
4545   READ REPORT functioninternalname INTO ilines.
4546 
4547 * If we found any text elements for this function then we ought to append them to the main include.
4548   IF NOT iloctextelements[] IS INITIAL.
4549     PERFORM appendtextelements USING iloctextelements[]
4550                                      ilines[].
4551   ENDIF.
4552 
4553 * If we found any message classes for this function then we ought to append them to the main include.
4554   IF NOT ilocmessages[] IS INITIAL.
4555     PERFORM appendmessagestofile USING ilocmessages[]
4556                                        ilines[]
4557                                        space.
4558   ENDIF.
4559 
4560   IF converttohtml IS INITIAL.
4561     APPEND '' TO ilines.
4562     APPEND '----------------------------------------------------------------------------------' TO ilines.
4563     PERFORM buildfootermessage USING 'TEXT'
4564                                      ilines.
4565     APPEND ilines.
4566   ELSE.
4567     PERFORM convertfunctiontohtml USING ilines[]
4568                                         functionname
4569                                         shorttext
4570                                         is_function
4571                                         functiondocumentationexists
4572                                         true
4573                                         syntaxhighlightcomments
4574                                         fileextension
4575                                         customernamerange
4576                                         getincludes
4577                                         getdictstructures.
4578   ENDIF.
4579 
4580   PERFORM buildfilename USING userfilepath
4581                               subdir
4582                               functionname
4583                               space
4584                               space
4585                               fileextension
4586                               is_function
4587                               savetoserver
4588                               slashseparator
4589                               localfilenamewithpath
4590                               localfilenameonly
4591                               newsubdirectory
4592                               completesavepath.
4593 
4594   IF savetoserver IS INITIAL.
4595     PERFORM savefiletopc USING ilines[]
4596                                localfilenamewithpath
4597                                localfilenameonly
4598                                space
4599                                space
4600                                displayprogressmessage.
4601   ELSE.
4602     PERFORM savefiletoserver USING ilines[]
4603                                    localfilenamewithpath
4604                                    localfilenameonly
4605                                    completesavepath
4606                                    displayprogressmessage.
4607   ENDIF.
4608 ENDFORM.                                                                        "readFunctionAndDownload
4609 
4610 *-------------------------------------------------------------------------------------------------------
4611 *  buildFilename...
4612 *-------------------------------------------------------------------------------------------------------
4613 FORM buildfilename USING value(userpath)
4614                          value(additionalsubdirectory)
4615                          value(objectname)
4616                          value(mainfunctionno)
4617                          value(includename)
4618                          value(fileextension)
4619                          value(downloadtype)
4620                          value(downloadtoserver)
4621                          value(slashseparator)
4622                                newfilenamewithpath
4623                                newfilenameonly
4624                                newsubdirectory
4625                                completepath.
4626 
4627 * If we are running on a non UNIX environment we will need to remove forward slashes from the additional path.
4628   IF downloadtoserver IS INITIAL.
4629     IF frontendopsystem = non_unix.
4630       IF NOT additionalsubdirectory IS INITIAL.
4631         TRANSLATE additionalsubdirectory USING '/_'.
4632         IF additionalsubdirectory+0(1) = '_'.
4633           SHIFT additionalsubdirectory LEFT BY 1 PLACES.
4634         ENDIF.
4635       ENDIF.
4636     ENDIF.
4637   ELSE.
4638     IF serveropsystem = non_unix.
4639       IF NOT additionalsubdirectory IS INITIAL.
4640         TRANSLATE additionalsubdirectory USING '/_'.
4641         IF additionalsubdirectory+0(1) = '_'.
4642           SHIFT additionalsubdirectory LEFT BY 1 PLACES.
4643         ENDIF.
4644       ENDIF.
4645     ENDIF.
4646   ENDIF.
4647 
4648   CASE downloadtype.
4649 *   Programs
4650     WHEN is_program.
4651       IF additionalsubdirectory IS INITIAL.
4652         CONCATENATE userpath slashseparator objectname period fileextension INTO newfilenamewithpath.
4653         CONCATENATE userpath slashseparator INTO completepath.
4654       ELSE.
4655         CONCATENATE userpath slashseparator additionalsubdirectory
4656                              slashseparator objectname period fileextension INTO newfilenamewithpath.
4657         CONCATENATE userpath slashseparator additionalsubdirectory INTO completepath.
4658       ENDIF.
4659 
4660 *   Function Modules
4661     WHEN is_function.
4662       IF additionalsubdirectory IS INITIAL.
4663         FIND 'top' IN includename IGNORING CASE.
4664         IF sy-subrc = 0.
4665           CONCATENATE userpath slashseparator objectname
4666                                slashseparator 'Global-' objectname
4667                                period fileextension
4668                                INTO newfilenamewithpath.
4669         ELSE.
4670           IF includename CS mainfunctionno AND NOT mainfunctionno IS INITIAL.
4671             CONCATENATE userpath slashseparator objectname
4672                                  slashseparator objectname
4673                                  period fileextension
4674                                  INTO newfilenamewithpath.
4675           ELSE.
4676             CONCATENATE userpath slashseparator objectname
4677                                  slashseparator objectname
4678                                  period fileextension
4679                                  INTO newfilenamewithpath.
4680           ENDIF.
4681         ENDIF.
4682         newsubdirectory = objectname.
4683         CONCATENATE userpath slashseparator INTO completepath.
4684       ELSE.
4685         FIND 'top' IN includename IGNORING CASE.
4686         IF sy-subrc = 0.
4687           CONCATENATE userpath slashseparator additionalsubdirectory
4688                                slashseparator objectname
4689                                slashseparator 'Global-' objectname
4690                                period fileextension
4691                                INTO newfilenamewithpath.
4692         ELSE.
4693           IF includename CS mainfunctionno AND NOT mainfunctionno IS INITIAL.
4694             CONCATENATE userpath slashseparator additionalsubdirectory
4695                                  slashseparator objectname
4696                                  slashseparator objectname
4697                                  period fileextension
4698                                  INTO newfilenamewithpath.
4699           ELSE.
4700             CONCATENATE userpath slashseparator additionalsubdirectory
4701                                  slashseparator objectname
4702                                  slashseparator objectname
4703                                  period fileextension
4704                                  INTO newfilenamewithpath.
4705           ENDIF.
4706         ENDIF.
4707         CONCATENATE additionalsubdirectory slashseparator objectname INTO newsubdirectory.
4708         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO completepath.
4709       ENDIF.
4710 
4711 *   Table definition
4712     WHEN is_table.
4713       IF additionalsubdirectory IS INITIAL.
4714         CONCATENATE userpath slashseparator objectname
4715                              slashseparator 'Dictionary-'
4716                              objectname period fileextension
4717                              INTO newfilenamewithpath.
4718 
4719         CONCATENATE userpath slashseparator objectname INTO newsubdirectory.
4720         CONCATENATE userpath slashseparator objectname INTO completepath.
4721       ELSE.
4722         CONCATENATE userpath slashseparator additionalsubdirectory
4723                              slashseparator objectname
4724                              slashseparator 'Dictionary-'
4725                              objectname period fileextension
4726                              INTO newfilenamewithpath.
4727 
4728         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO newsubdirectory.
4729         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO completepath.
4730       ENDIF.
4731 
4732 *   Program & Function documentation
4733     WHEN is_documentation.
4734       IF additionalsubdirectory IS INITIAL.
4735         CONCATENATE userpath slashseparator objectname
4736                              slashseparator 'Docs-'
4737                              objectname period
4738                              fileextension
4739                              INTO newfilenamewithpath.
4740 
4741         CONCATENATE userpath slashseparator objectname INTO newsubdirectory.
4742         CONCATENATE userpath slashseparator objectname INTO completepath.
4743       ELSE.
4744         CONCATENATE userpath slashseparator additionalsubdirectory
4745                              slashseparator objectname
4746                              slashseparator 'Docs-'
4747                              objectname period fileextension
4748                              INTO newfilenamewithpath.
4749 
4750         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO newsubdirectory.
4751         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO completepath.
4752       ENDIF.
4753 
4754 *   Screens
4755     WHEN is_screen.
4756       IF additionalsubdirectory IS INITIAL.
4757         CONCATENATE userpath slashseparator 'Screens'
4758                              slashseparator 'screen_'
4759                              objectname period
4760                              fileextension INTO newfilenamewithpath.
4761 
4762         CONCATENATE userpath slashseparator 'screens' INTO newsubdirectory.
4763         CONCATENATE userpath slashseparator 'screens' INTO completepath.
4764 
4765       ELSE.
4766         CONCATENATE userpath slashseparator additionalsubdirectory
4767                              slashseparator 'Screens'
4768                              slashseparator 'screen_'
4769                              objectname period
4770                              fileextension INTO newfilenamewithpath.
4771 
4772         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator 'screens' INTO newsubdirectory.
4773         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator 'screens' INTO completepath.
4774       ENDIF.
4775 
4776 *   GUI title
4777     WHEN is_guititle.
4778       IF additionalsubdirectory IS INITIAL.
4779         CONCATENATE userpath slashseparator 'Screens'
4780                              slashseparator 'gui_title_'
4781                              objectname period
4782                              fileextension INTO newfilenamewithpath.
4783 
4784         CONCATENATE userpath slashseparator 'screens' INTO newsubdirectory.
4785         CONCATENATE userpath slashseparator 'screens' INTO completepath.
4786       ELSE.
4787         CONCATENATE userpath slashseparator additionalsubdirectory
4788                              slashseparator 'Screens'
4789                              slashseparator 'gui_title_'
4790                              objectname period
4791                              fileextension INTO newfilenamewithpath.
4792 
4793         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator 'Screens' INTO newsubdirectory.
4794         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator 'Screens' INTO completepath.
4795       ENDIF.
4796 
4797 *   Message Class
4798     WHEN is_messageclass.
4799       IF additionalsubdirectory IS INITIAL.
4800         CONCATENATE userpath slashseparator objectname
4801                              slashseparator 'Message class-'
4802                              objectname period
4803                              fileextension
4804                              INTO newfilenamewithpath.
4805 
4806         CONCATENATE userpath slashseparator objectname INTO newsubdirectory.
4807         CONCATENATE userpath slashseparator objectname INTO completepath.
4808       ELSE.
4809         CONCATENATE userpath slashseparator additionalsubdirectory
4810                              slashseparator objectname
4811                              slashseparator 'Message class-'
4812                              objectname period fileextension
4813                              INTO newfilenamewithpath.
4814 
4815         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO newsubdirectory.
4816         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO completepath.
4817       ENDIF.
4818 
4819 *   Class definition
4820     WHEN is_class.
4821       IF additionalsubdirectory IS INITIAL.
4822         CONCATENATE userpath slashseparator objectname
4823                              slashseparator 'Class-'
4824                              objectname period fileextension
4825                              INTO newfilenamewithpath.
4826 
4827         CONCATENATE userpath slashseparator objectname INTO newsubdirectory.
4828         CONCATENATE userpath slashseparator objectname INTO completepath.
4829       ELSE.
4830         CONCATENATE userpath slashseparator additionalsubdirectory
4831                              slashseparator objectname
4832                              slashseparator 'Class-'
4833                              objectname period fileextension
4834                              INTO newfilenamewithpath.
4835 
4836         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO newsubdirectory.
4837         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO completepath.
4838       ENDIF.
4839 
4840 *   Class definition
4841     WHEN is_method.
4842       IF additionalsubdirectory IS INITIAL.
4843         CONCATENATE userpath slashseparator 'Method-'
4844                              objectname period fileextension
4845                              INTO newfilenamewithpath.
4846 
4847         CONCATENATE userpath slashseparator objectname INTO newsubdirectory.
4848         CONCATENATE userpath slashseparator objectname INTO completepath.
4849       ELSE.
4850         CONCATENATE userpath slashseparator additionalsubdirectory
4851                              slashseparator 'Method-'
4852                              objectname period fileextension
4853                              INTO newfilenamewithpath.
4854 
4855         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO newsubdirectory.
4856         CONCATENATE userpath slashseparator additionalsubdirectory slashseparator objectname INTO completepath.
4857       ENDIF.
4858   ENDCASE.
4859 
4860   TRANSLATE completepath TO LOWER CASE.
4861   CONCATENATE objectname period fileextension INTO newfilenameonly.
4862   TRANSLATE newfilenameonly TO LOWER CASE.
4863   TRANSLATE newfilenamewithpath TO LOWER CASE.
4864   TRANSLATE newsubdirectory TO LOWER CASE.
4865 
4866 * If we are running on a non UNIX environment we will need to remove incorrect characters from the filename.
4867   IF downloadtoserver IS INITIAL.
4868     IF frontendopsystem = non_unix.
4869       TRANSLATE newfilenameonly USING '/_'.
4870       TRANSLATE newfilenamewithpath USING '/_'.
4871       TRANSLATE newfilenameonly USING '< '.
4872       TRANSLATE newfilenamewithpath USING '< '.
4873       TRANSLATE newfilenameonly USING '> '.
4874       TRANSLATE newfilenamewithpath USING '> '.
4875       TRANSLATE newfilenameonly USING '? '.
4876       TRANSLATE newfilenamewithpath USING '? '.
4877       TRANSLATE newfilenameonly USING '| '.
4878       TRANSLATE newfilenamewithpath USING '| '.
4879       CONDENSE newfilenameonly NO-GAPS.
4880       CONDENSE newfilenamewithpath NO-GAPS.
4881     ENDIF.
4882   ELSE.
4883     IF serveropsystem = non_unix.
4884       TRANSLATE newfilenameonly USING '/_'.
4885       TRANSLATE newfilenamewithpath USING '/_'.
4886       TRANSLATE newfilenameonly USING '< '.
4887       TRANSLATE newfilenamewithpath USING '< '.
4888       TRANSLATE newfilenameonly USING '> '.
4889       TRANSLATE newfilenamewithpath USING '> '.
4890       TRANSLATE newfilenameonly USING '? '.
4891       TRANSLATE newfilenamewithpath USING '? '.
4892       TRANSLATE newfilenameonly USING '| '.
4893       TRANSLATE newfilenamewithpath USING '| '.
4894       CONDENSE newfilenameonly NO-GAPS.
4895       CONDENSE newfilenamewithpath NO-GAPS.
4896     ENDIF.
4897   ENDIF.
4898 ENDFORM.                                                                                 "buildFilename
4899 
4900 *-------------------------------------------------------------------------------------------------------
4901 *  saveFileToPc...    write an internal table to a file on the local PC
4902 *-------------------------------------------------------------------------------------------------------
4903 FORM savefiletopc USING idownload TYPE STANDARD TABLE
4904                         value(filenamewithpath)
4905                         value(filename)
4906                         value(writefieldseparator)
4907                         value(truncatetrailingblanks)
4908                         value(displayprogressmessage).
4909 
4910   DATA: statusmessage TYPE string.
4911   DATA: objfile TYPE REF TO cl_gui_frontend_services.
4912   DATA: strsubrc TYPE string.
4913 
4914   IF NOT displayprogressmessage IS INITIAL.
4915     CONCATENATE `Downloading: ` filename INTO statusmessage.
4916     PERFORM displaystatus USING statusmessage 0.
4917   ENDIF.
4918 
4919   CREATE OBJECT objfile.
4920   CALL METHOD objfile->gui_download
4921     EXPORTING
4922       filename                = filenamewithpath
4923       filetype                = 'ASC'
4924       write_field_separator   = writefieldseparator
4925       trunc_trailing_blanks   = truncatetrailingblanks
4926     CHANGING
4927       data_tab                = idownload[]
4928     EXCEPTIONS
4929       file_write_error        = 1
4930       no_batch                = 2
4931       gui_refuse_filetransfer = 3
4932       invalid_type            = 4
4933       no_authority            = 5
4934       unknown_error           = 6
4935       header_not_allowed      = 7
4936       separator_not_allowed   = 8
4937       filesize_not_allowed    = 9
4938       header_too_long         = 10
4939       dp_error_create         = 11
4940       dp_error_send           = 12
4941       dp_error_write          = 13
4942       unknown_dp_error        = 14
4943       access_denied           = 15
4944       dp_out_of_memory        = 16
4945       disk_full               = 17
4946       dp_timeout              = 18
4947       file_not_found          = 19
4948       dataprovider_exception  = 20
4949       control_flush_error     = 21
4950       not_supported_by_gui    = 22
4951       error_no_gui            = 23.
4952 
4953   IF sy-subrc <> 0.
4954     strsubrc = sy-subrc.
4955     CONCATENATE `File save error: ` filename ` sy-subrc: ` strsubrc INTO statusmessage.
4956     PERFORM displaystatus USING statusmessage 3.
4957   ENDIF.
4958 ENDFORM.                                                                                                  "saveFileToPc
4959 
4960 *----------------------------------------------------------------------------------------------------------------------
4961 *  saveFileToServer...    write an internal table to a file on the SAP server
4962 *----------------------------------------------------------------------------------------------------------------------
4963 FORM savefiletoserver USING idownload TYPE STANDARD TABLE
4964                             value(filenamewithpath)
4965                             value(filename)
4966                             value(path)
4967                             value(displayprogressmessage).
4968 
4969   DATA: wadownload TYPE string.
4970   DATA: statusmessage TYPE string.
4971 
4972   IF NOT displayprogressmessage IS INITIAL.
4973     CONCATENATE `Downloading: ` filename INTO statusmessage.
4974     PERFORM displaystatus USING statusmessage 0.
4975   ENDIF.
4976 
4977   READ TABLE iserverpaths WITH KEY table_line = path.
4978   IF sy-subrc <> 0.
4979     PERFORM createserverdirectory USING path.
4980     APPEND path TO iserverpaths.
4981   ENDIF.
4982 
4983   OPEN DATASET filenamewithpath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
4984   IF sy-subrc = 0.
4985     LOOP AT idownload INTO wadownload.
4986       TRANSFER wadownload TO filenamewithpath.
4987       IF sy-subrc <> 0.
4988         MESSAGE e000(oo) WITH 'Error transferring data to file'.
4989       ENDIF.
4990     ENDLOOP.
4991 
4992     CLOSE DATASET filenamewithpath.
4993     IF sy-subrc <> 0.
4994       MESSAGE e000(oo) WITH 'Error closing file'.
4995     ENDIF.
4996   ELSE.
4997 *   Unable to create a file
4998     MESSAGE e000(oo) WITH 'Error creating file on SAP server' 'check permissions'.
4999   ENDIF.
5000 ENDFORM.                                                                                              "saveFileToServer
5001 
5002 *----------------------------------------------------------------------------------------------------------------------
5003 * createServerDirectory...
5004 *----------------------------------------------------------------------------------------------------------------------
5005 FORM createserverdirectory USING value(path).
5006 
5007 *  Parameters for remove command.
5008   DATA: param1 TYPE sxpgcolist-parameters.
5009 *  Return status
5010   DATA: funcstatus TYPE extcmdexex-status.
5011 *  Command line listing returned by the function
5012   DATA: iserveroutput TYPE STANDARD TABLE OF btcxpm.
5013   DATA: waserveroutput TYPE btcxpm.
5014 *  Targetsystem type conversion variable.
5015   DATA: target TYPE rfcdisplay-rfchost.
5016 * Operating system
5017   DATA: operatingsystem TYPE sxpgcolist-opsystem.
5018 *  Head for split command.
5019   DATA: head TYPE string..
5020   DATA: tail TYPE string.
5021 
5022   param1 = path.
5023   target = sy-host.
5024   operatingsystem = sy-opsys.
5025 
5026   CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
5027     EXPORTING
5028       commandname                   = 'ZMKDIR'
5029       additional_parameters         = param1
5030       operatingsystem               = operatingsystem
5031       targetsystem                  = target
5032       stdout                        = 'X'
5033       stderr                        = 'X'
5034       terminationwait               = 'X'
5035     IMPORTING
5036       status                        = funcstatus
5037     TABLES
5038       exec_protocol                 = iserveroutput[]
5039     EXCEPTIONS
5040       no_permission                 = 1
5041       command_not_found             = 2
5042       parameters_too_long           = 3
5043       security_risk                 = 4
5044       wrong_check_call_interface    = 5
5045       program_start_error           = 6
5046       program_termination_error     = 7
5047       x_error                       = 8
5048       parameter_expected            = 9
5049       too_many_parameters           = 10
5050       illegal_command               = 11
5051       wrong_asynchronous_parameters = 12
5052       cant_enq_tbtco_entry          = 13
5053       jobcount_generation_error     = 14
5054       OTHERS                        = 15.
5055 
5056   IF sy-subrc = 0.
5057 *   Although the function succeded did the external command actually work
5058     IF funcstatus = 'E'.
5059 *     External command returned with an error
5060       IF sy-opsys CS 'Windows NT'.
5061         READ TABLE iserveroutput INDEX 1 INTO waserveroutput.
5062         IF waserveroutput-message NS 'already exists'.
5063 *         An error occurred creating the directory on the server
5064           MESSAGE e000(oo) WITH 'An error occurred creating a directory'.
5065         ENDIF.
5066       ELSE.
5067         READ TABLE iserveroutput INDEX 2 INTO waserveroutput.
5068         SPLIT waserveroutput-message AT space INTO head tail.
5069         SHIFT tail LEFT DELETING LEADING space.
5070         IF tail <> 'Do not specify an existing file.'.
5071 *         An error occurred creating the directory on the server
5072           MESSAGE e000(oo) WITH 'An error occurred creating a directory'.
5073         ENDIF.
5074       ENDIF.
5075     ENDIF.
5076   ELSE.
5077     CASE sy-subrc.
5078       WHEN 1.
5079 *       No permissions to run the command
5080         MESSAGE e000(oo) WITH 'No permissions to run external command ZMKDIR'.
5081       WHEN 2.
5082 *       External command not found
5083         MESSAGE e000(oo) WITH 'External comand ZMKDIR not found'.
5084 
5085       WHEN OTHERS.
5086 *       Unable to create the directory
5087         MESSAGE e000(oo) WITH 'An error occurred creating a directory'
5088                               ', subrc:'
5089                               sy-subrc.
5090     ENDCASE.
5091   ENDIF.
5092 ENDFORM.                                                                                         "createServerDirectory
5093 
5094 *----------------------------------------------------------------------------------------------------------------------
5095 * appendTextElements...
5096 *----------------------------------------------------------------------------------------------------------------------
5097 FORM appendtextelements USING iloctextelements LIKE dumitexttab[]
5098                               iloclines LIKE dumihtml[].
5099 
5100   FIELD-SYMBOLS: <watextelement> TYPE ttexttable.
5101   DATA: waline TYPE string.
5102 
5103   IF LINES( iloctextelements ) > 0.
5104     APPEND '' TO iloclines.
5105 
5106     APPEND '*Text elements' TO iloclines.
5107     APPEND '*----------------------------------------------------------' TO  iloclines.
5108     LOOP AT iloctextelements ASSIGNING <watextelement>.
5109       CONCATENATE '*  ' <watextelement>-key <watextelement>-entry INTO waline SEPARATED BY space.
5110       APPEND waline TO iloclines.
5111     ENDLOOP.
5112   ENDIF.
5113 ENDFORM.                                                                                            "appendTextElements
5114 
5115 *----------------------------------------------------------------------------------------------------------------------
5116 * appendGUITitles...
5117 *----------------------------------------------------------------------------------------------------------------------
5118 FORM appendguititles USING ilocguititles LIKE dumiguititle[]
5119                            iloclines LIKE dumihtml[].
5120 
5121   FIELD-SYMBOLS: <waguititle> TYPE tguititle.
5122   DATA: waline TYPE string.
5123 
5124   IF LINES( ilocguititles ) > 0.
5125     APPEND '' TO iloclines.
5126 
5127     APPEND '*GUI Texts' TO iloclines.
5128     APPEND '*----------------------------------------------------------' TO  iloclines.
5129     LOOP AT ilocguititles ASSIGNING <waguititle>.
5130       CONCATENATE '*  ' <waguititle>-obj_code '-->' <waguititle>-text INTO waline SEPARATED BY space.
5131       APPEND waline TO iloclines.
5132     ENDLOOP.
5133   ENDIF.
5134 ENDFORM.                                                                                               "appendGUITitles
5135 
5136 *----------------------------------------------------------------------------------------------------------------------
5137 * appendSelectionTexts...
5138 *----------------------------------------------------------------------------------------------------------------------
5139 FORM appendselectiontexts USING ilocselectiontexts LIKE dumitexttab[]
5140                                 iloclines LIKE dumihtml[].
5141 
5142   FIELD-SYMBOLS: <waselectiontext> TYPE ttexttable.
5143   DATA: waline TYPE string.
5144 
5145   IF LINES( ilocselectiontexts ) > 0.
5146     APPEND '' TO iloclines.
5147     APPEND '' TO iloclines.
5148 
5149     APPEND '*Selection texts' TO iloclines.
5150     APPEND '*----------------------------------------------------------' TO  iloclines.
5151     LOOP AT ilocselectiontexts ASSIGNING <waselectiontext>.
5152       CONCATENATE '*  ' <waselectiontext>-key <waselectiontext>-entry INTO waline SEPARATED BY space.
5153       APPEND waline TO iloclines.
5154     ENDLOOP.
5155   ENDIF.
5156 ENDFORM.                                                                                          "appendSelectionTexts
5157 
5158 *----------------------------------------------------------------------------------------------------------------------
5159 * appendExceptionTexts...
5160 *----------------------------------------------------------------------------------------------------------------------
5161 FORM appendexceptiontexts USING iconcepts LIKE dumiconcepts[]
5162                                 iloclines LIKE dumihtml[].
5163 
5164   FIELD-SYMBOLS: <waconcept> TYPE tconcept.
5165   DATA: waline TYPE string.
5166   DATA: concepttext TYPE sotr_txt.
5167 
5168   IF LINES( iconcepts ) > 0.
5169     APPEND '' TO iloclines.
5170 
5171     APPEND '*Exception texts' TO iloclines.
5172     APPEND '*----------------------------------------------------------' TO  iloclines.
5173     LOOP AT iconcepts ASSIGNING <waconcept>.
5174 *     Find the text for this concept
5175       CALL FUNCTION 'SOTR_GET_TEXT_KEY' EXPORTING concept = <waconcept>-concept
5176                                                   langu = sy-langu
5177                                                   search_in_second_langu = 'X'
5178 *                                                  second_langu = 'DE'
5179                                         IMPORTING e_text = concepttext
5180                                         EXCEPTIONS no_entry_found = 1
5181                                                    parameter_error = 2
5182                                                    OTHERS  = 3.
5183 
5184       IF sy-subrc = 0.
5185         CONCATENATE '*  ' <waconcept>-constname '-' concepttext  INTO waline SEPARATED BY space.
5186         APPEND waline TO iloclines.
5187       ENDIF.
5188     ENDLOOP.
5189   ENDIF.
5190 ENDFORM.                                                                                          "appendExceptionTexts
5191 
5192 *----------------------------------------------------------------------------------------------------------------------
5193 * downloadFunctionDocs...
5194 *----------------------------------------------------------------------------------------------------------------------
5195 FORM downloadfunctiondocs USING value(functionname)
5196                                 value(functiondescription)
5197                                 value(userfilepath)
5198                                 value(fileextension)
5199                                 value(converttohtml)
5200                                 value(slashseparator)
5201                                 value(savetoserver)
5202                                 value(displayprogressmessage)
5203                                       subdir
5204                                       documentationdownloaded.
5205 
5206   DATA: ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
5207   DATA: idocumentation TYPE STANDARD TABLE OF funct WITH HEADER LINE.
5208   DATA: iexceptions TYPE STANDARD TABLE OF rsexc WITH HEADER LINE.
5209   DATA: iexport TYPE STANDARD TABLE OF rsexp WITH HEADER LINE.
5210   DATA: iparameter TYPE STANDARD TABLE OF rsimp WITH HEADER LINE.
5211   DATA: itables TYPE STANDARD TABLE OF rstbl WITH HEADER LINE.
5212   DATA: iscriptlines TYPE STANDARD TABLE OF tline WITH HEADER LINE.
5213   DATA: htmlpagename TYPE string.
5214   DATA: newfilenamewithpath TYPE string.
5215   DATA: newfilenameonly TYPE string.
5216   DATA: object LIKE dokhl-object.
5217   DATA: stringlength TYPE i VALUE 0.
5218   DATA: newsubdirectory TYPE string.
5219   DATA: waline(255).
5220   DATA: completesavepath TYPE string.
5221 
5222   documentationdownloaded = false.
5223   object = functionname.
5224 
5225   CALL FUNCTION 'FUNCTION_IMPORT_DOKU'
5226     EXPORTING
5227       funcname           = functionname
5228     TABLES
5229       dokumentation      = idocumentation
5230       exception_list     = iexceptions
5231       export_parameter   = iexport
5232       import_parameter   = iparameter
5233       tables_parameter   = itables
5234     EXCEPTIONS
5235       error_message      = 1
5236       function_not_found = 2
5237       invalid_name       = 3
5238       OTHERS             = 4.
5239 
5240   CALL FUNCTION 'DOCU_GET'
5241     EXPORTING
5242       id                     = 'FU'
5243       langu                  = sy-langu
5244       object                 = object
5245       typ                    = 'T'
5246       version_active_or_last = 'L'
5247     TABLES
5248       line                   = iscriptlines
5249     EXCEPTIONS
5250       no_docu_on_screen      = 1
5251       no_docu_self_def       = 2
5252       no_docu_temp           = 3
5253       ret_code               = 4
5254       OTHERS                 = 5.
5255 
5256   IF sy-subrc = 0 AND NOT ( iscriptlines[] IS INITIAL ).
5257     APPEND 'SHORT TEXT' TO ilines.
5258     CONCATENATE space functiondescription INTO functiondescription SEPARATED BY space.
5259     APPEND functiondescription TO ilines.
5260     APPEND space TO ilines.
5261     LOOP AT iscriptlines.
5262       MOVE iscriptlines-tdline TO ilines.
5263       CONCATENATE space ilines INTO ilines SEPARATED BY space.
5264       WHILE ilines CP '&*' OR ilines CP '*&'.
5265         REPLACE '&' INTO ilines WITH space.
5266         SHIFT ilines LEFT DELETING LEADING space.
5267       ENDWHILE.
5268       APPEND ilines.
5269     ENDLOOP.
5270 
5271     CLEAR ilines.
5272     IF NOT ( idocumentation[] IS INITIAL ).
5273       APPEND ilines.
5274       APPEND 'PARAMETER DOCUMENTATION' TO ilines.
5275       APPEND '-----------------------' TO ilines.
5276       APPEND ilines.
5277 
5278       DESCRIBE FIELD idocumentation-parameter LENGTH stringlength IN CHARACTER MODE.
5279       stringlength = stringlength + 3.
5280       LOOP AT idocumentation.
5281         MOVE idocumentation-parameter TO waline.
5282         MOVE idocumentation-stext TO waline+stringlength.
5283         APPEND waline TO ilines.
5284       ENDLOOP.
5285     ENDIF.
5286 
5287     CONCATENATE `Documentation - ` functionname INTO htmlpagename.
5288 
5289     IF converttohtml IS INITIAL.
5290       APPEND ilines.
5291       APPEND  '----------------------------------------------------------------------------------' TO ilines.
5292       APPEND ilines.
5293       PERFORM buildfootermessage USING 'TEXT'
5294                                        ilines.
5295       APPEND ilines.
5296     ELSE.
5297       PERFORM convertcodetohtml USING ilines[]
5298                                       htmlpagename
5299                                       space
5300                                       is_documentation
5301                                       true
5302                                       space
5303                                       space
5304                                       space
5305                                       space
5306                                       space
5307                                       space.
5308     ENDIF.
5309 
5310     PERFORM buildfilename USING userfilepath
5311                                 subdir
5312                                 functionname
5313                                 space
5314                                 space
5315                                 fileextension
5316                                 is_documentation
5317                                 savetoserver
5318                                 slashseparator
5319                                 newfilenamewithpath
5320                                 newfilenameonly
5321                                 newsubdirectory
5322                                 completesavepath.
5323 
5324     IF savetoserver IS INITIAL.
5325       PERFORM savefiletopc USING ilines[]
5326                                  newfilenamewithpath
5327                                  newfilenameonly
5328                                  space
5329                                  space
5330                                  displayprogressmessage.
5331     ELSE.
5332       PERFORM savefiletoserver USING ilines[]
5333                                      newfilenamewithpath
5334                                      newfilenameonly
5335                                      completesavepath
5336                                      displayprogressmessage.
5337     ENDIF.
5338 
5339     documentationdownloaded = true.
5340   ENDIF.
5341 ENDFORM.                                                                                          "downloadFunctionDocs
5342 
5343 *----------------------------------------------------------------------------------------------------------------------
5344 *  downloadScreens...
5345 *----------------------------------------------------------------------------------------------------------------------
5346 FORM downloadscreens USING ilocscreenflow LIKE dumiscreen[]
5347                            value(programname)
5348                            value(userfilepath)
5349                            value(textfileextension)
5350                            value(subdir)
5351                            value(slashseparator)
5352                            value(savetoserver)
5353                            value(displayprogressmessage).
5354 
5355 
5356   TABLES: d020t.
5357   DATA: header LIKE d020s.
5358   DATA: ifields TYPE STANDARD TABLE OF d021s WITH HEADER LINE.
5359   DATA: iflowlogic TYPE STANDARD TABLE OF d022s WITH HEADER LINE.
5360   FIELD-SYMBOLS <wascreen> TYPE tscreenflow.
5361   DATA: wacharheader TYPE scr_chhead.
5362   DATA: iscreenchar TYPE STANDARD TABLE OF scr_chfld WITH HEADER LINE.
5363   DATA: ifieldschar TYPE STANDARD TABLE OF scr_chfld WITH HEADER LINE.
5364   DATA: stars TYPE string VALUE '****************************************************************'.
5365   DATA: comment1 TYPE string VALUE '*   This file was generated by Direct Download Enterprise.     *'.
5366   DATA: comment2 TYPE string VALUE '*   Please do not change it manually.                          *'.
5367   DATA: dynprotext TYPE string VALUE '%_DYNPRO'.
5368   DATA: headertext TYPE string VALUE '%_HEADER'.
5369   DATA: paramstext TYPE string VALUE '%_PARAMS'.
5370   DATA: descriptiontext TYPE string VALUE '%_DESCRIPTION'.
5371   DATA: fieldstext TYPE string VALUE '%_FIELDS'.
5372   DATA: flowlogictext TYPE string VALUE '%_FLOWLOGIC'.
5373   DATA: programlength TYPE string.
5374   DATA: newsubdirectory TYPE string.
5375   DATA: newfilenamewithpath TYPE string.
5376   DATA: newfilenameonly TYPE string.
5377   DATA: completesavepath TYPE string.
5378 
5379   LOOP AT ilocscreenflow ASSIGNING <wascreen>.
5380     CALL FUNCTION 'RS_IMPORT_DYNPRO'
5381       EXPORTING
5382         dylang = sy-langu
5383         dyname = programname
5384         dynumb = <wascreen>-screen
5385       IMPORTING
5386         header = header
5387       TABLES
5388         ftab   = ifields
5389         pltab  = iflowlogic.
5390 
5391     CALL FUNCTION 'RS_SCRP_HEADER_RAW_TO_CHAR'
5392       EXPORTING
5393         header_int  = header
5394       IMPORTING
5395         header_char = wacharheader
5396       EXCEPTIONS
5397         OTHERS      = 1.
5398 
5399 *   Add in the top comments for the file
5400     APPEND stars TO iscreenchar .
5401     APPEND comment1 TO iscreenchar.
5402     APPEND comment2 TO iscreenchar.
5403     APPEND stars TO iscreenchar.
5404 
5405 *   Screen identification
5406     APPEND dynprotext TO iscreenchar.
5407     APPEND wacharheader-prog TO iscreenchar.
5408     APPEND wacharheader-dnum TO iscreenchar.
5409     APPEND sy-saprl TO iscreenchar.
5410     DESCRIBE FIELD d020t-prog LENGTH programlength IN CHARACTER MODE.
5411     CONCATENATE `                ` programlength INTO iscreenchar.
5412     APPEND iscreenchar.
5413 
5414 *   Header
5415     APPEND headertext TO iscreenchar.
5416     APPEND wacharheader TO iscreenchar.
5417 
5418 *   Description text
5419     APPEND descriptiontext TO iscreenchar.
5420     SELECT SINGLE dtxt FROM d020t INTO iscreenchar
5421                        WHERE prog = programname
5422                              AND dynr = <wascreen>-screen
5423                              AND lang = sy-langu.
5424     APPEND iscreenchar.
5425 
5426 *   Fieldlist text
5427     APPEND fieldstext TO iscreenchar.
5428 
5429     CALL FUNCTION 'RS_SCRP_FIELDS_RAW_TO_CHAR'
5430       TABLES
5431         fields_int  = ifields[]
5432         fields_char = ifieldschar[]
5433       EXCEPTIONS
5434         OTHERS      = 1.
5435 
5436     LOOP AT ifieldschar.
5437       MOVE-CORRESPONDING ifieldschar TO iscreenchar.
5438       APPEND iscreenchar.
5439     ENDLOOP.
5440 
5441 *   Flowlogic text
5442     APPEND flowlogictext TO iscreenchar.
5443 *   Flow logic.
5444     LOOP AT iflowlogic.
5445       APPEND iflowlogic TO iscreenchar.
5446     ENDLOOP.
5447 
5448     PERFORM buildfilename USING userfilepath
5449                                 subdir
5450                                 wacharheader-dnum
5451                                 space
5452                                 space
5453                                 textfileextension
5454                                 is_screen
5455                                 savetoserver
5456                                 slashseparator
5457                                 newfilenamewithpath
5458                                 newfilenameonly
5459                                 newsubdirectory
5460                                 completesavepath.
5461 
5462     IF savetoserver IS INITIAL.
5463 *     Save the screen to the local computer
5464       PERFORM savefiletopc USING iscreenchar[]
5465                                  newfilenamewithpath
5466                                  newfilenameonly
5467                                  'X'
5468                                  'X'
5469                                  displayprogressmessage.
5470     ELSE.
5471 *     Save the screen to the SAP server
5472       PERFORM savefiletoserver USING iscreenchar[]
5473                                      newfilenamewithpath
5474                                      newfilenameonly
5475                                      completesavepath
5476                                      displayprogressmessage.
5477     ENDIF.
5478 
5479     CLEAR header. CLEAR wacharheader.
5480     CLEAR iscreenchar[].
5481     CLEAR ifieldschar[].
5482     CLEAR ifields[].
5483     CLEAR iflowlogic[].
5484   ENDLOOP.
5485 ENDFORM.                                                                                               "downloadScreens
5486 
5487 *----------------------------------------------------------------------------------------------------------------------
5488 *  downloadGUITitles..
5489 *----------------------------------------------------------------------------------------------------------------------
5490 FORM downloadguititles USING ilocguititles LIKE dumiguititle[]
5491                              value(userfilepath)
5492                              value(textfileextension)
5493                              value(subdir)
5494                              value(slashseparator)
5495                              value(savetoserver)
5496                              value(displayprogressmessage).
5497 
5498   DATA: ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
5499   FIELD-SYMBOLS: <waguititle> TYPE tguititle.
5500   DATA: newsubdirectory TYPE string.
5501   DATA: newfilenamewithpath TYPE string.
5502   DATA: newfilenameonly TYPE string.
5503   DATA: completesavepath TYPE string.
5504 
5505   LOOP AT ilocguititles ASSIGNING <waguititle>.
5506     APPEND <waguititle>-text TO ilines.
5507 
5508     PERFORM buildfilename USING userfilepath
5509                                 subdir
5510                                 <waguititle>-obj_code
5511                                 space
5512                                 space
5513                                 textfileextension
5514                                 is_guititle
5515                                 savetoserver
5516                                 slashseparator
5517                                 newfilenamewithpath
5518                                 newfilenameonly
5519                                 newsubdirectory
5520                                 completesavepath.
5521 
5522     IF savetoserver IS INITIAL.
5523       PERFORM savefiletopc USING ilines[]
5524                                  newfilenamewithpath
5525                                  newfilenameonly
5526                                  space
5527                                  space
5528                                  displayprogressmessage.
5529     ELSE.
5530       PERFORM savefiletoserver USING ilines[]
5531                                      newfilenamewithpath
5532                                      newfilenameonly
5533                                      completesavepath
5534                                      displayprogressmessage.
5535     ENDIF.
5536 
5537     CLEAR ilines[].
5538   ENDLOOP.
5539 ENDFORM.                                                                                             "downloadGUITitles
5540 
5541 *----------------------------------------------------------------------------------------------------------------------
5542 *  downloadPrograms..
5543 *----------------------------------------------------------------------------------------------------------------------
5544 FORM downloadprograms USING ilocprogram LIKE iprograms[]
5545                             ilocfunctions LIKE ifunctions[]
5546                             value(userfilepath)
5547                             value(fileextension)
5548                             value(htmlfileextension)
5549                             value(textfileextension)
5550                             value(converttohtml)
5551                             value(syntaxhighlightcomments)
5552                             value(customernamerange)
5553                             value(getincludes)
5554                             value(getdictstruct)
5555                             value(downloaddocumentation)
5556                             value(sorttablesasc)
5557                             value(slashseparator)
5558                             value(savetoserver)
5559                             value(displayprogressmessage).
5560 
5561 
5562   DATA: iprogfunctions TYPE STANDARD TABLE OF tfunction WITH HEADER LINE.
5563   FIELD-SYMBOLS: <waprogram> TYPE tprogram.
5564   FIELD-SYMBOLS: <wainclude> TYPE tinclude.
5565   DATA: iemptytextelements TYPE STANDARD TABLE OF ttexttable.
5566   DATA: iemptyselectiontexts TYPE STANDARD TABLE OF ttexttable.
5567   DATA: iemptymessages TYPE STANDARD TABLE OF tmessage.
5568   DATA: iemptyguititles TYPE STANDARD TABLE OF tguititle.
5569   DATA: locconverttohtml(1).
5570   DATA: locfileextension TYPE string.
5571 
5572   SORT ilocprogram ASCENDING BY progname.
5573 
5574   LOOP AT ilocprogram ASSIGNING <waprogram>.
5575 *   if the program to download is this program then always download as text otherwise you will get a rubbish file
5576     IF <waprogram>-progname = sy-cprog.
5577       locconverttohtml = ''.
5578       locfileextension = textextension.
5579     ELSE.
5580       locconverttohtml = converttohtml.
5581       locfileextension = fileextension.
5582     ENDIF.
5583 
5584 *   Download the main program
5585     PERFORM readincludeanddownload USING <waprogram>-itextelements[]
5586                                          <waprogram>-iselectiontexts[]
5587                                          <waprogram>-imessages[]
5588                                          <waprogram>-iguititle[]
5589                                          <waprogram>-progname
5590                                          space
5591                                          <waprogram>-programtitle
5592                                          is_program
5593                                          userfilepath
5594                                          locfileextension
5595                                          <waprogram>-progname
5596                                          locconverttohtml
5597                                          syntaxhighlightcomments
5598                                          customernamerange
5599                                          getincludes
5600                                          getdictstruct
5601                                          slashseparator
5602                                          savetoserver
5603                                          displayprogressmessage.
5604 
5605 *   Download screens.
5606     IF NOT <waprogram>-iscreenflow[] IS INITIAL.
5607       PERFORM downloadscreens USING <waprogram>-iscreenflow[]
5608                                     <waprogram>-progname
5609                                     userfilepath
5610                                     textfileextension
5611                                     <waprogram>-progname
5612                                     slashseparator
5613                                     savetoserver
5614                                     displayprogressmessage.
5615     ENDIF.
5616 
5617 *   Download GUI titles
5618     IF NOT <waprogram>-iguititle[] IS INITIAL.
5619       PERFORM downloadguititles USING <waprogram>-iguititle
5620                                       userfilepath
5621                                       textfileextension
5622                                       <waprogram>-progname
5623                                       slashseparator
5624                                       savetoserver
5625                                       displayprogressmessage.
5626     ENDIF.
5627 
5628 *   Download all other includes
5629     LOOP AT <waprogram>-iincludes ASSIGNING <wainclude>.
5630       PERFORM readincludeanddownload USING iemptytextelements[]
5631                                            iemptyselectiontexts[]
5632                                            iemptymessages[]
5633                                            iemptyguititles[]
5634                                            <wainclude>-includename
5635                                            space
5636                                            <wainclude>-includetitle
5637                                            is_program
5638                                            userfilepath
5639                                            fileextension
5640                                            <waprogram>-progname
5641                                            converttohtml
5642                                            syntaxhighlightcomments
5643                                            customernamerange
5644                                            getincludes
5645                                            getdictstruct
5646                                            slashseparator
5647                                            savetoserver
5648                                            displayprogressmessage.
5649 
5650     ENDLOOP.
5651 
5652 *   Download all dictionary structures
5653     IF NOT <waprogram>-idictstruct[] IS INITIAL.
5654       PERFORM downloadddstructures USING <waprogram>-idictstruct[]
5655                                          userfilepath
5656                                          htmlfileextension
5657                                          <waprogram>-progname
5658                                          sorttablesasc
5659                                          slashseparator
5660                                          savetoserver
5661                                          displayprogressmessage.
5662     ENDIF.
5663 
5664 *   Download any functions used by these programs
5665     LOOP AT ilocfunctions INTO iprogfunctions WHERE programlinkname = <waprogram>-progname.
5666       APPEND iprogfunctions.
5667     ENDLOOP.
5668 
5669     IF NOT iprogfunctions[] IS INITIAL.
5670       PERFORM downloadfunctions USING iprogfunctions[]
5671                                       userfilepath
5672                                       fileextension
5673                                       <waprogram>-progname
5674                                       downloaddocumentation
5675                                       converttohtml
5676                                       syntaxhighlightcomments
5677                                       customernamerange
5678                                       getincludes
5679                                       getdictstruct
5680                                       textfileextension
5681                                       htmlfileextension
5682                                       sorttablesasc
5683                                       slashseparator
5684                                       savetoserver
5685                                       displayprogressmessage.
5686       CLEAR iprogfunctions[].
5687     ENDIF.
5688   ENDLOOP.
5689 ENDFORM.                                                                                              "downloadPrograms
5690 
5691 *----------------------------------------------------------------------------------------------------------------------
5692 *  downloadClasses..
5693 *----------------------------------------------------------------------------------------------------------------------
5694 FORM downloadclasses USING ilocclasses LIKE iclasses[]
5695                            ilocfunctions LIKE ifunctions[]
5696                            value(userfilepath)
5697                            value(fileextension)
5698                            value(htmlfileextension)
5699                            value(textfileextension)
5700                            value(converttohtml)
5701                            value(syntaxhighlightcomments)
5702                            value(customernamerange)
5703                            value(getincludes)
5704                            value(getdictstruct)
5705                            value(downloaddocumentation)
5706                            value(sorttablesasc)
5707                            value(slashseparator)
5708                            value(savetoserver)
5709                            value(displayprogressmessage).
5710 
5711 
5712   DATA: iclassfunctions TYPE STANDARD TABLE OF tfunction WITH HEADER LINE.
5713   FIELD-SYMBOLS: <waclass> TYPE tclass.
5714   FIELD-SYMBOLS: <wamethod> TYPE tmethod.
5715 
5716   SORT ilocclasses ASCENDING BY clsname.
5717 
5718   LOOP AT ilocclasses ASSIGNING <waclass>.
5719 *   Download the class
5720     PERFORM readclassanddownload USING <waclass>
5721                                         <waclass>-clsname
5722                                         space
5723                                         is_class
5724                                         userfilepath
5725                                         fileextension
5726                                         space
5727                                         converttohtml
5728                                         syntaxhighlightcomments
5729                                         customernamerange
5730                                         getincludes
5731                                         getdictstruct
5732                                         slashseparator
5733                                         savetoserver
5734                                         displayprogressmessage.
5735 
5736 
5737 *   Download all of the methods
5738     LOOP AT <waclass>-imethods ASSIGNING <wamethod>.
5739       PERFORM readmethodanddownload USING <wamethod>
5740                                           <wamethod>-cmpname
5741                                           <wamethod>-methodkey
5742                                           space
5743                                           is_method
5744                                           userfilepath
5745                                           fileextension
5746                                           <waclass>-clsname
5747                                           converttohtml
5748                                           syntaxhighlightcomments
5749                                           customernamerange
5750                                           getincludes
5751                                           getdictstruct
5752                                           slashseparator
5753                                           savetoserver
5754                                           displayprogressmessage.
5755 
5756     ENDLOOP.
5757 
5758 *   Download all dictionary structures
5759     IF NOT <waclass>-idictstruct[] IS INITIAL.
5760       PERFORM downloadddstructures USING <waclass>-idictstruct[]
5761                                          userfilepath
5762                                          htmlfileextension
5763                                          <waclass>-clsname
5764                                          sorttablesasc
5765                                          slashseparator
5766                                          savetoserver
5767                                          displayprogressmessage.
5768     ENDIF.
5769 
5770 *   Download any functions used by these programs
5771     LOOP AT ilocfunctions INTO iclassfunctions WHERE programlinkname = <waclass>-clsname.
5772       APPEND iclassfunctions.
5773     ENDLOOP.
5774 
5775     IF NOT iclassfunctions[] IS INITIAL.
5776       PERFORM downloadfunctions USING iclassfunctions[]
5777                                       userfilepath
5778                                       fileextension
5779                                       <waclass>-clsname
5780                                       downloaddocumentation
5781                                       converttohtml
5782                                       syntaxhighlightcomments
5783                                       customernamerange
5784                                       getincludes
5785                                       getdictstruct
5786                                       textfileextension
5787                                       htmlfileextension
5788                                       sorttablesasc
5789                                       slashseparator
5790                                       savetoserver
5791                                       displayprogressmessage.
5792       CLEAR iclassfunctions[].
5793     ENDIF.
5794   ENDLOOP.
5795 ENDFORM.                                                                                               "downloadClasses
5796 
5797 *----------------------------------------------------------------------------------------------------------------------
5798 *  reFormatClassCode...   Expand a classes public, private and protected section from the 72 characters that the class
5799 *                         builder sets it to back to the wide editor mode
5800 *----------------------------------------------------------------------------------------------------------------------
5801 FORM reformatclasscode USING itemplines LIKE dumihtml[].
5802 
5803   FIELD-SYMBOLS: <waline> TYPE string.
5804   DATA: newline TYPE string.
5805   DATA: inewtable TYPE STANDARD TABLE OF string.
5806   DATA: foundone TYPE i VALUE false.
5807 
5808   LOOP AT itemplines ASSIGNING <waline>.
5809     IF NOT <waline> IS INITIAL.
5810       IF foundone = false.
5811         FIND 'data' IN <waline> RESPECTING CASE.
5812         IF sy-subrc = 0.
5813           foundone = true.
5814         ENDIF.
5815 
5816         FIND 'constants' IN <waline> RESPECTING CASE.
5817         IF sy-subrc = 0.
5818           foundone = true.
5819         ENDIF.
5820 
5821         IF foundone = true.
5822           newline = <waline>.
5823 
5824           IF ( newline CS '.' OR newline CS '*' ).
5825             REPLACE '!' IN <waline> WITH ''.
5826             APPEND newline TO inewtable.
5827             CLEAR newline.
5828             foundone = false.
5829           ENDIF.
5830         ELSE.
5831           REPLACE '!' IN <waline> WITH ''.
5832           APPEND <waline> TO inewtable.
5833         ENDIF.
5834       ELSE.
5835         CONCATENATE newline <waline> INTO newline SEPARATED BY space.
5836         IF ( newline CS '.' OR newline CS '*' ).
5837           APPEND newline TO inewtable.
5838           CLEAR newline.
5839           foundone = false.
5840         ENDIF.
5841       ENDIF.
5842     ELSE.
5843       REPLACE '!' IN <waline> WITH ''.
5844       APPEND <waline> TO inewtable[].
5845     ENDIF.
5846   ENDLOOP.
5847 
5848   itemplines[] = inewtable[].
5849 ENDFORM.                                                                             "reFormatClassCode
5850 
5851 ***********************************************************************************************************************
5852 **********************************************HTML ROUTINES************************************************************
5853 ***********************************************************************************************************************
5854 
5855 *----------------------------------------------------------------------------------------------------------------------
5856 *  convertDDToHTML...   Convert text description to HTML
5857 *----------------------------------------------------------------------------------------------------------------------
5858 FORM convertddtohtml USING ilocdictstructure LIKE dumidictstructure[]
5859                            ilochtml LIKE dumihtml[]
5860                            value(tablename)
5861                            value(tabletitle)
5862                            value(sorttablesasc).
5863 
5864   DATA: icolumncaptions TYPE STANDARD TABLE OF string WITH HEADER LINE.
5865   DATA: wadictionary TYPE tdicttablestructure.
5866   DATA: wahtml TYPE string.
5867   DATA: title TYPE string.
5868 
5869   PERFORM buildcolumnheaders USING icolumncaptions[].
5870 
5871 * Add a html header to the table
5872   CONCATENATE 'Dictionary object-' tablename INTO title SEPARATED BY space.
5873   PERFORM addhtmlheader USING ilochtml[]
5874                               title.
5875 
5876   CONCATENATE '<h2>' tablename '</h2>' INTO wahtml.
5877   APPEND wahtml TO ilochtml.
5878   APPEND '' TO ilochtml.
5879 
5880   CONCATENATE '<h3>' tabletitle '</h3>' INTO wahtml.
5881   APPEND wahtml TO ilochtml.
5882   APPEND '' TO ilochtml.
5883 
5884 * Do we need to sort the fields into alphabetical order
5885   IF NOT sorttablesasc IS INITIAL.
5886     SORT ilocdictstructure ASCENDING BY fieldname.
5887   ENDIF.
5888 
5889   PERFORM convertitabtohtml USING icolumncaptions[]
5890                                   ilocdictstructure[]
5891                                   ilochtml
5892                                   'X'
5893                                   colour_black
5894                                   ''
5895                                   colour_yellow
5896                                   ''
5897                                   background_colour
5898                                   'Arial'
5899                                   'green'
5900                                   '1'
5901                                   '1'.
5902 
5903 * Add a html footer to the table
5904   APPEND '<br>' TO ilochtml.
5905   PERFORM addhtmlfooter USING ilochtml[].
5906 ENDFORM.                                                                                               "convertDDToHTML
5907 
5908 *----------------------------------------------------------------------------------------------------------------------
5909 *  convertITABtoHtml... produces a html table from an internal table
5910 *----------------------------------------------------------------------------------------------------------------------
5911 FORM convertitabtohtml USING ilocheader LIKE dumiheader[]
5912                              ilocdictstructure LIKE dumidictstructure[]
5913                              ilochtml LIKE dumihtml[]
5914                              value(includerowcount)
5915                              headingbackcolour
5916                              headingfontname
5917                              headingfontcolour
5918                              headingfontsize
5919                              bodybackcolour
5920                              bodyfontname
5921                              bodyfontcolour
5922                              bodyfontsize
5923                              bordersize.
5924 
5925 * Holds one cell from the internal table
5926   FIELD-SYMBOLS: <fsfield>.
5927 * The value of one cell form the internal table
5928   DATA: wtextcell TYPE string.
5929 * work area for putting the CSV value into
5930   DATA: wacsvtable TYPE string.
5931 * Have we used any font tags in the html code
5932   DATA: usedafontattribute TYPE i VALUE 0.
5933 * Work area for HTML table
5934   DATA: wahtml TYPE string.
5935 * Loop counter for adding row numbers onto the output table
5936   DATA: loopcounter TYPE string.
5937 * Work area for header table
5938   FIELD-SYMBOLS: <waheader> TYPE string.
5939   FIELD-SYMBOLS: <ilocdictstructure> TYPE tdicttablestructure.
5940 
5941   CONCATENATE '<table border="' bordersize '">' INTO wahtml.
5942   APPEND wahtml TO ilochtml.
5943 
5944   IF NOT ilocheader[] IS INITIAL.
5945     APPEND '<tr>' TO ilochtml.
5946   ENDIF.
5947 
5948   LOOP AT ilocheader ASSIGNING <waheader>.
5949     IF headingbackcolour IS INITIAL.
5950       wahtml = '<th>'.
5951     ELSE.
5952       CONCATENATE '<th bgcolor="' headingbackcolour '">' INTO wahtml.
5953     ENDIF.
5954 
5955     IF NOT headingfontname IS INITIAL OR NOT headingfontcolour IS INITIAL OR NOT headingfontsize IS INITIAL.
5956       CONCATENATE wahtml '<font' INTO wahtml.
5957 
5958 *      Add the font name
5959       IF NOT headingfontname IS INITIAL.
5960         CONCATENATE wahtml ' face ="' INTO wahtml.
5961         CONCATENATE wahtml headingfontname '"' INTO wahtml.
5962       ENDIF.
5963 
5964 *      Add the font colour
5965       IF NOT headingfontcolour IS INITIAL.
5966         CONCATENATE wahtml ' color ="' INTO wahtml.
5967         CONCATENATE wahtml headingfontcolour '"' INTO wahtml.
5968       ENDIF.
5969 
5970 *      Add the fontsize
5971       IF NOT headingfontsize IS INITIAL.
5972         CONCATENATE wahtml' size ="' INTO wahtml.
5973         CONCATENATE wahtml  headingfontsize '"' INTO wahtml.
5974       ENDIF.
5975 
5976       CONCATENATE wahtml '>' INTO wahtml.
5977       usedafontattribute = true.
5978     ENDIF.
5979 
5980 *   Add the caption name
5981     CONCATENATE wahtml <waheader> INTO wahtml.
5982 
5983     IF usedafontattribute = true.
5984       CONCATENATE wahtml '</font>' INTO wahtml.
5985       usedafontattribute = false.
5986     ENDIF.
5987 
5988     CONCATENATE wahtml '</th>' INTO wahtml.
5989     APPEND wahtml TO ilochtml.
5990   ENDLOOP.
5991 
5992   APPEND '</tr>' TO ilochtml.
5993   FREE ilocheader.
5994 
5995 
5996 *  Line item data
5997   LOOP AT ilocdictstructure ASSIGNING <ilocdictstructure>.
5998 
5999     loopcounter = sy-tabix.
6000 
6001     APPEND '' TO ilochtml.
6002     APPEND '<tr>' TO ilochtml.
6003 
6004 *   Add the row count
6005     IF NOT includerowcount IS INITIAL.
6006       IF bodybackcolour IS INITIAL.
6007         wahtml = '<td>'.
6008       ELSE.
6009         CONCATENATE '<td bgcolor="' bodybackcolour '">' INTO wahtml.
6010       ENDIF.
6011 
6012       IF NOT bodyfontname IS INITIAL OR NOT bodyfontcolour IS INITIAL OR NOT bodyfontsize IS INITIAL.
6013         CONCATENATE wahtml '<font' INTO wahtml.
6014 
6015 *        Add the font name
6016         IF NOT bodyfontname IS INITIAL.
6017           CONCATENATE wahtml ' face ="' INTO wahtml.
6018           CONCATENATE wahtml bodyfontname '"' INTO wahtml.
6019         ENDIF.
6020 
6021 *        Add the font colour
6022         IF NOT bodyfontcolour IS INITIAL.
6023           CONCATENATE wahtml ' color ="' INTO wahtml.
6024           CONCATENATE wahtml bodyfontcolour '"' INTO wahtml.
6025         ENDIF.
6026 
6027 *        Add the fontsize
6028         IF NOT bodyfontsize IS INITIAL.
6029           CONCATENATE wahtml ' size ="' INTO wahtml.
6030           CONCATENATE wahtml bodyfontsize '"' INTO wahtml.
6031         ENDIF.
6032 
6033         CONCATENATE wahtml '>' INTO wahtml.
6034         usedafontattribute = true.
6035       ENDIF.
6036 
6037 *     Add the row number into the table
6038       CONCATENATE wahtml loopcounter INTO wahtml.
6039 
6040 
6041       IF usedafontattribute = true.
6042         CONCATENATE wahtml '</font>' INTO wahtml.
6043         usedafontattribute = false.
6044       ENDIF.
6045 
6046       CONCATENATE wahtml '</td>' INTO wahtml.
6047       APPEND wahtml TO ilochtml.
6048     ENDIF.
6049 
6050     DO.
6051 *     Assign each field in the table to the field symbol
6052       ASSIGN COMPONENT sy-index OF STRUCTURE <ilocdictstructure> TO <fsfield>.
6053       IF sy-subrc = 0.
6054         MOVE <fsfield> TO wtextcell.
6055 
6056 *       Cell data processing
6057         IF bodybackcolour IS INITIAL.
6058           wahtml = '<td>'.
6059         ELSE.
6060           CONCATENATE '<td bgcolor="' bodybackcolour '">' INTO wahtml.
6061         ENDIF.
6062 
6063         IF NOT bodyfontname IS INITIAL OR NOT bodyfontcolour IS INITIAL OR NOT bodyfontsize IS INITIAL.
6064           CONCATENATE wahtml '<font' INTO wahtml.
6065 
6066 *          Add the font name
6067           IF NOT bodyfontname IS INITIAL.
6068             CONCATENATE wahtml ' face ="' INTO wahtml.
6069             CONCATENATE wahtml bodyfontname '"' INTO wahtml.
6070           ENDIF.
6071 
6072 *          Add the font colour
6073           IF NOT bodyfontcolour IS INITIAL.
6074             CONCATENATE wahtml ' color ="' INTO wahtml.
6075             CONCATENATE wahtml bodyfontcolour '"' INTO wahtml.
6076           ENDIF.
6077 
6078 *          Add the fontsize
6079           IF NOT bodyfontsize IS INITIAL.
6080             CONCATENATE wahtml ' size ="' INTO wahtml.
6081             CONCATENATE wahtml bodyfontsize '"' INTO wahtml.
6082           ENDIF.
6083 
6084           CONCATENATE wahtml '>' INTO wahtml.
6085           usedafontattribute = true.
6086         ENDIF.
6087 
6088 *       Add the caption name
6089         IF wtextcell IS INITIAL.
6090           CONCATENATE wahtml '&nbsp;' INTO wahtml.
6091         ELSE.
6092           CONCATENATE wahtml wtextcell INTO wahtml.
6093         ENDIF.
6094 
6095         IF usedafontattribute = true.
6096           CONCATENATE wahtml '</font>' INTO wahtml.
6097           usedafontattribute = false.
6098         ENDIF.
6099 
6100         CONCATENATE wahtml '</td>' INTO wahtml.
6101         APPEND wahtml TO ilochtml.
6102       ELSE.
6103         EXIT.
6104       ENDIF.
6105     ENDDO.
6106 
6107     APPEND '</tr>' TO ilochtml.
6108   ENDLOOP.
6109 
6110   APPEND '</table>' TO ilochtml.
6111 ENDFORM.                                                                                             "convertITABtoHtml
6112 
6113 *----------------------------------------------------------------------------------------------------------------------
6114 *  convertCodeToHtml... Builds an HTML table based upon a text table.
6115 *----------------------------------------------------------------------------------------------------------------------
6116 FORM convertcodetohtml USING icontents LIKE dumihtml[]
6117                              value(programname)
6118                              value(shortdescription)
6119                              value(sourcecodetype)
6120                              value(functiondocumentationexists)
6121                              value(ismainfunctioninclude)
6122                              value(syntaxhighlightcomments)
6123                              value(htmlextension)
6124                              value(customernamerange)
6125                              value(getincludes)
6126                              value(getdictstructures).
6127 
6128   DATA: htmltable TYPE STANDARD TABLE OF string WITH HEADER LINE.
6129   DATA: listingname TYPE string VALUE 'Code listing for:'.
6130   DATA: descriptionname TYPE string VALUE `Description: `.
6131   DATA: head(255).
6132   DATA: tail(255).
6133   DATA: mytabix TYPE sytabix.
6134   DATA: nextline TYPE sytabix.
6135   DATA: hyperlinkname TYPE string.
6136   DATA: copyofcurrentline TYPE string.
6137   DATA: currentlinelength TYPE i VALUE 0.
6138   DATA: copylinelength TYPE i VALUE 0.
6139   DATA: ignorefuturelines TYPE i VALUE false.
6140   DATA: foundasterix TYPE i VALUE false.
6141   DATA: lowercaselink TYPE string.
6142   DATA: wanextline TYPE string.
6143   DATA: wacontent(255).
6144 
6145 * Add a html header to the table
6146   PERFORM addhtmlheader USING htmltable[]
6147                               programname.
6148 
6149   CONCATENATE listingname programname INTO listingname SEPARATED BY space.
6150   CONCATENATE '<font size="3" face = "Arial" color="' colour_black '"><b>' listingname '</b></font>' INTO htmltable.
6151   APPEND htmltable.
6152 
6153   IF NOT shortdescription IS INITIAL.
6154     APPEND '<br>' TO htmltable.
6155     CONCATENATE descriptionname shortdescription INTO descriptionname SEPARATED BY space.
6156     CONCATENATE '<font size="3" face = "Arial" color="' colour_black '"><b>' descriptionname '</b></font>' INTO htmltable.
6157     APPEND htmltable.
6158   ENDIF.
6159 
6160   htmltable = '<hr>'.
6161   APPEND htmltable.
6162 
6163   htmltable = '<pre width="100">'.
6164   APPEND htmltable.
6165 
6166   LOOP AT icontents INTO wacontent.
6167     mytabix = sy-tabix.
6168 
6169     IF NOT ( icontents IS INITIAL ).
6170       WHILE ( wacontent CS '<' OR wacontent CS '>' ).
6171         REPLACE '<' IN wacontent WITH lt.
6172         REPLACE '>' IN wacontent WITH gt.
6173       ENDWHILE.
6174 
6175       IF wacontent+0(1) <> asterix.
6176         currentlinelength = STRLEN( wacontent ).
6177         copyofcurrentline = wacontent.
6178 
6179 *       Don't hyperlink anything for files of type documentation
6180         IF sourcecodetype <> is_documentation.
6181 *         Check for any functions to highlight
6182           IF ( wacontent CS callfunction ) AND ( wacontent <> 'DESTINATION' ).
6183             nextline = mytabix + 1.
6184             READ TABLE icontents INTO wanextline INDEX nextline.
6185             TRANSLATE wanextline TO UPPER CASE.
6186             IF wanextline NS 'DESTINATION'.
6187               SHIFT copyofcurrentline LEFT DELETING LEADING space.
6188 
6189               copylinelength = STRLEN( copyofcurrentline ).
6190 
6191               SPLIT copyofcurrentline AT space INTO head tail.
6192               SPLIT tail AT space INTO head tail.
6193               SPLIT tail AT space INTO head tail.
6194 *             Function name is now in head
6195               TRANSLATE head USING ''' '.
6196               SHIFT head LEFT DELETING LEADING space.
6197 
6198               TRY.
6199                   IF head+0(1) = 'Y' OR head+0(1) = 'Z' OR head+0(1) = 'y' OR head+0(1) = 'z' OR head CS customernamerange.
6200 *                 Definately a customer function module
6201                     hyperlinkname = head.
6202 
6203                     IF sourcecodetype = is_function.
6204                       copyofcurrentline = 'call function <a href ="../'.
6205                     ELSE.
6206                       copyofcurrentline = 'call function <a href ="'.
6207                     ENDIF.
6208 
6209                     lowercaselink = hyperlinkname.
6210                     TRANSLATE lowercaselink TO LOWER CASE.
6211 *                 If we are running on a non UNIX environment we will need to remove forward slashes
6212                     IF frontendopsystem = non_unix.
6213                       TRANSLATE lowercaselink USING '/_'.
6214                     ENDIF.
6215 
6216                     CONCATENATE copyofcurrentline
6217                                 lowercaselink     "hyperlinkName
6218                                 '/'
6219                                 lowercaselink     "hyperlinkName
6220                                 period htmlextension '">'
6221                                 ''''
6222                                 hyperlinkname
6223                                 ''''
6224                                 '</a>'
6225                                 tail INTO copyofcurrentline.
6226 
6227 *                 Pad the string back out with spaces
6228                     WHILE copylinelength < currentlinelength.
6229                       SHIFT copyofcurrentline RIGHT BY 1 PLACES.
6230                       copylinelength = copylinelength + 1.
6231                     ENDWHILE.
6232 
6233                     wacontent = copyofcurrentline.
6234                   ENDIF.
6235                 CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
6236               ENDTRY.
6237             ENDIF.
6238           ENDIF.
6239         ENDIF.
6240 
6241 *       Check for any customer includes to hyperlink
6242         IF wacontent CS include OR wacontent CS lowinclude.
6243           SHIFT copyofcurrentline LEFT DELETING LEADING space.
6244           copylinelength = STRLEN( copyofcurrentline ).
6245 
6246           SPLIT copyofcurrentline AT space INTO head tail.
6247           SHIFT tail LEFT DELETING LEADING space.
6248 
6249           TRY.
6250               IF ( tail+0(1) = 'Y' OR tail+0(1) = 'Z' OR tail+0(1) = 'y' OR tail+0(1) = 'z' OR tail CS customernamerange OR tail+0(2) = 'mz' OR tail+0(2) = 'MZ' )
6251                   AND NOT getincludes IS INITIAL AND  tail NS structure AND tail NS lowstructure.
6252 
6253 *             Hyperlink for program includes
6254                 CLEAR wacontent.
6255                 SHIFT tail LEFT DELETING LEADING space.
6256                 SPLIT tail AT period INTO hyperlinkname tail.
6257                 copyofcurrentline = 'include <a href ="'.
6258 
6259                 lowercaselink = hyperlinkname.
6260                 TRANSLATE lowercaselink TO LOWER CASE.
6261 
6262 *             If we are running on a non UNIX environment we will need to remove forward slashes
6263                 IF frontendopsystem = non_unix.
6264                   TRANSLATE lowercaselink USING '/_'.
6265                 ENDIF.
6266 
6267                 CONCATENATE copyofcurrentline
6268                             lowercaselink       "hyperlinkName
6269                             period htmlextension '">'
6270                             hyperlinkname
6271                             '</a>'
6272                             period tail INTO copyofcurrentline.
6273 
6274 *             Pad the string back out with spaces
6275                 WHILE copylinelength < currentlinelength.
6276                   SHIFT copyofcurrentline RIGHT BY 1 PLACES.
6277                   copylinelength = copylinelength + 1.
6278                 ENDWHILE.
6279                 wacontent = copyofcurrentline.
6280               ELSE.
6281                 IF NOT getdictstructures IS INITIAL.
6282 *              Hyperlink for structure include e.g. "include structure zfred."
6283                   copylinelength = STRLEN( copyofcurrentline ).
6284                   SPLIT copyofcurrentline AT space INTO head tail.
6285                   SHIFT tail LEFT DELETING LEADING space.
6286                   SPLIT tail AT space INTO head tail.
6287 
6288                   TRY.
6289                       IF tail+0(1) = 'Y' OR tail+0(1) = 'Z' OR tail+0(1) = 'y' OR tail+0(1) = 'z' OR tail CS customernamerange.
6290                         CLEAR wacontent.
6291                         SHIFT tail LEFT DELETING LEADING space.
6292                         SPLIT tail AT period INTO hyperlinkname tail.
6293                         copyofcurrentline = 'include structure <a href ='.
6294 
6295                         lowercaselink = hyperlinkname.
6296                         TRANSLATE lowercaselink TO LOWER CASE.
6297 *                  If we are running on a non UNIX environment we will need to remove forward slashes
6298                         IF frontendopsystem = non_unix.
6299                           TRANSLATE lowercaselink USING '/_'.
6300                         ENDIF.
6301 
6302                         CONCATENATE copyofcurrentline
6303                                     '"'
6304                                     lowercaselink    "hyperlinkName
6305                                     '/'
6306                                     'dictionary-'
6307                                     lowercaselink    "hyperlinkName
6308                                     period htmlextension
6309                                     '">'
6310                                     hyperlinkname
6311                                     '</a>'
6312                                     period tail INTO copyofcurrentline.
6313 
6314 *                  Pad the string back out with spaces
6315                         WHILE copylinelength < currentlinelength.
6316                           SHIFT copyofcurrentline RIGHT BY 1 PLACES.
6317                           copylinelength = copylinelength + 1.
6318                         ENDWHILE.
6319                         wacontent = copyofcurrentline.
6320                       ENDIF.
6321                     CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
6322                   ENDTRY.
6323                 ENDIF.
6324               ENDIF.
6325             CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
6326           ENDTRY.
6327         ENDIF.
6328       ELSE.
6329         IF NOT syntaxhighlightcomments IS INITIAL AND wacontent+0(1) = asterix.
6330           CONCATENATE '<font color ="' comment_colour '">' INTO head.
6331           CONCATENATE head wacontent '</font>' INTO tail.
6332           wacontent = tail.
6333         ENDIF.
6334       ENDIF.
6335 
6336       htmltable = wacontent.
6337 
6338     ELSE.
6339       htmltable = ''.
6340     ENDIF.
6341     APPEND htmltable.
6342   ENDLOOP.
6343 
6344   htmltable = '</pre>'.
6345   APPEND htmltable.
6346 
6347 * Add a html footer to the table
6348   PERFORM addhtmlfooter USING htmltable[].
6349 
6350   icontents[] = htmltable[].
6351 ENDFORM.                                                                                             "convertCodeToHtml
6352 
6353 *----------------------------------------------------------------------------------------------------------------------
6354 *  convertClassToHtml... Builds an HTML table based upon a text table.
6355 *----------------------------------------------------------------------------------------------------------------------
6356 FORM convertclasstohtml USING icontents LIKE dumihtml[]
6357                               value(classname)
6358                               value(shortdescription)
6359                               value(sourcecodetype)
6360                               value(syntaxhighlightcomments)
6361                               value(htmlextension)
6362                               value(customernamerange)
6363                               value(getdictstructures).
6364 
6365   DATA: htmltable TYPE STANDARD TABLE OF string WITH HEADER LINE.
6366   DATA: listingname TYPE string VALUE 'Code listing for class:'.
6367   DATA: descriptionname TYPE string VALUE `Description: `.
6368   DATA: mytabix TYPE sytabix.
6369   DATA: wacontent(255).
6370   DATA: head TYPE string.
6371   DATA: tail TYPE string.
6372   DATA: hyperlinkname TYPE string.
6373   DATA: lowercaselink TYPE string.
6374   DATA: copyofcurrentline TYPE string.
6375   DATA: currentlinelength TYPE i VALUE 0.
6376   DATA: copylinelength TYPE i VALUE 0.
6377 
6378 * Add a html header to the table
6379   PERFORM addhtmlheader USING htmltable[]
6380                               classname.
6381 
6382   CONCATENATE listingname classname INTO listingname SEPARATED BY space.
6383   CONCATENATE '<font size="3" face = "Arial" color="' colour_black '"><b>' listingname '</b></font>' INTO htmltable.
6384   APPEND htmltable.
6385 
6386   IF NOT shortdescription IS INITIAL.
6387     APPEND '<br>' TO htmltable.
6388     CONCATENATE descriptionname shortdescription INTO descriptionname SEPARATED BY space.
6389     CONCATENATE '<font size="3" face = "Arial" color="' colour_black '"><b>' descriptionname '</b></font>' INTO htmltable.
6390     APPEND htmltable.
6391   ENDIF.
6392 
6393   htmltable = '<hr>'.
6394   APPEND htmltable.
6395 
6396   htmltable = '<pre width="100">'.
6397   APPEND htmltable.
6398 
6399   LOOP AT icontents INTO wacontent.
6400     mytabix = sy-tabix.
6401 
6402 *   Comments
6403     IF NOT syntaxhighlightcomments IS INITIAL AND wacontent+0(1) = asterix.
6404       CONCATENATE '<font color ="' comment_colour '">' INTO head.
6405       CONCATENATE head wacontent '</font>' INTO wacontent.
6406       htmltable = wacontent.
6407     ELSE.
6408 *     Smaller than, greater than signs
6409       IF NOT ( icontents IS INITIAL ).
6410         WHILE ( wacontent CS '<' OR wacontent CS '>' ).
6411           REPLACE '<' IN wacontent WITH lt.
6412           REPLACE '>' IN wacontent WITH gt.
6413         ENDWHILE.
6414 
6415 *       Dictionary structures
6416         IF NOT getdictstructures IS INITIAL.
6417           FIND 'class' IN wacontent IGNORING CASE.
6418           IF sy-subrc <> 0.
6419 *           Hyperlink for dictionary/structure include
6420             copylinelength = STRLEN( wacontent ).
6421             copyofcurrentline = wacontent.
6422             SPLIT copyofcurrentline AT space INTO head tail.
6423             SHIFT tail LEFT DELETING LEADING space.
6424             SPLIT tail AT space INTO head tail.
6425 
6426             TRY.
6427                 IF tail+0(1) = 'Y' OR tail+0(1) = 'Z' OR tail+0(1) = 'y' OR tail+0(1) = 'z' OR tail CS customernamerange.
6428                   CLEAR wacontent.
6429                   SHIFT tail LEFT DELETING LEADING space.
6430                   SPLIT tail AT period INTO hyperlinkname tail.
6431                   copyofcurrentline = 'include structure <a href ='.
6432 
6433                   lowercaselink = hyperlinkname.
6434                   TRANSLATE lowercaselink TO LOWER CASE.
6435 *               If we are running on a non UNIX environment we will need to remove forward slashes
6436                   IF frontendopsystem = non_unix.
6437                     TRANSLATE lowercaselink USING '/_'.
6438                   ENDIF.
6439 
6440                   CONCATENATE copyofcurrentline
6441                               '"'
6442                               lowercaselink    "hyperlinkName
6443                               '/'
6444                               'dictionary-'
6445                               lowercaselink    "hyperlinkName
6446                               period htmlextension
6447                               '">'
6448                               hyperlinkname
6449                               '</a>'
6450                               period tail INTO copyofcurrentline.
6451 
6452 *               Pad the string back out with spaces
6453                   WHILE copylinelength < currentlinelength.
6454                     SHIFT copyofcurrentline RIGHT BY 1 PLACES.
6455                     copylinelength = copylinelength + 1.
6456                   ENDWHILE.
6457                   wacontent = copyofcurrentline.
6458                 ENDIF.
6459               CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
6460             ENDTRY.
6461           ENDIF.
6462         ENDIF.
6463 
6464         htmltable = wacontent.
6465       ELSE.
6466         htmltable = ''.
6467       ENDIF.
6468     ENDIF.
6469 
6470     APPEND htmltable.
6471   ENDLOOP.
6472 
6473   htmltable = '</pre>'.
6474   APPEND htmltable.
6475 
6476 * Add a html footer to the table
6477   PERFORM addhtmlfooter USING htmltable[].
6478 
6479   icontents[] = htmltable[].
6480 ENDFORM.                                                                                            "convertClassToHtml
6481 
6482 *----------------------------------------------------------------------------------------------------------------------
6483 *  convertFunctionToHtml... Builds an HTML table based upon a text table.
6484 *----------------------------------------------------------------------------------------------------------------------
6485 FORM convertfunctiontohtml USING icontents LIKE dumihtml[]
6486                                  value(functionname)
6487                                  value(shortdescription)
6488                                  value(sourcecodetype)
6489                                  value(functiondocumentationexists)
6490                                  value(ismainfunctioninclude)
6491                                  value(syntaxhighlightcomments)
6492                                  value(htmlextension)
6493                                  value(customernamerange)
6494                                  value(getincludes)
6495                                  value(getdictstructures).
6496 
6497   DATA: htmltable TYPE STANDARD TABLE OF string WITH HEADER LINE.
6498   DATA: listingname TYPE string VALUE 'Code listing for function:'.
6499   DATA: descriptionname TYPE string VALUE `Description: `.
6500   DATA: head(255).
6501   DATA: tail(255).
6502   DATA: mytabix TYPE sytabix.
6503   DATA: nextline TYPE sytabix.
6504   DATA: hyperlinkname TYPE string.
6505   DATA: copyofcurrentline TYPE string.
6506   DATA: currentlinelength TYPE i VALUE 0.
6507   DATA: copylinelength TYPE i VALUE 0.
6508   DATA: ignorefuturelines TYPE i VALUE false.
6509   DATA: foundasterix TYPE i VALUE false.
6510   DATA: lowercaselink TYPE string.
6511   DATA: wanextline TYPE string.
6512   DATA: wacontent(255).
6513 
6514 * Add a html header to the table
6515   PERFORM addhtmlheader USING htmltable[]
6516                               functionname.
6517 
6518   CONCATENATE listingname functionname INTO listingname SEPARATED BY space.
6519   CONCATENATE '<font size="3" face = "Arial" color="' colour_black '"><b>' listingname '</b></font>' INTO htmltable.
6520   APPEND htmltable.
6521 
6522   IF NOT shortdescription IS INITIAL.
6523     APPEND '<br>' TO htmltable.
6524     CONCATENATE descriptionname shortdescription INTO descriptionname SEPARATED BY space.
6525     CONCATENATE '<font size="3" face = "Arial" color="' colour_black '"><b>' descriptionname '</b></font>' INTO htmltable.
6526     APPEND htmltable.
6527   ENDIF.
6528 
6529   htmltable = '<hr>'.
6530   APPEND htmltable.
6531 
6532   htmltable = '<pre width="100">'.
6533   APPEND htmltable.
6534 
6535   LOOP AT icontents INTO wacontent.
6536     mytabix = sy-tabix.
6537 
6538 *   Extra code for adding global and doc hyperlinks to functions
6539     IF sourcecodetype = is_function AND ismainfunctioninclude = true.
6540       IF sy-tabix > 1.
6541         IF wacontent+0(1) = asterix AND ignorefuturelines = false.
6542           foundasterix = true.
6543         ELSE.
6544           IF foundasterix = true.
6545 *           Lets add our extra HTML lines in here
6546             APPEND '' TO htmltable.
6547 
6548 *           Global data hyperlink
6549             IF NOT syntaxhighlightcomments IS INITIAL.
6550               CONCATENATE '<font color ="' comment_colour '">' INTO copyofcurrentline.
6551             ENDIF.
6552 
6553             CONCATENATE copyofcurrentline '*       <a href ="' INTO copyofcurrentline.
6554             lowercaselink = functionname.
6555             TRANSLATE lowercaselink TO LOWER CASE.
6556 *           If we are running on a non UNIX environment we will need to remove forward slashes
6557             IF frontendopsystem = non_unix.
6558               TRANSLATE lowercaselink USING '/_'.
6559             ENDIF.
6560 
6561             CONCATENATE copyofcurrentline 'global-' lowercaselink  "functionName
6562                         period htmlextension '">' 'Global data declarations' '</a>' INTO copyofcurrentline.
6563 
6564             IF NOT syntaxhighlightcomments IS INITIAL.
6565               CONCATENATE copyofcurrentline '</font>' INTO copyofcurrentline.
6566             ENDIF.
6567 
6568             APPEND copyofcurrentline TO htmltable.
6569 
6570 *           Documentation hyperlink.
6571             IF functiondocumentationexists = true.
6572               IF NOT syntaxhighlightcomments IS INITIAL.
6573                 CONCATENATE '<font color ="' comment_colour '">' INTO copyofcurrentline.
6574               ENDIF.
6575 
6576               CONCATENATE copyofcurrentline '*       <a href ="' INTO copyofcurrentline.
6577 
6578               lowercaselink = functionname.
6579               TRANSLATE lowercaselink TO LOWER CASE.
6580 *             If we are running on a non UNIX environment we will need to remove forward slashes
6581               IF frontendopsystem = non_unix.
6582                 TRANSLATE lowercaselink USING '/_'.
6583               ENDIF.
6584 
6585               CONCATENATE copyofcurrentline
6586                           'docs-'
6587                           lowercaselink  "functionName
6588                           period htmlextension '">'
6589                           'Function module documentation'
6590                           '</a>'
6591                           INTO copyofcurrentline.
6592 
6593               IF NOT pcomm IS INITIAL.
6594                 CONCATENATE copyofcurrentline '</font>' INTO copyofcurrentline.
6595               ENDIF.
6596               APPEND copyofcurrentline TO htmltable.
6597             ENDIF.
6598 
6599             foundasterix = false.
6600             ignorefuturelines = true.
6601           ENDIF.
6602         ENDIF.
6603       ENDIF.
6604     ENDIF.
6605 
6606 *   Carry on as normal
6607     IF NOT ( icontents IS INITIAL ).
6608       WHILE ( wacontent CS '<' OR wacontent CS '>' ).
6609         REPLACE '<' IN wacontent WITH lt.
6610         REPLACE '>' IN wacontent WITH gt.
6611       ENDWHILE.
6612 
6613       IF wacontent+0(1) <> asterix.
6614         currentlinelength = STRLEN( wacontent ).
6615 
6616 *       Don't hyperlink anything for files of type documentation
6617         IF sourcecodetype <> is_documentation.
6618 *       Check for any functions to highlight
6619           IF ( wacontent CS callfunction ) AND ( wacontent <> 'DESTINATION' ).
6620             nextline = mytabix + 1.
6621             READ TABLE icontents INTO wanextline INDEX nextline.
6622             TRANSLATE wanextline TO UPPER CASE.
6623             IF wanextline NS 'DESTINATION'.
6624               copyofcurrentline = wacontent.
6625               SHIFT copyofcurrentline LEFT DELETING LEADING space.
6626 
6627               copylinelength = STRLEN( copyofcurrentline ).
6628 
6629               SPLIT copyofcurrentline AT space INTO head tail.
6630               SPLIT tail AT space INTO head tail.
6631               SPLIT tail AT space INTO head tail.
6632 *             Function name is now in head
6633               TRANSLATE head USING ''' '.
6634               SHIFT head LEFT DELETING LEADING space.
6635 
6636               TRY.
6637                   IF head+0(1) = 'Y' OR head+0(1) = 'Z' OR head+0(1) = 'y' OR head+0(1) = 'z' OR head CS customernamerange.
6638 
6639 *                 Definately a customer function module
6640                     hyperlinkname = head.
6641 
6642                     IF sourcecodetype = is_function.
6643                       copyofcurrentline = 'call function <a href ="../'.
6644                     ELSE.
6645                       copyofcurrentline = 'call function <a href ="'.
6646                     ENDIF.
6647 
6648                     lowercaselink = hyperlinkname.
6649                     TRANSLATE lowercaselink TO LOWER CASE.
6650 *                 If we are running on a non UNIX environment we will need to remove forward slashes
6651                     IF frontendopsystem = non_unix.
6652                       TRANSLATE lowercaselink USING '/_'.
6653                     ENDIF.
6654 
6655                     CONCATENATE copyofcurrentline
6656                                 lowercaselink     "hyperlinkName
6657                                 '/'
6658                                 lowercaselink     "hyperlinkName
6659                                 period htmlextension '">'
6660                                 ''''
6661                                 hyperlinkname
6662                                 ''''
6663                                 '</a>'
6664                                 tail INTO copyofcurrentline.
6665 
6666 *                 Pad the string back out with spaces
6667                     WHILE copylinelength < currentlinelength.
6668                       SHIFT copyofcurrentline RIGHT BY 1 PLACES.
6669                       copylinelength = copylinelength + 1.
6670                     ENDWHILE.
6671 
6672                     wacontent = copyofcurrentline.
6673                   ENDIF.
6674                 CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
6675               ENDTRY.
6676             ENDIF.
6677           ENDIF.
6678         ENDIF.
6679 
6680 *       Check for any customer includes to hyperlink
6681         IF wacontent CS include OR wacontent CS lowinclude.
6682           copyofcurrentline = wacontent.
6683 
6684           SHIFT copyofcurrentline LEFT DELETING LEADING space.
6685           copylinelength = STRLEN( copyofcurrentline ).
6686 
6687           SPLIT copyofcurrentline AT space INTO head tail.
6688           SHIFT tail LEFT DELETING LEADING space.
6689 
6690           TRY.
6691               IF ( tail+0(1) = 'Y' OR tail+0(1) = 'Z' OR tail+0(1) = 'y' OR tail+0(1) = 'z'
6692                    OR tail CS customernamerange OR tail+0(2) = 'mz' OR tail+0(2) = 'MZ' ) AND NOT getincludes IS INITIAL.
6693 
6694 *             Hyperlink for program includes
6695                 CLEAR wacontent.
6696                 SHIFT tail LEFT DELETING LEADING space.
6697                 SPLIT tail AT period INTO hyperlinkname tail.
6698                 copyofcurrentline = 'include <a href ="'.
6699 
6700                 lowercaselink = hyperlinkname.
6701                 TRANSLATE lowercaselink TO LOWER CASE.
6702 *             If we are running on a non UNIX environment we will need to remove forward slashes
6703                 IF frontendopsystem = non_unix.
6704                   TRANSLATE lowercaselink USING '/_'.
6705                 ENDIF.
6706 
6707                 CONCATENATE copyofcurrentline
6708                             lowercaselink       "hyperlinkName
6709                             period htmlextension '">'
6710                             hyperlinkname
6711                             '</a>'
6712                             period tail INTO copyofcurrentline.
6713 
6714 *             Pad the string back out with spaces
6715                 WHILE copylinelength < currentlinelength.
6716                   SHIFT copyofcurrentline RIGHT BY 1 PLACES.
6717                   copylinelength = copylinelength + 1.
6718                 ENDWHILE.
6719                 wacontent = copyofcurrentline.
6720               ELSE.
6721                 IF NOT getdictstructures IS INITIAL.
6722 *               Hyperlink for structure include
6723                   copylinelength = STRLEN( copyofcurrentline ).
6724                   SPLIT copyofcurrentline AT space INTO head tail.
6725                   SHIFT tail LEFT DELETING LEADING space.
6726                   SPLIT tail AT space INTO head tail.
6727 
6728                   TRY.
6729                       IF tail+0(1) = 'Y' OR tail+0(1) = 'Z' OR tail+0(1) = 'y' OR tail+0(1) = 'z' OR tail CS customernamerange.
6730                         CLEAR wacontent.
6731                         SHIFT tail LEFT DELETING LEADING space.
6732                         SPLIT tail AT period INTO hyperlinkname tail.
6733                         copyofcurrentline = 'include structure <a href ='.
6734 
6735                         lowercaselink = hyperlinkname.
6736                         TRANSLATE lowercaselink TO LOWER CASE.
6737 *                   If we are running on a non UNIX environment we will need to remove forward slashes
6738                         IF frontendopsystem = non_unix.
6739                           TRANSLATE lowercaselink USING '/_'.
6740                         ENDIF.
6741 
6742                         CONCATENATE copyofcurrentline
6743                                     '"'
6744                                     lowercaselink    "hyperlinkName
6745                                     '/'
6746                                     'dictionary-'
6747                                     lowercaselink    "hyperlinkName
6748                                     period htmlextension
6749                                     '">'
6750                                     hyperlinkname
6751                                     '</a>'
6752                                     period tail INTO copyofcurrentline.
6753 
6754 *                   Pad the string back out with spaces
6755                         WHILE copylinelength < currentlinelength.
6756                           SHIFT copyofcurrentline RIGHT BY 1 PLACES.
6757                           copylinelength = copylinelength + 1.
6758                         ENDWHILE.
6759                         wacontent = copyofcurrentline.
6760                       ENDIF.
6761                     CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
6762                   ENDTRY.
6763                 ENDIF.
6764               ENDIF.
6765             CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
6766           ENDTRY.
6767         ENDIF.
6768       ELSE.
6769         IF NOT syntaxhighlightcomments IS INITIAL AND wacontent+0(1) = asterix.
6770           CONCATENATE '<font color ="' comment_colour '">' INTO head.
6771           CONCATENATE head wacontent '</font>' INTO tail.
6772           wacontent = tail.
6773         ENDIF.
6774       ENDIF.
6775 
6776       htmltable = wacontent.
6777 
6778     ELSE.
6779       htmltable = ''.
6780     ENDIF.
6781     APPEND htmltable.
6782   ENDLOOP.
6783 
6784   htmltable = '</pre>'.
6785   APPEND htmltable.
6786 
6787 * Add a html footer to the table
6788   PERFORM addhtmlfooter USING htmltable[].
6789 
6790   icontents[] = htmltable[].
6791 ENDFORM.                                                                                         "convertFunctionToHtml
6792 
6793 *----------------------------------------------------------------------------------------------------------------------
6794 *  buildColumnHeaders... build table column names
6795 *----------------------------------------------------------------------------------------------------------------------
6796 FORM buildcolumnheaders USING iloccolumncaptions LIKE dumihtml[].
6797 
6798   APPEND 'Row' TO iloccolumncaptions.
6799   APPEND 'Field name' TO iloccolumncaptions.
6800   APPEND 'Position' TO iloccolumncaptions.
6801   APPEND 'Key' TO iloccolumncaptions.
6802   APPEND 'Data element' TO iloccolumncaptions.
6803   APPEND 'Domain' TO iloccolumncaptions.
6804   APPEND 'Datatype' TO iloccolumncaptions.
6805   APPEND 'Length' TO iloccolumncaptions.
6806   APPEND 'Domain text' TO iloccolumncaptions.
6807 ENDFORM.                                                                                            "buildColumnHeaders
6808 
6809 *----------------------------------------------------------------------------------------------------------------------
6810 * addHTMLHeader...  add a html formatted header to our output table
6811 *----------------------------------------------------------------------------------------------------------------------
6812 FORM addhtmlheader USING ilocheader LIKE dumihtml[]
6813                          value(title).
6814 
6815   DATA: waheader TYPE string.
6816 
6817   APPEND '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">' TO ilocheader.
6818   APPEND '<html>' TO ilocheader.
6819   APPEND '<head>' TO ilocheader.
6820 
6821   CONCATENATE '<title>' title '</title>' INTO waheader.
6822   APPEND waheader TO ilocheader.
6823 
6824   APPEND '</head>' TO ilocheader.
6825 
6826   IF NOT pback IS INITIAL.
6827     CONCATENATE '<body bgcolor="' background_colour '">' INTO waheader.
6828   ELSE.
6829     CONCATENATE '<body bgcolor="' colour_white '">' INTO waheader.
6830   ENDIF.
6831 
6832   APPEND waheader TO ilocheader.
6833 ENDFORM.                                                                                                 "addHTMLHeader
6834 
6835 *----------------------------------------------------------------------------------------------------------------------
6836 * addHTMLFooter...  add a html formatted footer to our output table
6837 *----------------------------------------------------------------------------------------------------------------------
6838 FORM addhtmlfooter USING ilocfooter LIKE dumihtml[].
6839 
6840   DATA: footermessage TYPE string.
6841   DATA: wafooter TYPE string.
6842 
6843   PERFORM buildfootermessage USING 'HTML'
6844                                    footermessage.
6845 
6846   APPEND '<hr>' TO ilocfooter.
6847   CONCATENATE '<font size="2" face = "Sans Serif">' footermessage INTO wafooter.
6848   APPEND wafooter TO ilocfooter.
6849   APPEND '</font>' TO ilocfooter.
6850   APPEND '</body>' TO ilocfooter.
6851   APPEND '</html>' TO ilocfooter.
6852 ENDFORM.                                                                                                 "addHTMLFooter
6853 
6854 *----------------------------------------------------------------------------------------------------------------------
6855 * buildFooterMessage...Returns a footer message based on the output file type.
6856 *----------------------------------------------------------------------------------------------------------------------
6857 FORM buildfootermessage USING filetype
6858                               returnmessage.
6859 
6860   IF filetype = 'HTML'.
6861     CONCATENATE `Extracted by Direct Download Enterprise version `
6862                  versionno ` - E.G.Mellodew. 1998-2005 UK. Sap Release ` sy-saprl
6863                 INTO returnmessage.
6864   ELSE.
6865     CONCATENATE `Extracted by Direct Download Enterprise version `
6866                  versionno ` - E.G.Mellodew. 1998-2005 UK. Sap Release ` sy-saprl
6867                 INTO returnmessage.
6868   ENDIF.
6869 ENDFORM.                                                                                            "buildFooterMessage
6870 
6871 ***********************************************************************************************************************
6872 ********************************************DISPLAY ROUTINES***********************************************************
6873 ***********************************************************************************************************************
6874 
6875 *----------------------------------------------------------------------------------------------------------------------
6876 *  fillTreeNodeTables...
6877 *----------------------------------------------------------------------------------------------------------------------
6878 FORM filltreenodetables USING ilocdictionary LIKE idictionary[]
6879                               iloctreedisplay LIKE itreedisplay[]
6880                               value(runtime).
6881 
6882   DATA: tablelines TYPE i.
6883   DATA: watreedisplay LIKE snodetext.
6884   FIELD-SYMBOLS: <wadictionary> TYPE tdicttable.
6885   DATA: tablelinesstring TYPE string.
6886   DATA: runtimechar(10).
6887   DATA: sublevel TYPE string.
6888 
6889   tablelines = LINES( ilocdictionary ).
6890   tablelinesstring = tablelines.
6891 
6892   IF tablelines = 1.
6893     CONCATENATE tablelinesstring 'table downloaded' INTO watreedisplay-text2 SEPARATED BY space.
6894   ELSE.
6895     CONCATENATE tablelinesstring 'tables downloaded' INTO watreedisplay-text2 SEPARATED BY space.
6896   ENDIF.
6897 
6898   WRITE runtime TO runtimechar.
6899   CONCATENATE watreedisplay-text2 '- runtime' runtimechar INTO watreedisplay-text2 SEPARATED BY space.
6900 
6901 * include header display record.
6902   watreedisplay-tlevel = '1'.
6903   watreedisplay-tlength2  = 60.
6904   watreedisplay-tcolor2    = 1.
6905   APPEND watreedisplay TO iloctreedisplay.
6906 
6907   LOOP AT ilocdictionary ASSIGNING <wadictionary>.
6908     watreedisplay-tlevel = '2'.
6909     watreedisplay-text2 = <wadictionary>-tablename.
6910     watreedisplay-tcolor2    = 3.
6911     watreedisplay-tlength3   = 80.
6912     watreedisplay-tcolor3    = 3.
6913     watreedisplay-tpos3      = 60.
6914     CONCATENATE 'Dictionary:' <wadictionary>-tabletitle INTO watreedisplay-text3 SEPARATED BY space.
6915 
6916     APPEND watreedisplay TO iloctreedisplay.
6917   ENDLOOP.
6918 ENDFORM.                                                                                            "fillTreeNodeTables
6919 
6920 *----------------------------------------------------------------------------------------------------------------------
6921 *  fillTreeNodeMessages...
6922 *----------------------------------------------------------------------------------------------------------------------
6923 FORM filltreenodemessages USING ilocmessages LIKE imessages[]
6924                                 iloctreedisplay LIKE itreedisplay[]
6925                                 value(runtime).
6926 
6927   DATA: tablelines TYPE i.
6928   DATA: watreedisplay LIKE snodetext.
6929   FIELD-SYMBOLS: <wamessage> TYPE tmessage.
6930   DATA: tablelinesstring TYPE string.
6931   DATA: runtimechar(10).
6932 
6933   SORT ilocmessages ASCENDING BY arbgb.
6934 
6935   LOOP AT ilocmessages ASSIGNING <wamessage>.
6936     AT NEW arbgb.
6937       tablelines = tablelines + 1.
6938     ENDAT.
6939   ENDLOOP.
6940   tablelinesstring = tablelines.
6941 
6942   IF tablelines = 1.
6943     CONCATENATE tablelinesstring 'message class downloaded' INTO watreedisplay-text2 SEPARATED BY space.
6944   ELSE.
6945     CONCATENATE tablelinesstring 'message classes downloaded' INTO watreedisplay-text2 SEPARATED BY space.
6946   ENDIF.
6947 
6948   WRITE runtime TO runtimechar.
6949   CONCATENATE watreedisplay-text2 '- runtime' runtimechar INTO watreedisplay-text2 SEPARATED BY space.
6950 
6951 * include header display record.
6952   watreedisplay-tlevel = '1'.
6953   watreedisplay-tlength2 = 60.
6954   watreedisplay-tcolor2 = 1.
6955   APPEND watreedisplay TO iloctreedisplay.
6956 
6957   LOOP AT ilocmessages ASSIGNING <wamessage>.
6958     AT NEW arbgb.
6959       watreedisplay-tlevel = '2'.
6960       watreedisplay-text2 = <wamessage>-arbgb.
6961       watreedisplay-tcolor2    = 5.
6962       watreedisplay-tlength3   = 80.
6963       watreedisplay-tcolor3    = 5.
6964       watreedisplay-tpos3      = 60.
6965       watreedisplay-text3 = <wamessage>-stext.
6966       CONCATENATE 'Message class:'  watreedisplay-text3 INTO watreedisplay-text3 SEPARATED BY space.
6967       APPEND watreedisplay TO iloctreedisplay.
6968     ENDAT.
6969   ENDLOOP.
6970 ENDFORM.                                                                                          "fillTreeNodeMessages
6971 
6972 *----------------------------------------------------------------------------------------------------------------------
6973 *  fillTreeNodeFunctions...
6974 *----------------------------------------------------------------------------------------------------------------------
6975 FORM filltreenodefunctions USING ilocfunctions LIKE ifunctions[]
6976                                  iloctreedisplay LIKE itreedisplay[]
6977                                  value(runtime).
6978 
6979   DATA: tablelines TYPE i.
6980   DATA: watreedisplay LIKE snodetext.
6981   FIELD-SYMBOLS: <wafunction> TYPE tfunction.
6982   FIELD-SYMBOLS: <wascreen> TYPE tscreenflow.
6983   FIELD-SYMBOLS: <waguititle> TYPE tguititle.
6984   FIELD-SYMBOLS: <wadictionary> TYPE tdicttable.
6985   FIELD-SYMBOLS: <wainclude> TYPE tinclude.
6986   FIELD-SYMBOLS: <wamessage> TYPE tmessage.
6987   DATA: tablelinesstring TYPE string.
6988   DATA: runtimechar(10).
6989 
6990   SORT ilocfunctions ASCENDING BY functionname.
6991 
6992   tablelines = LINES( ilocfunctions ).
6993   tablelinesstring = tablelines.
6994 
6995   IF tablelines = 1.
6996     CONCATENATE tablelinesstring ` function downloaded` INTO watreedisplay-text2.
6997   ELSE.
6998     CONCATENATE tablelinesstring ` functions downloaded` INTO watreedisplay-text2.
6999   ENDIF.
7000 
7001   WRITE runtime TO runtimechar.
7002 
7003   CONCATENATE watreedisplay-text2 ` - runtime ` runtimechar INTO watreedisplay-text2.
7004 * include header display record.
7005   watreedisplay-tlevel = '1'.
7006   watreedisplay-tlength2  = 60.
7007   watreedisplay-tcolor2    = 1.
7008   APPEND watreedisplay TO iloctreedisplay.
7009 
7010 * Lets fill the detail in
7011   LOOP AT ilocfunctions ASSIGNING <wafunction>.
7012     watreedisplay-tlevel = 2.
7013     watreedisplay-text2 = <wafunction>-functionname.
7014     watreedisplay-tcolor2    = 7.
7015     watreedisplay-tlength3   = 80.
7016     watreedisplay-tcolor3    = 7.
7017     watreedisplay-tpos3      = 60.
7018     CONCATENATE `Function: ` <wafunction>-functionname INTO watreedisplay-text3.
7019     APPEND watreedisplay TO iloctreedisplay.
7020 
7021 *   Screens.
7022     LOOP AT <wafunction>-iscreenflow ASSIGNING <wascreen>.
7023       watreedisplay-tlevel = '2'.
7024       watreedisplay-text2 = <wascreen>-screen.
7025       watreedisplay-tcolor2    = 6.
7026       watreedisplay-tlength3   = 80.
7027       watreedisplay-tcolor3    = 6.
7028       watreedisplay-tpos3      = 60.
7029       watreedisplay-text3 = 'Screen'.
7030       APPEND watreedisplay TO itreedisplay.
7031     ENDLOOP.
7032 
7033 *   GUI Title.
7034     LOOP AT <wafunction>-iguititle ASSIGNING <waguititle>.
7035       watreedisplay-tlevel = '2'.
7036       watreedisplay-text2 = <waguititle>-obj_code.
7037       watreedisplay-tcolor2    = 6.
7038       watreedisplay-tlength3   = 80.
7039       watreedisplay-tcolor3    = 6.
7040       watreedisplay-tpos3      = 60.
7041       watreedisplay-text3 = 'GUI Title'.
7042       APPEND watreedisplay TO itreedisplay.
7043     ENDLOOP.
7044 
7045 *   Fill in the tree with include information
7046     LOOP AT <wafunction>-iincludes ASSIGNING <wainclude>.
7047       watreedisplay-tlevel = 3.
7048       watreedisplay-text2 =  <wainclude>-includename.
7049       watreedisplay-tcolor2    = 4.
7050       watreedisplay-tlength3   = 80.
7051       watreedisplay-tcolor3    = 4.
7052       watreedisplay-tpos3      = 60.
7053       CONCATENATE `Include:   ` <wainclude>-includetitle INTO watreedisplay-text3.
7054       APPEND watreedisplay TO iloctreedisplay.
7055     ENDLOOP.
7056 
7057 *   fill in the tree with dictionary information
7058     LOOP AT <wafunction>-idictstruct ASSIGNING <wadictionary>.
7059       watreedisplay-tlevel = 3.
7060       watreedisplay-text2 =  <wadictionary>-tablename.
7061       watreedisplay-tcolor2    = 3.
7062       watreedisplay-tlength3   = 80.
7063       watreedisplay-tcolor3    = 3.
7064       watreedisplay-tpos3      = 60.
7065       CONCATENATE `Dictionary:` <wadictionary>-tabletitle INTO watreedisplay-text3.
7066       APPEND watreedisplay TO iloctreedisplay.
7067     ENDLOOP.
7068 
7069 *   fill in the tree with message information
7070     SORT <wafunction>-imessages[] ASCENDING BY arbgb.
7071     LOOP AT <wafunction>-imessages ASSIGNING <wamessage>.
7072       AT NEW arbgb.
7073         watreedisplay-tlevel = 3.
7074         watreedisplay-text2 = <wamessage>-arbgb.
7075         watreedisplay-tcolor2    = 5.
7076         watreedisplay-tlength3   = 80.
7077         watreedisplay-tcolor3    = 5.
7078         watreedisplay-tpos3      = 60.
7079 
7080 *       Select the message class text if we do not have it already
7081         IF <wamessage>-stext IS INITIAL.
7082           SELECT SINGLE stext FROM t100a
7083                               INTO <wamessage>-stext
7084                               WHERE arbgb = <wamessage>-arbgb.
7085         ENDIF.
7086 
7087         watreedisplay-text3 = <wamessage>-stext.
7088         CONCATENATE `Message class: `  watreedisplay-text3 INTO watreedisplay-text3.
7089         APPEND watreedisplay TO iloctreedisplay.
7090       ENDAT.
7091     ENDLOOP.
7092   ENDLOOP.
7093 ENDFORM.                                                                                         "fillTreeNodeFunctions
7094 
7095 *----------------------------------------------------------------------------------------------------------------------
7096 *  fillTreeNodePrograms
7097 *----------------------------------------------------------------------------------------------------------------------
7098 FORM filltreenodeprograms USING ilocprograms LIKE iprograms[]
7099                                 ilocfunctions LIKE ifunctions[]
7100                                 iloctreedisplay LIKE itreedisplay[]
7101                                 value(runtime).
7102 
7103   DATA: tablelines TYPE i.
7104   DATA: watreedisplay LIKE snodetext.
7105   FIELD-SYMBOLS: <waprogram> TYPE tprogram.
7106   FIELD-SYMBOLS: <wascreen> TYPE tscreenflow.
7107   FIELD-SYMBOLS: <wafunction> TYPE tfunction.
7108   FIELD-SYMBOLS: <wadictionary> TYPE tdicttable.
7109   FIELD-SYMBOLS: <wainclude> TYPE tinclude.
7110   FIELD-SYMBOLS: <wamessage> TYPE tmessage.
7111   DATA: tablelinesstring TYPE string.
7112   DATA: runtimechar(10).
7113 
7114   tablelines = LINES( ilocprograms ).
7115   tablelinesstring = tablelines.
7116 
7117   IF tablelines = 1.
7118     CONCATENATE tablelinesstring ` program downloaded` INTO watreedisplay-text2.
7119   ELSE.
7120     CONCATENATE tablelinesstring ` programs downloaded` INTO watreedisplay-text2.
7121   ENDIF.
7122 
7123   WRITE runtime TO runtimechar.
7124 
7125   CONCATENATE watreedisplay-text2 ` - runtime ` runtimechar INTO watreedisplay-text2.
7126 * include header display record.
7127   watreedisplay-tlevel = '1'.
7128   watreedisplay-tlength2  = 60.
7129   watreedisplay-tcolor2    = 1.
7130   APPEND watreedisplay TO itreedisplay.
7131 
7132   LOOP AT ilocprograms ASSIGNING <waprogram>.
7133 *   Main programs.
7134     watreedisplay-tlevel = '2'.
7135     watreedisplay-text2 = <waprogram>-progname.
7136     watreedisplay-tcolor2    = 1.
7137 *   Description
7138     watreedisplay-tlength3   = 80.
7139     watreedisplay-tcolor3    = 1.
7140     watreedisplay-tpos3      = 60.
7141     CONCATENATE `Program: ` <waprogram>-programtitle INTO watreedisplay-text3.
7142     APPEND watreedisplay TO itreedisplay.
7143 *   Screens.
7144     LOOP AT <waprogram>-iscreenflow ASSIGNING <wascreen>.
7145       watreedisplay-tlevel = '3'.
7146       watreedisplay-text2 = <wascreen>-screen.
7147       watreedisplay-tcolor2    = 6.
7148       watreedisplay-tlength3   = 80.
7149       watreedisplay-tcolor3    = 6.
7150       watreedisplay-tpos3      = 60.
7151       watreedisplay-text3 = 'Screen'.
7152       APPEND watreedisplay TO itreedisplay.
7153     ENDLOOP.
7154 *   fill in the tree with message information
7155     SORT <waprogram>-imessages[] ASCENDING BY arbgb.
7156     LOOP AT <waprogram>-imessages ASSIGNING <wamessage>.
7157       AT NEW arbgb.
7158         watreedisplay-tlevel = 3.
7159         watreedisplay-text2 = <wamessage>-arbgb.
7160         watreedisplay-tcolor2    = 5.
7161         watreedisplay-tlength3   = 80.
7162         watreedisplay-tcolor3    = 5.
7163         watreedisplay-tpos3      = 60.
7164 
7165 *       Select the message class text if we do not have it already
7166         IF <wamessage>-stext IS INITIAL.
7167           SELECT SINGLE stext FROM t100a
7168                               INTO <wamessage>-stext
7169                               WHERE arbgb = <wamessage>-arbgb.
7170         ENDIF.
7171 
7172         watreedisplay-text3 = <wamessage>-stext.
7173         CONCATENATE `Message class: `  watreedisplay-text3 INTO watreedisplay-text3.
7174         APPEND watreedisplay TO iloctreedisplay.
7175       ENDAT.
7176     ENDLOOP.
7177 *   Fill in the tree with include information
7178     LOOP AT <waprogram>-iincludes ASSIGNING <wainclude>.
7179       watreedisplay-tlevel = 3.
7180       watreedisplay-text2 =  <wainclude>-includename.
7181       watreedisplay-tcolor2    = 4.
7182       watreedisplay-tlength3   = 80.
7183       watreedisplay-tcolor3    = 4.
7184       watreedisplay-tpos3      = 60.
7185       CONCATENATE `Include:   ` <wainclude>-includetitle INTO watreedisplay-text3.
7186       APPEND watreedisplay TO iloctreedisplay.
7187     ENDLOOP.
7188 *   fill in the tree with dictionary information
7189     LOOP AT <waprogram>-idictstruct ASSIGNING <wadictionary>.
7190       watreedisplay-tlevel = 3.
7191       watreedisplay-text2 =  <wadictionary>-tablename.
7192       watreedisplay-tcolor2    = 3.
7193       watreedisplay-tlength3   = 80.
7194       watreedisplay-tcolor3    = 3.
7195       watreedisplay-tpos3      = 60.
7196       CONCATENATE `Dictionary:    ` <wadictionary>-tabletitle INTO watreedisplay-text3.
7197       APPEND watreedisplay TO iloctreedisplay.
7198     ENDLOOP.
7199 
7200 *   Function Modules
7201     LOOP AT ilocfunctions ASSIGNING <wafunction> WHERE programlinkname = <waprogram>-progname.
7202       watreedisplay-tlevel = 3.
7203       watreedisplay-text2 = <wafunction>-functionname.
7204       watreedisplay-tcolor2    = 7.
7205       watreedisplay-tlength3   = 80.
7206       watreedisplay-tcolor3    = 7.
7207       watreedisplay-tpos3      = 60.
7208       CONCATENATE `Function:      ` <wafunction>-functionname INTO watreedisplay-text3.
7209       APPEND watreedisplay TO iloctreedisplay.
7210 
7211 *     Fill in the tree with include information
7212       LOOP AT <wafunction>-iincludes ASSIGNING <wainclude>.
7213         watreedisplay-tlevel = 4.
7214         watreedisplay-text2 =  <wainclude>-includename.
7215         watreedisplay-tcolor2    = 4.
7216         watreedisplay-tlength3   = 80.
7217         watreedisplay-tcolor3    = 4.
7218         watreedisplay-tpos3      = 60.
7219         CONCATENATE `Include:       ` <wainclude>-includetitle INTO watreedisplay-text3.
7220         APPEND watreedisplay TO iloctreedisplay.
7221       ENDLOOP.
7222 
7223 *     fill in the tree with dictionary information
7224       LOOP AT <wafunction>-idictstruct ASSIGNING <wadictionary>.
7225         watreedisplay-tlevel = 4.
7226         watreedisplay-text2 =  <wadictionary>-tablename.
7227         watreedisplay-tcolor2    = 3.
7228         watreedisplay-tlength3   = 80.
7229         watreedisplay-tcolor3    = 3.
7230         watreedisplay-tpos3      = 60.
7231         CONCATENATE `Dictionary:    ` <wadictionary>-tabletitle INTO watreedisplay-text3.
7232         APPEND watreedisplay TO iloctreedisplay.
7233       ENDLOOP.
7234 
7235 *     fill in the tree with message information
7236       SORT <wafunction>-imessages[] ASCENDING BY arbgb.
7237       LOOP AT <wafunction>-imessages ASSIGNING <wamessage>.
7238         AT NEW arbgb.
7239           watreedisplay-tlevel = 4.
7240           watreedisplay-text2 = <wamessage>-arbgb.
7241           watreedisplay-tcolor2    = 5.
7242           watreedisplay-tlength3   = 80.
7243           watreedisplay-tcolor3    = 5.
7244           watreedisplay-tpos3      = 60.
7245 
7246 *         Select the message class text if we do not have it already
7247           IF <wamessage>-stext IS INITIAL.
7248             SELECT SINGLE stext FROM t100a
7249                                 INTO <wamessage>-stext
7250                                 WHERE arbgb = <wamessage>-arbgb.
7251           ENDIF.
7252 
7253           watreedisplay-text3 = <wamessage>-stext.
7254           CONCATENATE `Message class:  `  watreedisplay-text3 INTO watreedisplay-text3.
7255           APPEND watreedisplay TO iloctreedisplay.
7256         ENDAT.
7257       ENDLOOP.
7258     ENDLOOP.
7259   ENDLOOP.
7260 ENDFORM.                                                                                          "fillTreeNodePrograms
7261 
7262 *----------------------------------------------------------------------------------------------------------------------
7263 *  fillTreeNodeClasses
7264 *----------------------------------------------------------------------------------------------------------------------
7265 FORM filltreenodeclasses USING ilocclasses LIKE iclasses[]
7266                                ilocfunctions LIKE ifunctions[]
7267                                iloctreedisplay LIKE itreedisplay[]
7268                                value(runtime).
7269 
7270   DATA: tablelines TYPE i.
7271   DATA: watreedisplay LIKE snodetext.
7272   FIELD-SYMBOLS: <waclass> TYPE tclass.
7273   FIELD-SYMBOLS: <wamethod> TYPE tmethod.
7274   FIELD-SYMBOLS: <wafunction> TYPE tfunction.
7275   FIELD-SYMBOLS: <wadictionary> TYPE tdicttable.
7276   FIELD-SYMBOLS: <wainclude> TYPE tinclude.
7277   FIELD-SYMBOLS: <wamessage> TYPE tmessage.
7278   DATA: tablelinesstring TYPE string.
7279   DATA: runtimechar(10).
7280 
7281   tablelines = LINES( ilocclasses ).
7282   tablelinesstring = tablelines.
7283 
7284   IF tablelines = 1.
7285     CONCATENATE tablelinesstring ` class downloaded` INTO watreedisplay-text2.
7286   ELSE.
7287     CONCATENATE tablelinesstring ` classes downloaded` INTO watreedisplay-text2.
7288   ENDIF.
7289 
7290   WRITE runtime TO runtimechar.
7291 
7292   CONCATENATE watreedisplay-text2 ` - runtime ` runtimechar INTO watreedisplay-text2.
7293 * include header display record.
7294   watreedisplay-tlevel = '1'.
7295   watreedisplay-tlength2  = 60.
7296   watreedisplay-tcolor2    = 1.
7297   APPEND watreedisplay TO itreedisplay.
7298 
7299   LOOP AT ilocclasses ASSIGNING <waclass>.
7300 *   Main Class.
7301     watreedisplay-tlevel = '2'.
7302     watreedisplay-text2 = <waclass>-clsname.
7303     watreedisplay-tcolor2    = 1.
7304 *   Description
7305     watreedisplay-tlength3   = 80.
7306     watreedisplay-tcolor3    = 1.
7307     watreedisplay-tpos3      = 60.
7308     CONCATENATE `Class:    ` <waclass>-descript INTO watreedisplay-text3.
7309     APPEND watreedisplay TO itreedisplay.
7310 
7311 *   fill in the tree with method information
7312     LOOP AT <waclass>-imethods[] ASSIGNING <wamethod>.
7313       watreedisplay-tlevel = 3.
7314       watreedisplay-text2 =  <wamethod>-cmpname.
7315       watreedisplay-tcolor2    = 2.
7316       watreedisplay-tlength3   = 80.
7317       watreedisplay-tcolor3    = 2.
7318       watreedisplay-tpos3      = 60.
7319       CONCATENATE `Method:   ` <wamethod>-descript INTO watreedisplay-text3.
7320       APPEND watreedisplay TO iloctreedisplay.
7321     ENDLOOP.
7322 
7323 *   fill in the tree with message information
7324     SORT <waclass>-imessages[] ASCENDING BY arbgb.
7325     LOOP AT <waclass>-imessages ASSIGNING <wamessage>.
7326       AT NEW arbgb.
7327         watreedisplay-tlevel = 3.
7328         watreedisplay-text2 = <wamessage>-arbgb.
7329         watreedisplay-tcolor2    = 5.
7330         watreedisplay-tlength3   = 80.
7331         watreedisplay-tcolor3    = 5.
7332         watreedisplay-tpos3      = 60.
7333 
7334 *       Select the message class text if we do not have it already
7335         IF <wamessage>-stext IS INITIAL.
7336           SELECT SINGLE stext FROM t100a
7337                               INTO <wamessage>-stext
7338                               WHERE arbgb = <wamessage>-arbgb.
7339         ENDIF.
7340 
7341         watreedisplay-text3 = <wamessage>-stext.
7342         CONCATENATE `Message class: `  watreedisplay-text3 INTO watreedisplay-text3.
7343         APPEND watreedisplay TO iloctreedisplay.
7344       ENDAT.
7345     ENDLOOP.
7346 
7347 *   fill in the tree with dictionary information
7348     LOOP AT <waclass>-idictstruct ASSIGNING <wadictionary>.
7349       watreedisplay-tlevel = 3.
7350       watreedisplay-text2 =  <wadictionary>-tablename.
7351       watreedisplay-tcolor2    = 3.
7352       watreedisplay-tlength3   = 80.
7353       watreedisplay-tcolor3    = 3.
7354       watreedisplay-tpos3      = 60.
7355       CONCATENATE `Dictionary:    ` <wadictionary>-tabletitle INTO watreedisplay-text3.
7356       APPEND watreedisplay TO iloctreedisplay.
7357     ENDLOOP.
7358 
7359 *   Function Modules
7360     LOOP AT ilocfunctions ASSIGNING <wafunction> WHERE programlinkname = <waclass>-clsname.
7361       watreedisplay-tlevel = 3.
7362       watreedisplay-text2 = <wafunction>-functionname.
7363       watreedisplay-tcolor2    = 7.
7364       watreedisplay-tlength3   = 80.
7365       watreedisplay-tcolor3    = 7.
7366       watreedisplay-tpos3      = 60.
7367       CONCATENATE `Function:      ` <wafunction>-functionname INTO watreedisplay-text3.
7368       APPEND watreedisplay TO iloctreedisplay.
7369 
7370 *     Fill in the tree with include information
7371       LOOP AT <wafunction>-iincludes ASSIGNING <wainclude>.
7372         watreedisplay-tlevel = 4.
7373         watreedisplay-text2 =  <wainclude>-includename.
7374         watreedisplay-tcolor2    = 4.
7375         watreedisplay-tlength3   = 80.
7376         watreedisplay-tcolor3    = 4.
7377         watreedisplay-tpos3      = 60.
7378         CONCATENATE `Include:       ` <wainclude>-includetitle INTO watreedisplay-text3.
7379         APPEND watreedisplay TO iloctreedisplay.
7380       ENDLOOP.
7381 
7382 *     fill in the tree with dictionary information
7383       LOOP AT <wafunction>-idictstruct ASSIGNING <wadictionary>.
7384         watreedisplay-tlevel = 4.
7385         watreedisplay-text2 =  <wadictionary>-tablename.
7386         watreedisplay-tcolor2    = 3.
7387         watreedisplay-tlength3   = 80.
7388         watreedisplay-tcolor3    = 3.
7389         watreedisplay-tpos3      = 60.
7390         CONCATENATE `Dictionary:    ` <wadictionary>-tabletitle INTO watreedisplay-text3.
7391         APPEND watreedisplay TO iloctreedisplay.
7392       ENDLOOP.
7393 
7394 *     fill in the tree with message information
7395       SORT <wafunction>-imessages[] ASCENDING BY arbgb.
7396       LOOP AT <wafunction>-imessages ASSIGNING <wamessage>.
7397         AT NEW arbgb.
7398           watreedisplay-tlevel = 4.
7399           watreedisplay-text2 = <wamessage>-arbgb.
7400           watreedisplay-tcolor2    = 5.
7401           watreedisplay-tlength3   = 80.
7402           watreedisplay-tcolor3    = 5.
7403           watreedisplay-tpos3      = 60.
7404 
7405 *         Select the message class text if we do not have it already
7406           IF <wamessage>-stext IS INITIAL.
7407             SELECT SINGLE stext FROM t100a
7408                                 INTO <wamessage>-stext
7409                                 WHERE arbgb = <wamessage>-arbgb.
7410           ENDIF.
7411 
7412           watreedisplay-text3 = <wamessage>-stext.
7413           CONCATENATE `Message class:  `  watreedisplay-text3 INTO watreedisplay-text3.
7414           APPEND watreedisplay TO iloctreedisplay.
7415         ENDAT.
7416       ENDLOOP.
7417     ENDLOOP.
7418   ENDLOOP.
7419 ENDFORM.                                                                                           "fillTreeNodeClasses
7420 
7421 *----------------------------------------------------------------------------------------------------------------------
7422 * displayTree...
7423 *----------------------------------------------------------------------------------------------------------------------
7424 FORM displaytree USING iloctreedisplay LIKE itreedisplay[].
7425 
7426   DATA: watreedisplay TYPE snodetext.
7427 
7428 * build up the tree from the internal table node
7429   CALL FUNCTION 'RS_TREE_CONSTRUCT'
7430     TABLES
7431       nodetab            = itreedisplay
7432     EXCEPTIONS
7433       tree_failure       = 1
7434       id_not_found       = 2
7435       wrong_relationship = 3
7436       OTHERS             = 4.
7437 
7438 * get the first index and expand the whole tree
7439   READ TABLE iloctreedisplay INTO watreedisplay INDEX 1.
7440   CALL FUNCTION 'RS_TREE_EXPAND'
7441     EXPORTING
7442       node_id   = watreedisplay-id
7443       all       = 'X'
7444     EXCEPTIONS
7445       not_found = 1
7446       OTHERS    = 2.
7447 
7448 * now display the tree
7449   CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
7450     EXPORTING
7451       callback_program      = sy-cprog
7452       callback_user_command = 'CB_USER_COMMAND'
7453       callback_text_display = 'CB_text_DISPLAY'
7454       callback_top_of_page  = 'TOP_OF_PAGE'
7455     EXCEPTIONS
7456       OTHERS                = 1.
7457 ENDFORM.                                                                                                   "displayTree
7458 
7459 *----------------------------------------------------------------------------------------------------------------------
7460 *  topOfPage... for tree display routines.
7461 *----------------------------------------------------------------------------------------------------------------------
7462 FORM topofpage.
7463 
7464 ENDFORM.                    "topOfPage
7465 
7466 
7467 *Messages
7468 *----------------------------------------------------------
7469 *
7470 * Message class: OO
7471 *000   & & & &
7472 
7473 
7474 *Messages
7475 *----------------------------------------------------------
7476 *
7477 * Message class: OO
7478 *000   & & & &
7479 
7480 *----------------------------------------------------------------------------------
7481 *Extracted by Direct Download Enterprise version 1.3.1 - E.G.Mellodew. 1998-2005 UK. Sap Release 731
View Code
上一篇:HTML下直接调用Less文件


下一篇:WebAPI上传大文件