‎2010 Mar 04 10:19 AM
My requirement is to create spool and then send spool as PDF attachment.
PDF is created using FM CONVERT_ABAPSPOOLJOB_2_PDF.
Spool is created using following statements -
NEW-PAGE PRINT ON PARAMETERS x_print_parameters NO DIALOG.
NEW-PAGE PRINT OFF.
This will create spool and I retrieve the spool using sy-spono.
This works fine in foreground processing. But when I execute report for 4 cost centers. This should create 4 spools and then send 4 mails.
But program only creates 1 spool and rest of the spools are not created though I am able to fetch the spool number using sy-spono.
Edited by: vnair09 on Mar 4, 2010 11:20 AM
‎2010 Mar 04 10:34 AM
Hi,
<li>Try to call function module ABAP4_COMMIT_WORK after NEW PAGE-PRINT OFF .
Thanks
Venkat.ONEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
‎2010 Mar 04 7:40 PM
Hi,
How about submitting 4 jobs one with each cost center. You need to place sy-batch check in appropriate places.
Thanks,
Vinod.
‎2010 Mar 05 4:55 AM
Hi ,
If you are submitting to spool with same report name , the it will be recursion and will result in infinite loop.
To resolve this, we need to use ABAP memory and Export a flag variable with a dummy value to restrict the execution of Submit statement, only once.
Hope this helps you.
‎2012 Jan 10 5:43 AM
Hi,
I have a requirement to create Spool request using set_table_for_first_display method in foreground without showing print window. then from that spool, i have to create PDF file and send as e-mail.
I have done everything. but stuck with spool creation step.
my code for spool creation step looks like this.In this,variable v_spono everytime showing 0.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
* ARCHIVE_ID = C_CHAR_UNKNOWN
* ARCHIVE_INFO = C_CHAR_UNKNOWN
* ARCHIVE_MODE = C_CHAR_UNKNOWN
* ARCHIVE_TEXT = C_CHAR_UNKNOWN
* AR_OBJECT = C_CHAR_UNKNOWN
* ARCHIVE_REPORT = C_CHAR_UNKNOWN
* AUTHORITY = C_CHAR_UNKNOWN
* COPIES = C_NUM3_UNKNOWN
* COVER_PAGE = C_CHAR_UNKNOWN
* DATA_SET = C_CHAR_UNKNOWN
* DEPARTMENT = C_CHAR_UNKNOWN
* DESTINATION = C_CHAR_UNKNOWN
* EXPIRATION = C_NUM1_UNKNOWN
immediately = ' '
* IN_ARCHIVE_PARAMETERS = ' '
* IN_PARAMETERS = ' '
* LAYOUT = C_CHAR_UNKNOWN
* LINE_COUNT = C_INT_UNKNOWN
line_size = 220
* LIST_NAME = C_CHAR_UNKNOWN
* LIST_TEXT = C_CHAR_UNKNOWN
mode = 'CURRENT'
* NEW_LIST_ID = C_CHAR_UNKNOWN
* PROTECT_LIST = C_CHAR_UNKNOWN
no_dialog = 'X'
* RECEIVER = C_CHAR_UNKNOWN
release = 'X'
* REPORT = C_CHAR_UNKNOWN
* SAP_COVER_PAGE = C_CHAR_UNKNOWN
* HOST_COVER_PAGE = C_CHAR_UNKNOWN
* PRIORITY = C_NUM1_UNKNOWN
* SAP_OBJECT = C_CHAR_UNKNOWN
* TYPE = C_CHAR_UNKNOWN
user = sy-uname
* USE_OLD_LAYOUT = ' '
* UC_DISPLAY_MODE = C_CHAR_UNKNOWN
* DRAFT = C_CHAR_UNKNOWN
* ABAP_LIST = ' '
* USE_ARCHIVENAME_DEF = ' '
* DEFAULT_SPOOL_SIZE = C_CHAR_UNKNOWN
* WITH_STRUCTURE = C_CHAR_UNKNOWN
* SUPPRESS_SHADING = C_CHAR_UNKNOWN
* PO_FAX_STORE = ' '
* NO_FRAMES = C_CHAR_UNKNOWN
IMPORTING
* OUT_ARCHIVE_PARAMETERS =
out_parameters = st_print-print_ctrl-pri_params
* VALID =
* VALID_FOR_SPOOL_CREATION =
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 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 ON PARAMETERS st_print-print_ctrl-pri_params
NO DIALOG.
* st_print-print = ' '.
* IF sy-batch = 'X'.
st_print-print = ' '.
st_print-prnt_info = 'X'.
st_print-print_ctrl-pri_params-prnew = 'X'.
* ENDIF.
gs_layout_alv-zebra = 'X'.
gs_layout_alv-cwidth_opt = selected.
* display alv
CALL METHOD grid->set_table_for_first_display
EXPORTING
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name =
* is_variant =
* i_save =
* i_default = 'X'
is_layout = gs_layout_alv
is_print = st_print
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
CHANGING
it_outtab = git_summary[]
it_fieldcatalog = gt_fieldcat_lvc[]
* it_sort =
* it_filter =
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.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
* SELECT * FROM tsp01 INTO tsp01
* WHERE rq2name = st_print-print_ctrl-pri_params-plist
* ORDER BY rqcretime DESCENDING.
* v_spono = tsp01-rqident.
* EXIT.
* ENDSELECT.
*
* IF sy-subrc NE 0.
* CLEAR v_spono.
* ENDIF.
*convert spool to pdf and send as attachment to sap inbox.
MOVE sy-spono TO v_spono.waiting for early reply.