‎2008 Jul 27 9:03 PM
hi,
I need to generate PDF of a ALV Report automatically if the user selects a check box on the Selection screen.
The user does not run the program in background, nor does he select the print option from the Menu. In that case is it possible to get a spool number?
I tried the Function module GET_PRINT_PARAMETERS with the no_dialog parameter as 'X', but it did not generate a spool number.
I tried the Submit program to spool option also and did not succeed.
Please let me know if we have any other options of getting the spool number
Thanks,
Janani
‎2008 Jul 27 9:40 PM
you can use the sample code..
REPORT Z_TEST_PRINT.
DATA: L_PARAMS TYPE PRI_PARAMS,
L_VALID TYPE C.
START-OF-SELECTION.
"get the data etc here
END-OF-SELECTION.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
IMMEDIATELY = 'X'
LINE_SIZE = 220
RELEASE = 'X'
MODE = 'CURRENT'
NO_DIALOG = ' '
IMPORTING
OUT_PARAMETERS = L_PARAMS
VALID = L_VALID
EXCEPTIONS
ARCHIVE_INFO_NOT_FOUND = 1
INVALID_PRINT_PARAMS = 2
INVALID_ARCHIVE_PARAMS = 3
OTHERS = 4.
NEW-PAGE PRINT ON PARAMETERS L_PARAMS NO DIALOG.
PERFORM DISPLAY_REPORT.
NEW-PAGE PRINT OFF.
ENDCASE.
FORM DISPLAY_REPORT .
" here you call the alv display function
ENDFORM.
this will generate a spool.
‎2008 Jul 27 9:15 PM
using get_print_parameters you will get the print parameters like printer etc.
now you have to use the new-page print on and new-page print off.
in between on and off you have to call your report.
for new-page print on you have to pass print parameters.
‎2008 Jul 27 9:40 PM
you can use the sample code..
REPORT Z_TEST_PRINT.
DATA: L_PARAMS TYPE PRI_PARAMS,
L_VALID TYPE C.
START-OF-SELECTION.
"get the data etc here
END-OF-SELECTION.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
IMMEDIATELY = 'X'
LINE_SIZE = 220
RELEASE = 'X'
MODE = 'CURRENT'
NO_DIALOG = ' '
IMPORTING
OUT_PARAMETERS = L_PARAMS
VALID = L_VALID
EXCEPTIONS
ARCHIVE_INFO_NOT_FOUND = 1
INVALID_PRINT_PARAMS = 2
INVALID_ARCHIVE_PARAMS = 3
OTHERS = 4.
NEW-PAGE PRINT ON PARAMETERS L_PARAMS NO DIALOG.
PERFORM DISPLAY_REPORT.
NEW-PAGE PRINT OFF.
ENDCASE.
FORM DISPLAY_REPORT .
" here you call the alv display function
ENDFORM.
this will generate a spool.
‎2008 Jul 28 9:18 AM
Hi Vijay,
I have read many of your blogs and replies in SDN. Didnt expect an answer from this expert.
I did not try the new page on and off option before. It is perfectly now.
Thanks for your help,
Janani
‎2008 Jul 28 3:11 PM
Hi Janani,
I need to generate a PDF file from spool...
How can I do that?
I saw this function that Vijay sent for get printer parameters, but I'm trying to use some functions to genarate a PDF file and this functions aren't working.
Do you have some complete example code about that?
Do you know if is possible change the settings in PF-STATUS to put some command in Printer button or in printer options on sap menu??
Thanks for your help.
Fernando Pena.
‎2008 Jul 28 3:35 PM
1. Goto SE41 and copy the Status of the Standard progrm.
Program name : SAPLSLVC_FULLSCREEN
Status: STANDARD_FULLSCREEN
2. In the status that you have created, go and add a push button, which would appear on the screen.
2. In the FM for calling the ALV,
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_prog_name
i_callback_pf_status_set = lc_status " STATUS_SET
i_callback_top_of_page = lc_top
i_callback_user_command = lc_dclick
is_layout = wa_layout
it_fieldcat = i_fieldcat
TABLES
t_outtab = i_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
where lc_Status contains the name of the Perform which sets the Status.
3. Set the status in the STATUS_SET,
FORM status_set USING fp_extab TYPE slis_t_extab. "#EC CALLED
IF fp_extab[] IS NOT INITIAL.
SET PF-STATUS 'ZSDSOR_TERMS'.
ENDIF.
ENDFORM. "status_set
where 'ZSDSOR_TERMS' is the name of the status you created by copying from the standard.
Then the button would appear.
‎2008 Jul 28 3:36 PM
Please create a new thread, if it does not solve ur problem still, and we would be ready to help