Duda con inserción a itab

Colapsar
X
 
  • Tiempo
  • Mostrar
Limpiar Todo
nuevos mensajes
  • funkeeiads
    Member
    • mar
    • 47

    #1

    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
    Senior Member
    • may
    • 481

    #2
    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

    Comentario

    • manu_lolo27
      Member
      • mar
      • 90

      #3
      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.

      Comentario

      • funkeeiads
        Member
        • mar
        • 47

        #4
        [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

        Comentario

        • Mauricio Hidalgo
          Senior Member
          • may
          • 481

          #5
          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 ©

          Comentario

          Trabajando...