INSERT
INSERT zavto FROm TABLE avto ACCEPTING DUPLICATE KEYS.
UPDATE и Полное удаление записей в таблице
DATA avto TYPE TABLE OF zavto WITH HEADER LINE.
SELECT * FROM zavto INTO TABLE avto.
DO 5 TIMES.
avto–car_mass = sy–index + 100.
avto–name = ‘car’ && sy–index.
UPDATE zavto FROM avto .
ENDDO.
dat–car_mass = ’10’.
DELETE FROM zavto.
INSERT zavto FROm TABLE avto ACCEPTING DUPLICATE KEYS.
SELECT SINGLE
SELECT SINGLE * FROM zavto INTO z.
WRITE z–name.
SELECT С Условием
SELECT * FROM zavto INTO TABLE avto WHERE ( name = ‘car1’ ) AND ( car_mass > 0 ) .
SELECT с BETWEEN
SELECT * FRom zavto INTO TABLE avto WHERE car_mass BETWEEN 103 AND 110.
JOIN
INSERT ZINNERAVTO FROM TABLE inner_avto ACCEPTING DUPLICATE KEYS.
SELECT SINGLE F~car_mass F~name P~total_mass
INTO ( avto–car_mass, avto–name, inner_avto–total_mass )
FROM zavto AS F
JOIN ZINNERAVTO AS P ON P~name = F~name.
ПОДПРОГРАММЫ И ВЫЗОВ
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 |
DATA: w_var type s_carrid. Perform sub_routine. FORM sub_routine. DATA: w_var TYPE s_carrid. ENDFORM. <strong>USING DATA </strong><span class="L0S52">DATA </span>int <span class="L0S52">TYPE </span><span class="L0S52">I</span><span class="L0S55">.</span> <span class="L0S52">PERFORM </span>read_data <span class="L0S52">CHANGING </span>int<span class="L0S55">.</span> <span class="L0S52">FORM </span>read_data <span class="L0S52">CHANGING </span><span class="L0S52">VALUE</span><span class="L0S55">(</span>r_data<span class="L0S55">)</span><span class="L0S55">.</span> <span class="L0S52">ENDFORM</span><span class="L0S55">.</span> <strong>EXAMPLE CALC </strong> <!--StartFragment --><span class="L0S52">DATA</span><span class="L0S55">: </span>a1 <span class="L0S52">TYPE </span><span class="L0S52">i</span><span class="L0S55">,</span> a2 <span class="L0S52">TYPE </span><span class="L0S52">i</span><span class="L0S55">,</span> a3 <span class="L0S52">TYPE </span><span class="L0S52">i</span><span class="L0S55">.</span> a1 <span class="L0S55">= </span><span class="L0S32">10</span><span class="L0S55">.</span> a2 <span class="L0S55">= </span><span class="L0S32">10</span><span class="L0S55">.</span> a3 <span class="L0S55">= </span><span class="L0S32">10</span><span class="L0S55">.</span> <span class="L0S52">PERFORM </span>calc <span class="L0S52">USING </span>a1 a2 a3<span class="L0S55">.</span> <span class="L0S52">WRITE </span>a3<span class="L0S55">.</span> <span class="L0S52">FORM </span>calc <span class="L0S52">CHANGING </span>f1 f2 f3<span class="L0S55">. "По ссылке <!--StartFragment --><span class="L0S52">"FORM </span>calc <span class="L0S52">CHANGING </span><span class="L0S52">VALUE</span><span class="L0S55">(</span>f1<span class="L0S55">) </span><span class="L0S52">VALUE</span><span class="L0S55">(</span>f2<span class="L0S55">) </span><span class="L0S52">VALUE</span><span class="L0S55">(</span>f3<span class="L0S55">)</span><span class="L0S55">.</span> По значению</span> f3 <span class="L0S55">= </span>f1 + f2 * f3<span class="L0S55">.</span> <span class="L0S52">ENDFORM</span><span class="L0S55">. <strong><span style="text-decoration: underline;">ПОДЗАПРОСЫ</span> </strong><span class="L0S52">DATA </span>ztab <span class="L0S52">TYPE </span><span class="L0S52">TABLE </span><span class="L0S52">OF </span>zavto <span class="L0S52">WITH </span><span class="L0S52">HEADER </span><span class="L0S52">LINE</span><span class="L0S55">.</span> <span class="L0S52">SELECT </span>* <span class="L0S52">FROM </span>zavto <span class="L0S52">INTO </span><span class="L0S52">TABLE </span>ztab <span class="L0S52">WHERE </span>name <span class="L0S52">IN </span><span class="L0S55">( </span><span class="L0S52">SELECT </span>name <span class="L0S52">FROM </span>zavto <span class="L0S52">where </span>name <span class="L0S55">= </span><span class="L0S33">'car1' </span><span class="L0S55">)</span><span class="L0S55">.</span> <strong>ФМ с параметром EXPORT табличного типа </strong><span class="L0S52">DATA </span>it_table <span class="L0S52">TYPE </span>zkre_t_productsdenisov<span class="L0S55">.</span> <span class="L0S52">DATA </span>wa_table <span class="L0S52">LIKE </span><span class="L0S52">LINE </span><span class="L0S52">OF </span>it_table<span class="L0S55">.</span> <span class="L0S52">CALL </span><span class="L0S52">FUNCTION </span><span class="L0S33">'ZET_PRIDUCT'</span> <span class="L0S52">IMPORTING</span> product <span class="L0S55">= </span>it_table<span class="L0S55">.</span> <span class="L0S52">LOOP </span><span class="L0S52">AT </span>it_table <span class="L0S52">INTO </span>wa_table<span class="L0S55">.</span> <span class="L0S52">WRITE </span>/ wa_table<span class="L0S70">-</span>name<span class="L0S55">.</span> <span class="L0S52">ENDLOOP</span><span class="L0S55">.</span> <strong>ПРИМЕР отчета</strong> <!--StartFragment --><span class="L0S31">*&---------------------------------------------------------------------*</span> <span class="L0S31">*& Report ZFIRST_OTCHET_DENISOV</span> <span class="L0S31">*&</span> <span class="L0S31">*&---------------------------------------------------------------------*</span> <span class="L0S31">*&</span> <span class="L0S31">*&</span> <span class="L0S31">*&---------------------------------------------------------------------*</span> <span class="L0S52">REPORT </span>zfirst_otchet_denisov<span class="L0S55">.</span> <span class="L0S52">DATA </span>itab <span class="L0S52">TYPE </span><span class="L0S52">TABLE </span><span class="L0S52">OF </span>dd02l <span class="L0S52">WITH </span><span class="L0S52">HEADER </span><span class="L0S52">LINE</span><span class="L0S55">.</span> <span class="L0S52">DATA </span>itab2 <span class="L0S52">TYPE </span><span class="L0S52">TABLE </span><span class="L0S52">OF </span>dd03l <span class="L0S52">WITH </span><span class="L0S52">HEADER </span><span class="L0S52">LINE</span><span class="L0S55">.</span> <span class="L0S52">TYPES</span><span class="L0S55">: </span><span class="L0S52">BEGIN </span><span class="L0S52">OF </span>pers_data<span class="L0S55">,</span> tabname <span class="L0S52">TYPE </span>dd02l<span class="L0S70">-</span>tabname<span class="L0S55">,</span> as4user <span class="L0S52">TYPE </span>dd02l<span class="L0S70">-</span>as4user<span class="L0S55">,</span> fieldname <span class="L0S52">TYPE </span>dd03l<span class="L0S70">-</span>fieldname<span class="L0S55">,</span> datatype <span class="L0S52">TYPE </span>dd03l<span class="L0S70">-</span>datatype<span class="L0S55">,</span> <span class="L0S52">END </span><span class="L0S52">OF </span>pers_data<span class="L0S55">.</span> <span class="L0S52">DATA </span>result <span class="L0S52">TYPE </span><span class="L0S52">TABLE </span><span class="L0S52">OF </span>pers_data <span class="L0S52">WITH </span><span class="L0S52">HEADER </span><span class="L0S52">LINE</span><span class="L0S55">.</span> <span class="L0S52">SELECT-OPTIONS </span>name <span class="L0S52">FOR </span>itab<span class="L0S70">-</span>tabname<span class="L0S55">.</span> <span class="L0S52">SELECT-OPTIONS </span>user <span class="L0S52">FOR </span>itab<span class="L0S70">-</span>as4user<span class="L0S55">.</span> <span class="L0S52">START-OF-SELECTION</span><span class="L0S55">.</span> <span class="L0S52">SELECT </span>f<span class="L0S70">~</span>tabname f<span class="L0S70">~</span>as4user p<span class="L0S70">~</span>fieldname p<span class="L0S70">~</span>datatype <span class="L0S31">"INTO corresponding fields of table ( itab-tabname, itab-as4user, itab2-fieldname, itab2-datatype )</span> <span class="L0S52">INTO </span>CORRESPONDING <span class="L0S52">FIELDS </span><span class="L0S52">OF </span><span class="L0S52">TABLE </span>result <span class="L0S52">FROM </span>dd02l <span class="L0S52">AS </span>f <span class="L0S52">JOIN </span>dd03l <span class="L0S52">AS </span>p <span class="L0S52">ON </span>f<span class="L0S70">~</span>tabname <span class="L0S55">= </span>p<span class="L0S70">~</span>tabname <span class="L0S52">WHERE </span>f<span class="L0S70">~</span>tabname <span class="L0S52">IN </span>name <span class="L0S52">AND </span>as4user <span class="L0S52">IN </span>user <span class="L0S52">AND </span>tabclass <span class="L0S55">= </span><span class="L0S33">'TRANSP'</span><span class="L0S55">.</span> <span class="L0S52">LOOP </span><span class="L0S52">AT </span>result<span class="L0S55">.</span> <span class="L0S52">WRITE</span><span class="L0S55">: </span>/ result<span class="L0S70">-</span>tabname<span class="L0S55">, </span>result<span class="L0S70">-</span>as4user<span class="L0S55">, </span>result<span class="L0S70">-</span>fieldname<span class="L0S55">, </span>result<span class="L0S70">-</span>datatype<span class="L0S55">.</span> <span class="L0S52">ENDLOOP</span><span class="L0S55">.</span> <strong>ALV GRIDE </strong>*&---------------------------------------------------------------------* *& Report ZFIRST_OTCHET_DENISOV *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zfirst_otchet_denisov. DATA itab TYPE dd02l. DATA: grid1 TYPE REF TO cl_gui_alv_grid, custom_container1 TYPE REF TO cl_gui_custom_container. TYPES: BEGIN OF pers_data, tabname TYPE dd02l-tabname, as4user TYPE dd02l-as4user, fieldname TYPE dd03l-fieldname, datatype TYPE dd03l-datatype, END OF pers_data. DATA result TYPE TABLE OF pers_data WITH HEADER LINE. SELECT-OPTIONS name FOR itab-tabname. SELECT-OPTIONS user FOR itab-as4user. START-OF-SELECTION. * SELECT f~tabname f~as4user p~fieldname p~datatype * "INTO corresponding fields of table ( itab-tabname, itab-as4user, itab2-fieldname, itab2-datatype ) * INTO CORRESPONDING FIELDS OF TABLE result * FROM dd02l AS f * JOIN dd03l AS p ON f~tabname = p~tabname * WHERE f~tabname IN name * AND as4user IN user * AND tabclass = 'TRANSP'. * LOOP AT result. * WRITE: / result-tabname, result-as4user, result-fieldname, result-datatype. * ENDLOOP. "--------------------------ALV TEST REPORT------------------------------------ DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE. PERFORM data_retrieval. PERFORM build_fieldcatalog. PERFORM display_alv_report. FORM build_fieldcatalog. fieldcatalog-fieldname = 'tabname'. fieldcatalog-seltext_m = 'Tabname'. fieldcatalog-col_pos = 0. fieldcatalog-outputlen = 10. fieldcatalog-emphasize = 'X'. fieldcatalog-key = 'X'. APPEND fieldcatalog. fieldcatalog-fieldname = 's4user'. fieldcatalog-seltext_m = 's4user'. fieldcatalog-col_pos = 1. APPEND fieldcatalog TO fieldcatalog. CLEAR fieldcatalog. fieldcatalog-fieldname = 'fieldname'. fieldcatalog-seltext_m = 'Fieldname'. fieldcatalog-col_pos = 2. APPEND fieldcatalog TO fieldcatalog. CLEAR fieldcatalog. fieldcatalog-fieldname = 'datatype'. fieldcatalog-seltext_m = 'Datatype'. fieldcatalog-col_pos = 3. APPEND fieldcatalog TO fieldcatalog. CLEAR fieldcatalog. ENDFORM. FORM display_alv_report. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING it_fieldcat = fieldcatalog[] i_save = 'X' TABLES t_outtab = result EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. " DISPLAY_ALV_REPORT FORM data_retrieval. SELECT f~tabname f~as4user p~fieldname p~datatype INTO CORRESPONDING FIELDS OF TABLE result FROM dd02l AS f JOIN dd03l AS p ON f~tabname = p~tabname WHERE f~tabname IN name AND as4user IN user AND tabclass = 'TRANSP'. ENDFORM. </span> |