cancel
Showing results for 
Search instead for 
Did you mean: 

convert sapscript Format .Pdf

Former Member
0 Kudos

Hello Friends,

I want to convert sapscript en format pdf.

Code :

&----


*& Report ZPROGRAM_IMPRESSION_SAPSCRIPT *

*& *

&----


*& Programme d'impression sapscript : Flight Detail

*& Date Creation : 06.05.09

*& Autor : SAID_EL FANNASSI

&----


REPORT zprogram_impression_sapscript NO STANDARD PAGE HEADING .

"----


  • ..............................Declarations.....................

"----


TABLES :sflight. "Flight Details

"----


  • Type declaration of the structure to hold *

  • FLIGHT CONNECTION DETAILS *

  • from TABLE SFLIGHT

"----


TYPES:

BEGIN OF type_s_sflight,

carrid TYPE sflight-carrid, " Airline code

connid TYPE sflight-connid, " Flight connection number

fldate TYPE sflight-fldate, " Flight date

planetype TYPE sflight-planetype, " Plane Type

price TYPE sflight-price, " Airfare

END OF type_s_sflight.

"----


  • FIELD-SYMBOLS *

*

"----


FIELD-SYMBOLS : <fs_sflight> TYPE type_s_sflight.

*

"----


  • Internal table to hold Flight details

"----


DATA :

t_sflight LIKE STANDARD TABLE OF <fs_sflight>.

*"Selection screen elements...........................................

SELECT-OPTIONS:

s_carrid FOR sflight-carrid . "Airline code

*" Data declarations...................................................

"----


  • Work variables

"----


DATA:

w_index TYPE n VALUE 1, " Serial number

w_sum TYPE p DECIMALS 2. " Sum variable

"----


  • START-OF-SELECTION EVENT *

"----


START-OF-SELECTION.

&----


*& Subroutines for displaying the data

&----


PERFORM getsflightrecords.

PERFORM open_form.

PERFORM start_form USING 'ZEMPLE_SAPSCRIPT'.

PERFORM main_window.

PERFORM end_form.

PERFORM close_form.

&----


*& Form GETSFLIGHTRECORDS

&----


  • This subroutine gets the Flight records from the table SFLIGHT

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM getsflightrecords .

SELECT carrid " Airline code

connid " Flight connection number

fldate " Flight date

planetype " Plane type

price " Airfare

FROM sflight

INTO TABLE t_sflight

WHERE carrid IN s_carrid.

IF sy-subrc NE 0.

MESSAGE 'Records Not Found'(001) TYPE 'S'.

ENDIF.

ENDFORM. " GETSFLIGHTRECORDS

&----


*& Form OPEN_FORM

&----


  • This subroutine opens the script form Z_SCRIPTS

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM open_form .

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

  • DEVICE = 'PRINTER'

  • DIALOG = 'X'

form = 'ZEMPLE_SAPSCRIPT'

language = sy-langu

  • OPTIONS =

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • SPONUMIV =

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

EXCEPTIONS

canceled = 1

device = 2

form = 3

options = 4

unclosed = 5

mail_options = 6

archive_error = 7

invalid_fax_number = 8

more_params_needed_in_batch = 9

spool_error = 10

codepage = 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.

ENDFORM. " OPEN_FORM

&----


*& Form START_FORM

&----


  • This subroutine fetches the form ZEMPLE_SAPSCRIPT

----


  • -->P_0068 - ZEMPLE_SAPSCRIPT

----


FORM start_form USING value(p_0068).

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

form = p_0068

  • LANGUAGE = ' '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

EXCEPTIONS

form = 1

format = 2

unended = 3

unopened = 4

unused = 5

spool_error = 6

codepage = 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.

ENDFORM. " START_FORM

&----


*& Form MAIN_WINDOW

&----


  • This subroutine prints the SFLIGHT records in a MAIN window

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM main_window .

LOOP AT t_sflight ASSIGNING <fs_sflight>.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'SFLIGHT'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

window = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10.

IF sy-subrc <> 0.

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

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

ENDIF.

&----


*& This statement is used to display the grand total for the last page

&----


AT LAST.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'GRAND_TOTAL'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

window = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10.

IF sy-subrc <> 0.

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

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

ENDIF.

EXIT.

ENDAT.

ADD 1 TO w_index.

IF w_index EQ 6.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'PAGE_TOTAL'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

window = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

command = 'NEW-PAGE'

EXCEPTIONS

unopened = 1

unstarted = 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.

w_index = 1.

ENDIF.

ENDLOOP.

ENDFORM. " MAIN_WINDOW "

&----


*& Form END_FORM

&----


  • This subroutine ends the form ZEMPSAPSCRIPT

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM end_form .

CALL FUNCTION 'END_FORM'

  • IMPORTING

  • RESULT =

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

spool_error = 3

codepage = 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.

ENDFORM. "end_form

&----


*& Form CLOSE_FORM

&----


  • This subroutine closes the form ZEMPSAPSCRIPT

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM close_form .

CALL FUNCTION 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

OTHERS = 6.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDFORM. " CLOSE_FORM

Regards

said el fannassi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try with Function module CONVERT_OTF_2_PDF. for this fm provide otf data as input .

Former Member
0 Kudos

Hi

Use the following FM to convert into pdf format

CONVERT_OTF

Thanks

Vanamali

Former Member
0 Kudos

Hi,

Refer to the following program.

DATA: pdftab type standard TABLE OF tline,

datab TYPE standard TABLE OF itcoo.

itcpo-tdgetotf = 'X'.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = 'ZPRAC'

LANGUAGE = SY-LANGU

OPTIONS = itcpo

CALL FUNCTION 'START_FORM'

EXPORTING

FORM = 'ZPRAC'

LANGUAGE = SY-LANGU

STARTPAGE = 'PAGE1'

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = ' '

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'LOGO'

.

CALL FUNCTION 'END_FORM'

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SPOOL_ERROR = 3

CODEPAGE = 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.

CALL FUNCTION 'CLOSE_FORM'

TABLES

OTFDATA = datab

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

IMPORTING

BIN_FILESIZE = BINFILE

TABLES

otf = datab

lines = pdftab

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = binfile

filename = 'D:\MYFILE.PDF'

FILETYPE = 'BIN'

tables

data_tab = pdftab

Regards

Rajesh Kumar