2015 Mar 03 6:59 PM
Hi,
I have created zprogram, in that i'm calling background program "RKO7CJ8G".
now it displays list. i wanted to acess this basic list/ALV list and tried FM: REUSE_ALV_LIST_DISPLAY. but this gives me
"Field catalog not found" error
i have below code: please let me know if this the correct way to get the list. i wanted to get the error messages of the displayed list.
DATA: I_BAL_S_DMSG TYPE STANDARD TABLE OF BAL_S_DMSG INITIAL SIZE 0.
SUBMIT RKO7CJ8G
WITH kokrs EQ 'WEC0'
WITH variant EQ p_varint-low
WITH perio EQ p_perio
WITH gjahr EQ p_gjahr
WITH vaart EQ p_vaart
WITH testlauf EQ p_testlf
WITH buperio EQ p_buperi
WITH budat EQ p_budat
WITH bzdat EQ p_bzdat
WITH tdcheck EQ p_tdchek
WITH list EQ p_detlls
* EXPORTING LIST TO MEMORY
AND RETURN.
COMMIT WORK AND WAIT.
SKIP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = I_BAL_S_DMSG[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
once i execute above program i have below screen displayed and i want to access: those displayed messages.
2015 Mar 03 8:07 PM
To make your ALV work, just add the following parameter under EXPORTING:
I_STRUCTURE_NAME = 'BAL_S_DMSG'
This will read the DDIC definition of BAL_S_DMSG and automatically create the fieldcatalog from it.
If you have a table with a non-DDIC-structure, you'll have to fill IT_FIELDCAT with the complete fieldcatalog.
But,You cannot just access a internal table from another report, because it only exists during runtime of this report.
In order to access it, the submitted report has to put the information into some memory area (EXPORT TO MEMORY) or into a database table that you could access using a SELECT.
Maybe, you can also use application log functions from function group SLG0 or SLG3 (like APPL_LOG_DISPLAY), because those messages are created with standard application log functions. But I'm not sure.
Alternatively, you can use SUBMIT ... EXPORTING LIST TO MEMORY and access it with functionmodule LIST_FROM_MEMORY.
There is a similar discussion here: http://scn.sap.com/thread/39352
2015 Mar 03 8:07 PM
To make your ALV work, just add the following parameter under EXPORTING:
I_STRUCTURE_NAME = 'BAL_S_DMSG'
This will read the DDIC definition of BAL_S_DMSG and automatically create the fieldcatalog from it.
If you have a table with a non-DDIC-structure, you'll have to fill IT_FIELDCAT with the complete fieldcatalog.
But,You cannot just access a internal table from another report, because it only exists during runtime of this report.
In order to access it, the submitted report has to put the information into some memory area (EXPORT TO MEMORY) or into a database table that you could access using a SELECT.
Maybe, you can also use application log functions from function group SLG0 or SLG3 (like APPL_LOG_DISPLAY), because those messages are created with standard application log functions. But I'm not sure.
Alternatively, you can use SUBMIT ... EXPORTING LIST TO MEMORY and access it with functionmodule LIST_FROM_MEMORY.
There is a similar discussion here: http://scn.sap.com/thread/39352
2015 Mar 03 8:27 PM
Thanks Heiko,
I tried EXPORTING LIST TO MEMORY that gives short dump when program is executed.
and i included I_STRUCTURE_NAME = 'BAL_S_DMSG'
but the table did not return any values; its blank.
2015 Mar 09 6:53 PM
2015 Mar 09 7:37 PM
* first call to suppress display of called programm and save
* both content and metadata (needed for fieldcatalog)
cl_salv_bs_runtime_info=>set( display = abap_false
metadata = abap_true
data = abap_true ).
* Then call your submitted program
submit (p_repid) using selection-set p_vari
and return.
* You will need something like:
data: ls_metadata type cl_salv_bs_runtime_info=>s_type_metadata.
data: lr_alv type ref to data.
field-symbols: <alv_cont> type standard table.
* to get hold of the alv-content:
cl_salv_bs_runtime_info=>get_data_ref( importing r_data = lr_alv ).
* Of course, You'll need a field-symbol to make it accessible.
assign lr_alv->* to <alv_cont>.
* Now we're going to fetch the field-catalog (in ls_metadata-t_fcat)
ls_metadata = cl_salv_bs_runtime_info=>get_metadata( ).
Now, the rest is up to you, to figure out.
It really works great, once you get the principle.
Hope it helps.
Best regards - Jörg
2015 Mar 09 8:09 PM
2015 Mar 09 9:04 PM
Hi Jorg,
I'm geeting FLUSH error
Trigger Location of Runtime Error
Program CL_GUI_CFW====================CP
Include CL_GUI_CFW====================CM002
Row 23
Module type (METHOD)
Module Name FLUSH
Line SourceCde
1
2 METHOD FLUSH .
3 * ...
4 data: rc like sy-subrc, msgli like sy-msgli.
5
6 CALL FUNCTION 'AC_FLUSH_CALL'
7 EXPORTING
8 SYSTEM_FLUSH = ' '
9 IMPORTING
10 MESSAGE_NR = rc
11 MESSAGE_TEXT = msgli.
12
13 sy-subrc = rc.
14 sy-msgli = msgli.
15
16 CASE SY-SUBRC.
17 WHEN 0.
18 WHEN 1.
19 * system_error
20 MESSAGE ID 'CNDP' TYPE 'X' NUMBER 007 RAISING CNTL_SYSTEM_ERRO
21 WHEN 2.
22 * method_call_error
>>>>> MESSAGE ID 'CNDP' TYPE 'X' NUMBER 006 RAISING CNTL_ERROR.
24 WHEN 3.
25 * property_set_error
26 MESSAGE ID 'CNDP' TYPE 'X' NUMBER 006 RAISING CNTL_ERROR.
27 WHEN 4.
28 * property_get_error
29 MESSAGE ID 'CNDP' TYPE 'X' NUMBER 006 RAISING CNTL_ERROR.
30 WHEN 8.
31 * maximal number of modi reached
32 MESSAGE ID 'CNDP' TYPE 'X' NUMBER 011 RAISING CNTL_SYSTEM_ERROR.
33 WHEN OTHERS.
34 RAISE CNTL_ERROR.
35 ENDCASE.
36 ENDMETHOD.
2015 Mar 10 9:06 AM
Hi,
can you elaborate a bit more?
where does that error come from?
When you hit the runtime-error, go to debugger, chose the tab named standard, where you'll find the call-stack. there you can trace back until you find the last bit of your own coding. When you doubleclick the line in the call-stack table, the debugger will navigate to that code-segment, making accessible all variables known in that context, holding the values, they last had before the dump.
Try to find out what lead to the problem. If you're not successfull, you can navigate from the debugger to the sourcecode and give us a bit more to work on (snippet).
Thanks - Jörg
2015 Mar 11 1:50 PM
Thanks Jorg,
I get error at 'submit' statement.
when I have below code before 'submit' statment.
* first call to suppress display of called programm and save
* both content and metadata (needed for fieldcatalog)
cl_salv_bs_runtime_info=>set( display = abap_false
metadata = abap_true
data = abap_true ).
and once I commnet that, I get error at
ls_metadata = cl_salv_bs_runtime_info=>get_metadata( ).
2015 Mar 11 6:20 PM
Hi,
the screenshot helps some but still leaves things to guess.
Of course,
cl_salv_bs_runtime_info=>get_metadata( )
will not work when you didn't invoke
cl_salv_bs_runtime_info=>set( display = abap_false
metadata = abap_true
data = abap_true ).
earlier.
So let's fokus on the scenario, when you hadn't commented it and the problem arose at submit.
Can you give me a code sample from there?
Using this approach, it is essential that the called program really produces an alv output, not a list.
And of course,
you don't use EXPORTING LIST TO MEMORY or TO SAP-SPOOL!
It should look somewhat like in my first post:
data: ls_metadata type cl_salv_bs_runtime_info=>s_type_metadata.
data: lr_alv type ref to data.
field-symbols: <alv_cont> type standard table.
cl_salv_bs_runtime_info=>set( display = abap_false
metadata = abap_true
data = abap_true ).
submit THE_OTHER_REPORT
[ using selection-set p_vari ]
[ with parm1 = somevalue
with parm2 = someother
with selop1 in myrange ... ]
and return.
cl_salv_bs_runtime_info=>get_data_ref( importing r_data = lr_alv ).
assign lr_alv->* to <alv_cont>.
ls_metadata = cl_salv_bs_runtime_info=>get_metadata( ).
Now that you have both, metadata and content available, you can build your own alv or
output in file, process the data or whatever it is you need to do.
BTW: which NW release do you run?
BR - Jörg
2015 Mar 12 5:30 PM
Thanks Jorg, I appreciate your time.
I have below code, for the first few runs(F8) the system could display the runtime error same as earlier one i posted (FLUSH error), now later runs, the system is exiting out completely i had to sign in back again after each run.
the error is at submit statement
*&---------------------------------------------------------------------*
*& Report ZCJ8G_NEW1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZCJ8G_NEW1.
* You will need something like:
data: ls_metadata type cl_salv_bs_runtime_info=>s_type_metadata.
data: lr_alv type ref to data.
field-symbols: <alv_cont> type standard table.
* first call to suppress display of called programm and save
* both content and metadata (needed for fieldcatalog)
cl_salv_bs_runtime_info=>set( display = abap_false
metadata = abap_true
data = abap_true ).
SUBMIT RKO7CJ8G
WITH kokrs EQ 'WEC0'
WITH variant EQ 'MID_WBS_GROUP1'
WITH perio EQ '012'
WITH gjahr EQ '2014'
WITH vaart EQ '1'
WITH testlauf EQ 'X'
* WITH buperio EQ p_buperi
* WITH budat EQ p_budat
* WITH bzdat EQ p_bzdat
* WITH tdcheck EQ p_tdchek
* WITH list EQ p_detlls
* EXPORTING LIST TO MEMORY
AND RETURN.
* to get hold of the alv-content:
cl_salv_bs_runtime_info=>get_data_ref( importing r_data = lr_alv ).
* Of course, You'll need a field-symbol to make it accessible.
assign lr_alv->* to <alv_cont>.
* Now we're going to fetch the field-catalog (in ls_metadata-t_fcat)
ls_metadata = cl_salv_bs_runtime_info=>get_metadata( ).
WRITE : /1 'CJ8G report extract processed'.