PROMO AGOSTO en CVOSOFT United States Of America: 💎Calidad, 🔥Bonificaciones, 🥶Precios Congelados y MÁS!

 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 Expert


Jaime Eduardo Gomez Arango

Profesión: Ingeniero de Sistemas y Computación - España - Legajo: SW34C

✒️Autor de: 149 Publicaciones Académicas

🎓Egresado de los módulos:

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 Master

PASOS PARA BATCH INPUT UTILIZANDO CALL TRANSACTION. 1.- Declaración de datos propias del Batch input. 2.- Lectura de datos de archivos de entrada, ejecutando el metodo CA_GUI_FRONTED_SERVICES=>GUI_UPLOAD. 3.-Carga de la tabla BDCDATA, utilizamos la subrutina BDC_FIELD. 4.- ejecusión de la sentencia CALL TRANSACTION

Acceder a esta publicación

Creado y Compartido por: Maria Ysabel Colina De Magdaleno

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

SAP Master

Creacion del primer batch input utilizando CALL TRANSACTION. ESTRUCTURA BCDMSGCOLL es una estructura estandar del sistema, es utilizada para definir la tabla interna que almacenara los mensajes del batch input.

Acceder a esta publicación

Creado y Compartido por: Rainer Diaz

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

SAP Senior

BATCH INPUT UTILIZANDO CALL TRANSACTION declaracion de datos propios del batch input declaramos una tabla interna y una estructura, ambas del tipo BDCDATA, otra tabla interna del tipo BDCMDHCOLL con su estructura,que serviran para almacenar los mensajes que se produzcan cuando ejecutemos CALL TRANSACTION, la tabla interna usuarios, que contendra los datos que levantemos del archivo de entrada y una tabla para mostrar por pantalla los errores entre otras declaraciones. lectura de datos de archivo de entrada ejecutamos el metodo CL GUI FRONTEND SERVICES=> GUI UPLOAD para levantar el archivo de entrada con la informacion para generar el batch input carga de la tabla BDCDATA para cargar la tabla BDCDATA utilizamos la subrutina...

Acceder a esta publicación

Creado y Compartido por: Luis Car

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

SAP Senior

Batch Input utilizando call transaction. call transaction: Sentencia estándar ABAP que permite la llamada a una transacción SAP Carga inicial de datos: Proceso que consiste en el ingreso de los datos necesarios para el funcionamiento de una aplicación en un ambiente del sistema. BDCMSGCOLL: Estructura estándar SAP que se utiliza para almacenar los mensajes de la ejecución de un CALL TRANSACTION. Paso para carga inicial. 1.- Declaración de datos propios del batch input. 2.- Lectura de datos de archivo de entrada. 3.- Carga de la tabla BDCDATA. 4.- Ejecución de la sentencia Call Transaction. 5.- Ejecutarlo con modo de procesamiento A, que nos permite ver los pasos de las actualizaciones....

Acceder a esta publicación

Creado y Compartido por: Rafael Razo

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

SAP Senior

CALL TRANSACTION: Sentencia estandar que permite la llamada a una transaccion SAP. BDCDATA: Estructura estandar que se utiliza para la carga de datos en un Batch Input. BDCMSGCOLL: Estructura estandar que se utiliza para almacenar los mensajes resultantes de la ejecucion de un CALL TRANSACTION. CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD: Metodo estandar que se utiliza para levantar archivos locales. MESSAGE_PREPARE: Funcion estandar que se utiliza para el armado de mensajes generalmente en un Batch Input.

Acceder a esta publicación

Creado y Compartido por: David Camacho Espinoza

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

SAP Senior

Lección: Batch Input utilizando Call transaction 1. Mi primer Batch Input utilizando Call Transaction Vamos a crear nuestro primer Batch Input utilizando la técnica de CALL TRANSACTION. El obejtivo del Batch Input será la carga inicial de datos de la tabla ZTABLA_USUARIOS. Para ello, vamos a crear un archivo de texto con registros que cumplan con la estructura de la tabla ZTABLA_USUARIOS, sin tener en cuenta al campo mandante. Como lo que vamos a hacer será la carga inicial de la tabla de usuarios, borraremos su contenido previamente a la ejecución de este ejemplo. Ahora, seguiremos los pasos que establecimos en la primer lección de la unidad. Declaración de datos propios del Batch Input...

Acceder a esta publicación

Creado y Compartido por: Pedro Alejandro Arroyo Gutierrez

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

SAP Master

***************** Batch Input utilizando Call transaction [ 4º de 8 ] Crear Batch Input utilizando la técnica de CALL TRANSACTION (Sentencia estándar ABAP que permite la llamada a una transacción SAP) El objetivo del Batch Input será la carga inicial de datos de dicha tabla. Se crea un archivo de texto con registros que cumplan con la estructura de la tabla, SIN TENER EN CUENTA EL CAMPO MANDANTE. PASO1: Declaración de datos propios del batch input Se declara una tabla interna y una estructura, ambas tipo BDCDATA. Otra tabla interna del tipo BDCMSGCOLL con su estructura, que servirán para almacenar los mensajes que se produzcan cuando se ejecuta el CALL TRANSACTION, la tabla interna de usuarios,...

Acceder a esta publicación

Creado y Compartido por: Jose Angel Valles Bustos

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

SAP SemiSenior

Batch input utilizando call transaction. El objetivo del batch input será la carga inicial de datos de la tabla ZTABLA_USUARIOS. Pasos. 1. Declaración de datos propios del bacth input. Declaramos una tabla interna y una estructura, ambas del tipo BDCDATA, otra tabla interna del tipo BDCMSGCOLL con su estructura, que servirán para almacenar los mensajes que se produzcan cuando ejecutemos el CALL TRANSACTION, la tabla interna de usuarios, que contendrá los datos que levantemos del archivo de entrada y una tabla para mostrar por pantalla los errores entre otras declaraciones. Estructura BDCMSGCOLL. Esta estructura estándar del sistema es utilzada para definir la tabla interna que almacenará los mensajes...

Acceder a esta publicación

Creado y Compartido por: Fabio Gallo

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

SAP Master

Mi primer Batch Input utilizando CALL TRANSACTION. Para crear el programa de carga inicial de usuarios con la técnica CALL TRANSACTION, procesamos los siguientes pasos que vimos en la lección 1: Declaración de datos propios del Batch Input. Lectura de datos de archivo de entrada. Carga de la tabla BDCDATA. Ejecución de la sentencia CALL TRANSACTION. Observaciones de la practica: Hay que tener mucho cuidado cuando generamos el archivo de texto que vamos a levantar de nuestra PC, hay que verificar que las separaciones entre campos sea la correcta, ya que en el campo de "Estado de Usuario" no me ponía nada, y ese dato lo ponía junto con la dirección en el campo de "Dirección",...

Acceder a esta publicación

Creado y Compartido por: Calixto Gutiérrez

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

SAP Senior

MI PRIMER BATCH INPUT UTILIZANDO CALL TRANSACTION: 1. Creación del archivo de texto: para esto ver el Código Fuente del ejemplo en la lección. 2. Se siguen los pasos de la lección 1 de esta unidad. Analizar cuidadosamente estos pasos. La estructura BDCMSGCOLL sirve para definir la tabla interna que almacenará los mensajes del batch input. La sintaxis de la sentencia CALL TRANSACTION es: CALL TRANSACTION v_cod_trans USING ti_bdc_data MODE v_modo MESSAGES INTO ti_messages. ...

Acceder a esta publicación

Creado y Compartido por: Pedro Ernesto Maldonado

 


 

👌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!