12-29-2011 7:03 AM
Hello,
I am currently trying to create a program that submits a different program with its variant and get the resulting alv report as an internal table to send it in mail as excel attachment. I know it seems a little bit complex, but I resolved all of the parts except getting internal table from alv report. Please help me to do this, <<removed>>
I can upload my code if it is requested.
Thank you.
Edited by: kishan P on Dec 29, 2011 12:34 PM
12-30-2011 11:48 AM
What i understood from ur question is...
u have a zprogram in which u r calling another program say xyz and u need the ouput of that xyz program in ur zprogram internal table??
If i am correct then u take the example of below code which i successfully used in my program
Check the types of t_tab1 and t_tab2.
SUBMIT xyz
EXPORTING LIST TO MEMORY AND RETURN.
REFRESH t_tab1.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_tab1
EXCEPTIONS
not_found = 1.
IF sy-subrc <> 0.
ENDIF.
*Converting to ASCII
REFRESH t_tab2.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_tab2
listobject = t_tab1
EXCEPTIONS
empty_list = 1
list_index_invalid = 2.
IF sy-subrc <> 0.
WRITE: / 'LIST_TO_ASCI error'(098).
ENDIF.
IF t_tab2 IS NOT INITIAL.
DELETE t_tab2 INDEX 1.
DELETE t_tab2 INDEX 1.
DELETE t_tab2 INDEX 1.
DESCRIBE TABLE t_tab2 LINES g_tabix.
DELETE t_tab2 INDEX g_tabix.
ENDIF.
t_tab2 has the alv report ouput
12-29-2011 7:08 AM
12-29-2011 7:16 AM
report kerim.
tables: knb1.
DATA list_tab TYPE TABLE OF abaplist.
data utab like standard table of abaplist with header line.
data btab like standard table of zya_itab20 with header line.
data main_text type bcsy_text.
data w_body_msg like solisti1.
DATA RECEIVERS like standard table of somlreci1 with header line.
data result type char50.
selection-screen begin of block 1.
parameters program type char20.
parameters variant type char20.
selection-screen end of block 1.
selection-screen begin of block 2.
select-options p_mailad for knb1-intad no intervals.
parameters mailsb type char50.
selection-screen begin of line.
parameters p_satr(30) type c.
selection-screen end of line.
selection-screen begin of line.
parameters p_satir1(30) type c.
selection-screen end of line.
selection-screen begin of line.
parameters p_satir2(30) type c.
selection-screen end of line.
selection-screen begin of line.
parameters p_satir3(30) type c.
selection-screen end of line.
selection-screen end of block 2.
SUBMIT (program) using selection-set variant EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
***** This is the part that i need a fm to convert alv report(list_tab) into utab*
perform build_body_of_mail
using:space,
p_satr,
p_satir1,
p_satir2,
p_satir3.
*------------------------------------------------------------------
*Mail Recipients
*--------------------------------------------------------------------
loop at p_mailad.
receivers = p_mailad-low.
append receivers.
endloop.
*-----------------------------------------------------------------
*------------------------------------------------------------------------*
call function 'ZYA_SEND_MAIL_EXCEL'
EXPORTING
subject = mailsb
IMPORTING
RESULT = result
TABLES
EXCEL_table = utab
EXCEL_header = btab
RECEIVERS = RECEIVERS
BODY = main_text.
WRITE : result.
*--------------------------------------------------------------------------*
*----------------------------------------------------------------------*
*mail body
*----------------------------------------------------------------------*
form build_body_of_mail using l_message.
w_body_msg = l_message.
append w_body_msg to main_text.
clear w_body_msg.
endform.
************************************************************
12-29-2011 9:32 PM
Hi kerimmkilic,
the method suggested by keshav will not work because you submit the report. This means it runs in it's own memory area that can not be accessed from outside.
But as utab and list_tab are the same structure, why don't you just
append lines of list_tab to utab.
Regards,
Clemens
12-29-2011 7:22 AM
Are you aware of this blog [Gain Programmatic Access to Data of SAPGUI ALV Reports|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/24944] [original link is broken] [original link is broken];
12-29-2011 3:07 PM
Hi Keshav,
The link you have sent is really useful and the class seems to do the thing what I want. But, I couldn't modified it to my code. I got dumped when It is trying to use get_ref_data method.
12-30-2011 4:31 AM
REPORT ymard.
TYPE-POOLS:slis.
DATa:it TYPE TABLE OF mard,
fcat TYPE slis_t_fieldcat_alv.
SELECT * FROM mard UP TO 10 ROWS INTO TABLE it.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = 'MARD'
CHANGING
ct_fieldcat = fcat.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = fcat
TABLES
t_outtab = it.
REPORT abc.
FIELD-SYMBOLS:<fs_tab> TYPE ANY TABLE,
<fs_line> type any.
DATA:lf_ref TYPE REF TO data,
lf_ref1 type ref to data.
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).
SUBMIT ymard AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lf_ref ).
ASSIGN lf_ref->* TO <fs_tab>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
CREATE DATA lf_ref1 LIKE LINE OF <fs_tab>.
ASSIGN lf_ref1->* TO <fs_line>.
LOOP AT <fs_tab> ASSIGNING <fs_line>.
"--
ENDLOOP.
This works fine. Now please post the code where you face the error.
@Clemens - Its works fine. This blog demonstrates to get the data from ALV after a Submit statement.
10-03-2014 12:27 PM
Works fine for me.
Also works using CALL TRANSACTION.
I use it to put several calls to FBL3N transaction into internal tables.
Thank you.
12-30-2011 6:18 AM
Hello Keshav,
My problem is not getting the internal table after submitting. I have it but I don't have an idea how to append its lines into my internal table.
The resulting internal table lt_pay_data is a field symbol. And I need to convert it to my internal table structure 'zya_itab20'. It is a (20 string) internal table. Here is my code:
report kerim.
tables: knb1.
DATA list_tab TYPE TABLE OF abaplist.
*field-symbols: <utab> type any table.
data utab like standard table of zya_itab20 with header line.
data btab like standard table of zya_itab20 with header line.
data main_text type bcsy_text.
data w_body_msg like solisti1.
DATA RECEIVERS like standard table of somlreci1 with header line.
data result type char50.
FIELD-SYMBOLS <lt_pay_data> TYPE ANY TABLE.
DATA lr_pay_data TYPE REF TO data.
selection-screen begin of block 1.
parameters program type char20.
parameters variant type char20.
selection-screen end of block 1.
selection-screen begin of block 2.
select-options p_mailad for knb1-intad no intervals.
parameters mailsb type char50.
selection-screen begin of line.
parameters p_satr(30) type c.
selection-screen end of line.
selection-screen begin of line.
parameters p_satir1(30) type c.
selection-screen end of line.
selection-screen begin of line.
parameters p_satir2(30) type c.
selection-screen end of line.
selection-screen begin of line.
parameters p_satir3(30) type c.
selection-screen end of line.
selection-screen end of block 2.
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).
Submit (program) USING SELECTION-SET variant
AND RETURN.
TRY. cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lr_pay_data ).
ASSIGN lr_pay_data->* TO <lt_pay_data>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `Unable to retrieve ALV data` TYPE 'E'. ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
perform build_body_of_mail
using:space,
p_satr,
p_satir1,
p_satir2,
p_satir3.
*------------------------------------------------------------------
*Mail Recipients
*--------------------------------------------------------------------
loop at p_mailad.
receivers = p_mailad-low.
append receivers.
endloop.
*-----------------------------------------------------------------
* Problem is here. Can't convert field symbol data into utab.
append lines of <lt_pay_data> to utab.
*------------------------------------------------------------------------*
call function 'ZYA_SEND_MAIL_EXCEL'
EXPORTING
subject = mailsb
IMPORTING
RESULT = result
TABLES
EXCEL_TABLO = utab "lr_pay_data
EXCEL_BASLIK = btab
RECEIVERS = RECEIVERS
BODY = main_text.
WRITE : result.
*--------------------------------------------------------------------------*
*----------------------------------------------------------------------*
*mail body
*----------------------------------------------------------------------*
form build_body_of_mail using l_message.
w_body_msg = l_message.
append w_body_msg to main_text.
clear w_body_msg.
endform.
************************************************************
12-30-2011 6:35 AM
It is a (20 string) internal table
Please explain the above.
Extra Notes - Please search in SCN or read F1 for assign component of structure
12-30-2011 7:05 AM
Let me explain it manually:
zya_itab20 is a (max) 20 fields internal table. All of these fields are string type. When I use your code I get all of the values in the line of fs_line. I need every single value of each component from fs_line into utab-stringx.(x is the number of string).
At the end I want a table like utab.
From Alv report I get:
"1st loop" <fs_line> = "Beko UK 300,000TL"
"2nd loop" <fs_line> = "Arcelik TR 600,000TL"
"3rd loop" <fs_line> = "LG DE 500,000TL"
I need:
''1st tab of utab'' utab-string1 = 'Beko' utab-string2 = 'UK' utab-string3 = '300,000TL'
''2nd tab of utab'' utab-string1 = 'Arcelik' utab-string2 = 'TR' utab-string3 = '600,000TL'
''3rd tab of utab'' utab-string1 = 'LG' utab-string2 = 'DE' utab-string3 = '500,000TL'
''4th tab of utab'' utab-string1 = 'Bregenz' utab-string2 = 'AU' utab-string3 = '400,000TL'
12-30-2011 11:48 AM
What i understood from ur question is...
u have a zprogram in which u r calling another program say xyz and u need the ouput of that xyz program in ur zprogram internal table??
If i am correct then u take the example of below code which i successfully used in my program
Check the types of t_tab1 and t_tab2.
SUBMIT xyz
EXPORTING LIST TO MEMORY AND RETURN.
REFRESH t_tab1.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_tab1
EXCEPTIONS
not_found = 1.
IF sy-subrc <> 0.
ENDIF.
*Converting to ASCII
REFRESH t_tab2.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_tab2
listobject = t_tab1
EXCEPTIONS
empty_list = 1
list_index_invalid = 2.
IF sy-subrc <> 0.
WRITE: / 'LIST_TO_ASCI error'(098).
ENDIF.
IF t_tab2 IS NOT INITIAL.
DELETE t_tab2 INDEX 1.
DELETE t_tab2 INDEX 1.
DELETE t_tab2 INDEX 1.
DESCRIBE TABLE t_tab2 LINES g_tabix.
DELETE t_tab2 INDEX g_tabix.
ENDIF.
t_tab2 has the alv report ouput
01-20-2014 3:02 PM
Hi suruchi,
I am also doing the same Within a Z program ,I am calling a standard program RFITEMAR and trying to store the output inside an Internal table but the standard report out put format is in ALV. and i need to store also in ALV
And what is here t_tab1 and t_tab2 ? one is final internal table for standard report and other is of same type ?
12-30-2011 12:16 PM
Hello Suruchi,
In your code, you get the output of program as a list. But in our programs, output is generally in ALV format. SO I need to use standard table in my last function. I resolved how to convert alv report into raw internal table with the class in my last code preview. Now, I need to solve how to append its content into my internal table. Please check my last code.
01-20-2014 2:48 PM
Hi kerim,
I am also doing the same Within a Z program ,I am calling a standard program RFITEMAR and trying to store the output inside an Internal table but the standard report out put format is in ALV. and i need to store
And what is here t_tab1 and t_tab2 ? one is final internal table for standard report and other is of same type?
05-22-2015 2:15 PM
Hi Sunil,
Its regarding t_tab1 and t_tab2. in FM 'LIST_TO_ASCI'.
EXAMPLE :
DATA : t_tab1 LIKE ABAPLIST OCCURS 1.
DATA : BEGIN OF t_tab2 OCCURS 1,
LINE(256),
END OF t_tab2.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_tab2
listobject = t_tab1
EXCEPTIONS
empty_list = 1
list_index_invalid = 2.
IF sy-subrc <> 0.
WRITE: / 'LIST_TO_ASCI error'(098).
ENDIF.
once you get the list you can get individual column by split t_tab2 at '/' (delimiter)
SPLIT t_tab2-LINE AT '/' INTO TABLE lt_split.
Functionality of FM LIST_TO_ASCI
Converts the provided list (LISTOBJECT) to ASCI.
Here, the purely text part of the list is copied line by line to the prepared internal table (LISTASCI) without any attributes (color, icon, symbol, ...). There is no line break in this case, i.e. if the internal table line is not long enough, the list line is truncated. If the parameter WITH_LINE_BREAK is set, then the lines are wrapped.
Regards,
Chetan