Skip to Content
-1

Class cl_salv_bs_runtime_info not returning ALV data

Dec 15, 2016 at 09:23 AM

209

avatar image

REPORT /db0/dm_abr_izv_auto.

TABLES : bca_bpare,
bca_rcn_sums_in.

FIELD-SYMBOLS <lt_pay_data> TYPE ANY TABLE.
DATA lr_pay_data TYPE REF TO data.
DATA number TYPE tbtcjob-jobcount.
DATA name TYPE tbtcjob-jobname VALUE 'JOB_IZV_TEST'.
FIELD-SYMBOLS <ls_pay_data> TYPE ANY TABLE.
DATA print_parameters TYPE pri_params.



SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-p01.
SELECT-OPTIONS:
o_bpare FOR bca_bpare-bpare MEMORY ID bns OBLIGATORY.
PARAMETERS:
p_date_p LIKE bca_rcn_sums_in-date_post OBLIGATORY,
p_maingp LIKE tbca_drp_maingrp-main_grp OBLIGATORY.

SELECTION-SCREEN END OF BLOCK block1.
** Authority Check
AUTHORITY-CHECK OBJECT 'ZTT_REPORT'
ID 'ACTVT' FIELD '16'
ID 'PROGRAM' FIELD 'ZDM2'.
IF sy-subrc <> 0.
MESSAGE i001(/db0/dm_cx_tt_main) WITH 'ZDM2' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDIF.
* Instantiate the class to fetch the data
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).
** Start of selection
START-OF-SELECTION.
IF sy-batch IS INITIAL.
MESSAGE 'Report can only be executed in Background' TYPE 'E'.
STOP.
ENDIF.
** Open the job to write the logs( SM37)
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
STOP.
ENDIF.
** Import results call the main program
SUBMIT rbca_rcn_drp_maingrp_disp USING SELECTION-SCREEN '1000'
WITH p_date_p EQ p_date_p
WITH o_bpare IN o_bpare[]
WITH p_maingp EQ p_maingp
VIA JOB name NUMBER number
AND RETURN.
** Import the main program data
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data_line = lr_pay_data ).
ASSIGN lr_pay_data->* TO <lt_pay_data>.
CATCH cx_salv_bs_sc_runtime_info.
ENDTRY.
** Write into the logs in case no data is found.
IF <lt_pay_data> IS NOT ASSIGNED.
MESSAGE e000(/db0/dm_abr_izv) WITH sy-msgno INTO sy-msgli.
cl_bca_msg_log_srv=>s_add_message( ).
ENDIF.
** Close the logs to be written( Sm37)
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
** Instantiate the logs for SLG1
cl_bca_msg_log_srv=>s_create( ).
** Write the actual retrieved data into the logs( SLG1)
*CHECK <lt_pay_data> IS NOT INITIAL.
* LOOP AT <lt_pay_data> ASSIGNING <ls_pay_data>.
* MESSAGE s000(00) WITH sy-msgno INTO sy-msgli.
* cl_bca_msg_log_srv=>s_add_message( ).
* ENDLOOP.
**Write the logs
IF sy-batch IS INITIAL.
cl_bca_msg_log_srv=>s_display_log( i_flg_delete = space ).
ENDIF.
** Save the Logs in the memory
cl_bca_msg_log_srv=>s_save_all( ).
** Close the instantiated object
cl_bca_msg_log_srv=>s_close( ).
** Clear the importing class memory.
cl_salv_bs_runtime_info=>clear_all( ).

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Shoumya Chowdhury Dec 15, 2016 at 09:50 AM
-1

Hey Tomas,

Thank you for your answer, I have removed the submit via job and have also tried, however that did not help, somehow the class still does not fetch the results.

Share
10 |10000 characters needed characters left characters exceeded
Tomas Buryanek Dec 15, 2016 at 09:44 AM
0

I think it is because you are submiting report via job. So ALV is executed in different runtime.

By the way forum has new feature where you can post formated code and it is also syntax highlighted. Please use it for better readability...

Share
10 |10000 characters needed characters left characters exceeded
Raymond Giuseppi
Dec 15, 2016 at 10:03 AM
0

Prerequisites

  • Remove the stuff relative to background job
  • Move every call of cl_salv_bs_runtime_info in the START-OF-SELECTION event
  • Handle the error returned in exceptions
  • If no data returned in r_data_line, try r_data parameter, also insure correct format

Regards,
Raymond

Share
10 |10000 characters needed characters left characters exceeded