2024 Dec 09 7:50 AM - edited 2024 Dec 09 7:51 AM
Requirement is to create interface that will be triggered by outside app, They will pass invoice number then SAP will call the invoice form and download to PDF in a local file.
So far i am calling program RFKORD50 but this only let me preview the file and will only generate spool once i manually select PRINT. I need this program to auto generate the spool once called then i will convert the spool to PDF
REPORT z_trigger_script_to_pdf.
PARAMETERS: p_docnum TYPE bkorm-belnr OBLIGATORY DEFAULT '7035000025', " Document Number
p_path TYPE rlgrap-filename OBLIGATORY DEFAULT 'C:\Users\jasmine.clemencio\Desktop\UAT.pdf', " File path for PDF output
p_comp TYPE bkorm-bukrs OBLIGATORY DEFAULT 'MY10',
p_year TYPE bkorm-gjahr OBLIGATORY DEFAULT '2023',
p_cor TYPE bkorm-event OBLIGATORY DEFAULT 'Z0017'.
DATA: lv_spool_no TYPE tsp01-rqident,
lv_file_path TYPE rlgrap-filename,
lv_parameters TYPE string.
" Step 1: Call RFKORD50 to generate spool
SUBMIT zrfkord50
WITH rbelnr = p_docnum
WITH rgjahr = p_comp
WITH rgjahr = p_year
WITH revent = p_cor
WITH spool = 'X' " Indicate spool creation
AND RETURN.
" Step 2: Retrieve the spool number
SELECT SINGLE rqident
INTO lv_spool_no
FROM tsp01
WHERE rq2name = sy-uname
AND rqclient = sy-mandt.
lv_spool_no = 13300.
*IF sy-subrc NE 0.
* WRITE: / 'Failed to retrieve spool number.'.
* EXIT.
*ENDIF.
WRITE: / 'Spool Number:', lv_spool_no.
" Step 3: Call RSTXPDFT4 to convert spool to PDF
SUBMIT zrstxpdft4
WITH spoolno = 13300
WITH p_file = p_path
EXPORTING LIST TO MEMORY
AND RETURN.
Requirement is to create interface that will be triggered by outside app, They will pass invoice number then SAP will call the invoice form and download to PDF in a local file.
So far i am calling program RFKORD50 but this only let me preview the file and will only generate spool once i manually select PRINT. I need this program to auto generate the spool once called then i will convert the spool to PDF
REPORT z_trigger_script_to_pdf.
PARAMETERS: p_docnum TYPE bkorm-belnr OBLIGATORY DEFAULT '7035000025', " Document Number
p_path TYPE rlgrap-filename OBLIGATORY DEFAULT 'C:\Users\jasmine.clemencio\Desktop\UAT.pdf', " File path for PDF output
p_comp TYPE bkorm-bukrs OBLIGATORY DEFAULT 'MY10',
p_year TYPE bkorm-gjahr OBLIGATORY DEFAULT '2023',
p_cor TYPE bkorm-event OBLIGATORY DEFAULT 'Z0017'.
DATA: lv_spool_no TYPE tsp01-rqident,
lv_file_path TYPE rlgrap-filename,
lv_parameters TYPE string.
" Step 1: Call RFKORD50 to generate spool
SUBMIT zrfkord50
WITH rbelnr = p_docnum
WITH rgjahr = p_comp
WITH rgjahr = p_year
WITH revent = p_cor
WITH spool = 'X' " Indicate spool creation
AND RETURN.
" Step 2: Retrieve the spool number
SELECT SINGLE rqident
INTO lv_spool_no
FROM tsp01
WHERE rq2name = sy-uname
AND rqclient = sy-mandt.
lv_spool_no = 13300.
*IF sy-subrc NE 0.
* WRITE: / 'Failed to retrieve spool number.'.
* EXIT.
*ENDIF.
WRITE: / 'Spool Number:', lv_spool_no.
" Step 3: Call RSTXPDFT4 to convert spool to PDF
SUBMIT zrstxpdft4
WITH spoolno = 13300
WITH p_file = p_path
EXPORTING LIST TO MEMORY
AND RETURN.
2024 Dec 19 2:02 PM
Did you try to call function like SET_PRINT_PARAMETERS ?
to set create new spool
print immedialty ...
2025 Jan 20 7:07 AM
the code above works fine. Except i cannot run the program in background because of program
rfkord50
@FredericGirod wrote:Did you try to call function like SET_PRINT_PARAMETERS ?
to set create new spool
print immedialty ...
2024 Dec 19 2:57 PM
You could also
2025 Jan 20 7:08 AM
the code above works fine. Except i cannot run the program in background because of program
2025 Jan 13 10:29 PM
And use CL_RSPO_SPOOLID_TO_PDF=>GET_SPOOL_PDF to get the PDF as an xstring.
2025 Jan 20 7:09 AM
this works when i run background? external app will trigger the FM
2025 Jan 20 7:43 AM
Yes, CL_RSPO_SPOOLID_TO_PDF=>GET_SPOOL_PDF can be called in the background.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |