Wednesday, June 27, 2018

Display Lines Of Code in websites

just hit the site http://hilite.me/,

Create, Update, Delete, Read Using Container in Screen Painter

first things first,  you need to create the screen, and on that screen make container with name 'CONT_1'.


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
*******************************
DATA:
  g_container        TYPE scrfname VALUE 'CONT_1', 
  grid1              TYPE REF TO cl_gui_alv_grid,
  g_custom_container TYPE REF TO cl_gui_custom_container.
*******************************

MODULE user_command_0400 INPUT.
  CASE sy-ucomm.
    WHEN 'CHANGE'.
      SET PF-STATUS 'ALV1'.
    WHEN 'SAVE'.
*     Lock the table
      CALL FUNCTION 'ENQUEUE_E_TABLE'
        EXPORTING
          mode_rstable   = 'E'
          tabname        = 'ZTBFI0020' "viewname
        EXCEPTIONS
          foreign_lock   = 1
          system_failure = 2
          OTHERS         = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      IF NOT grid1 IS INITIAL .
        CALL METHOD grid1->check_changed_data .
      ENDIF .
      SORT i_mod BY row.
      DELETE ADJACENT DUPLICATES  FROM i_mod COMPARING row.
      lh_norec = LINES( i_mod ).
      lh_total = lh_norec.
      SHIFT lh_total LEFT DELETING LEADING space.
*  Standard Table Update
      IF i_mod[] IS NOT INITIAL.
        LOOP AT i_mod INTO lwa_mod.
          READ TABLE <i_itab> INTO <wa_tab> INDEX lwa_mod-row.
          IF sy-subrc = 0 .
            IF lh_flag NE 'X'.
              ASSIGN COMPONENT 'TBLTYPE' OF STRUCTURE <wa_tab> to <ttype>.
             IF <ttype> is   ASSIGNED.
               <ttype> = '1'.
             ENDIF.
              MODIFY ZTBFI0020 FROM <wa_tab>.
*              MODIFY (viewname) FROM <wa_tab>.
            ELSE.
             ASSIGN COMPONENT 'TBLTYPE' OF STRUCTURE <wa_tab> to <ttype>.
             IF <ttype> is   ASSIGNED.
               <ttype> = '1'.
             ENDIF.
              INSERT ZTBFI0020 FROM <wa_tab>.
*              INSERT (viewname) FROM <wa_tab>.
              IF sy-subrc NE 0.
*                MESSAGE e009.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.
        CONCATENATE lh_total '  ' text-s01 INTO lh_succ SEPARATED BY space.
*        MESSAGE i000 WITH lh_succ.

        MESSAGE text-001 type 'S'.
      ELSE.
*        MESSAGE i000 WITH text-s02.

        MESSAGE text-002 type 'S'.
      ENDIF.
*     Unlock the table
      CALL FUNCTION 'DEQUEUE_E_TABLE'
        EXPORTING
          mode_rstable = 'E'
          tabname      = 'ZTBFI0020' ."viewname.
      CLEAR : i_mod[],
              lh_flag.
    WHEN 'DELETE'.
*      Selecting Selected Rows
      PERFORM handle_user_command USING sy-ucomm.
      IF i_del[] IS NOT INITIAL.
        LOOP AT i_del INTO lwa_del.
          READ TABLE <i_itab> INTO <wa_tab> INDEX lwa_del-row.
          IF sy-subrc = 0.
            DELETE ZTBFI0020 FROM <wa_tab>.
*            DELETE (viewname) FROM <wa_tab>.
          ENDIF.
        ENDLOOP.
        lh_totdel = LINES( i_del ).
*        MESSAGE i011 WITH lh_totdel.

        MESSAGE text-003 type 'S'.
        CLEAR : i_del[], lh_totdel .
      ELSE.
*        MESSAGE i000 WITH text-s03.
        MESSAGE text-002 type 'S'.
      ENDIF.
    WHEN 'EXIT'   OR '&F03' or '&F04' or '&F05' or
         'BACK'   OR
         'CANCEL'.
      CLEAR : li_fieldcat[],
              i_exclude[],
              i_del[],
              lh_totdel.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0400  INPUT


*&---------------------------------------------------------------------*
*&      Module  STATUS_0400  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0400 OUTPUT.


  SET PF-STATUS 'STATUS_TABL'.
  SET TITLEBAR 'Entry Value Pengukuran Kembali'.
*DATA :
*    gr_event_handler TYPE REF TO lcl_event_handler .
* Creating an instance for the event handler
  CREATE OBJECT gr_event_handler .
  TRY.
*      CREATE DATA i_table TYPE ZTBFI0020.
      CREATE DATA i_table TYPE TABLE OF   ('ZTBFI0020').
      ASSIGN i_table->* TO <i_itab>.
      CREATE DATA wa_all LIKE LINE OF <i_itab>.
      ASSIGN wa_all->* TO <wa_tab>.
*     Selecting data dynamically
      SELECT * FROM ZTBFI0020 INTO TABLE <i_itab> WHERE TBLTYPE eq '1'.
*      SELECT * FROM (viewname) INTO TABLE <i_itab>.
*     Building the fieldcatelog
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'ZTBFI0020' " viewname
        CHANGING
          ct_fieldcat            = li_fieldcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.

        READ TABLE li_fieldcat INTO lwa_fieldcat WITH KEY fieldname = 'MONAT'.
        IF sy-subrc eq 0.
          lwa_fieldcat-OUTPUTLEN = '6'.
          MODIFY li_fieldcat FROM lwa_fieldcat  INDEX sy-tabix TRANSPORTING OUTPUTLEN.
        ENDIF.

        READ TABLE li_fieldcat INTO lwa_fieldcat WITH KEY fieldname = 'TBLTYPE'.
        IF sy-subrc eq 0.
          lwa_fieldcat-tech = 'X'.
          MODIFY li_fieldcat FROM lwa_fieldcat  INDEX sy-tabix TRANSPORTING tech.
        ENDIF.

        CLEAR lwa_fieldcat.
        READ TABLE li_fieldcat INTO lwa_fieldcat WITH KEY fieldname = 'ZNUMC'.
        IF sy-subrc eq 0.
          lwa_fieldcat-col_pos = '3'.
          lwa_fieldcat-OUTPUTLEN = '6'.
          MODIFY li_fieldcat FROM lwa_fieldcat  INDEX sy-tabix TRANSPORTING col_pos OUTPUTLEN.
        ENDIF.

          CLEAR lwa_fieldcat.
        READ TABLE li_fieldcat INTO lwa_fieldcat WITH KEY fieldname = 'BUKRS'.
        IF sy-subrc eq 0.
          lwa_fieldcat-col_pos = '6'.
          MODIFY li_fieldcat FROM lwa_fieldcat  INDEX sy-tabix TRANSPORTING col_pos.
        ENDIF.


      ENDIF.
*     Making fields editable except key fields
      IF sy-ucomm = 'UPD' OR  sy-ucomm = 'CHANGE'.
        LOOP AT li_fieldcat INTO lwa_fieldcat.
          IF lwa_fieldcat-key = space.
            lwa_fieldcat-edit = 'X'.
            MODIFY li_fieldcat FROM lwa_fieldcat.
          ENDIF.
        ENDLOOP.
      ENDIF.
*     Making fields editable
      IF sy-ucomm = 'NEW'.
        LOOP AT li_fieldcat INTO lwa_fieldcat.
          lwa_fieldcat-edit = 'X'.
          MODIFY li_fieldcat FROM lwa_fieldcat.
        ENDLOOP.
        lh_flag = 'X'.
        CLEAR : <i_itab>.
        DO 100 TIMES.
          APPEND <wa_tab> TO <i_itab>.
        ENDDO.
      ENDIF.
*     Exclude buttons
      PERFORM exclude_tb_functions CHANGING i_exclude.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
          EXPORTING
            container_name = g_container.
        CREATE OBJECT grid1
          EXPORTING
            i_parent = g_custom_container.
      ENDIF.
*     Making all fields non-editable if display mode
      IF sy-ucomm = 'SHOW'.
        LOOP AT li_fieldcat INTO lwa_fieldcat.
          lwa_fieldcat-edit = ' '.
          MODIFY li_fieldcat FROM lwa_fieldcat.
        ENDLOOP.
      ENDIF.
      IF sy-ucomm = 'SAVE'.
        LOOP AT li_fieldcat INTO lwa_fieldcat.
          IF lwa_fieldcat-key NE space.
            lwa_fieldcat-edit = space.
            MODIFY li_fieldcat FROM lwa_fieldcat.
          ENDIF.
        ENDLOOP.
      ENDIF.
*     Displaying ALV Grid
      CALL METHOD grid1->set_table_for_first_display
        EXPORTING
          i_structure_name     = 'ZTBFI0020' "viewname
          it_toolbar_excluding = i_exclude
        CHANGING
          it_outtab            = <i_itab>
          it_fieldcatalog      = li_fieldcat.
      IF sy-subrc NE 0.
        EXIT.
      ENDIF.

      CALL METHOD grid1->SET_GRIDTITLE
      EXPORTING
      I_GRIDTITLE = 'Entry Value Pengukuran Kembali'.
*      Getting the changed data
      SET HANDLER gr_event_handler->handle_data_changed FOR grid1 .
    CATCH cx_sy_create_data_error.
  ENDTRY.
ENDMODULE.                 " STATUS_0400  OUTPUT