Giter VIP home page Giter VIP logo

Comments (3)

ivanfemia avatar ivanfemia commented on May 23, 2024

I'll have a look.

from abap2xlsx.

ivanfemia avatar ivanfemia commented on May 23, 2024

Internal table lt_test has to be accessible in scope when calling lo_excel_writer->write_file.
In your demo lt_test is freed by the system when leaving method get_it_excel and cannot be accessed during xlsx creation.

I used the same pattern as for example standard ALV classes - just the reference is stored not the copy of internal table. The reference to internal table is needed to perform some calculations during file creation.

With standard ALV you are also getting short dump when internal table is not in scope - you can try this demo:

REPORT zdemo_excel1_ref.

----------------------------------------------------------------------

  •   CLASS lcl_alv DEFINITION
    
    ----------------------------------------------------------------------
    *
    ----------------------------------------------------------------------
    CLASS lcl_alv DEFINITION.
    PUBLIC SECTION.
    METHODS get_alv
    EXPORTING
    e_alv TYPE REF TO cl_salv_table.

ENDCLASS. "lcl_alv DEFINITION

----------------------------------------------------------------------

  •   CLASS lcl_alv IMPLEMENTATION
    

    ----------------------------------------------------------------------
    *
    ----------------------------------------------------------------------
    CLASS lcl_alv IMPLEMENTATION.
    METHOD get_alv.
    DATA lt_test TYPE TABLE OF sflight.
    SELECT * FROM sflight INTO TABLE lt_test.

    TRY.
    cl_salv_table=>factory(
    IMPORTING
    r_salv_table = e_alv
    CHANGING
    t_table = lt_test ).
    CATCH cx_salv_msg. "#EC NO_HANDLER
    ENDTRY.
    ENDMETHOD. "get_alv
    ENDCLASS. "lcl_alv IMPLEMENTATION

START-OF-SELECTION.

DATA: lr_alv TYPE REF TO lcl_alv,
lr_table TYPE REF TO cl_salv_table.

CREATE OBJECT lr_alv.
lr_alv->get_alv( IMPORTING e_alv = lr_table ).
lr_table->display( ).

To make it work change declaration of lt_test - it can be global or returned from the class method.
If there is a strong requirement to use it like in your demo with lt test declared locally please reopen the issue and I'll try to workaround it by doing the calculations early in the bind_table() method without storing the reference.

from abap2xlsx.

ivanfemia avatar ivanfemia commented on May 23, 2024

[[file:cAazaYdcKr473dacwqjQYw]]
ZDEMO_EXCEL1_REF.slnk

from abap2xlsx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.