¡Caminando hacia el éxito!

Aprende en Comunidad

Avalados por :

Guía para principiantes en ABAP: Uso de free, refresh, clear y delete con ejemplos de código

  • Creado 01/03/2024
  • Modificado 01/03/2024
  • 244 Vistas
0
Cargando...

Hola a todos,

Soy nuevo en ABAP.

¿Alguien puede explicarme los siguientes temas con ejemplos de código? ¿Cuál es su uso y dónde deberíamos utilizarlos?

1. free

2. refresh

3. clear

4. delete

Gracias y saludos,

navneeth

Pedro Pascal
Se unió el 07/03/2018
Pinterest
Telegram
Linkedin
Whatsapp

4 Respuestas

0
Cargando...

Hi Navneth,

CLEAR

Sets a variable to its initial value.

Syntax

CLEAR <f>.

The variable <f>, which can have any data type, is set to an initial value appropriate to its type.

DELETE for Files

Deletes files on the application server

Syntax

DELETE DATASET <dsn>.

Deletes the file <dsn> from the file system of the application server.

DELETE for Database Table Entries

Deletes entries from database tables.

Syntax

DELETE FROM <dbtab> WHERE <cond>.

All of the lines in the database table that satisfy the conditions in the WHERE clause are deleted.

Syntax

DELETE <dbtab> FROM <wa>.

DELETE <dbtab> FROM TABLE <itab>.

This deletes the line that has the same primary key as the work area <wa>, or deletes all the lines in the database that have the same primary key as a line in the internal table <itab>. The work area <wa> or the lines of the internal table <itab> must have at least the same length as the work area of the database table.

DELETE for Cluster Databases

Deletes data clusters from cluster database tables.

Syntax

DELETE FROM DATABASE <dbtab>(<ar>) ID <key>.

Deletes the entire cluster in area <ar> with the name <key> from the cluster database table <dbtab>.

DELETE for the Cross-Transaction Application Buffer

Deletes data clusters from the cross-transaction application buffer.

Syntax

DELETE FROM SHARED BUFFER <dbtab>(<ar>) ID <key>.

Deletes the data cluster for the area <ar> with the name <key> stored in the cross-transaction application buffer for the table <dbtab>.

DELETE for Lines from an Internal Table

Deletes lines from internal tables of any type.

Syntax

DELETE TABLE <itab> FROM <wa>.

DELETE TABLE <itab> WITH TABLE KEY <k1> = <f 1>... <k n> = <f n>.

Deletes using the table key. All lines with the same key are deleted. The key values are taken either from a compatible work area <wa> or specified explicitly.

Syntax

DELETE <itab> WHERE <cond>.

Deletes using conditions. Deletes all table entries that satisfy the logical expression <cond>. The logical condition can consist of more than one comparison. In each comparison, the first operand must be a component of the line structure.

Syntax

DELETE ADJACENT DUPLICATE ENTRIES FROM <itab> [COMPARING... ].

Deletes adjacent duplicate entries, either by comparing the key fields or the comparison fields specified explicitly in the COMPARING addition.

DELETE for Lines from Index Tables

Deletes entries from index tables.

Syntax

DELETE <itab> [INDEX <idx>].

If you use the INDEX addition, the line with index <idx> is deleted from the table <itab>. Without the INDEX addition, you can only use the above statement within a LOOP. In this case, you delete the current line.

Syntax

DELETE <itab> [FROM <n1>] [TO <n 2>] [WHERE <cond>].

The system deletes all of the lines of <itab> whose index lies between <n 1 > and <n 2 > and who meet the conditions specified in the WHERE clause. If you do not specify a FROM addition, the system deletes lines

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

CLEAR

Syntax

CLEAR dobj [ {WITH val [IN {BYTE|CHARACTER} MODE] }

| {WITH NULL} ].

Extras:

1. ... WITH val [IN {BYTE|CHARACTER} MODE]

2. ... WITH NULL

Effect

Without the optional additions, the data object dobj is assigned the type-specific initial value. The following applies:

The initial values are assigned to elementary data types according to the table of built-in ABAP types.

Reference variables are assigned null references.

Structures are set to their initial values component by component.

All rows in an internal table are deleted. All the memory required for the table, except for the initial memory requirement, is released (see Declaring Internal Tables). The FREE statement is used to release the memory space occupied by the rows of internal tables.

The optional additions allow you to fill the spaces of a data object with other values than the initial value.

Note

If dobj is an internal table with a header line, you must specify dobj[] to delete the rows, otherwise only the header line will be deleted.

Addition 1

... WITH val [IN {BYTE|CHARACTER} MODE]

Effect

If you use the WITH val addition and specify BYTE or CHARACTER MODE, all spaces are replaced either with the first byte or the first character in val. If dobj is of the type string or xstring (as of Release 6.10), the string is processed in its current length.

The IN BYTE and CHARACTER MODE additions can be used as of Release 6.10 (see also Processing Byte Strings and Character Strings ). Without specification and before Release 6.10 the IN CHARACTER MODE addition applies. Depending on the addition, the data object dobj must be either byte-type or character-type and the data object val must be either byte-type or character type and have the length 1. Before Release 6.10, dobj and val must be flat. If dobj and val do not have the correct type and correct length in a non- Unicode program, they are still handled as if they do, independently of the actual type. In Unicode programs, this will cause a Syntax error or an exception that cannot be handled.

Example

The byte string hexstring as assigned a specific byte value over the entire current length.

DATA: hexstring TYPE xstring,

hex(1) TYPE x VALUE 'FF'.

...

hexstring = '00000000'.

...

CLEAR hexstring WITH hex IN BYTE MODE.

Addition 2

... WITH NULL

Effect

This addition, which is not allowed in ABAP Objects, replaces all bytes of dobj with the value hexadecimal 0. In this case, the data object dobj must be flat.

Note

The WITH NULL addition should only be used for byte-type data objects and therefore be replaced with the CLEAR WITH val addition, which - in this context - at least ensures a higher level of security in Unicode programs.

Exceptions

Non-Catchable Exceptions

Cause: Field val does not have length 1 for variant CLEAR fld WITH val IN BYTE MODE.

Runtime Error: CLEAR_VALUE_BYTEMODE_WRONG_LEN

Cause: Field val does not have length 1 for variant CLEAR fld WITH val [IN CHARACTER MODE].

Runtime Error: CLEAR_VALUE_WRONG_LENGTH

REFRESH

Syntax

REFRESH itab.

Effect

This statement sets an internal table itab to its initial value, meaning that it deletes all rows of the internal table. The memory space required for the table is freed up to the initial memory size INITIAL SIZE. For itab, you must specify an internal table.

To delete all rows and free the entire memory space occupied by rows, you can use the statement FREE.

Note

The statement REFRESH itab acts for all internal tables like CLEAR itab[]. If an internal table itab has a header line, then the table body and not the

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Hola,

1. Liberar: Liberará la memoria de la tabla interna y eliminará los registros.

2. Actualizar: Eliminará los registros pero la memoria permanecerá.

3. Limpiar: Limpiará el encabezado de los registros de la tabla interna.

4. Eliminar: Eliminar los registros requeridos.

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Hola,

Por favor, encuentra la explicación a continuación.

Cuando defines una variable o una tabla en un programa y la ejecutas, el procesador asignará la memoria apropiada a la variable, espero que sepas esto.

Por ejemplo:

DATA: Variable(1) type c.

Entonces, el procesador asignará memoria (con identificación de memoria Algunos dicen 412536) igual al tamaño de 1 carácter.

Luego, si asignas un valor a la variable anterior como

Variable = 'X'. la variable o la identificación de memoria 412536 contendrá este valor 'X'.

Si escribes:

1. FREE Variable.

La memoria asignada se actualiza y se libera. Significa que después de esta declaración, la memoria de la variable ya no está. Se libera del programa y se puede utilizar para otro programa o propósito.

2. REFRESH i_tab.

Usado para tablas para borrar todas las entradas del cuerpo de la tabla interna, pero aún existe la asignación de memoria y puedes usarla en otro programa.

3. CLEAR variable.

Borra la memoria de la variable, es decir, la variable estará vacía.

4. DELETE variable o I_tab índice i, etc.

Elimina un valor específico del cuerpo de una tabla I_tab basado en una condición.

Espero que esté claro,

Gracias,

Surya

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019

contacto@primeinstitute.com

(+51) 1641 9379
(+57) 1489 6964

© 2024 Copyright. Todos los derechos reservados.

Desarrollado por Prime Institute

¡Hola! Soy Diana, asesora académica de Prime Institute, indícame en que curso estas interesado, saludos!
Hola ¿Puedo ayudarte?