🚀PROMO #PLANCARRERA2024 - 🔥Bonificaciones, Precios Congelados y Cuotas

 X 

✒️ABAP El Batch Input utilizando Call transaction

ABAP El Batch Input utilizando Call transaction

ABAP El Batch Input utilizando Call transaction

Batch Input using CALL TRANSACTION

The objective of BI is the initial data load into a Z table, in this case ZUSER_TABLE. For this, we need to have a text file with records that match the structure of the database table. Subsequently, we need to create a program with the following structure:

  • STEP 1 - Declaration of BI-specific data: Declare an internal table (IT) and a structure, both of type BDCDATA. Declare another IT and a structure, both of type BDCMSGCOLL, to store the messages produced when executing the CALL TRANSACTION. The user IT will contain data lifted from the input file and a table to display errors among other declarations

BDCMSGCOLL: It's a standard system structure used to define the internal table that stores batch input messages.

* Internal table for BI with the structure of BDCDATA
DATA: BEGIN OF it_bdcdata OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF it_bdcdata.

* Structure for BI
DATA: wa_bdcdata TYPE bdcdata.

* Internal table for messages
DATA: BEGIN OF it_messages OCCURS 0.
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF it_messages.

* Structure for messages
DATA: wa_messages TYPE bdcmsgcoll.

* Internal table for users
DATA: it_input_file TYPE STANDARD TABLE OF zuser_table,
wa_input_file LIKE LINE OF it_input_file.

  • STEP 2 - Reading data from the input file: Execute the method GUI_UPLOAD of the class CL_GUI_FRONTEND_SERVICES to lift the input file with the information to generate the BI.

*&---------------------------------------------------------------------*
*& Form upload_input_file
*&---------------------------------------------------------------------*
*& Uploads the selected input file from the file system to the internal
*& table for further processing.
*&----------------------------------------------------------------------*
FORM upload_input_file.

DATA: lv_file TYPE string.

IF p_path IS INITIAL.
MESSAGE s000(z_prueba) WITH TEXT-003.
ELSE.

lv_file = p_path.

* Open the input file for reading
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_file
filetype = 'ASC'
has_field_separator = ''
CHANGING
data_tab = it_input_file[]
EXCEPTIONS
file_open_error = 1
file_read_error = 2
OTHERS = 19.

IF sy-subrc NE 0.
MESSAGE e000(z_test) WITH TEXT-004.
ENDIF.

IF it_input_file[] IS INITIAL.
MESSAGE s000(z_test) WITH TEXT-005.
ENDIF.
ENDIF.
ENDFORM. " upload_input_file

  • STEP 3 - Loading the BDCDATA IT: use the subroutine FILL_BDCDATA_TABLE to load the IT. Before that, the initialization of the batch input IT and the messages table are required. Since there are many records, we need to handle indexes to know which row of the screen we are loading the data into, therfore the row number should be concatenated with the field name.

*&---------------------------------------------------------------------*
*& Form fill_bdcdata_table
*&---------------------------------------------------------------------*
* Fills the BDCDATA internal table with the required data for BDC processing.
* Parameters:
* - p_dynpro: Indicates whether it's a dynpro (X) or a field value (blank).
* - p_field1: First field value.
* - p_field2: Second field value.
*----------------------------------------------------------------------*
FORM fill_bdcdata_table USING p_dynpro TYPE c
p_field1
p_field2.
CLEAR wa_bdcdata.

IF p_dynpro EQ c_x.
wa_bdcdata-dynbegin = p_dynpro.
wa_bdcdata-program = p_field1.
wa_bdcdata-dynpro = p_field2.
ELSE.
wa_bdcdata-fnam = p_field1.
wa_bdcdata-fval = p_field2.
ENDIF.

APPEND wa_bdcdata TO it_bdcdata.

ENDFORM. " fill_bdcdata_table

*&---------------------------------------------------------------------*
*& Form LOAD_BDCDATA_TABLE
*&---------------------------------------------------------------------*
*& Description: Loads data into BDCDATA table for SAP transaction.
*&---------------------------------------------------------------------*

FORM load_bdcdata_table .
CLEAR: ti_bdcdata, ti_messages.
REFRESH: ti_bdcdata, ti_messages.

* Navigate to the initial screen and press the maintenance button.
PERFORM fill_bdcdata_table USING 'X' 'SAPMSVMA' '0100'.
PERFORM fill_bdcdata_table USING ' ' 'VIEWNAME' 'ZTABLE_USERS'.
PERFORM fill_bdcdata_table USING ' ' 'BDC_OKCODE' '=UPD'.

* Click on the new entries button.
PERFORM fill_bdcdata_table USING 'X' 'SAPLZTABLE_USERS' '0001'.
PERFORM fill_bdcdata_table USING ' ' 'BDC_OKCODE' '=NEWL'.

ADD 1 TO v_index.
PERFORM complete_leading_zeros.

* Load user data.
PERFORM fill_bdcdata_table USING 'X' 'SAPLZTABLE_USERS' '0001'.

CLEAR v_field.
CONCATENATE 'ZTABLE_USERS-DNI(' v_index ')' INTO v_field.
PERFORM fill_bdcdata_table USING ' ' v_field wa_file-dni.

CLEAR v_field.
CONCATENATE 'ZTABLE_USERS-NAME_LASTNAME(' v_index ')' INTO v_field.
PERFORM fill_bdcdata_table USING ' ' v_field wa_file-name_last.

CLEAR v_field.
CONCATENATE 'ZTABLE_USERS-USER_STATE(' v_index ')' INTO v_field.
PERFORM fill_bdcdata_table USING ' ' v_field wa_file-user_state.

CLEAR v_field.
CONCATENATE 'ZTABLE_USERS-BIRTHDATE(' v_index ')' INTO v_field.
PERFORM fill_bdcdata_table USING ' ' v_field wa_file-birthdate.

* Save the records.
PERFORM fill_bdcdata_table USING ' ' 'BDC_OKCODE' '=SAVE'.

* Close the second screen.
PERFORM fill_bdcdata_table USING 'X' 'SAPLZTABLE_USERS' '0001'.
PERFORM fill_bdcdata_table USING ' ' 'BDC_OKCODE' '=ENDE'.

* Close the initial screen.
PERFORM fill_bdcdata_table USING 'X' 'SAPMSVMA' '0100'.
PERFORM fill_bdcdata_table USING ' ' 'BDC_OKCODE' '/EENDE'.

ENDFORM. " LOAD_BDCDATA_TABLE"

  • STEP 4 - Executing the CALL TRANSACTION statement:

*&---------------------------------------------------------------------*
*& Form call_sm30
*&---------------------------------------------------------------------*
*& Description: Calls transaction SM30 with specified parameters.
*&---------------------------------------------------------------------*
FORM call_sm30 .

CLEAR: it_messages, v_error.
REFRESH it_messages.

IF p_a EQ c_x.
v_mode = c_a.
ELSE.
v_mode = c_n.
ENDIF.

* Call transaction.
CALL TRANSACTION v_trans_code USING it_bdcdata
MODE v_mode
UPDATE v_update
MESSAGES INTO it_messages.

IF NOT sy-subrc IS INITIAL.
v_error = c_x.
ENDIF.

ENDFORM. " call_sm30

Let's review each of the options:

  • USING: Here we specify the BDCDATA IT to be used.

  • MODE: Determines the processing mode that BI will use. Possible modes are:

    • A: processing with visualization of all screens. It's the default value.

    • E: processing where screens are displayed only if an error occurs. If a breakpoint is reached, processing ends with SY-SUBRC = 1001. The field SY-MSGTY will contain "S", SY-MSGID will contain "00", SY-MSGNO will contain "344", SY-MSGV1 will contain "SAPMSSY3", and SY-MSGV2 will contain "0131".

    • N: processing where screens are not displayed.

    • P: processing where screens are not displayed. If a breakpoint is reached, control is passed to the debugger.

  • UPDATE: Determines the update mode of the fields that BI will produce. Possible modes are:

    • A: asynchronous update. The update is done similarly to what happens if we use the COMMIT WORK statement. Default value.

    • S: synchronous update. The update is done similarly to what happens if we use the COMMIT WORK AND WAIT statement.

    • L: local update.

  • MESSAGES INTO: With the use of this option, all messages generated during the BI processing are stored in an IT of type BDCMSGCOLL.

To build the messages, we use the function module MESSAGE_PREPARE.

CALL FUNCTION 'MESSAGE_PREPARE'
EXPORTING
msg_id = v_msg_id
msg_no = v_msg_no
msg_var1 = v_msg_v1
msg_var2 = v_msg_v2
msg_var3 = v_msg_v3
msg_var4 = v_msg_v4
IMPORTING
msg_text = v_message
EXCEPTIONS
function_not_completed = 1
message_not_found = 2
OTHERS = 3.

IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Now that we've completed all the steps of BI, we execute it with processing mode "A", which allows us to see the step-by-step updates.

  • Enter transaction SM30 with the name of the database table and press "Update".
  • Click "New Entries", and the system informs that there are no entries in the table. =UPD
  • Enter the fields of the record and press "Save". =NEWL and =SAVE
  • Exit the dynpro where the database table record is completed. =ENDE
  • Exit the initial screen and repeat the steps for the number of user records entered in the database table.

The CALL TRANSACTION statement is also used in reports to access a specific transaction based on the data entered on the screen, with the addition of the AND SKIP FIRST SCREEN clause.

Finally, if we view the contents of the ZUSER_TABLE through transaction SE16, we will verify that indeed, there are three records that are the ones we inserted into the table.


 

 

 


Sobre el autor

Publicación académica de Jaime Eduardo Gomez Arango, en su ámbito de estudios para la Carrera Consultor ABAP.

SAP Master

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

✒️+Comunidad Académica CVOSOFT

Continúe aprendiendo sobre el tema "El Batch Input utilizando Call transaction" de la mano de nuestros alumnos.

SAP Senior

1| MI PRIMER BATCH INPUT UTILIZANDO CALL TRANSACTION SE CREARA EL BATCH INPUT UTILIZANDO LA TECNICA DE CALL TRANSACTION EL OBJETIVO DEL BATCH INPUT SERA LA CARGA INICIAL DE DATOS DE LA TABLA ZTABLA_USUARIOS PASO 1 DECLARACION DE DATOS PROPIOS DEL BATCH INPUT DECLARAREMOS UNA TABLA INTERNA Y UNA ESTRUCTURA DEL TIPO BDCDATA OTRA TABLA INTERNA DEL TIPO BDCMSGCOLL CON SU ESTRUCTURA. PASO 2 LECTURA DE DATOS DE ARCHIVO DE ENTRADA EJECUTAMOS EL METODO GUI_UPLOAD PARA LEVANTAR EL ARCHIVO DE ENTRADA CON LA INFORMACION PARA GENERAR EL BATCH INPUT. PASO 3 CARGA DE LA TABLA BDCDATA SE UTILIZARA LA SUBRUTINA BDC_FIELD. PASO 4 EJECUCION DE LA SENTENCIA CALL TRANSACCTION AHORA VAMOS A EJECUTAR LA SENTENCIA CALL TRANSACTION. VEAMOS EN DETALLE CADA UNA DE...

Acceder a esta publicación

Creado y Compartido por: Luis Eugenio Leyva Orozco

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert


El Batch Input utilizando la sentencia CALL TRANSACTION en ABAP es una técnica que te permite automatizar la entrada masiva de datos en SAP. Esta técnica utiliza la función CALL TRANSACTION para emular la interacción del usuario con una transacción SAP y realizar entradas o actualizaciones en lote de manera automatizada. A diferencia de la grabación de Batch Input, que crea programas automáticamente, en este caso debes construir el programa de Batch Input manualmente utilizando la sentencia CALL TRANSACTION. Es importante tener en cuenta que el uso de CALL TRANSACTION para Batch Input requiere un buen conocimiento de las transacciones SAP y cómo interactúan con los datos. También...

Acceder a esta publicación

Creado y Compartido por: Darling Geraldino

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master

mi primer batch input utilizando CALL TRANSACTION vamos a crear nuestro primer batch input utilizando la tecnica de CAL TRANSACTION. El objetivo de batch input sera la carga inicial de datos de la tabla ZTABLA_USUARIOS. primer paso declaracion de datos propios de batch input declaramos una tabla interna y una estructura, ambas del tipo BDCDATA, otra tabla interna del tipo BDCMSGCOLL. con su estructura, que serviran para almacenar los mensajes que se produzcan cuando ejecutamos el call trasaction, la tabla interna de usuarios. que contendra los datos que levantamos del archivo de entrada y una tabla para mastrar por pantalla los errores entre otras declaraciones. segundo paso lectura de datos de archivo de entrada. ejecutamos el metodo GUI_UPLOAD...

Acceder a esta publicación

Creado y Compartido por: Oscar Sebastian Caicedo Carlier / Disponibilidad Laboral: PartTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert

1 - BATCH INPUT UTILIZANDO CALL TRANSACTION. CALL TRANSACTION: se realiza de forma Online, por lo que ejecuta las actualizaciones en el momento en que se ejecuta el programa del Batch Input. Se utiliza la sentencia estándar CALL TRANSACTION. Los pasos para la realización de un Batch Input mediante la técnica de CALL TRANSACCTION son los siguientes: 1ero: Declaración de datos propios del Batch Input. Declarar Tabla Interna y Esructura del tipo BDCDATA (Guarda los datos a cargar en la tabla). Declarar Tabla Interna y Esructura del tipo BDCMSGCOLL (Guardar los mensajes que se producen durante la ejecución). 2do: Lectura de datos de archivo de entrada.generar el Batch Input. Ejecutar el metodo GUI_UPLOAD para...

Acceder a esta publicación

Creado y Compartido por: Francisco Javier Gomez Jimenez

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master


Batch Input Utilizando Call Transaction Abap batch input utilizando call transaction existen dos técnicas para realizar un Batch Input, una se realiza de forma Online y la otra en forma Batch. Ellas son: CALL TRANSACTION: se realiza de forma Online, por lo que ejecuta las actualizaciones en el momento en que se ejecuta el programa del Batch Input. Se utiliza la sentencia estándar CALL TRANSACTION. JUEGO DE DATOS: se realiza de forma Batch (o de fondo) y queda almacenado en SAP para su posterior ejecución mediante la transacción SM35. Consiste en la ejecución de una serie de funciones estándar para la apertura, ejecución y cierre del juego de datos. Los pasos para la realización de...

Acceder a esta publicación

Creado y Compartido por: Cesar Armando Gutierrez Gomez / Disponibilidad Laboral: FullTime

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master

BATCH INPUT CON CALL TRANSACTION Para realizar un BI con call transaction debemos seguir los siguientes pasos: Declaración de tabla y estructura del tipo bdcdata; declaración de tabla y estructura del tipo bdcmsgcoll para almacenar los mensajes del call transaction; declaración de tabla y estructura de datos; declaración de tabla y estructura de errores Lectura de datos del archivo de entrada con el método gui_upload Carga de la tabla bdcdata con la subrutina bdc_field utilizando índices para cargar más de un registro Ejecutar call transaction como: CALL TRANSACTION v_cod_trx USING ti_bdc_data MODE v_mode UPDATE v_update MESSAGES INTO ti_messages. En la sentencia call transaction...

Acceder a esta publicación

Creado y Compartido por: Jonatan Richioni

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert


Batch Input utilizando Call transaction Pasos para crear un Batch Input usando CALL TRANSACTION: Declaración de datos propios del batch input.- Declaramos una tabla interna y una estructura, ambas del tipo BDCDATA otra tabla interna del tipo BDCMSGCOLL, una tabla interna que contendrá los datos que levantemos del archivo de entrada. Lectura de datos de archivo de entrada.- Usaremos el método GUI_UPLOAD para levantar el archivo de entrada con la información para generar el Batch Input. Carga de la tabla BDCDATA.- Para cargar la tabla BDCDATA usamos la subrutina BDC_FIELD y como vamos a ingresar más de un registro manejaremos índices para saber en que fila de la pantalla estamos cargando los...

Acceder a esta publicación

Creado y Compartido por: José Luis Zevallos Mamani

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

BATCH INPUT CON CALL TRANSACTION Declaración de datos propios del batch input: Lectura de datos de archivo:utilizamos el metodo GUIUPLOAD Carga de la tabla interna BDCDATA Ejecutar la sentencia call transaction: USING: especificamos la tabla interna BDCDATA que se utilizara MODE: determina el modo de procesamiento que utilizara el batch input A: procesamiento con la visualización de todas las pantallas E:solo me muestran las pantallas si ocurre un error N:procesamiento donde no se muestran las pantallas P: procesamiento donde no se muestran las pantallas UPDATE: determina el modo de actualización de los cambios en el batch input A: actualización asincronica S:actualización...

Acceder a esta publicación

Creado y Compartido por: Valentina Muñoz Medina / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

1. Mi primer programa Bach Input utilizando CALL TRANSACTION Haremos un bach input usando el CALL TRANSACTION, la finalidad de este serà la carga inical de datos de la tabla a trabajar. Creamos un archivo de texto que contenga registros pero con la misma estructura de la tabla a cargar. Al ser datos iniciales entonces se limpiarà dicha tabla antes de realizar la carga. 1er: Declaraciòn de datos propios del batch Input: declararemos una tabla interna y una estructura, ambas del tipo BDCDATA, y la otra tabla interna serà del tipo BDCMSGCOLL con su estructura, la cual se usarà para almacenar los mensajes. Estructura BDCMSGCOLL: estructura usada para almacenar los mensajes del batch bach input. 2do: Lectura del...

Acceder a esta publicación

Creado y Compartido por: Daniel Arias Sarmiento

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master


MI PRIMER BATCH INPUT UTILIZANDO LA TÉCNICA CALL TRANSACTION Lo primero que tendremos que hacer será crear un Archivo de texto con registros que cumplan con la estructura de la tabla: ZTABLA_USUARIOS sin tener en cuenta el campo mandante. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ MEDIANTE CALL TRANSACTION vemos a detalle cada paso, para la CARGA INICIAL DE LA TABLA ZTABLA_USUARIOS 1. Declaración de datos propios del BI. 2. Lectura de datos de archivo de entrada. 3. Carga de la Tabla BDCDATA. (INDICES) 4. Ejecución de la sentencia CALL TRANSACTION Tip Cuando estamos desarrollando un programa...

Acceder a esta publicación

Creado y Compartido por: Jorge Iván Pérez Becerra / Disponibilidad Laboral: PartTime + Carta Presentación

 


 

👌Genial!, estos fueron los últimos artículos sobre más de 79.000 publicaciones académicas abiertas, libres y gratuitas compartidas con la comunidad, para acceder a ellas le dejamos el enlace a CVOPEN ACADEMY.

Buscador de Publicaciones:

 


 

No sea Juan... Solo podrá llegar alto si realiza su formación con los mejores!