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: 

report to spool

Former Member
0 Kudos

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

10 REPLIES 10

Former Member
0 Kudos

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á

Former Member
0 Kudos

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.

0 Kudos

Hi chandrashekhar,

Thanks for the answer!But how ill i spool the report?Is There any sort of coding to accomplish this?

regards

Prasun

0 Kudos

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

0 Kudos

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

0 Kudos

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.

0 Kudos

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.

0 Kudos

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.

varma_narayana
Active Contributor
0 Kudos

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>

0 Kudos

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.