11-30-2007 3:31 PM
Is there a function module I can use to issue output type and then extract the spool id generated
11-30-2007 10:58 PM
Hi,
Check this sample code..to get the spool id after the job is completed.
DATA: v_jobgroup LIKE tbtcjob-jobgroup.
DATA: v_jobname LIKE tbtcjob-jobname.
DATA: v_jobcount LIKE tbtcjob-jobcount.
DATA: v_status TYPE tbtco-status.
DATA: v_spool TYPE tbtcp-listident.
v_jobgroup = 'Test'.
v_jobname = sy-repid.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobgroup = v_jobgroup
jobname = v_jobname
IMPORTING
jobcount = v_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
SUBMIT z_test_program " Change the program here
VIA JOB v_jobname
NUMBER v_jobcount
AND RETURN.
*Close job to start immediately
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = v_jobcount
jobname = v_jobname
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.
* Check the status.
DO.
SELECT SINGLE status FROM tbtco
INTO v_status
WHERE jobname = v_jobname
AND jobcount = v_jobcount.
IF sy-subrc = 0 AND v_status = 'F'.
EXIT.
ENDIF.
ENDDO.
* Get the spool
SELECT SINGLE listident FROM tbtcp
INTO v_spool
WHERE jobname = v_jobname
AND jobcount = v_jobcount.
WRITE: / v_spool.
Thanks
Naren
11-30-2007 3:44 PM
Can you please expand on "issue output type"? You create or change documents, and the output types associated with that document are triggered and they go to NAST table along with the key (typically document number). Once the NAST entry is processed (immediately or batch), you will have to get the job ID and then can get the spool ID. Just having an output type will not be sufficient because the output type only holds the information about the FORM, processing program/routine and the print preferences. The actual output is what is assigned a spool id which is tied to the object for which it is created and the date/time it is created. If you just search by output type, you will find many entries in NAST (field KSCHL).
11-30-2007 4:11 PM
I have the following
OBJKY (Object key from NAST)
KSCHL (Output Type)
KAPPL (Application)
Normally, you trigger output type from the document which then creates NAST and then spoolid, else if there is a record in NAST already then it uses that to create another spoolid. This is done using program RSNAST00.
I want to do something similar but in the background in a custom program. I need to use the 3 keys to triiger output type and generate a spool id.
11-30-2007 6:14 PM
Why not do a submit of RSNAST00 from your custom program and get the spool ID from that submitted job? If you want the entire thing in your custom program, it will be difficult to implement. Check RSPO_* function modules, but I doubt it.
11-30-2007 6:44 PM
Hi,
You can submit RSNAST00 from your custom program as suggested by Srinivas.
Also you can submit these alternative standard programs.
SD70AV1A (Output for Orders)
SD70AV2A (Output for Deliveries)
SD70AV3A (Output for Billing)
Regards,
Ferry Lianto
11-30-2007 8:47 PM
I am using RSNAST00 to do the output type. But how do I extract the spool id from it. I have been debugging it and the spool id is displayed in the message box that pops up. But otherwise I cant find any variable in the program for the spool id. Can you help me find the spool id generated. Thank you
11-30-2007 9:30 PM
I haven't used it but try calling WFMC_PROTOCOL_GET to get the NAST messages and may be spool id is there in that internal table. Otherwise, you can SUBMIT RSNAST00 via job and once the job is completed, you can get the spool id from that job.
11-30-2007 9:42 PM
11-30-2007 10:28 PM
Use JOB_OPEN to open the job with some name, and it returns JOBCOUNT. Do a SUBMIT VIA JOB (see help on SUBMIT) with JOBCOUNT and then finally do a JOB_CLOSE. This will create and start the job execution. To know if the job is completed or not, use BP_JOB_STATUS_GET in a DO loop and once the job is completed, exit the DO loop. You can read the job log using BP_JOBLOG_READ. You can use BAPI_XBP_JOB_SPOOLLIST_READ to get the spool of the job.
11-30-2007 10:58 PM
Hi,
Check this sample code..to get the spool id after the job is completed.
DATA: v_jobgroup LIKE tbtcjob-jobgroup.
DATA: v_jobname LIKE tbtcjob-jobname.
DATA: v_jobcount LIKE tbtcjob-jobcount.
DATA: v_status TYPE tbtco-status.
DATA: v_spool TYPE tbtcp-listident.
v_jobgroup = 'Test'.
v_jobname = sy-repid.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobgroup = v_jobgroup
jobname = v_jobname
IMPORTING
jobcount = v_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
SUBMIT z_test_program " Change the program here
VIA JOB v_jobname
NUMBER v_jobcount
AND RETURN.
*Close job to start immediately
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = v_jobcount
jobname = v_jobname
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.
* Check the status.
DO.
SELECT SINGLE status FROM tbtco
INTO v_status
WHERE jobname = v_jobname
AND jobcount = v_jobcount.
IF sy-subrc = 0 AND v_status = 'F'.
EXIT.
ENDIF.
ENDDO.
* Get the spool
SELECT SINGLE listident FROM tbtcp
INTO v_spool
WHERE jobname = v_jobname
AND jobcount = v_jobcount.
WRITE: / v_spool.
Thanks
Naren