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: 

Generate spool request and PDF

former_member734916
Participant
0 Kudos

Hello Friends,

I have the below requirement in Scripts.

I need to generate spool request and also download the form as pdf simultaneously.

I can able to generate spool request and able to download as PDF separately, but I want to do both in a single open_form is it possible?

Regards.

Krishna.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

*for that do declarations like this

data: v_spoolid type ssfcrescl.

data: v_spoolno type rspoid

*at last process a loop like this

loop at v_spoolid-spoolids into v_spoolno.

endloop.

submit rstxpdft4 with spoolno = v_spoolno

the above is for smartforms.

and the below is the process for scripts

while executing the standard scripts driver progrram a spool id will be created

take that spoolid and go to transaction sp01. execute it

and goto se38 execute program rstxpdft4

type the spool request no.

and excute it , it will generate pdf for the spool no which u have given.

hope this will be useful for you.

with regards

S.Janagar

3 REPLIES 3

former_member181995
Active Contributor
0 Kudos

yup it's possible but only when you seach in SDN i'm sure you will get answer WITH CODE

lets start search.

Amit.

Former Member
0 Kudos

*for that do declarations like this

data: v_spoolid type ssfcrescl.

data: v_spoolno type rspoid

*at last process a loop like this

loop at v_spoolid-spoolids into v_spoolno.

endloop.

submit rstxpdft4 with spoolno = v_spoolno

the above is for smartforms.

and the below is the process for scripts

while executing the standard scripts driver progrram a spool id will be created

take that spoolid and go to transaction sp01. execute it

and goto se38 execute program rstxpdft4

type the spool request no.

and excute it , it will generate pdf for the spool no which u have given.

hope this will be useful for you.

with regards

S.Janagar

Former Member
0 Kudos

Copy and Paste following code in a Z program type executable:

REPORT ZRSTXPDFT4 LINE-SIZE 80.

*

  • Read spool job contents (OTF or ABAP list) and convert

  • to PDF, download PDF

  • B20K8A0IKH replace WS_DOWNLOAD with GUI_DOWNLOAD

SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-015.

SELECTION-SCREEN SKIP.

PARAMETERS:

SPOOLNO LIKE TSP01-RQIDENT.

SELECTION-SCREEN SKIP.

PARAMETERS : DOWNLOAD AS CHECKBOX DEFAULT 'X',

P_FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\temp\file.pdf' NO-DISPLAY."#EC NOTEXT

SELECTION-SCREEN END OF BLOCK B.

DATA OTF LIKE ITCOO OCCURS 100 WITH HEADER LINE.

DATA CANCEL.

DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.

DATA DOCTAB LIKE DOCS OCCURS 1 WITH HEADER LINE.

DATA: NUMBYTES TYPE I,

ARC_IDX LIKE TOA_DARA,

PDFSPOOLID LIKE TSP01-RQIDENT,

JOBNAME LIKE TBTCJOB-JOBNAME,

JOBCOUNT LIKE TBTCJOB-JOBCOUNT,

IS_OTF.

DATA: CLIENT LIKE TST01-DCLIENT,

NAME LIKE TST01-DNAME,

OBJTYPE LIKE RSTSTYPE-TYPE,

TYPE LIKE RSTSTYPE-TYPE.

TABLES: TSP01.

DATA : RETFIELD TYPE DFIES-FIELDNAME.

DATA : SPOOL TYPE HELP_INFO-DYNPROFLD.

DATA : BEGIN OF ITAB OCCURS 0,

SPOOL TYPE TSP01-RQIDENT,

END OF ITAB.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR SPOOLNO.

RETFIELD = SPOOLNO.

SPOOL = 'SPOOLNO'.

SELECT RQIDENT FROM TSP01 INTO TABLE ITAB."#EC CI_NOWHERE

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • DDIC_STRUCTURE = ' '

RETFIELD = RETFIELD

  • PVALKEY = ' '

DYNPPROG = SY-REPID

DYNPNR = SY-DYNNR

DYNPROFIELD = SPOOL

  • STEPL = 0

  • WINDOW_TITLE =

  • VALUE = ' '

VALUE_ORG = 'S'

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

CALLBACK_PROGRAM = SY-CPROG

  • CALLBACK_FORM = ' '

  • MARK_TAB =

  • IMPORTING

  • USER_RESET =

TABLES

VALUE_TAB = ITAB[]

  • FIELD_TAB =

  • RETURN_TAB =

  • DYNPFLD_MAPPING =

EXCEPTIONS

PARAMETER_ERROR = 1

NO_VALUES_FOUND = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

START-OF-SELECTION.

SELECT SINGLE * FROM TSP01 WHERE RQIDENT = SPOOLNO.

IF SY-SUBRC <> 0.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Spoolauftrag existiert nicht'(003).

EXIT.

ENDIF.

CLIENT = TSP01-RQCLIENT.

NAME = TSP01-RQO1NAME.

CALL FUNCTION 'RSTS_GET_ATTRIBUTES'

EXPORTING

AUTHORITY = 'SP01'

CLIENT = CLIENT

NAME = NAME

PART = 1

IMPORTING

  • CHARCO =

  • CREATER =

  • CREDATE =

  • DELDATE =

  • MAX_CREDATE =

  • MAX_DELDATE =

  • NON_UNIQ =

  • NOOF_PARTS =

  • RECTYP =

  • SIZE =

  • STOTYP =

TYPE = TYPE

OBJTYPE = OBJTYPE

EXCEPTIONS

FB_ERROR = 1

FB_RSTS_OTHER = 2

NO_OBJECT = 3

NO_PERMISSION = 4.

IF OBJTYPE(3) = 'OTF'.

IS_OTF = 'X'.

ELSE.

IS_OTF = SPACE.

ENDIF.

IF IS_OTF = 'X'.

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = SPOOLNO

NO_DIALOG = ' '

  • DST_DEVICE =

  • PDF_DESTINATION =

IMPORTING

PDF_BYTECOUNT = NUMBYTES

PDF_SPOOLID = PDFSPOOLID

  • OTF_PAGECOUNT =

BTC_JOBNAME = JOBNAME

BTC_JOBCOUNT = JOBCOUNT

TABLES

PDF = PDF

EXCEPTIONS

ERR_NO_OTF_SPOOLJOB = 1

ERR_NO_SPOOLJOB = 2

ERR_NO_PERMISSION = 3

ERR_CONV_NOT_POSSIBLE = 4

ERR_BAD_DSTDEVICE = 5

USER_CANCELLED = 6

ERR_SPOOLERROR = 7

ERR_TEMSEERROR = 8

ERR_BTCJOB_OPEN_FAILED = 9

ERR_BTCJOB_SUBMIT_FAILED = 10

ERR_BTCJOB_CLOSE_FAILED = 11.

CASE SY-SUBRC.

WHEN 0.

PERFORM BD_TEXTBOX_MSG(RSTXPDFT) USING 80

'Funktion CONVERT_OTFSPOOLJOB_2_PDF erfolgreich'(001).

WHEN 1.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Kein OTF- und kein ABAP-Spoolauftrag'(002).

EXIT.

WHEN 2.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Spoolauftrag existiert nicht'(003).

EXIT.

WHEN 3.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Keine Berechtigung zum Lesen Spoolauftrag'(004).

EXIT.

WHEN OTHERS.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Fehler bei Funktion CONVERT_OTFSPOOLJOB_2_PDF'(005).

EXIT.

ENDCASE.

ELSE.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = SPOOLNO

NO_DIALOG = ' '

  • DST_DEVICE =

  • PDF_DESTINATION =

IMPORTING

PDF_BYTECOUNT = NUMBYTES

PDF_SPOOLID = PDFSPOOLID

  • LIST_PAGECOUNT =

BTC_JOBNAME = JOBNAME

BTC_JOBCOUNT = JOBCOUNT

TABLES

PDF = PDF

EXCEPTIONS

ERR_NO_ABAP_SPOOLJOB = 1

ERR_NO_SPOOLJOB = 2

ERR_NO_PERMISSION = 3

ERR_CONV_NOT_POSSIBLE = 4

ERR_BAD_DESTDEVICE = 5

USER_CANCELLED = 6

ERR_SPOOLERROR = 7

ERR_TEMSEERROR = 8

ERR_BTCJOB_OPEN_FAILED = 9

ERR_BTCJOB_SUBMIT_FAILED = 10

ERR_BTCJOB_CLOSE_FAILED = 11.

CASE SY-SUBRC.

WHEN 0.

PERFORM BD_TEXTBOX_MSG(RSTXPDFT) USING 80

'Funktion CONVERT_ABAPSPOOLJOB_2_PDF erfolgreich'(006).

WHEN 1.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Kein OTF- und kein ABAP-Spoolauftrag'(002).

EXIT.

WHEN 2.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Spoolauftrag existiert nicht'(003).

EXIT.

WHEN 3.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Keine Berechtigung zum Lesen Spoolauftrag'(004).

EXIT.

WHEN OTHERS.

PERFORM BD_TEXTBOX_ERR(RSTXPDFT) USING 80

'Fehler bei Funktion CONVERT_ABAPSPOOLJOB_2_PDF'(007).

EXIT.

ENDCASE.

ENDIF.

                              • download PDF file ***********

CHECK DOWNLOAD = 'X'.

IF NOT ( JOBNAME IS INITIAL ).

PERFORM BD_TEXTBOX_VAR2_MSG(RSTXPDFT) USING 80

'Konvertierung per Hintergrundjob'(008)

JOBNAME

JOBCOUNT.

EXIT.

ENDIF.

PERFORM DOWNLOAD_W_EXT(RSTXPDFT) TABLES PDF

USING P_FILE

'.pdf'

'BIN'

NUMBYTES

CANCEL.

IF CANCEL = SPACE.

DATA: S(80).

S = NUMBYTES. CONDENSE S.

CONCATENATE S 'Bytes heruntergeladen in Datei'(009)

INTO S SEPARATED BY SPACE.

PERFORM BD_TEXTBOX_VAR1_MSG(RSTXPDFT) USING 80

S

P_FILE.

ENDIF.

Regards,

Jeet K Bhatt