Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to fetch data from standard report using Class cl_salv_bs_runtime_info

former_member608267
Participant
0 Kudos

Hi Experts,

Currently i am working on a requirement to fetch output(ALV) of a standard report and place it on application server.

The standard report is using REUSE_ALV_GRID_DISPLAY to display the output.

I followed below approaches

1) SUBMIT XXXXXX AND RETURN EXPORTING LIST TO MEMORY and the FM's

'LIST_FROM_MEMORY' and 'LIST_TO_ASCI' .

The data is getting truncated while converting to ASCI when standard report output is run by selecting all columns.

2) Using Class CL_SALV_BS_RUNTIME_INFO .

1. I still see the output of the standard report after setting up run time info.
2. No data is retrieved in submit statement.
3. I set a break-point in the method SET_METADATA of CL_SALV_BS_RUNTIME_INFO but it is not getting triggered. 
cl_salv_bs_runtime_info=>set(
    EXPORTING display  = space
              metadata = space
              data     = 'X' ).
SUBMIT XXXXXX AND RETURN.
  TRY.
     cl_salv_bs_runtime_info=>get_data_ref(
        IMPORTING r_data = gt_pos_data ).
      ASSIGN gt_pos_data->* TO <gt_pos_data>.
    CATCH cx_salv_bs_sc_runtime_info.
       MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
  ENDTRY.


Appreciate if you could let me know if I am missing something here.

Regards,

Muhammed

25 REPLIES 25

DoanManhQuynh
Active Contributor
0 Kudos

may i ask what report is it? maybe there is an option to display the report in ALV or not but you forget to set it when submit...

former_member608267
Participant
0 Kudos

Hi ,

Thanks. The report is rkaep000 and tcode is 'KSB1'.

SUBMIT rkaep000 WITH p_kokrs =  p_kokrs   
WITH p_tcode EQ 'KSB1'
WITH kostl IN s_kostl
WITH r_budat IN s_budat
WITH p_disvar = p_disvar
WITH p_usegrd = ' '
AND RETURN.

Regards,

Muhammed

DoanManhQuynh
Active Contributor

I think p_usegrd should be X, not space.

former_member608267
Participant
0 Kudos

Hi,

p_usegrd is to display either LIST or GRID ALV.

Thanks

Tomas_Buryanek
Active Contributor
0 Kudos

mohammed.mukhtar CL_SALV_BS_RUNTIME_INFO is used to get data from ALV Grid (EDIT: mistake - it should work for both Grid & List). But by that empty p_usegrd you are using ALV List. Try what Quynh Doan Manh recommended you...

-- Tomas --

Sandra_Rossi
Active Contributor
0 Kudos

You should run SUBMIT only to make sure there program doesn't stop on the selection screen (there should be no warning and no error). I just tried on my system, SUBMIT alone displays directly the ALV. If I wrap it with the CL_SALV_BS_RUNTIME_INFO stuff, then I retrieve the internal table.

I have tested it successfully in both P_USEGRD situations, p_usegrd = ' ' and p_usegrd = 'X'.

former_member608267
Participant
0 Kudos

Hi,

Thanks tomas.buryanek sandra.rossi .

I posted this query in SCN after testing with both P_USEGRD situations, p_usegrd = ' ' and p_usegrd = 'X' in addition with CL_SALV_BS_RUNTIME_INFO which is used to get data from ALV Grid.

Ideally method SET_METADATA of CL_SALV_BS_RUNTIME_INFO should trigger in either of FM's REUSE_ALV_GRID_DISPLAY or REUSE_ALV_LIST_DISPLAY,but in my system this method is not triggering hence the metdata values are not set while ALV FM's are getting executed.

The program doesn't stop on the selection screen, it shows the output even after setting up ALV RUNTIME INFO values.

We are currently on ECC 5 version. May be this feature is not enabled in this version.

Regards,

Muhammed

DoanManhQuynh
Active Contributor
0 Kudos

Muhammed M

sorry for last suggestion, p_usegrd display either ALV List and Grid so whatever you set you would still get data using cl_salv_bs_runtime_info. I tested in my system and it work as normal, you may check your input parameter as Sandra suggested.

Sandra_Rossi
Active Contributor

I couldn't find SAP notes. Maybe the corrections were provided via a support package.

Anyway, if you're a little adventurous, to help you, on my S/4HANA system, I have this call stack (when I use P_USEGRD='X'):

CL_SALV_BS_RUNTIME_INFO     set_data [method]	
CL_GUI_ALV_GRID [system]    do_runtime_info [method]	
CL_GUI_ALV_GRID [system]    set_table_for_first_display [method]

In method SET_DATA, there is the following check which is true (when I use cl_salv_bs_runtime_info=>set( data = 'X' )), consequently the data is made available "externally":

check ls_runtime_info-data eq abap_true.

And in method DO_RUNTIME_INFO, there's no display (when I use cl_salv_bs_runtime_info=>set( display = ' ' )) because of these lines:

      case ls_runtime_info-display.
        when abap_true.
        when others.
          set screen 0.
          leave screen.
      endcase.

former_member608267
Participant
0 Kudos

Thanks sandra.rossi .

Can you please share the call stack when the below method(Program name) is triggered.

CL_GUI_ALV_GRID [system]    do_runtime_info [method]

I will check in my system why this method is not getting triggered.

Regards,

Muhammed

Sandra_Rossi
Active Contributor
0 Kudos

Muhammed M cf my previous answer. What form of "call stack" do you want?

former_member608267
Participant
0 Kudos

Hi Sandra Rossi

Call stack of CL_SALV_BS_RUNTIME_INFO set_data [method]

Regards

Muhammed

Sandra_Rossi
Active Contributor

do_runtime_info is called by set_table_for_first_display:

CL_SALV_BS_RUNTIME_INFO     set_data [method]
CL_GUI_ALV_GRID [system]    do_runtime_info [method]	
CL_GUI_ALV_GRID [system]    set_table_for_first_display [method]

former_member608267
Participant
0 Kudos

Hi Sandra Rossi

Thanks for your patience.

Can you share form/program/include name where method do_runtime_info is getting called in set table for display.

Regards

Muhammad

Sandra_Rossi
Active Contributor

I'm probably infringing the copyright, so look at it quickly (---set-table-for-first-display.txt attachment deleted---) before I delete the message.

former_member608267
Participant

Thanks . I will go through and will let you know what's missing from our system.

Regards

Muhammed

former_member608267
Participant

Hi sandra.rossi ,

Thanks for your help. The call to method 'do_runtime_info' is missing from my system at line no 310 in method 'SET_TABLE_FOR_FIRST_DISPLAY'.

I will try to search OSS NOTES or will use some standard user exit to export internal table of KSB1 to memory and read it in my custom program.

me->do_runtime_info( ).

Regards,

Muhammed

DoanManhQuynh
Active Contributor

Muhammed M

if it help, in my 7.40 SP 14 system, that method at line 377 and CL_GUI_ALV_GRID last edited is 2015/10/10, note or sp it should around there...

you may see there is a memory ID : ALV_EXTRACT_MODE which used there, maybe you could use it instead of find enhancement (if you cant find a right note..)

Sandra_Rossi
Active Contributor
0 Kudos

Muhammed M what is the SAP_ABA/SAP_BASIS version/SP corresponding to your ECC5 ?

former_member608267
Participant

quynh.doanmanh Thanks for your inputs, checking the feasibility.

sandra.rossi

SAP_ABA 640 0027 SAPKA64027

SAP_BASIS 640 0027 SAPKB64027

Regards,

Muhammed

Sandra_Rossi
Active Contributor

Muhammed M 640 is old, I don't think there is a note. The enhancement framework doesn't exist yet. I'd go for asking a SSCR modification key to change RKAEP000, just adding a piece of code to export the ALV internal table into memory, when RKAEP000 is called by your program.

former_member608267
Participant
0 Kudos

Hi sandra.rossi

I am exploring the possibility(as suggested by quynh.doanmanh ) of exporting data to memory be setting up l_mode VALUE to 'B'.

FREE MEMORY ID 'ALV_EXTRACT_MODE'.
EXPORT l_mode FROM l_mode TO MEMORY ID 'ALV_EXTRACT_MODE'.
SUBMIT rkaep000 WITH p_kokrs =  p_kokrs        
                 WITH p_tcode EQ 'KSB1'
                 WITH kostl   IN s_kostl                 
                 WITH r_budat IN s_budat
                 WITH p_disvar = p_disvar
                 WITH p_usegrd = 'X'
                 USING SELECTION-SCREEN 1000
                 AND RETURN.
IMPORT it_fieldcatalog TO it_fieldcatalog  FROM MEMORY ID 'ALV_EXTRACT_FCAT'.
* Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
  EXPORTING
    it_fieldcatalog = it_fieldcatalog
  IMPORTING
    ep_table        = it_outtab.
ASSIGN it_outtab->* TO <gt_pos_data>.
"-->the program is going to dump in below statement
*- Runtime Error CONNE_IMPORT_WRONG_STRUCTURE
*- Except.                CX_SY_IMPORT_MISMATCH_ERROR
IMPORT it_outtab to <gt_pos_data> FROM MEMORY ID 'ALV_EXTRACT_TABLE'.
FREE MEMORY ID : 'ALV_EXTRACT_MODE',
                 'ALV_EXTRACT_FCAT',
                 'ALV_EXTRACT_TABLE'.

Regards,

Muhammed

former_member608267
Participant
0 Kudos

Hi quynh.doanmanh

I was trying with to export data using memory id 'ALV_EXTRACT_MODE'.

I am able to import internal table it_fieldcatlog from memory id 'ALV_EXTRACT_FCAT'.

When I'm trying to import it_outtab, the program is throwing up runtime error "

CONNE_IMPORT_WRONG_STRUCTURE" because the internal table structures are different.

IMPORT it_outtab to <gt_pos_data> FROM MEMORY ID 'ALV_EXTRACT_TABLE'.

Is there any way to declare dynamic internal table with name it_outtab .

sandra.rossi appreciate your inputs.

Regards,

Muhammed

DoanManhQuynh
Active Contributor
0 Kudos

Im afraid that catalog and table columns not always the same and it true in this case. you may have to check the difference by yourself and hardcode it...(table output is saved in mt_outtab attribute of alv).

former_member608267
Participant
0 Kudos

Hi quynh.doanmanh

Exactly the internal tables it_outtab it_fieldcatlog columns are not same and causing runtime errors.

I will try to use exit EXIT_SAPLKAEP_009 to export/import <gt_pos_data> to memory.

Regards,

Muhammed