MUNDOSAP

MUNDOSAP (foro/index.php)
-   Programación ABAP IV (foro/forumdisplay.php?f=4)
-   -   Duda con inserción a itab (foro/showthread.php?t=67214)

funkeeiads 02/06/13 22:48:30

Duda con inserción a itab
 
Hola a todos, tengo una consulta que no me deja tranquilo.

Codigo de ejemplo:
DATA : it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE INITIAL SIZE 10.

DATA : wa TYPE ty_test.


it_test-code = 300.
it_test-name = 'Ramesh'.
it_test-amount = 5500.
APPEND it_test.

*acá se puede asignar directamente.

wa-code = 207.
wa-name = 'Prem'.
wa-amount = 5000.
APPEND wa TO it_test.

*aca se usó un workarea.

it_test-code = 117.
it_test-name = 'James Bond'.
it_test-amount = 9900.
INSERT it_test INDEX 3.

* acá con INSERT e INDEX 3.

PreguntaS:
Cuando se usa un workarea para la asignacion de valores?
Cuando se usa el INSERT, y que quiere decir INDEX 3?

Saludos

Mauricio Hidalgo 02/06/13 23:20:47

Respuesta 1: Una work área se usa cuando quieres independizar el área de entrada de datos de tu tabla interna, esta técnica de trabajo es obligatoria en un entorno OO. Fuera de OO puedes usar el área explicita (WA) o implícita (línea de cabecera de tu tabla interna) indistintamente.

Respuesta 2: La inserción se hace explícitamente en la fila 3 de la tabla interna. Tipicamente esto se usa cuando quieres insertar nuevos datos entre registros existentes.

Saludos

manu_lolo27 06/06/13 11:49:05

Hola,

Los INSERT NUNCA se usan para una tabla interna, en todo caso, tendrias q poner APPEND it_test index 3. PERO NO ENTIENDO para que quieres esto, solo con un APPEND valdria.

Explicanos mas que es lo q quieres hacer
saludo
Manuel H.

funkeeiads 07/06/13 01:19:46

[quote=Una work área se usa cuando quieres independizar el área de entrada de datos de tu tabla interna[/QUOTE]

No entendí esa parte..
Gracias por la respuesta

Mauricio Hidalgo 07/06/13 14:38:37

Siempre es mejor la explicación oficial.

You can define internal tables either with (addition WITH HEADER LINE) or
without header line. An internal table with header line consists of a work area
(header line) and the actual table body. You address both objects using the same
name.
The way in which the system interprets the name depends on the context. For
example, the name stands for the header line in MOVE and CLEAR, but for the
body in SEARCH and REFRESH. To avoid confusion, we recommend using
internal tables without header lines. This is particularly important when you
use nested tables.
However, internal tables with header line do offer a shorter syntax in several
statements (APPEND, INSERT, MODIFY, COLLECT, DELETE, READ, and LOOP
AT).
Within object-oriented contexts, however you can only use internal table without
a header line.
You can always address the body of an internal table itab explicitly by using
the following syntax: itab[]. This syntax is always valid, whether the internal
table has a header line or not.
288 ©


Husos Horarios son GMT. La hora en este momento es 17:22:13.

www.mundosap.com 2006 - Spain
software crm, crm on demand, software call center, crm act, crm solutions, crm gratis, crm web