Eigenschaften | Quelltext
Titel | SoftCopy - text tools |
Originalsprache | DE | Deutsch
Erstellt | 04.01.2013 |  | CREYTZ |
Letzte Änderung | 23.02.2021 |  | CREYTZ |
Status | aktiv |
Attribute
Typ | Include-Programm |
Status | Produktives Kundenprogramm |
Anwendung |  |
Berechtigungsgruppe |  |
Paket | ZSOFTCOPY | SoftCopy
| Editorsperre
txt
    1
    *&---------------------------------------------------------------------*
    2
    *&  Include           ZSOFTCOPY_TEXT_TOOLS                             *
    3
    *&                                                                     *
    4
    *&---------------------------------------------------------------------*
    5
    *&                                                                     *
    6
    *& This file is part of ZSOFTCOPY.                                     *
    7
    *&                                                                     *
    8
    *& ZSOFTCOPY is free software: you can redistribute it and/or modify   *
    9
    *& it under the terms of the GNU General Public License as published   *
    10
    *& by the Free Software Foundation, either version 3 of the License,   *
    11
    *& or any later version.                                               *
    12
    *&                                                                     *
    13
    *& ZSOFTCOPY is distributed in the hope that it will be useful,        *
    14
    *& but WITHOUT ANY WARRANTY; without even the implied warranty of      *
    15
    *& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
    16
    *& GNU General Public License for more details.                        *
    17
    *&                                                                     *
    18
    *& You should have received a copy of the GNU General Public License   *
    19
    *& along with ZDOWNLOAD. If not, see <http://www.gnu.org/licenses/>.   *
    20
    *&                                                                     *
    21
    *&---------------------------------------------------------------------*
    22
    *&                                                                     *
    23
    *&  Author:     Ruediger von Creytz     ruediger.creytz@globalbit.net  *
    24
    *&  Copyright:  globalBIT, LLC          http://www.globalbit.net       *
    25
    *&                                                                     *
    26
    *&---------------------------------------------------------------------*
    27
    28
    29
    *-----------------------------------------------------------------------
    30
    * text_tools
    31
    *-----------------------------------------------------------------------
    32
    FORM text_tools.
    33
      PERFORM text_tools_text_elements.
    34
      PERFORM text_tools_text_concatenated.
    35
      PERFORM text_tools_text_message.
    36
    37
    *tables are not needed any more:
    38
      REFRESH:
    39
      gt_text_element,
    40
      gt_text_element_t.
    41
    ENDFORM.                    "text_tools
    42
    43
    44
    *-----------------------------------------------------------------------
    45
    * text_tools_text_concatenated
    46
    *-----------------------------------------------------------------------
    47
    FORM text_tools_text_concatenated.
    48
      DATA:
    49
      l_text TYPE string,
    50
      l_str1 TYPE string,
    51
      l_str2 TYPE string.
    52
    53
      FIELD-SYMBOLS:
    54
      <ls_txt> TYPE st_text_element,
    55
      <l_fs> TYPE ANY,
    56
      <l_fs1> TYPE ANY,
    57
      <l_fs2> TYPE ANY.
    58
    59
      LOOP AT gt_text_element ASSIGNING <ls_txt>
    60
          WHERE is_set = abap_false
    61
          AND ( NOT conc_v1 IS INITIAL
    62
                or NOT conc_copula IS INITIAL
    63
                OR NOT conc_v2 IS INITIAL ).
    64
        CLEAR l_str1.
    65
        CLEAR l_str2.
    66
        CLEAR l_text.
    67
        IF NOT <ls_txt>-conc_v1 IS INITIAL.
    68
          ASSIGN (<ls_txt>-conc_v1) TO <l_fs1>.
    69
          l_str1 = <l_fs1>.
    70
          UNASSIGN <l_fs1>.
    71
        ENDIF.
    72
        IF NOT <ls_txt>-conc_v2 IS INITIAL.
    73
          ASSIGN (<ls_txt>-conc_v2) TO <l_fs2>.
    74
          l_str2 = <l_fs2>.
    75
          UNASSIGN <l_fs2>.
    76
        ENDIF.
    77
        IF <ls_txt>-conc_sep_space = abap_false.
    78
          CONCATENATE l_str1 <ls_txt>-conc_copula l_str2
    79
              INTO l_text.
    80
        ELSE.
    81
          CONCATENATE l_str1 <ls_txt>-conc_copula l_str2
    82
              INTO l_text SEPARATED BY space.
    83
        ENDIF.
    84
    *Set text
    85
        IF NOT l_text IS INITIAL.
    86
          <ls_txt>-is_set = abap_true.
    87
          ASSIGN (<ls_txt>-fieldname) TO <l_fs>.
    88
          <l_fs> = l_text.
    89
          UNASSIGN <l_fs>.
    90
        ENDIF.
    91
      ENDLOOP.
    92
    ENDFORM.                    "text_tools_text_concatenated
    93
    94
    95
    *-----------------------------------------------------------------------
    96
    * text_tools_text_elements
    97
    *-----------------------------------------------------------------------
    98
    FORM text_tools_text_elements.
    99
      DATA:
    100
      l_text TYPE string,
    101
      l_val_text TYPE val_text,
    102
      l_str TYPE string.
    103
    104
      FIELD-SYMBOLS:
    105
      <ls_txt> TYPE st_text_element,
    106
      <ls_txtt> TYPE st_text_element_t,
    107
      <l_fs> TYPE ANY.
    108
    109
      LOOP AT gt_text_element ASSIGNING <ls_txt>.
    110
        CLEAR:
    111
        l_text,
    112
        l_str.
    113
    *Text from CSV
    114
        READ TABLE gt_text_element_t ASSIGNING <ls_txtt>
    115
            WITH KEY fieldname = <ls_txt>-fieldname
    116
                     spras = sy-langu.
    117
        IF sy-subrc = 0 AND NOT <ls_txtt>-text IS INITIAL.
    118
          <ls_txt>-is_set = abap_true.
    119
          l_text = <ls_txtt>-text.
    120
        ELSE.
    121
    *Default text in English from CSV
    122
          READ TABLE gt_text_element_t ASSIGNING <ls_txtt>
    123
              WITH KEY fieldname = <ls_txt>-fieldname
    124
                       spras = 'E'.
    125
          IF sy-subrc = 0.
    126
            l_text = <ls_txtt>-text.
    127
          ENDIF.
    128
        ENDIF.
    129
        UNASSIGN <ls_txtt>.
    130
    *Text from data element
    131
        IF <ls_txt>-is_set = abap_false
    132
        AND NOT <ls_txt>-dtel_rollname IS INITIAL.
    133
          PERFORM get_dtel_text
    134
            USING
    135
              <ls_txt>-dtel_rollname
    136
              <ls_txt>-dtel_field
    137
            CHANGING
    138
              l_str.
    139
          IF NOT l_str IS INITIAL.
    140
            <ls_txt>-is_set = abap_true.
    141
            l_text = l_str.
    142
          ENDIF.
    143
        ENDIF.
    144
    *Text from domain value
    145
        IF <ls_txt>-is_set = abap_false
    146
        AND NOT <ls_txt>-domname IS INITIAL.
    147
          PERFORM get_dom_value_text
    148
            USING
    149
              <ls_txt>-domname
    150
              <ls_txt>-domvalue
    151
            CHANGING
    152
              l_val_text.
    153
          IF NOT l_val_text IS INITIAL.
    154
            <ls_txt>-is_set = abap_true.
    155
            l_text = l_val_text.
    156
          ENDIF.
    157
        ENDIF.
    158
    *Text from icon
    159
        IF <ls_txt>-is_set = abap_false
    160
        AND NOT <ls_txt>-icon_id IS INITIAL.
    161
          PERFORM get_icon_text
    162
            USING
    163
              <ls_txt>-icon_id
    164
              <ls_txt>-icon_field
    165
            CHANGING
    166
              l_str.
    167
          IF NOT l_str IS INITIAL.
    168
            <ls_txt>-is_set = abap_true.
    169
            l_text = l_str.
    170
          ENDIF.
    171
        ENDIF.
    172
    *Set text
    173
        IF NOT l_text IS INITIAL.
    174
          ASSIGN (<ls_txt>-fieldname) TO <l_fs>.
    175
          <l_fs> = l_text.
    176
          UNASSIGN <l_fs>.
    177
        ENDIF.
    178
      ENDLOOP.
    179
    ENDFORM.                    "text_tools_text_elements
    180
    181
    182
    *-----------------------------------------------------------------------
    183
    * text_tools_text_message
    184
    *-----------------------------------------------------------------------
    185
    FORM text_tools_text_message.
    186
      DATA:
    187
      l_text TYPE string,
    188
      l_str1 TYPE string,
    189
      l_str2 TYPE string,
    190
      l_str3 TYPE string,
    191
      l_str4 TYPE string.
    192
    193
      FIELD-SYMBOLS:
    194
      <ls_txt> TYPE st_text_element,
    195
      <l_fs> TYPE ANY,
    196
      <l_fs1> TYPE ANY,
    197
      <l_fs2> TYPE ANY,
    198
      <l_fs3> TYPE ANY,
    199
      <l_fs4> TYPE ANY.
    200
    201
      LOOP AT gt_text_element ASSIGNING <ls_txt>
    202
          WHERE is_set = abap_false
    203
          AND NOT msg_id IS INITIAL.
    204
        CLEAR:
    205
        l_str1,
    206
        l_str2,
    207
        l_str3,
    208
        l_str4,
    209
        l_text.
    210
        IF NOT <ls_txt>-msg_v1 IS INITIAL.
    211
          ASSIGN (<ls_txt>-msg_v1) TO <l_fs1>.
    212
          IF <l_fs1> IS ASSIGNED.
    213
            l_str1 = <l_fs1>.
    214
          ENDIF.
    215
          UNASSIGN <l_fs1>.
    216
        ENDIF.
    217
        IF NOT <ls_txt>-msg_v2 IS INITIAL.
    218
          ASSIGN (<ls_txt>-msg_v2) TO <l_fs2>.
    219
          IF <l_fs2> IS ASSIGNED.
    220
            l_str2 = <l_fs2>.
    221
          ENDIF.
    222
          UNASSIGN <l_fs2>.
    223
        ENDIF.
    224
        IF NOT <ls_txt>-msg_v3 IS INITIAL.
    225
          ASSIGN (<ls_txt>-msg_v3) TO <l_fs3>.
    226
          IF <l_fs3> IS ASSIGNED.
    227
            l_str3 = <l_fs3>.
    228
          ENDIF.
    229
          UNASSIGN <l_fs3>.
    230
        ENDIF.
    231
        IF NOT <ls_txt>-msg_v4 IS INITIAL.
    232
          ASSIGN (<ls_txt>-msg_v4) TO <l_fs4>.
    233
          IF <l_fs4> IS ASSIGNED.
    234
            l_str4 = <l_fs4>.
    235
          ENDIF.
    236
          UNASSIGN <l_fs4>.
    237
        ENDIF.
    238
        PERFORM get_message_text
    239
          USING
    240
            <ls_txt>-msg_id
    241
            <ls_txt>-msg_nr
    242
            l_str1
    243
            l_str2
    244
            l_str3
    245
            l_str4
    246
          CHANGING
    247
            l_text.
    248
    *Set text
    249
        IF NOT l_text IS INITIAL.
    250
          <ls_txt>-is_set = abap_true.
    251
          ASSIGN (<ls_txt>-fieldname) TO <l_fs>.
    252
          <l_fs> = l_text.
    253
          UNASSIGN <l_fs>.
    254
        ENDIF.
    255
      ENDLOOP.
    256
    ENDFORM.                    "text_tools_text_message