很多时候我们需要在一个循环或者批量处理很多名称类似的变量,且这些变量名是可序的,即存在数字规律的,比如WORD01,WORD02等等。那么一个很好用的语法可以实现:VARYING 可以使用DO-VARING
DO 39 TIMES VARYING l_value FROM t_list_history_03-zhr_col01 NEXT t_list_history_03-zhr_col02.
PERFORM sub_set_cell_value USING application l_row l_col l_value.
l_row = l_row + 1.
ENDDO.
以下是SAP帮助文档
DO - varying
Syntax
DO ... VARYING dobj FROM dobj1 NEXT dobj2 [RANGE range].
[statement_block]
ENDDO.
Effect
: The addition VARYING assigns a new value to a variable dobj for each run of a DO loop. It can be used more than once in a DO statement.
dobj1 and dobj2 are the first two data objects in a sequence of data objects that are the same distance apart in the memory. The data types of the data objects dobj, dobj1, and dobj2 must be flat.
In Unicode programs, dobj, dobj1, and dobj2 must be compatible. Also in Unicode programs, dobj1 and dobj2 must either be structure components that belong to the same structure, or subareas of the same data object specified by offset/length specifications.
In the first completion of the loop, the content of the data object dobj1 is assigned to dobj, and in the second loop, the content of the data object dobj2 is assigned. In the subsequent loops, dobj is assigned the content of the data object that is the same distance in the memory from the previously assigned data object, as dobj2 is from dobj1. There is no type conversion.
If the processing block is not exited within the loop, the content of the variable dobj at the end of the loop run is assigned to the previously assigned data object dobj1 or dobj2 without conversion.
The addition RANGE determines the memory area that can be processed using the addition VARYING. After RANGE, an elementary data object range of type c, n, or x, or a structure can be specified. The memory area of range must include the ranges of dobj1 and dobj2. In deep structures, the deep components are exceptions to the permitted area. The DO loop must be ended before non-permitted memory areas are accessed, that is, areas outside of range or their deep components. Otherwise this may lead to an untreatable exception.
If RANGE is not explicitly specified, the permitted memory area is determined as follows:
- In non-Unicode programs and before release 6.10, the permitted memory area of dobj1 extends to the limit of the current data area of the ABAP program. If the RANGE addition is not specified, there is a danger of unintentionally overwriting the memory.
- In Unicode programs, , RANGE can only be omitted if it can be statically determined that dobj1 and dobj2 are components of the same structure. The permitted memory area is then determined from the smallest substructure that contains dobj1 and dobj2.
Note
: Instead of the addition VARYING, the statement ASSIGN should be used in the loop with the addition INCREMENT.
Example
: In the first DO loop, subareas of the data object text are edited using offset/length access. In Unicode programs, the addition RANGE must be specified here. In the second DO loop, the program accesses the components of the data object text. In this case, it is not necessary to specify RANGE. The third DO loop shows how the functions of the second loop can be programmed using the statement ASSIGN INCREMENT.
DATA: BEGIN OF text,
word1 TYPE c LENGTH 4 VALUE 'AAAA',
word2 TYPE c LENGTH 4 VALUE 'BBBB',
word3 TYPE c LENGTH 4 VALUE 'CCCC',
word4 TYPE c LENGTH 4 VALUE 'DDDD',
END OF text.
DATA: word TYPE c LENGTH 4,
char1 TYPE c LENGTH 1,
char2 TYPE c LENGTH 1,
leng TYPE i.
FIELD-SYMBOLS <word> LIKE text-word1.
DATA inc TYPE i.
DESCRIBE FIELD text LENGTH leng IN CHARACTER MODE.
leng = leng / 2.
DO leng TIMES VARYING char1 FROM text(1)
NEXT text+2(1) RANGE text
VARYING char2 FROM text+1(1)
NEXT text+3(1) RANGE text.
WRITE: char1, char2.
char1 = 'x'.
char2 = 'y'.
ENDDO.
DO 4 TIMES VARYING word FROM text-word1 NEXT text-word2.
WRITE / word.
ENDDO.
DO.
inc = sy-index - 1.
ASSIGN text-word1 INCREMENT inc TO <word> RANGE text.
IF sy-subrc = 0.
WRITE / <word>.
ELSE.
EXIT.
ENDIF.
ENDDO.
Exceptions
Non-Catchable Exceptions
-
Cause: Impermissible access to tables, strings, field or object references within the range specified by the RANGE addition.
Runtime Error: DO_WHILE_VARY_ILLEGAL_ACCESS -
Cause: Access to data outside the range specified by the RANGE addition.
Runtime Error: DO_WHILE_VARY_NOT_IN_RANGE
相关推荐
标题中提到的知识点是“Modeling and Identification of Linear Parameter-Varying Systems”,即线性参数时变系统(LPV)的建模与识别。LPV系统是指那些参数随着时间和外部环境变化而变化的系统,它们可以用来描述...
7. 出版信息:文档中还包含了ISBN、ISSN以及电子书的DOI信息,这些是出版物的标准标识,它们在全球范围内唯一识别一本出版物。这些信息表明该作品已经通过正式的出版流程发表,可以在学术图书馆或通过在线渠道获得。...
关于标题“Direction-of-arrival estimation with time-varying arrays via Bayesian multitask learning”的知识点非常专业,涉及无线通信和信号处理领域。首先需要明确的是,方向到达估计(Direction-of-Arrival, ...
to a computer with a camera connected to it, the camera feed is technically just a time-varying set of numbers. Enter computer vision. Computer vision is all about making robots intelligent enough to ...
In doping and post-treatment effect on holographic properties in In:Ce:Cu:LiNbO3 crystal,张涛,徐玉恒,A series of triply-doped In:Ce:Cu:LiNbO3 crystals with a varying level of In doping were grown ...
furthermore, in non-binary mode, some octet sequences are converted into other ones (in order to deal with varying end-of-line markers on different platforms). This may affect your ability to do ...
FDTD算法是解决电磁场问题的一种数值方法,尤其适用于计算时间-varying电磁场。它基于时间和空间的离散化,通过迭代更新场量(电场E和磁场H)来求解麦克斯韦方程组。这个算法的核心思想是将连续的三维空间分割成小的...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...
通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪(CEEMDAN)、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 1. EMD(经验...