Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Trying to generate the spool from at user command...

Hi Gurus,

The spool is not getting created in the foreground, I think I am missing something here, the code is below.

AT USER-COMMAND.

CASE sy-ucomm .

WHEN 'SEND'.

PERFORM get_cust_emails.

LOOP AT i_output.

READ TABLE i_mail INTO wa_mail WITH KEY kunnr = i_output-rcvprn. " rcvprn is customer number,

IF sy-subrc IS INITIAL.

IF wa_mail-smtp_addr IS NOT INITIAL. if the customer has an email then create the entry in i_output_mail.

i_output_mail = i_output.

APPEND i_output_mail.

CLEAR: i_output_mail.

DELETE i_output.

CLEAR: i_output.

ENDIF.

ENDIF.

ENDLOOP.

  • Setting the Print Parameter's for Portrait

PERFORM f_print_report. " form is below

SORT i_output_mail BY rcvprn belnr. "rcvprn is the customer number

PERFORM f_prepare_mail. " form is below

MESSAGE i307.

LEAVE LIST-PROCESSING.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'CANCEL'.

LEAVE PROGRAM.

ENDCASE.

Subroutines provided below:

FORM f_print_report .

*Program name

DATA : l_prog_name TYPE sy-repid,

i_print TYPE slis_print_alv.

  • Local Constants

CONSTANTS: lc_vline TYPE c VALUE '|'.

l_prog_name = sy-repid.

CLEAR: i_events[], wa_events.

wa_events-name = c_top. "'TOP_OF_PAGE'.

wa_events-form = c_top.

APPEND wa_events TO i_events.

CONSTANTS: lc_prtr TYPE sypdest VALUE 'LP01',

lc_layout TYPE sypaart VALUE 'X_90_120',

lc_layout1 TYPE sypaart VALUE 'X_65_255',

lc_lines TYPE sylinsz VALUE '-120',

lc_lines1 TYPE sylinsz VALUE '-185',

lc_mode TYPE sycallr VALUE 'CURRENT'.

  • Get the print paramters

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

authority = space

destination = lc_prtr

immediately = space

new_list_id = c_x

layout = lc_layout

line_size = lc_lines

mode = lc_mode

no_dialog = c_x

report = sy-repid

user = sy-uname

suppress_shading = c_x

IMPORTING

out_parameters = i_pr_param

valid = l_valid

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

CLEAR: g_heading_completed."Indicator for print header

ENDFORM. "f_print_report

FORM f_prepare_mail .

LOOP AT i_output_mail.

l_flag_mail = 'X'.

CLEAR: l_flag.

WRITE: /08(1) c_vline, 10(09) i_output_mail-stapa1, 20(1) c_vline,21(10) i_output_mail-datum,

31(1) c_vline, 32(10) i_output_mail-belnr, 42(1) c_vline,43(15) i_output_mail-total,

58(1) c_vline, 59(15) i_output_mail-surcrg, 74(1) c_vline,75(05) i_output_mail-kperc,

80(1) c_vline, 81(15) i_output_mail-betrg, 96(1) c_vline,97(19) i_output_mail-summe,

116(1) c_vline,117(03) i_output_mail-curcy, 120(1) c_vline.

AT END OF rcvprn.

SUM.

ULINE /8(113).

WRITE: /8(1) c_vline.

FORMAT COLOR 3.

WRITE: 10(09) text-064, 20(01) c_vline, 21(10) space,

31(1) c_vline, 32(10) space, 42(01) c_vline, 43(15) i_output_mail-total,

58(1) c_vline, 59(15) i_output_mail-surcrg, 74(1) c_vline, 75(05) space,

80(1) c_vline, 81(15) i_output_mail-betrg, 96(1) c_vline, 97(19) i_output_mail-summe,

116(1) c_vline,117(03) space, 120(01) c_vline.

FORMAT COLOR OFF.

ULINE /8(113).

NEW-PAGE.

ENDAT.

AT END OF rcvprn.

i_pr_param-linsz = 1000.

NEW-PAGE PRINT ON PARAMETERS i_pr_param NO DIALOG.

NEW-PAGE PRINT OFF.

  • If spool number is obtained, generate PDF

IF sy-spono IS NOT INITIAL.

PERFORM f_generate_pdf.

*Send the PDF as mail attachement

PERFORM f_send_email.

ENDIF.

ENDAT.

ENDLOOP.

ENDFORM. " SEND_MAIL

Please check the code and suggest some changes.

Thanks,

Sukumar.

Former Member
Former Member replied

Hi,

Write as below ..

LOOP AT i_output_mail.

at NEW rcvprn.

NEW-PAGE PRINT ON PARAMETERS i_pr_param NO DIALOG.

endat.

...

.

.

.

AT END OF rcvprn.

i_pr_param-linsz = 1000.

NEW-PAGE PRINT OFF.

  • If spool number is obtained, generate PDF

IF sy-spono IS NOT INITIAL.

PERFORM f_generate_pdf.

*Send the PDF as mail attachement

PERFORM f_send_email.

ENDIF.

ENDAT.

...

...

Regards,

Srini.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question