隆Caminando hacia el 茅xito!

Aprende en Comunidad

Avalados por :

Genera un archivo XLSX desde una tabla interna en ABAP con cl_salv_table

  • Creado 01/03/2024
  • Modificado 01/03/2024
  • 51 Vistas
0
Cargando...
Hi folks,

I know this is a very old topic, but I didn't find an easy solution for this. My solution is simple: to output the internal table data to an XLSX file. Just choose the file name using F4 help, and make sure you give it the extension 'xlsx'.

The solution is based on the built-in functions of the cl_salv_table class. I hope this will help you. Please let me know your comments and suggestions. Please ignore the naming conventions and untidiness of the code. 馃檪



Cheers! Happy coding! 馃檪



Code:
*&---------------------------------------------------------------------*
*& Report ZARNAB_XLSX
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zarnab_xlsx.

TYPES:
  BEGIN OF ty_s_cline,
    line TYPE c LENGTH 1024, " Line of type Character
  END OF ty_s_cline .

DATA: gr_table     TYPE REF TO cl_salv_table,          " Basis Class for Simple Tables
      gt_outtab    TYPE STANDARD TABLE OF sflight,     " Flight
      lr_functions TYPE REF TO cl_salv_functions_list, " Generic and User-Defined Functions in List-Type Tables
      lr_layout    TYPE REF TO cl_salv_layout,         " Settings for Layout
      lv_xml_type  TYPE salv_bs_constant,
      lv_xml       TYPE xstring,
      gt_srctab    TYPE STANDARD TABLE OF ty_s_cline,
      gt_len       TYPE i,                             " Len of type Integers
      lv_file_xlsx TYPE string,
      lv_file      TYPE localfile,                     " Local file for upload/download
      ls_key       TYPE salv_s_layout_key,             " Layout Key
      lr_content   TYPE REF TO cl_salv_form_element.   " General Element in Design Object

PARAMETERS: p_file TYPE localfile. " Local file for upload/download

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      file_name = lv_file.

  p_file = lv_file.
  lv_file_xlsx = lv_file.

START-OF-SELECTION.

  SELECT * FROM sflight <    
            
Pedro Pascal
Se uni贸 el 07/03/2018
Pinterest
Telegram
Linkedin
Whatsapp

Sin respuestas

No hay respuestas para mostrar No hay respuestas para mostrar Se el primero en responder

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?