‎2006 Jun 23 6:00 PM
Hi SDN,
I have a ALV GRID report that can run on-line and background.
In background I need to output the grid using
call method grid->set_table_for_first_display thats ok
And print other list, i.e. Ive two lists for one step in my job!
How can I achive this?
Best regards,
Maria João Rocha
‎2006 Jun 23 6:26 PM
Hi,
If you only want the spool, then its possible. Get the spool number as follows :-
FORM get_spool_details .
CLEAR : w_spool_number.
REFRESH : i_jobsteplist.
CHECK WHETHER STATUS OF JOB IS COMPLETED OR CANCELLED
WHILE 1 = 1.
GET THE JOB STEPLIST WHICH HAS THE SPOOL NUMBER
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '35'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF STATUS OF JOB IS COMPLETED(F) OR CANCELLED(A)
READ THE JOBSTEPLIST & GET THE SPOOL NUMBER
IF wa_jobhead-status = 'A' OR wa_jobhead-status = 'F'.
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident <> space.
w_spool_number = wa_jobsteplist-listident.
EXIT.
ENDIF.
ENDWHILE.
If you want the spool content into an internal table, then use the following FM :
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = w_spool_number
FIRST_LINE = 1
LAST_LINE =
TABLES
buffer = i_buffer
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7
OTHERS = 8
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Once you get the spool content into an internal table, pass this data to the email FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
DATA : l_spool_no TYPE tsp01_sp0r-rqid_char.
AFTER SENDING MAIL DELETE THE CORRESPONDING SPOOL
l_spool_no = w_spool_number.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = l_spool_no
IMPORTING
RC =
STATUS =
.
Best regards,
Prashant
Best regards,
Prashant
‎2006 Jun 23 6:04 PM
‎2006 Jun 23 6:05 PM
Hi,
Use OPEN_JOB to open the Job.
Then use FM GET_PRINT_PARAMETERS to get the print parameters. Pass PRINT immediately = 'X'.
Then use FM JOB_SUBMIT. " Pass the ALV program.
Then close job using JOB_CLOSE.
Best regards,
Prashant
‎2006 Jun 23 6:08 PM
Hi Rich Heilman
The problem is that I don't know how to print the 2nd list, via job.
Can you help?
Maria João Rocha
‎2006 Jun 23 6:09 PM
Hi,Prashant
I cant create a new job because I have already a job for this program that will be run every weekend and the data to print is in the main program!
Best Regards,
Maria João Rocha
‎2006 Jun 23 6:14 PM
You can kick off background jobs like this.
data: l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount,
l_jobname like tbtcjob-jobname.
* Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
* Open Job
l_jobname = 'ZRICH_0005'.
call function 'JOB_OPEN'
exporting
jobname = l_jobname
importing
jobcount = l_jobcount.
* Submit report to job
submit zrich_0005
via job l_jobname
number l_jobcount
to sap-spool without spool dynpro
spool parameters ls_params
and return.
* Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = l_jobname
strtimmed = 'X'.
Regards,
Rich Heilman
‎2006 Jun 23 6:15 PM
‎2006 Jun 23 6:19 PM
Heilman
I don't want to kick off background jobs in ABAP.
May job will be periodic and the spool will be send to users by mail sap (button spool list recipient in SM36).
Thanks,
Maria João Rocha
‎2006 Jun 23 6:23 PM
The problem is that I can get two spools but the job only recognises one spool for step! Is that correct? I only can have 1 step 1 spool?
I was trying to use grid (because the program runs on-line) , of course I can use traditional lists!
Thanks
Maria João Rocha
‎2006 Jun 23 6:26 PM
Hi,
If you only want the spool, then its possible. Get the spool number as follows :-
FORM get_spool_details .
CLEAR : w_spool_number.
REFRESH : i_jobsteplist.
CHECK WHETHER STATUS OF JOB IS COMPLETED OR CANCELLED
WHILE 1 = 1.
GET THE JOB STEPLIST WHICH HAS THE SPOOL NUMBER
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '35'
JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
CHANGING
RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF STATUS OF JOB IS COMPLETED(F) OR CANCELLED(A)
READ THE JOBSTEPLIST & GET THE SPOOL NUMBER
IF wa_jobhead-status = 'A' OR wa_jobhead-status = 'F'.
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident <> space.
w_spool_number = wa_jobsteplist-listident.
EXIT.
ENDIF.
ENDWHILE.
If you want the spool content into an internal table, then use the following FM :
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = w_spool_number
FIRST_LINE = 1
LAST_LINE =
TABLES
buffer = i_buffer
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7
OTHERS = 8
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Once you get the spool content into an internal table, pass this data to the email FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
DATA : l_spool_no TYPE tsp01_sp0r-rqid_char.
AFTER SENDING MAIL DELETE THE CORRESPONDING SPOOL
l_spool_no = w_spool_number.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = l_spool_no
IMPORTING
RC =
STATUS =
.
Best regards,
Prashant
Best regards,
Prashant
‎2006 Jun 23 6:54 PM
Hello Maria,
I assume that you do not have any problems with your program when it is run in the foreground.
Now, the reason why we generally use the ALV grid is to make the output <i>interactive</i>. That is, we would like to present it to an online user so that he can carry out some functions on it like SORTING etc.,
When the program runs in the background, there's no user who's waiting to see the output. So you don't really need the ALV!!
You can structure your program as follows -
REPORT ZTEST.
START-OF-SELECTION.
...
...
...
END-OF-SELECTION.
IF SY-BATCH EQ 'X'.
PERFORM DISPLAY_NORMAL_LIST.
ELSE.
PERFORM DISPLAY_ALV_LIST.
ENDIF.
FORM DISPLAY_NORMAL_LIST.
LOOP AT ITAB.
WRITE : ITAB-FIELD1 ....
ENDLOOP.
ENDFORM.
FORM DISPLAY_ALV_LIST.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
.....
ENDFORM.Hope the idea is clear...
Regards,
Anand Mandalika.
‎2006 Jun 26 12:38 PM
Hi,
Thank you all.
My solution is
1st job step (prints alv grid)
2nd job setp (prints the 2nd list). this step receive
the data from step 1 by using import/export to memory using shared buffer.
The result is send by mail (job option).
Regards,
Maria João Rocha