08-27-2007 12:32 PM
Hello experts:
I have a follwing situation in the project:
I am creating an output file in the appllication server by transfering the contents of an internal table .Now there is an additional requirement :
To report to spool:
with the following pieces of information:
- Resulting output file name
- Number of records in report
How will i accomplish this though the programme?
Please help me?
regards
Prasun
08-27-2007 12:37 PM
Hi!
There are a few fields in the system structure SYST, you might to use (check it out in SE11 transaction).
Try to move the filename into the SY-PRTXT field during the run.
Regards
Tamá
08-27-2007 12:40 PM
Hi Prasun,
You can add the data to the output file,
"to get no of records
describe table itab lines v_lines.
concatenate 'Number of records : ' v_lines into v_tot_lines.
"to get the filename
concatenate 'Filename :' w_file into v_file.
OPEN DATASET W_FILE FOR OUTPUT ....
<b>transfer v_file to w_file.
transfer v_tot_lines to w_file.</b>
loop at itab.
TRANSFER itab to w_file.
endloop.
CLOSE DATASET w_file.
08-27-2007 12:46 PM
Hi chandrashekhar,
Thanks for the answer!But how ill i spool the report?Is There any sort of coding to accomplish this?
regards
Prasun
08-27-2007 12:48 PM
Hi Prasun,
Spool will be created when you execute the report in background.
Execute the report in background ,
In menu program-->Execute in background
then check in SM37 for the job name which will be same as program name
select that job and click on SPOOL button , you can see there
08-27-2007 12:56 PM
Hi chandrashekhar,
yes that i know,but if i want to do it through coding from my programme is it possible? if possible .How can I Do that?
regards
Prasun
08-27-2007 12:58 PM
hi rudra,
try this one.
You can try to SUBMIT to this program in the background using a JOB.
For example see this
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
...
ENDIF.
ENDIF.
ENDIF.
Regards...
Arun.
08-27-2007 1:14 PM
Hi Rudra,
U can check this FM. It wil match for ur Req...
pass the program Name to g_listname.
CLEAR: g_destination, g_listname, g_listtext, g_count.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
copies = g_copies
cover_page = ' '
department = ''
destination = g_destination
expiration = g_days
immediately = ' '
layout = 'X_65_200'
line_count = 65
line_size = 200
list_name = g_listname
list_text = g_listtext
new_list_id = 'X'
no_dialog = 'X'
receiver = sy-uname
release = ' '
sap_cover_page = 'D'
user = sy-uname
IMPORTING
out_parameters = g_params
valid = g_valid.
IF g_valid <> space.
NEW-PAGE PRINT ON PARAMETERS g_params NO DIALOG.
*
IF NOT tb_output[] IS INITIAL.
LOOP AT tb_output INTO wa_output.
PERFORM write_summary.
ENDLOOP.
ENDIF.
*
NEW-PAGE PRINT OFF.
ENDIF.
PERFORM write_summary.
*Print wat ever u want send it to Spool..
ENDFORM.
Regards,
Kalam A.
08-27-2007 1:22 PM
Hi Rudra,
U can check this FM. It wil match for ur Req...
pass the program Name to g_listname.
CLEAR: g_destination, g_listname, g_listtext, g_count.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
copies = g_copies
cover_page = ' '
department = ''
destination = g_destination
expiration = g_days
immediately = ' '
layout = 'X_65_200'
line_count = 65
line_size = 200
list_name = g_listname
list_text = g_listtext
new_list_id = 'X'
no_dialog = 'X'
receiver = sy-uname
release = ' '
sap_cover_page = 'D'
user = sy-uname
IMPORTING
out_parameters = g_params
valid = g_valid.
IF g_valid <> space.
NEW-PAGE PRINT ON PARAMETERS g_params NO DIALOG.
*
IF NOT tb_output[] IS INITIAL.
LOOP AT tb_output INTO wa_output.
PERFORM write_summary.
ENDLOOP.
ENDIF.
*
NEW-PAGE PRINT OFF.
ENDIF.
PERFORM write_summary.
*Print wat ever u want send it to Spool..
ENDFORM.
Regards,
Kalam A.
08-27-2007 1:01 PM
Hi Prasun..
You can very much get this....
This is the Way coding has to be to send the output to Spool:
DATA: print_parameters TYPE pri_params,
valid_flag TYPE c LENGTH 1.
START-OF-SELECTION.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING
out_parameters = print_parameters
valid = valid_flag
EXCEPTIONS
invalid_print_params = 2
OTHERS = 4.
NEW-PAGE PRINT ON
PARAMETERS print_parameters
NO DIALOG.
Write: / <your file name> , <your no of records>.
NEW-PAGE PRINT OFF.
Write: / sy-spono. "Spool No.
Once you run the Program you can Check the Spool request in SP01.
<b>Reward if Helpful</b>
09-07-2007 8:55 AM
hi varma
Is there any any way to send the no of records and and file name to spool without using the get-print-parameters .Please suggest.