-
Notifications
You must be signed in to change notification settings - Fork 0
/
abapassign_mem_area_writable_exp.html
282 lines (280 loc) · 15.3 KB
/
abapassign_mem_area_writable_exp.html
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="EN">
<!-- ABAPASSIGN_MEM_AREA_WRITABLE_EXP -->
<!-- Mirrored from help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapassign_mem_area_writable_exp.htm by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 20 Jan 2022 17:39:31 GMT -->
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="SAP">
<meta name="description" content="ASSIGN - writable_exp">
<title>
ASSIGN - writable_exp - ABAP Keyword Documentation
</title>
<link rel="icon" href="ABAPIcon.ico" type="image/ico">
<link rel="shortcut icon" href="ABAPIcon.ico">
<LINK rel="stylesheet" href="abap_docu.css" type="text/css">
<script type="text/JavaScript">
function call_link(linked_file)
{
if(parent.frames.length>0){
parent.window.frames["basefrm"].window.location = linked_file;
parent.window.frames["treeframe"].window.location = "abap_docu_tree92bd.html?file=" + linked_file;}
else {
window.location = linked_file;}
}
function urlToClipboard(id){
try{ var loc = top.location.href;}
catch(e){ alert( "URL cannnot be determined" ); return; }
var field = document.getElementById(id);
field.focus();
if ( loc.search( ".htm" ) == -1 && loc.search( ".HTM" ) == -1 ){ loc = loc + "index.htm"; }
if ( loc.search( "index.html" ) != -1
|| loc.search( "INDEX-2.html" ) != -1 ){
var off = loc.search( "file=" );
if ( off == -1 ){
field.value = loc + "?file=abapassign_mem_area_writable_exp.htm"; }
else {
field.value = loc.substring( 0, off ) + "file=abapassign_mem_area_writable_exp.htm";
}
}
else {
field.value = loc; }
field.setSelectionRange(0, field.value.length);
var r = confirm( "Copy URL to clipboard?\n\n" + field.value + "\n\nCopy to clipboard does not work in all browsers." );
if (r == true) {
try{
document.execCommand("copy");
}
catch(e){ alert( "URL could not be copied to clipboard" ); }
}
window.scrollTo(0,0);
}
</script>
</head>
<body>
<div class="all">
<p class="copyright">SAP NetWeaver AS ABAP Release 751, ©Copyright 2017 SAP AG. All rights reserved.
<input type="button" value="URL" style="font-size:8px; width:26px; height:16px; padding:0"
onclick="urlToClipboard('url')" title="Copy URL to Clipboard" >
</p>
<span class="path">
<a href="javascript:call_link('abenabap.html')" class="blue">ABAP - Keyword Documentation</a> →
<a href="javascript:call_link('abenabap_reference.html')" class="blue">ABAP - Reference</a> →
<a href="javascript:call_link('abenabap_data_working.html')" class="blue">Processing Internal Data</a> →
<a href="javascript:call_link('abenvalue_assignments.html')" class="blue">Assignments</a> →
<a href="javascript:call_link('abenreference_assignments.html')" class="blue">Assigning References</a> →
<a href="javascript:call_link('abenset_field_symbols.html')" class="blue">Setting Field Symbols</a> →
<a href="javascript:call_link('abapassign.html')" class="blue">ASSIGN</a> →
<a href="javascript:call_link('abapassign_mem_area.html')" class="blue">ASSIGN - mem_area</a> →
</span>
<p><span class="h1">
ASSIGN - writable_exp <br><br>
</span></p>
<P>
<a href="javascript:call_link('abapassign_shortref.html')" class="blue">Quick Reference</a> <br><br>
</P>
<p><span class="h2">
<span class="bold">Syntax</span>
</span></p>
<P>
<span class="qtext">... <a href="javascript:call_link('abennew_constructor_params_class.html')" class="blue">NEW class( ... )->attr</a> <i class=bn>|</i>
<a href="javascript:call_link('abenconstructor_expression_cast.html')" class="blue">CAST type( ... )->dobj</a> <br>
<i class=bn>|</i> <a href="javascript:call_link('abentable_expressions.html')" class="blue">table_exp</a> ...</span> <br><br>
</P>
<p><span class="h2">
Alternatives:
</span></p>
<P>
<A HREF="#!ABAP_ALTERNATIVE_1@1@" class="blue"> 1. <span class="qtext">... NEW class( ... )->attr <i class=bn>|</i> CAST type( ... )->dobj</span> </A> <br>
<br><A HREF="#!ABAP_ALTERNATIVE_2@2@" class="blue"> 2. <span class="qtext">... table_exp</span> </A> <br><br>
</P>
<p><span class="h4">
Effect
</span></p>
<P>
The operand position after <span class="qtext">ASSIGN</span> is a
<a href="javascript:call_link('abenresult_position_glosry.html')" class="grey" title="Glossary Entry">result position</a> in which
<a href="javascript:call_link('abenwritable_expression_glosry.html')" class="grey" title="Glossary Entry">writable expressions</a> can be specified. <br><br>
</P>
<p><span class="h4">
Note
</span></p>
<P>
Writable expressions can be specified for the memory are but not any other expressions, because only
writable expressions can have a non-temporary result. Assigning a temporary data object to a field symbol would not make sense. <br><br>
</P>
<p><span class="h2">
<A NAME="!ABAP_ALTERNATIVE_1@1@"></A> <span class="bold">Alternative 1</span>
</span></p>
<P>
<span class="qtext">... NEW class( ... )->attr <i class=bn>|</i> CAST type( ... )->dobj</span> <br><br><br><!-- /A -->
</P>
<p><span class="h4">
Effect
</span></p>
<P>
This alternative to specifying the memory area <a href="javascript:call_link('abapassign_mem_area.html')" class="blue"><span class="qtext">
mem_area</span></a> of the statement <a href="javascript:call_link('abapassign.html')" class="blue"><span class="qtext">ASSIGN</span></a> assigns the result of a
<a href="javascript:call_link('abenconstructor_expression_glosry.html')" class="grey" title="Glossary Entry">constructor expression</a>
</P>
<ul class="disc">
<li>
<a href="javascript:call_link('abennew_constructor_params_class.html')" class="blue"><span class="qtext">NEW class( ... )->attr</span></a>
<br><br></li>
<li>
<a href="javascript:call_link('abenconstructor_expression_cast.html')" class="blue"><span class="qtext">CAST type( ... )->dobj</span></a>
<br></li>
</ul>
<P>
to the field symbol. The same rules apply as when <a href="javascript:call_link('abapassign_mem_area_static_dobj.html')" class="blue">statically specifying</a> the memory area, but no offsets/lengths can be specified. <br><br>
</P>
<p><span class="h4">
Notes
</span></p>
<ul class="disc">
<li>
Assigning an attribute <span class="qtext">attr</span> of an object created using <span class="qtext">NEW</span> to a field symbol persists this object as long as the field symbol points to the attribute.
<br><br></li>
<li>
In this variant, the constructor expression in question sets the return code <span class="qtext">sy-subrc</span>, not the statement <span class="qtext">ASSIGN</span>.
<br></li>
</ul>
<ul class="circlem2">
<li>If the object is created successfully, the instance operator <span class="qtext">NEW</span> sets the return code <span class="qtext">sy-subrc</span> to 0.</li>
</ul>
<ul class="circlem2">
<li>The casting operator <span class="qtext">CAST</span> does not set the return code <span class="qtext">sy-subrc</span>.</li>
</ul>
<p><span class="h4">
Example
</span></p>
<p>
Constructor expression with <span class="qtext">NEW</span> in the specified memory area of the statement
<span class="qtext">ASSIGN</span>. The assignment of the attribute <span class="qtext">attr</span> to a field symbol persists the object.
</p>
<p class="qtextml1">
<span class="qtext">
CLASS class DEFINITION. <br> PUBLIC SECTION. <br> DATA attr TYPE string VALUE 'foo'. <br>
ENDCLASS. <br> <br>START-OF-SELECTION. <br> ASSIGN NEW class( )->attr TO FIELD-SYMBOL(<fs>). <br> cl_demo_output=>display( <fs> ).
</span>
</p>
<p><span class="h4">
Example
</span></p>
<p>
Constructor expression with <span class="qtext">CAST</span> in the specified memory area of <span class="qtext">ASSIGN</span> statements.
</p>
<p class="qtextml1">
<span class="qtext">
TYPES: BEGIN OF t_struc, <br> col1 TYPE i, <br> col2 TYPE i, <br>
END OF t_struc. <br> <br>DATA dref TYPE REF TO data. <br>DATA struc TYPE t_struc. <br>
<br>dref = NEW t_struc( ). <br> <br>ASSIGN CAST t_struc( dref )->col1 TO FIELD-SYMBOL(<col1>). <br>ASSIGN CAST t_struc( dref )->col2 TO FIELD-SYMBOL(<col2>). <br><br>
</span>
</p>
<p><span class="h2">
<A NAME="!ABAP_ALTERNATIVE_2@2@"></A> <span class="bold">Alternative 2</span>
</span></p>
<P>
<span class="qtext">... table_exp</span> <br><br><br><!-- /A -->
</P>
<p><span class="h4">
Effect
</span></p>
<P>
This alternative way of specifying the memory area <a href="javascript:call_link('abapassign_mem_area.html')" class="blue"><span class="qtext">
mem_area</span></a> of the statement <a href="javascript:call_link('abapassign.html')" class="blue"><span class="qtext">ASSIGN</span></a> assigns the result of the
<a href="javascript:call_link('abentable_expression_glosry.html')" class="grey" title="Glossary Entry">table expression</a> <a href="javascript:call_link('abentable_expressions.html')" class="blue"><span class="qtext">table_exp</span></a> or
<a href="javascript:call_link('abentable_exp_chaining.html')" class="blue">table expression chaining</a> to the field symbol. The result of a table expression in these positions is always a temporary field symbol.
</P>
<ul class="disc">
<li>If a single table expression is specified, or a
<a href="javascript:call_link('abentable_exp_chaining.html')" class="blue">chaining</a> whose last position is a table expression, the entire row that was found is assigned to the field symbol.</li>
</ul>
<ul class="disc">
<li>If a <a href="javascript:call_link('abentable_exp_chaining.html')" class="blue">chaining</a> is specified whose last position
is a structure component after a structure component selector, this component is assigned to the field symbol. No offsets/lengths, however, can be specified for the structure component here.</li>
</ul>
<P>
In this variant, the statement <span class="qtext">ASSIGN</span> sets the return code <span class="qtext">sy-subrc</span>.
</P>
<ul class="disc">
<li>
If the specified row is not found, <span class="qtext">sy-subrc</span> is set to 0.
<br><br></li>
<li>
If the row is not found, <span class="qtext">sy-subrc</span> is set to 4, except when the end of the table is reached in binary searches in
<a href="javascript:call_link('abensorted_table_glosry.html')" class="grey" title="Glossary Entry">sorted tables</a>. In this case, <span class="qtext">sy-subrc</span> is set to 8.
<br></li>
</ul>
<P>
Unlike when table expressions are used in other ways, the system field <span class="qtext">sy-tabix</span>
is set here in the same way as in a corresponding <a href="javascript:call_link('abapread_table.html')" class="blue"><span class="qtext">READ TABLE</span></a> statement.
</P>
<P>
If the assignment is not successful, the field symbol keeps its previous state. In this variant, it is therefore not enough just to evaluate the
<a href="javascript:call_link('abenpredicate_expression_glosry.html')" class="grey" title="Glossary Entry">predicate expression</a>
<a href="javascript:call_link('abenlogexp_assigned.html')" class="blue"><span class="qtext"><fs> IS ASSIGNED</span></a>; <span class="qtext">sy-subrc</span> needs to be checked as well.
</P>
<P>
In the case of this variant of the statement <span class="qtext">ASSIGN</span>, the addition <a href="javascript:call_link('abapassign_casting.html')" class="blue">
<span class="qtext">CASTING</span></a> can only be specified in assignments to an existing field symbol and not in
<a href="javascript:call_link('abenfield-symbol_inline.html')" class="blue">inline declarations</a>, and only as a standalone
addition. The addition <a href="javascript:call_link('abapassign_range.html')" class="blue"><span class="qtext">RANGE</span></a> cannot be specified.
</P>
<p><span class="h4">
Notes
</span></p>
<ul class="disc">
<li>
This variant of the statement <span class="qtext">ASSIGN</span> can be viewed as a different form of <a href="javascript:call_link('abapread_table_outdesc.html')" class="blue"><span class="qtext">READ TABLE ... ASSIGNING ...</span></a>.
<br></li>
</ul>
<ul class="circlem2">
<li>More specifically, the value of <span class="qtext">sy-subrc</span> and <span class="qtext">sy-tabix</span> is set as in the statement <span class="qtext">READ TABLE</span> and</li>
</ul>
<ul class="circlem2">
<li>the addition <a href="javascript:call_link('abapassign_casting.html')" class="blue"><span class="qtext">CASTING</span></a> cannot be specified after an
<a href="javascript:call_link('abenfield-symbol_inline.html')" class="blue">inline declaration</a> for the field symbol.</li>
</ul>
<dl><dd>
Unlike <span class="qtext">READ TABLE</span>, chainings can be used here to assign components of read rows or rows from nested internal tables.
</dd></dl>
<ul class="disc">
<li>
The constructor operators <span class="qtext">VALUE</span> and <span class="qtext">REF</span> used to control the <a href="javascript:call_link('abentable_exp_result.html')" class="blue">result</a> of the table expression cannot be used here.
<br><br></li>
<li>
If the specified row is not found, an exception is not raised (unlike in other uses of table expressions).
<br></li>
</ul>
<p><span class="h4">
Example
</span></p>
<P>
This example works in the same way as the example for <a href="javascript:call_link('abapread_table_outdesc.html')" class="blue"><span class="qtext">
READ TABLE ... ASSIGNING ...</span></a>. Here, the <span class="qtext">READ</span> statement is replaced by an <span class="qtext">ASSIGN</span> statements and the required component is assigned directly.
</P>
<p class="qtextml1">
<span class="qtext">
PARAMETERS: p_carrid TYPE sflight-carrid, <br> p_connid TYPE sflight-connid, <br>
p_fldate TYPE sflight-fldate. <br>
<br>DATA sflight_tab TYPE SORTED TABLE OF sflight <br> WITH UNIQUE KEY carrid connid fldate. <br>
<br>SELECT * <br> FROM sflight <br> WHERE carrid = @p_carrid AND <br>
connid = @p_connid <br> INTO TABLE @sflight_tab. <br>
<br>IF sy-subrc = 0. <br> ASSIGN sflight_tab[ KEY primary_key COMPONENTS <br>
carrid = p_carrid <br>
connid = p_connid <br>
fldate = p_fldate ]-price <br>
TO FIELD-SYMBOL(<price>). <br> IF sy-subrc = 0. <br> <price> = <price> * '0.9'. <br> ENDIF. <br>ENDIF.
</span>
</p>
<br>
<br>
<br>
<br>
</DIV>
<fieldset style="opacity:0">
<input id="url" type="text" />
</fieldset>
</BODY>
<!-- Mirrored from help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapassign_mem_area_writable_exp.htm by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 20 Jan 2022 17:39:31 GMT -->
</html>