Application Development and Automation 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: 
Read only

ALV to Spool using set_table_for_first_display

Former Member
0 Likes
9,846

xperts,

i have a report , i need the output in foreground ALV and background SPOOL.

For that i have used

set_table_for_first_display

i m getting the alv output correctly.

but not able to generate spool list of the same .

any other methods available other than SUBMIT report?

plz advice

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,231

Hi,

I was able to send the ALV grid to spool as following:

IF sy-batch = 'X'.

ls_print-print = 'X'.

ls_print-no_print_listinfos = 'X'.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = lt_fieldcat

is_print = ls_print

it_sort = lt_sort

TABLES

t_outtab = lt_data.

Thanks,

Arash

12 REPLIES 12
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
4,231

You can check the param IS_PRINT of the method SET_TABLE_FOR_FIRST_DISPLAY.

Read only

Former Member
0 Likes
4,232

Hi,

I was able to send the ALV grid to spool as following:

IF sy-batch = 'X'.

ls_print-print = 'X'.

ls_print-no_print_listinfos = 'X'.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = lt_fieldcat

is_print = ls_print

it_sort = lt_sort

TABLES

t_outtab = lt_data.

Thanks,

Arash

Read only

0 Likes
4,231

Hi,

If u want to display the alv output using SET_TABLE_FOR_FIRST_DISPLAY in a spool then u have use a docking container.

below code will be useful for you.

DATA: GV_DOC TYPE REF TO CL_GUI_DOCKING_CONTAINER,

GV_CCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

GV_GRID1 TYPE REF TO CL_GUI_ALV_GRID,

GV_EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.

IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.

CREATE OBJECT GV_CCONTAINER

EXPORTING

CONTAINER_NAME = 'GV_CCONTAINER'.

CREATE OBJECT GV_GRID1

EXPORTING

I_PARENT = GV_CCONTAINER.

ELSE.

CREATE OBJECT GV_GRID1

EXPORTING

I_PARENT = GV_DOC.

ENDIF.

then

CAll method GV_GRID1->SET_TABLE_FOR_FIRST_DISPLAY.

Edited by: subas Bose on May 12, 2010 12:23 AM

Read only

Former Member
0 Likes
4,231

Hi i know it's an old question but know i have the same but i'm not finding a solution.

can u please tell me how to get spool id after displaying my ALV GRID.

Regards.

imedix

Read only

Former Member
0 Likes
4,231

Hi,

All that is required is a simple check of the sy-batch variable to determine if the program is being executed in the foreground or background.

e.g. if sy-batch is initial.

call screen 0100.

else.

perform present_grid.

endif.

In a PBO module of screen 0100, the subroutine present_grid is also performed.

The set_table_for_first_display method will be invoked in the routine present_grid, however, due to the job being executed in the background, the ALV list output will be written as spool output for the background job.

Regards,

bhavana

Read only

0 Likes
4,231

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

cover_page = 'X'

list_name = 'X'

no_dialog = 'X'

IMPORTING

out_parameters = wa_params

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

wa_print-print_ctrl-pri_params = wa_params.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_bypassing_buffer = c_check

is_layout = is_layout

it_fieldcat = t_fc

is_print = wa_print

TABLES

t_outtab = t_output

EXCEPTIONS

program_error = 1

OTHERS = 2.

this works fine..

Read only

0 Likes
4,231

Hi,

So ur problem is solved?

cheers

Bhavana

Read only

0 Likes
4,231

It was an old post by me.

and got it solved a couple of days b4.

i jst put the solution

Thanks & Regards,

Anoop Chandran.

Read only

0 Likes
4,231

Ok Anoop,

Iam srry,please closed the thread if it is answered....

Bhavana

Read only

0 Likes
4,231

still have the same problem when when i'm calling screen 101 The spool is generated but i still in screen 100.

that's my code:

PBO of screen 101.

...

CREATE OBJECT grid04

EXPORTING i_parent = g_custom_container04.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

cover_page = 'X'

list_name = 'X'

no_dialog = 'X'

IMPORTING

out_parameters = wa_params

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

ls_print-print = 'X'.

ls_print-print_ctrl-pri_params = wa_params.

CALL METHOD grid04->set_table_for_first_display

EXPORTING

is_layout = ls_layo

it_toolbar_excluding = t_exclude

is_print = ls_print

CHANGING

it_fieldcatalog = lt_fieldcat4

it_outtab = <fs_output>.

Read only

0 Likes
4,231

I think that solution is:

1- Show ALV report as Spool report

2- Store spool report in pdf form

3- Send an email with pdf attached.

But I'm not sure. I'm investigating.

Read only

0 Likes
4,231

Hi Anoop,

I am also having the same requirement.

I am able to generate spool. But the next step in the code is not working.

FM 'CONVERT_ABAPSPOOLJOB_2_PDF' is not getting executed.

   CALL METHOD g_ref_grid->set_table_for_first_display

      EXPORTING

        i_save                        = 'A'

        is_layout                     = gs_layo "Layout

        is_print                      = gs_print "For Creating Spool

      CHANGING

        it_outtab                     = gt_output "Final Internal Table Containing Data to Display

        it_fieldcatalog               = gt_fcat "Fieldcatalog

      EXCEPTIONS

        invalid_parameter_combination = 1

        program_error                 = 2

        too_many_lines                = 3

        OTHERS                        = 4.

    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

*    NEW-PAGE PRINT OFF.

*convert spool to pdf and send as attachment to sap inbox.

    MOVE sy-spono TO lv_spool_nr.

    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

      EXPORTING

        src_spoolid                    = lv_spool_nr "Spool Number

        no_dialog                      = space

        dst_device                     = '%L01' "Printer Name

        importingpdf_bytecount         = lv_size "Output Size

        tablespdf                      = lt_pdf_output "Spool data in PDF Format

        exceptionserr_no_abap_spooljob = 1

        err_no_spooljob                = 2

        err_no_permission              = 3

        err_conv_not_possible          = 4

        err_bad_destdevice             = 5

        user_cancelled                 = 6

        err_spoolerror                 = 7

        err_temseerror                 = 8

        err_btcjob_open_failed         = 9.

    IF sy-subrc EQ 0.

      LOOP AT lt_pdf_output INTO ls_pdf_output.

        TRANSLATE ls_pdf_output USING c_col1.

        CONCATENATE lv_buffer ls_pdf_output INTO lv_buffer.

        CLEAR ls_pdf_output.

      ENDLOOP.