Listenüberschriften | Selektionstexte | Textelemente | Dokumentation | Varianten
Eigenschaften | Quelltext
Titel | Includes mit Daten aus DB-Tabellen generieren |
Originalsprache | DE | Deutsch
Erstellt | 04.01.2013 |  | CREYTZ |
Letzte Änderung | 02.03.2021 |  | CREYTZ |
Status | aktiv |
Attribute
Typ | Ausführbares Programm |
Status | Produktives Kundenprogramm |
Anwendung |  |
Berechtigungsgruppe |  |
Paket | ZSOFTCOPY | SoftCopy
Logische Datenbank |  |
Selektionsbildversion |  |
| Editorsperre |  |  | Festpunktarithmetik
| Unicodeprüfungen aktiv |  |  | Start über Variante
txt |  | vollständig.txt
    1
    *&---------------------------------------------------------------------*
    2
    *& Report  ZSOFTCOPY_MAKE                                              *
    3
    *&                                                                     *
    4
    *&---------------------------------------------------------------------*
    5
    *&                                                                     *
    6
    *& This program is free software: you can redistribute it and/or       *
    7
    *& modify it under the terms of the GNU General Public License as      *
    8
    *& published by the Free Software Foundation, either version 3 of the  *
    9
    *& License, or any later version.                                      *
    10
    *&                                                                     *
    11
    *& This program is distributed in the hope that it will be useful,     *
    12
    *& but WITHOUT ANY WARRANTY; without even the implied warranty of      *
    13
    *& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                *
    14
    *& See the GNU General Public License for more details.                *
    15
    *&                                                                     *
    16
    *& You should have received a copy of the GNU General Public License   *
    17
    *& along with this program. If not, see <http://www.gnu.org/licenses/>.*
    18
    *&                                                                     *
    19
    *&---------------------------------------------------------------------*
    20
    *&                                                                     *
    21
    *&  Author:     Ruediger von Creytz     ruediger.creytz@globalbit.net  *
    22
    *&  Copyright:  globalBIT, LLC          http://www.globalbit.net       *
    23
    *&  Version:    20210302                                               *
    24
    *&                                                                     *
    25
    *&---------------------------------------------------------------------*
    26
    27
    REPORT  zsoftcopy_make.
    28
    29
    30
    INCLUDE zsoftcopy_types.
    31
    32
    DATA:
    33
    gt_src TYPE it_abapsource.
    34
    35
    CONSTANTS:
    36
    gc_separator TYPE c VALUE ';',
    37
    gc_include_csv_name TYPE progname VALUE 'ZSOFTCOPY_CSV',
    38
    gc_include_csv_title TYPE repti VALUE 'SoftCopy - CSV',
    39
    gc_include_txt_name TYPE progname VALUE 'ZSOFTCOPY_TEXT',
    40
    gc_include_txt_title TYPE repti VALUE 'SoftCopy - TEXT'.
    41
    42
    43
    PERFORM make.
    44
    45
    46
    INCLUDE zutil_convert_text.
    47
    48
    49
    *-----------------------------------------------------------------------
    50
    * make
    51
    *-----------------------------------------------------------------------
    52
    FORM make.
    53
    54
      DATA:
    55
      l_subrc_csv TYPE string,
    56
      l_subrc_txt TYPE string,
    57
      l_infoline(80) TYPE c.
    58
    59
      PERFORM add_report_begin
    60
        USING gc_include_csv_name
    61
        CHANGING gt_src.
    62
    63
      PERFORM csv_table_structure.
    64
      PERFORM csv_tabstrip.
    65
      PERFORM csv_text_elements
    66
        CHANGING
    67
          l_subrc_txt.
    68
      PERFORM csv_varid_broken.
    69
    70
      PERFORM add_report_end
    71
        CHANGING gt_src.
    72
    73
      PERFORM save
    74
        USING
    75
          gc_include_csv_name
    76
          gc_include_txt_title
    77
          gt_src
    78
        CHANGING
    79
          l_subrc_csv.
    80
    81
      IF l_subrc_csv = 0 AND l_subrc_txt = 0.
    82
        CONCATENATE
    83
          'created ZSOFTCOPY_CSV'
    84
          ' and ZSOFTCOPY_TEXT successfully'
    85
          INTO l_infoline.
    86
      ELSE.
    87
        CONCATENATE
    88
          'created ZSOFTCOPY_CSV with subrc=' l_subrc_csv
    89
          ' and ZSOFTCOPY_TXT with subrc=' l_subrc_txt
    90
          INTO l_infoline.
    91
      ENDIF.
    92
    93
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    94
        EXPORTING
    95
          text = l_infoline.
    96
      WAIT UP TO 5 SECONDS.
    97
    98
    ENDFORM.                    "make
    99
    100
    101
    *-----------------------------------------------------------------------
    102
    * add_csv_line
    103
    *-----------------------------------------------------------------------
    104
    FORM add_csv_line
    105
      USING
    106
        value(i_str)
    107
      CHANGING
    108
        c_counter TYPE i.
    109
    110
      DATA:
    111
      ls_src TYPE abapsource,
    112
      l_length TYPE i,
    113
      l_str TYPE string,
    114
      l_strlen TYPE i,
    115
      l_cnt TYPE i VALUE 0.
    116
    117
      CONSTANTS:
    118
      lc_length_content TYPE i VALUE 68.
    119
    120
      IF c_counter = 100.
    121
        PERFORM add_form_middle.
    122
        c_counter = 0.
    123
      ENDIF.
    124
    125
      l_strlen = strlen( i_str ).
    126
      IF l_strlen > lc_length_content.
    127
        CONCATENATE '''' i_str+0(lc_length_content) ''''
    128
            INTO ls_src-line.
    129
        APPEND ls_src TO gt_src.
    130
        l_length = strlen( i_str ) - lc_length_content.
    131
        l_str = i_str+lc_length_content(l_length).
    132
        PERFORM add_csv_line
    133
          USING l_str
    134
          CHANGING l_cnt.
    135
      ELSE.
    136
        CONCATENATE '''' i_str '|''' INTO ls_src-line.
    137
        APPEND ls_src TO gt_src.
    138
      ENDIF.
    139
      c_counter = c_counter + 1.
    140
    141
    ENDFORM.                    "add_csv_line
    142
    143
    144
    *-----------------------------------------------------------------------
    145
    * add_form_begin
    146
    *-----------------------------------------------------------------------
    147
    FORM add_form_begin
    148
      USING
    149
        value(i_name).
    150
    151
      DATA:
    152
      ls_src TYPE abapsource.
    153
    154
      CONCATENATE 'form' i_name
    155
          INTO ls_src-line SEPARATED BY space.
    156
      APPEND ls_src TO gt_src.
    157
    158
      ls_src-line = 'changing ct_csv type it_string.'.
    159
      APPEND ls_src TO gt_src.
    160
    161
      ls_src-line = 'refresh ct_csv.'.
    162
      APPEND ls_src TO gt_src.
    163
    164
      ls_src-line = 'data ls_csv type string.'.
    165
      APPEND ls_src TO gt_src.
    166
    167
      ls_src-line = 'concatenate'.
    168
      APPEND ls_src TO gt_src.
    169
    170
    ENDFORM.                    "add_form_begin
    171
    172
    173
    *-----------------------------------------------------------------------
    174
    * add_form_end
    175
    *-----------------------------------------------------------------------
    176
    FORM add_form_end
    177
      USING
    178
        value(i_name).
    179
    180
      DATA:
    181
      ls_src TYPE abapsource.
    182
    183
      ls_src-line = 'space into ls_csv.'.
    184
      APPEND ls_src TO gt_src.
    185
    186
      ls_src-line = 'append ls_csv to ct_csv.'.
    187
      APPEND ls_src TO gt_src.
    188
    189
      CONCATENATE 'endform.  "' i_name INTO ls_src-line.
    190
      APPEND ls_src TO gt_src.
    191
    192
    ENDFORM.                    "add_form_end
    193
    194
    195
    *-----------------------------------------------------------------------
    196
    * add_form_middle
    197
    *-----------------------------------------------------------------------
    198
    FORM add_form_middle.
    199
    200
      DATA:
    201
      ls_src TYPE abapsource.
    202
    203
      ls_src-line = 'space into ls_csv.'.
    204
      APPEND ls_src TO gt_src.
    205
    206
      ls_src-line = 'append ls_csv to ct_csv.'.
    207
      APPEND ls_src TO gt_src.
    208
    209
      ls_src-line = 'concatenate'.
    210
      APPEND ls_src TO gt_src.
    211
    212
    ENDFORM.                    "add_form_end
    213
    214
    215
    *-----------------------------------------------------------------------
    216
    * add_report_begin
    217
    *-----------------------------------------------------------------------
    218
    FORM add_report_begin
    219
      USING
    220
        value(i_name) TYPE progname
    221
      CHANGING
    222
        ct_src TYPE it_abapsource.
    223
    224
      DATA:
    225
      ls_src TYPE abapsource.
    226
    227
      REFRESH ct_src.
    228
    229
      CONCATENATE
    230
      '*&-----------------------------'
    231
      '----------------------------------------*'
    232
      INTO ls_src-line.
    233
      APPEND ls_src TO ct_src.
    234
    235
      CLEAR ls_src.
    236
      ls_src-line+0(11) = '*&  Include'.
    237
      ls_src-line+21(30) = i_name.
    238
      ls_src-line+71(1) = '*'.
    239
      APPEND ls_src TO ct_src.
    240
    241
      CONCATENATE
    242
      '*&-----------------------------'
    243
      '----------------------------------------*'
    244
      INTO ls_src-line.
    245
      APPEND ls_src TO ct_src.
    246
    247
      CONCATENATE
    248
      '*&!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
    249
      '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*'
    250
      INTO ls_src-line.
    251
      APPEND ls_src TO ct_src.
    252
    253
      CONCATENATE
    254
      '*&!!!!!!!!!!! generated by ZSOFT'
    255
      'COPY_MAKE !!!!! do not edit !!!!!!!!!!!*'
    256
      INTO ls_src-line.
    257
      APPEND ls_src TO ct_src.
    258
    259
      CONCATENATE
    260
      '*&!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
    261
      '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*'
    262
      INTO ls_src-line.
    263
      APPEND ls_src TO ct_src.
    264
    265
      CONCATENATE
    266
      '*&------------------------------'
    267
      '---------------------------------------*'
    268
      INTO ls_src-line.
    269
      APPEND ls_src TO ct_src.
    270
    271
    ENDFORM.                    "add_report_begin
    272
    273
    274
    *-----------------------------------------------------------------------
    275
    * add_report_end
    276
    *-----------------------------------------------------------------------
    277
    FORM add_report_end
    278
      CHANGING
    279
        ct_src TYPE it_abapsource.
    280
    * nothing to do
    281
    ENDFORM.                    "add_report_end
    282
    283
    284
    *-----------------------------------------------------------------------
    285
    * csv_table_structure
    286
    *-----------------------------------------------------------------------
    287
    FORM csv_table_structure.
    288
    289
      DATA:
    290
      lt_table TYPE STANDARD TABLE OF zsoftcopy_table,
    291
      l_line TYPE string,
    292
      l_cnt TYPE i VALUE 0.
    293
    294
      FIELD-SYMBOLS:
    295
      <ls_table> TYPE zsoftcopy_table.
    296
    297
      CONSTANTS:
    298
      lc_name TYPE fieldname VALUE 'csv_table_structure'.
    299
    300
    301
      PERFORM add_form_begin USING lc_name.
    302
    303
      SELECT * FROM zsoftcopy_table INTO TABLE lt_table
    304
          ORDER BY id column_nr.
    305
    306
      LOOP AT lt_table ASSIGNING <ls_table>.
    307
        CONCATENATE
    308
            <ls_table>-id              gc_separator
    309
            <ls_table>-column_nr       gc_separator
    310
            <ls_table>-fieldname       gc_separator
    311
            <ls_table>-title_elem      gc_separator
    312
            <ls_table>-link_column     gc_separator
    313
            <ls_table>-column_def      gc_separator
    314
            <ls_table>-colored_column  gc_separator
    315
            <ls_table>-comparator      gc_separator
    316
            <ls_table>-comp_value
    317
            INTO l_line.
    318
        PERFORM add_csv_line
    319
          USING l_line
    320
          CHANGING l_cnt.
    321
      ENDLOOP.
    322
    323
      PERFORM add_form_end USING lc_name.
    324
    325
    ENDFORM.                    "csv_table_structure
    326
    327
    328
    *-----------------------------------------------------------------------
    329
    * csv_tabstrip
    330
    *-----------------------------------------------------------------------
    331
    FORM csv_tabstrip.
    332
    333
      DATA:
    334
      lt_strip TYPE STANDARD TABLE OF zsoftcopy_strip,
    335
      l_line TYPE string,
    336
      l_cnt TYPE i VALUE 0.
    337
    338
      FIELD-SYMBOLS:
    339
      <ls_strip> TYPE zsoftcopy_strip.
    340
    341
      CONSTANTS:
    342
      lc_name TYPE fieldname VALUE 'csv_tabstrip'.
    343
    344
    345
      PERFORM add_form_begin USING lc_name.
    346
    347
      SELECT * FROM zsoftcopy_strip INTO TABLE lt_strip
    348
          ORDER BY form tab_nr.
    349
    350
      LOOP AT lt_strip ASSIGNING <ls_strip>.
    351
        CONCATENATE
    352
            <ls_strip>-form         gc_separator
    353
            <ls_strip>-id           gc_separator
    354
            <ls_strip>-parent_id    gc_separator
    355
            <ls_strip>-tab_nr       gc_separator
    356
            <ls_strip>-firstrow     gc_separator
    357
            <ls_strip>-active_order gc_separator
    358
            <ls_strip>-text_elem    gc_separator
    359
            <ls_strip>-comparator   gc_separator
    360
            <ls_strip>-comp_value
    361
            INTO l_line.
    362
        PERFORM add_csv_line
    363
          USING l_line
    364
          CHANGING l_cnt.
    365
      ENDLOOP.
    366
    367
      PERFORM add_form_end USING lc_name.
    368
    369
    ENDFORM.                    "csv_table_structure
    370
    371
    372
    *-----------------------------------------------------------------------
    373
    * csv_text_elements
    374
    *-----------------------------------------------------------------------
    375
    FORM csv_text_elements
    376
      CHANGING
    377
        c_subrc TYPE string.
    378
    379
      DATA:
    380
      lt_txt TYPE STANDARD TABLE OF zsoftcopy_text,
    381
      lt_txtt TYPE STANDARD TABLE OF zsoftcopy_textt,
    382
      l_line TYPE string,
    383
      l_text TYPE string,
    384
      ls_src TYPE abapsource,
    385
      lt_src_txt TYPE it_abapsource,
    386
      l_cnt TYPE i VALUE 0.
    387
    388
      FIELD-SYMBOLS:
    389
      <ls_txt> TYPE zsoftcopy_text,
    390
      <ls_txtt> TYPE zsoftcopy_textt.
    391
    392
      CONSTANTS:
    393
      lc_name_1 TYPE fieldname VALUE 'csv_text_elements_1',
    394
      lc_name_2 TYPE fieldname VALUE 'csv_text_elements_2'.
    395
    396
    397
    *txt
    398
      l_cnt = 0.
    399
      PERFORM add_form_begin USING lc_name_1.
    400
    401
      SELECT * FROM zsoftcopy_text INTO TABLE lt_txt
    402
          ORDER BY fieldname.
    403
    404
      LOOP AT lt_txt ASSIGNING <ls_txt>.
    405
        CONCATENATE
    406
            <ls_txt>-fieldname      gc_separator
    407
            <ls_txt>-text_prefix    gc_separator
    408
            <ls_txt>-dtel_rollname  gc_separator
    409
            <ls_txt>-dtel_field     gc_separator
    410
            <ls_txt>-domname        gc_separator
    411
            <ls_txt>-domvalue       gc_separator
    412
            <ls_txt>-icon_id        gc_separator
    413
            <ls_txt>-icon_field     gc_separator
    414
            <ls_txt>-conc_v1        gc_separator
    415
            <ls_txt>-conc_copula    gc_separator
    416
            <ls_txt>-conc_v2        gc_separator
    417
            <ls_txt>-conc_sep_space gc_separator
    418
            <ls_txt>-msg_id         gc_separator
    419
            <ls_txt>-msg_nr         gc_separator
    420
            <ls_txt>-msg_v1         gc_separator
    421
            <ls_txt>-msg_v2         gc_separator
    422
            <ls_txt>-msg_v3         gc_separator
    423
            <ls_txt>-msg_v4         gc_separator
    424
            INTO l_line.
    425
        PERFORM add_csv_line
    426
          USING l_line
    427
          CHANGING l_cnt.
    428
      ENDLOOP.
    429
    430
      PERFORM add_form_end USING lc_name_1.
    431
    432
    *txtt
    433
      l_cnt = 0.
    434
      PERFORM add_form_begin USING lc_name_2.
    435
    436
      SELECT * FROM zsoftcopy_textt INTO TABLE lt_txtt
    437
          ORDER BY fieldname.
    438
    439
      LOOP AT lt_txtt ASSIGNING <ls_txtt>.
    440
        l_text = <ls_txtt>-text.
    441
        PERFORM encode_html CHANGING l_text.
    442
        CONCATENATE
    443
            <ls_txtt>-fieldname gc_separator
    444
            <ls_txtt>-spras     gc_separator
    445
            l_text
    446
            INTO l_line.
    447
        PERFORM add_csv_line
    448
          USING l_line
    449
          CHANGING l_cnt.
    450
      ENDLOOP.
    451
    452
      PERFORM add_form_end USING lc_name_2.
    453
    454
    *params
    455
      PERFORM add_report_begin
    456
        USING gc_include_txt_name
    457
        CHANGING lt_src_txt.
    458
    459
    * constants
    460
      CONCATENATE 'constants gc_version type sydatum value '''
    461
          sy-datum '''.'
    462
          INTO ls_src-line.
    463
      APPEND ls_src TO lt_src_txt.
    464
    465
    * texts
    466
      LOOP AT lt_txt ASSIGNING <ls_txt>.
    467
        AT FIRST.
    468
          ls_src-line = 'data:'.
    469
          APPEND ls_src TO lt_src_txt.
    470
        ENDAT.
    471
        CONCATENATE <ls_txt>-fieldname 'type string'
    472
            INTO ls_src-line SEPARATED BY space.
    473
        AT LAST.
    474
          CONCATENATE ls_src-line '.' INTO ls_src-line.
    475
          APPEND ls_src TO lt_src_txt.
    476
          EXIT.
    477
        ENDAT.
    478
        CONCATENATE ls_src-line ',' INTO ls_src-line.
    479
        APPEND ls_src TO lt_src_txt.
    480
      ENDLOOP.
    481
    482
      PERFORM add_report_end
    483
        CHANGING lt_src_txt.
    484
    485
      PERFORM save
    486
        USING
    487
          gc_include_txt_name
    488
          gc_include_txt_title
    489
          lt_src_txt
    490
        CHANGING
    491
          c_subrc.
    492
    493
    ENDFORM.                    "csv_text_elements
    494
    495
    496
    *-----------------------------------------------------------------------
    497
    * csv_varid_broken
    498
    *-----------------------------------------------------------------------
    499
    FORM csv_varid_broken.
    500
    501
      DATA:
    502
      lt_varid TYPE STANDARD TABLE OF zsoftcopy_varid,
    503
      l_line TYPE string,
    504
      l_cnt TYPE i VALUE 0.
    505
    506
      FIELD-SYMBOLS:
    507
      <ls_varid> TYPE zsoftcopy_varid.
    508
    509
      CONSTANTS:
    510
      l_c_name TYPE fieldname VALUE 'csv_varid_broken'.
    511
    512
    513
      PERFORM add_form_begin USING l_c_name.
    514
    515
      SELECT * FROM zsoftcopy_varid INTO TABLE lt_varid.
    516
    517
      LOOP AT lt_varid ASSIGNING <ls_varid>.
    518
        CONCATENATE
    519
            <ls_varid>-report       gc_separator
    520
            <ls_varid>-vari
    521
            INTO l_line.
    522
        PERFORM add_csv_line
    523
          USING l_line
    524
          CHANGING l_cnt.
    525
      ENDLOOP.
    526
    527
      PERFORM add_form_end USING l_c_name.
    528
    529
    ENDFORM.                    "csv_varid_broken
    530
    531
    532
    *-----------------------------------------------------------------------
    533
    * save
    534
    *-----------------------------------------------------------------------
    535
    FORM save
    536
      USING
    537
        value(i_progname) TYPE progname
    538
        value(i_title) TYPE repti
    539
        i_it_abapsource TYPE it_abapsource
    540
      CHANGING
    541
        c_subrc TYPE string.
    542
    543
      CALL FUNCTION 'BC_PR_INSERT'
    544
        EXPORTING
    545
          program_name     = i_progname
    546
          program_type     = 'I'
    547
          title_string     = i_title
    548
        TABLES
    549
          SOURCE           = i_it_abapsource
    550
        EXCEPTIONS
    551
          already_exists   = 1
    552
          cancelled        = 2
    553
          name_not_allowed = 3
    554
          permission_error = 4
    555
          OTHERS           = 5.
    556
    557
      IF sy-subrc = 1.
    558
        CALL FUNCTION 'BC_PR_UPDATE'
    559
          EXPORTING
    560
            program_name       = i_progname
    561
          TABLES
    562
            SOURCE             = i_it_abapsource
    563
          EXCEPTIONS
    564
            not_exists         = 6
    565
            cancelled          = 7
    566
            name_not_allowed   = 8
    567
            permission_error   = 9
    568
            object_is_inactive = 10
    569
            wrong_user         = 11
    570
            OTHERS             = 12.
    571
      ENDIF.
    572
    573
      c_subrc = sy-subrc.
    574
    575
    ENDFORM.                    "save