✒️La memoria en SAP y en ABAP
La memoria en SAP y en ABAP
Memory in SAP and ABAP
When executing a program/object in ABAP, there are instances where data is needed from a previously executed program. Addressing this requirement can be achieved by passing parameters between programs, if both objects are programs, or by utilizing memory to transfer data between programs. It's crucial to distinguish between SAP and ABAP memory, as ABAP memory is local and limited to a specific user session, while SAP memory is global, accessible across all programs within a session.
Differences between Memories
SAP Memory
|
ABAP Memory
|
Global accessibility. | Local accessibility. |
All SAP GUI sessions for all users have access. | All programs within the same session can access it. |
Data available in the main session. | Data available in various sessions within the same session. |
Exchange data using GET/SET. | Exchange data using IMPORT/EXPORT. |
SAP Memory Operations
- SET PARAMETER ID: Sends parameters during a transaction call.
SET PARAMETER ID 'PARAM_ID' FIELD 'PARAM_VALUE'.
- GET PARAMETER ID: Transfers the storage value of ID parameters from SAP memory or a field/variable.
GET PARAMETER ID 'PARAM_ID' FIELD io_variable.
DATA: v_value(4) TYPE c.
CLEAR v_value.
* SAP Memory access
SET PARAMETER ID 'AA' FIELD 'TEST'.
GET PARAMETER ID 'AA' FIELD v_value.
WRITE:/ v_value. " 'TEST' is displayed
ABAP Memory Operations
- EXPORT: Uploads or exports data to ABAP memory.
EXPORT <var> TO MEMORY ID '<unique_id>'.
- IMPORT: Downloads or imports data from ABAP memory.
IMPORT <var> FROM MEMORY ID '<unique_id>'.
- FREE MEMORY: To release allocated ABAP memory, use FREE MEMORY statement, This ensures efficient management of memory resources.
FREE MEMORY ID '<unique_id>'.
It is possible to import/export variables, structures, or internal tables to ABAP memory. Ensure to release the used memory area with FREE MEMORY ID after the data exchange.
You can call another program iniside the current execution by using SUBMIT... AND RETURN.
SUBMIT ztest_abap_jega_14_2 AND RETURN.
E.g
Report - Exporting Values:
*&---------------------------------------------------------------------*
*& Report ZTEST_ABAP_JEGA_14
*&---------------------------------------------------------------------*
*& Description: This report exports the user state to ABAP memory and
*& then submits another report for import.
*&---------------------------------------------------------------------*
REPORT ztest_abap_jega_14.
* Data declaration
DATA: v_user_state TYPE char10.
*----------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------*
CLEAR v_user_state.
v_user_state = 'ACTIVE'.
* Export user state to memory
EXPORT v_user_state TO MEMORY ID 'Z_USER_STATE'.
IF sy-subrc NE 0.
MESSAGE e000(z1) WITH 'Error exporting'.
ENDIF.
SUBMIT ztest_abap_jega_14_2 AND RETURN.
Report - Importing Values:
*&---------------------------------------------------------------------*
*& Report ZTEST_ABAP_JEGA_14_2
*&---------------------------------------------------------------------*
*& Description: This report imports the user state from ABAP memory and
*& displays it. Finally, it releases the ABAP memory.
*&---------------------------------------------------------------------*
REPORT ztest_abap_jega_14_2.
* Data declaration
DATA: v_user_state TYPE char10.
*----------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------*
* Import user state from memory
IMPORT v_user_state FROM MEMORY ID 'Z_USER_STATE'.
IF sy-subrc NE 0.
MESSAGE e000(z1) WITH 'Error importing'.
ELSE.
WRITE:/ v_user_state.
ENDIF.
* Free ABAP memory
FREE MEMORY ID 'Z_USER_STATE'.
 
 
 
Sobre el autor
Publicación académica de Jaime Eduardo Gomez Arango, en su ámbito de estudios para la Carrera Consultor ABAP.
Jaime Eduardo Gomez Arango
Profesión: Ingeniero de Sistemas y Computación - España - Legajo: SW34C
✒️Autor de: 99 Publicaciones Académicas
🎓Cursando Actualmente: Consultor ABAP Nivel Avanzado
🎓Egresado del módulo:
Disponibilidad Laboral: FullTime
Presentación:
Ingeniero de sistemas y computación con 8 años de experiencia el desarrollo frontend & backend (react/node) y en cloud (aws), actualmente desarrollando habilidades en sap btp, ui5, abap y fiori.
Certificación Académica de Jaime Gomez