** F O R
** FOR
**
** Uma forma de looping mas como expressão
* T_X = VALUE dtype|#(FOR wa IN t_base(field = wa-field))
** Criando uma tabela à partir de outra
** (T_CUSTOMER à partir de T_ORDER)
**
types: begin of y_t_customer,
kunnr type kunnr ,
end of y_t_customer.
types: begin of y_customer,
kunnr type kunnr ,
end of y_customer.
data t_order type table of y_customer WITH HEADER LINE.
data s_order type y_customer .
data t_customer type table of kunnr WITH HEADER LINE.
* Sem FOR: LOOP como instrução
LOOP AT t_order into data(ls_order).
APPEND value y_customer( kunnr = s_order-kunnr )
to t_customer.
ENDLOOP.
* COM FOR: LOOP como instrução
t_customer =
VALUE y_t_customer(
FOR s_order IN t_order ( kunnr = s_order-kunnr )
).
* COM FOR: LOOP como instrução + clasula WHERE
t_customer =
VALUE y_t_customer(
FOR s_order IN t_order
WHERE ( AUART = 'AB' )
( kunnr = s_order-kunnr )
).
** Quando a base não é uma tabela interna
** (criar tabela com o quadrado do numero (de 1 a 10)
**
types: begin of y_sqr,
nbase type i,
sqr type i,
end of y_sqr,
y_t_sqr type STANDARD TABLE OF y_sqr WITH DEFAULT KEY .
data(t_srq10) =
VALUE y_t_sqr(
FOR i = 1 then i + 1 UNTIL i > 10
(
nbase = i
sqr = ( i * i )
)
).
** FOR
**
** Uma forma de looping mas como expressão
* T_X = VALUE dtype|#(FOR wa IN t_base(field = wa-field))
** Criando uma tabela à partir de outra
** (T_CUSTOMER à partir de T_ORDER)
**
types: begin of y_t_customer,
kunnr type kunnr ,
end of y_t_customer.
types: begin of y_customer,
kunnr type kunnr ,
end of y_customer.
data t_order type table of y_customer WITH HEADER LINE.
data s_order type y_customer .
data t_customer type table of kunnr WITH HEADER LINE.
* Sem FOR: LOOP como instrução
LOOP AT t_order into data(ls_order).
APPEND value y_customer( kunnr = s_order-kunnr )
to t_customer.
ENDLOOP.
* COM FOR: LOOP como instrução
t_customer =
VALUE y_t_customer(
FOR s_order IN t_order ( kunnr = s_order-kunnr )
).
* COM FOR: LOOP como instrução + clasula WHERE
t_customer =
VALUE y_t_customer(
FOR s_order IN t_order
WHERE ( AUART = 'AB' )
( kunnr = s_order-kunnr )
).
** Quando a base não é uma tabela interna
** (criar tabela com o quadrado do numero (de 1 a 10)
**
types: begin of y_sqr,
nbase type i,
sqr type i,
end of y_sqr,
y_t_sqr type STANDARD TABLE OF y_sqr WITH DEFAULT KEY .
data(t_srq10) =
VALUE y_t_sqr(
FOR i = 1 then i + 1 UNTIL i > 10
(
nbase = i
sqr = ( i * i )
)
).