Skip to Content
0
Former Member
Jan 10, 2008 at 09:21 AM

pls execute in ur sys

23 Views

Hi frns ,This is my program to generate pdf file.it is working gud when i give single spoool no. but it is failing when i give spool nos in range .pdf is created but pdf contains only one spool no dat.

Can anybody help me

Thanks in advance....

&----


*& Report ZCASEMM_PDF

*&

&----


*&

*&

&----


REPORT zcasemm_pdf NO STANDARD PAGE HEADING

LINE-SIZE 60

LINE-COUNT 60

MESSAGE-ID zmmcase..

--


TABLES--

TABLES:tsp01,tline.

--


TYPE DECLARATIONS--

TYPES:BEGIN OF st_pdf, "Structure for internal table

reqid TYPE tsp01-rqident, "Spool request number

reqclnt TYPE tsp01-rqclient, "Client for which object was generated

dest TYPE tsp01-rqdest, "Spool: Output device

spoolname TYPE tsp01-rq0name, "Spool request: Name

objname TYPE tsp01-rqo1name, "TemSe object name

creation TYPE tsp01-rqcretime, "Time a spool request was created

END OF st_pdf.

--


DATA DECLARATIONS--

DATA:it_pdf TYPE STANDARD TABLE OF st_pdf, "Internal table of structure st_pdf

wa_pdf TYPE st_pdf, "work area for it_pdf

id TYPE sy-sysid, "variable of type sysid

text TYPE c, "variable of type c

type1 TYPE rststype-type, "TemSe: Object type name

objtype TYPE rststype-type, "TemSe: Object type name

numbytes TYPE i,"variable of type i

num type i,

pdfspoolid LIKE tsp01-rqident, "variable of type spool request number

jobname TYPE tbtcjob-jobname, "Background job name

jobcount TYPE tbtcjob-jobcount, "Job ID

pdf_temp TYPE TABLE OF tline , "Temporary file to store contents of particular spoolno

wa_temp TYPE tline, "workarea for pdf_temp

it_final TYPE TABLE OF tline, "Final internal table

wa_final TYPE tline, "workarea for it_final

p_fname TYPE string. "variable of type string

--


SELECTION SCREEN--

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS:spoolno for tsp01-rqident,

opdev FOR tsp01-rqdest.

PARAMETERS:

pc RADIOBUTTON GROUP g1 DEFAULT 'X',

unix RADIOBUTTON GROUP g1,

filepath TYPE ibipparms-path_z OBLIGATORY DEFAULT 'c:\download.PDF'. "Local file for upload/download

SELECTION-SCREEN END OF BLOCK b1.

--


END OF SELECTION SCREEN--

--


INITIALIZATION--

INITIALIZATION.

id = sy-sysid.

CONCATENATE '/INTERFACES/184/' id '/DATA_OUT/COMM/' INTO text.

num = 0.

--


AT SELECTION SCREEN--

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILEPATH.

IF PC = 'X'.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SY-REPID

DYNPRO_NUMBER = SY-DYNNR

FIELD_NAME = ' '

IMPORTING

FILE_NAME = FILEPATH

.

ELSE.

CALL FUNCTION 'F4_FILENAME_SERVER' "DESTINATION ibipparms-server_z

EXPORTING

PFAD = text

  • IMPORTING

  • FILE_NAME = filepath

EXCEPTIONS

NO_FILE_ON_SERVER = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

endif.

--


START OF SELECTION--

START-OF-SELECTION.

SELECT rqident

rqclient

rqdest

rq0name

rqo1name

rqcretime FROM tsp01 INTO TABLE it_pdf

WHERE rqident in spoolno AND

rqdest IN opdev.

IF sy-subrc NE 0.

MESSAGE e001(zmmcase).

ENDIF.

SORT it_pdf BY reqid.

--


END OF SELECTION--

END-OF-SELECTION.

LOOP AT it_pdf INTO wa_pdf .

CALL FUNCTION 'RSTS_GET_ATTRIBUTES'

EXPORTING

authority = 'SP01'

client = wa_pdf-reqclnt

name = wa_pdf-objname

part = 1

IMPORTING

type = type1

objtype = objtype

EXCEPTIONS

fb_error = 1

fb_rsts_other = 2

no_object = 3

no_permission = 4

OTHERS = 5.

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 objtype(3) = 'OTF'.

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = wa_pdf-reqid

no_dialog = ' '

IMPORTING

pdf_bytecount = numbytes

pdf_spoolid = pdfspoolid

btc_jobname = jobname

btc_jobcount = jobcount

TABLES

pdf = pdf_temp

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

OTHERS = 12.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ELSE.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = wa_pdf-reqid

no_dialog = ' '

IMPORTING

pdf_bytecount = numbytes

pdf_spoolid = pdfspoolid

btc_jobname = jobname

btc_jobcount = jobcount

TABLES

pdf = pdf_temp

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

OTHERS = 12.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

num = num + numbytes.

LOOP AT pdf_temp INTO wa_temp.

APPEND wa_temp TO it_final.

ENDLOOP.

ENDLOOP.

  • p_fname = filepath.

p_fname = filepath.

IF pc = 'X'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = num

filename = p_fname

filetype = 'BIN'

  • append = 'X'

IMPORTING

FILELENGTH = num

TABLES

data_tab = it_final

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.