Application Development 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: 

Printing report

Former Member
0 Kudos

Hi,

I need to allow user to specify the printer properties before printing the report out. Can anyone suggest which FM to use ? I tried using Get_Print_Parameters but it prompt me to enter spool request which I dont want the user to see this screen. I have a spool id available. Please assist.

Thanks,

Loo

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi...

You can use the following function to print a report

CALL FUNCTION 'PRINT_REPORT'

EXPORTING

NO_DIALOG = ' '

REPORT = L_REPID

EXCEPTIONS

ARCHIVE_INFO_NOT_FOUND = 1

OTHERS = 2.

check if it is working for ya!

all the best.

9 REPLIES 9

Former Member
0 Kudos

Try executing the same FM with:


mode                   = 'BATCH'

Rob

0 Kudos

Hie Rob,

May i know what the 'BATCH' here does ?

Rgds,

Loo

I found out the Batch means :-

'BATCH' Define the print parameters for a background job.

In this mode, the name of the report to be started

is passed with the REPORT parameter.The REPORT

statement of the specified report is checked for

LINE-SIZE and LINE-COUNT definitions. These

definitions are passed as default specifications.

Furthermore, the SAVE key is offered

instead of the PRINT key in this mode.

But i still dont understand the usage of Batch here got to do with the spool screen i got.

Message was edited by:

Loo BiE

0 Kudos

Try it - it works for me.

Rob

Former Member
0 Kudos

hi...

You can use the following function to print a report

CALL FUNCTION 'PRINT_REPORT'

EXPORTING

NO_DIALOG = ' '

REPORT = L_REPID

EXCEPTIONS

ARCHIVE_INFO_NOT_FOUND = 1

OTHERS = 2.

check if it is working for ya!

all the best.

Former Member
0 Kudos

hi..

You can also try this function module SET_PRINT_PARAMETERS.

0 Kudos

Hi Pavithra,

Thanks for the suggestion. I've tried dat but the parameter box keep popping up den when i finally get rid of dat parameter box, the spool screen still comes out. Any other way ?

Former Member
0 Kudos

Thanks guys for helping up. I've tried the FM "Print_Report" it actually work but i do not want the Spool Request screen to comes out. Thus, i've created my another selection-screen for that purposes using submit <sy-repid> ztest .... where ztest is another report.

0 Kudos

Hi loo,

Can you please send your code. What you have done?

0 Kudos

I'd submit my report to sap-spool and then i retrieve the spool number and perform the printing. The code are like below :-

      • In Report A ***

FORM print_to_printer.

PERFORM send_to_spool.

SUBMIT zhrr335_eeo_prt VIA SELECTION-SCREEN AND RETURN.

ENDFORM. "Print_to_printer

      • In Report B ***

  • Message Declaration

DATA: l_msg1 TYPE symsgv ,

l_msg2 TYPE symsgv ,

l_msg3 TYPE symsgv .

  • Print Parameters

DATA: l_print_parms LIKE pri_params,

l_valid(1) TYPE c,

l_rqname(12) TYPE c,

l_rqident LIKE tsp01-rqident.

SELECTION-SCREEN BEGIN OF BLOCK frm1 WITH FRAME TITLE text-prt.

PARAMETERS: p_dest TYPE tsp03-padest,

p_copies TYPE tsp02-pjcopies.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(31) TEXT-Z01 FOR FIELD p_strtpg.

PARAMETERS: p_strtpg TYPE tsp02-pjstrtpage.

SELECTION-SCREEN COMMENT 47(10) TEXT-Z02 FOR FIELD p_endpg.

PARAMETERS: p_endpg TYPE tsp02-pjendpage.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK frm1.

AT SELECTION-SCREEN.

IF p_dest EQ space.

p_dest = 'LOCL'.

ENDIF.

IF p_copies EQ space.

p_copies = 1.

ENDIF.

IF p_strtpg EQ space.

p_strtpg = 1.

ENDIF.

  • Find out what the spool number is that was just created

PERFORM get_spool_number USING sy-uname CHANGING l_rqident.

CALL FUNCTION 'RSPO_OUTPUT_SPOOL_REQUEST'

EXPORTING

copies = p_copies

device = p_dest

spool_request_id = l_rqident

startpage = p_strtpg

endpage = p_endpg

EXCEPTIONS

change_copies_no_right = 6

change_dest_no_right = 7

dest_invalid = 12

dest_not_found = 13

dest_no_right = 14

internal_problem = 15

OTHERS = 23.

IF sy-subrc EQ 0.

l_msg1 = 'Printing in process.'.

l_msg2 = 'Please wait.'.

MESSAGE i001(00) WITH l_msg1 l_msg2.

SET SCREEN 0.

LEAVE SCREEN.

ELSE.

l_msg3 = 'Error Printing report'.

MESSAGE e001(00) WITH l_msg3.

ENDIF.

----


  • FORM get_spool_number *

----


  • Get the most recent spool created by user/report *

----


  • --> F_REPID *

  • --> F_UNAME *

  • --> F_RQIDENT *

----


FORM get_spool_number USING f_uname CHANGING f_rqident.

DATA: lc_rq2name LIKE tsp01-rq2name.

DATA: li_tsp01 TYPE tsp01.

CONCATENATE 'ZHRR335_' f_uname+0(3) INTO lc_rq2name SEPARATED BY '_'.

SELECT * FROM tsp01 INTO li_tsp01

WHERE rq2name = lc_rq2name

ORDER BY rqcretime DESCENDING.

f_rqident = li_tsp01-rqident.

EXIT.

ENDSELECT.

IF sy-subrc NE 0.

CLEAR f_rqident.

ENDIF.

ENDFORM." get_spool_number

Hope it could help u.

Cheers,

Loo