Application Development and Automation 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: 
Read only

Function Module to download Raw data as a PDF file

Former Member
0 Likes
4,465

Hi,

Is there any function module which will allow to convert raw data to pdf and download in the local system.

The requirement is to download a payslip as a pdf format.

Function Module 'CONVERT_PAYSLIP_TO_PDF' converts the data into a raw format. The output of this FM is of type XSTRING.

Can this be downloaded as a pdf.

Hi,

Is there any function module which will allow to convert raw data to pdf and download in the local system.

The requirement is to download a payslip as a pdf format.

Function Module 'CONVERT_PAYSLIP_TO_PDF' converts the data into a raw format. The output of this FM is of type XSTRING.

Can this be downloaded as a pdf.

6 REPLIES 6
Read only

Former Member
0 Likes
2,005

Try FM : CONVERT_OTFSPOOLJOB_2_PDF

Regds,

Anil

Read only

Former Member
0 Likes
2,005

If the data in in raw format then we can download it by FM GUI_DOWNLOAD.

I am not sure whether it will work in ur case or not but incase of spool data it works.

Foe example.

FM 'CONVERT_ABAPSPOOLJOB_2_PDF' convert the data of spool into raw format

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = spool no

IMPORTING

pdf_bytecount = l_size(variable type i)

TABLES

pdf = g_pdf (table LIKE TABLE OF tline)

now we can download the data of g_pdf by gui_download as follows

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = l_size

filename = File anme

filetype = 'BIN'

TABLES

data_tab = g_pdf.

hope this will help u

Read only

0 Likes
2,005

No Spool is available in this case.

Without Spool is there any FM to do.

Read only

0 Likes
2,005

so.. do you have the internal table holding these data???

or where are you getting the raw data from?

Read only

Former Member
0 Likes
2,005

Hi

Please below coding

REPORT ZSAP_PDF_VIEWER.

DATA: LT_PDF TYPE TABLE OF TLINE,

LS_PDF LIKE LINE OF LT_PDF,

LV_URL TYPE CHAR255,

PDF_FSIZE TYPE I,

LV_CONTENT TYPE XSTRING,

LT_DATA TYPE STANDARD TABLE OF X255.

DATA : L_JOB_OUTPUT_INFO TYPE SSFCRESCL.

DATA : LS_CONTROL_PARAM TYPE SSFCTRLOP.

DATA : G_HTML_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

G_HTML_CONTROL TYPE REF TO CL_GUI_HTML_VIEWER.

DATA: LO_DIALOG_CONTAINER TYPE REF TO CL_GUI_DIALOGBOX_CONTAINER.

DATA: LO_DOCKING_CONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER.

DATA : P_VBELN TYPE VBELN_VL.

FIELD-SYMBOLS <FS_X> TYPE X.

INITIALIZATION.

LS_CONTROL_PARAM-GETOTF = 'X'.

LS_CONTROL_PARAM-NO_DIALOG = 'X'.

START-OF-SELECTION.

CALL FUNCTION '/1BCDWB/SF00000034'

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

CONTROL_PARAMETERS = LS_CONTROL_PARAM

P_VBELN = P_VBELN

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

IMPORTING

  • DOCUMENT_OUTPUT_INFO = L_DOCUMENT_OUTPUT_INFO

JOB_OUTPUT_INFO = L_JOB_OUTPUT_INFO

  • JOB_OUTPUT_OPTIONS = L_JOB_ OUTPUT_OPTIONS

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 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 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

IMPORTING

BIN_FILESIZE = PDF_FSIZE

TABLES

OTF = L_JOB_OUTPUT_INFO-OTFDATA

LINES = LT_PDF

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

OTHERS = 4.

  • convert pdf to xstring string

LOOP AT LT_PDF INTO LS_PDF.

ASSIGN LS_PDF TO <FS_X> CASTING.

CONCATENATE LV_CONTENT <FS_X> INTO LV_CONTENT IN BYTE MODE.

ENDLOOP.

CALL SCREEN 100.

MODULE STATUS_0100 OUTPUT.

SET PF-STATUS '100'.

**CREATE OBJECT LO_DOCKING_CONTAINER

    • EXPORTING

    • REPID = SY-REPID

    • DYNNR = '100'"SY-DYNNR

    • SIDE = LO_DOCKING_CONTAINER->DOCK_AT_LEFT

    • EXTENSION = 1200.

*

  • CREATE OBJECT g_html_container

  • EXPORTING

  • container_name = 'HTML'.

*

*CREATE OBJECT G_HTML_CONTROL

  • EXPORTING

  • PARENT = LO_DOCKING_CONTAINER.

CREATE OBJECT G_HTML_CONTAINER

EXPORTING

CONTAINER_NAME = 'HTML'.

CREATE OBJECT G_HTML_CONTROL

EXPORTING

PARENT = G_HTML_CONTAINER.

  • Convert xstring to binary table to pass to the LOAD_DATA method

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

BUFFER = LV_CONTENT

TABLES

BINARY_TAB = LT_DATA.

*application/

  • Load the HTML

CALL METHOD G_HTML_CONTROL->LOAD_DATA(

EXPORTING

TYPE = 'application'

SUBTYPE = 'pdf' "

IMPORTING

ASSIGNED_URL = LV_URL

CHANGING

DATA_TABLE = LT_DATA

EXCEPTIONS

DP_INVALID_PARAMETER = 1

DP_ERROR_GENERAL = 2

CNTL_ERROR = 3

OTHERS = 4 ).

CALL METHOD G_HTML_CONTROL->show_url

EXPORTING url = lv_url

in_place = 'X'

EXCEPTIONS cntl_error = 1.

ENDMODULE. " STATUS_0100 OUTPUT

MODULE user_command_0100 INPUT.

DATA ok_code LIKE sy-ucomm.

MOVE sy-ucomm TO ok_code.

CASE ok_code.

WHEN 'BACK' OR 'EXIT'.

  • CALL METHOD LO_DOCKING_CONTAINER->free.

CALL METHOD g_html_control->free.

LEAVE TO SCREEN 0.

WHEN OTHERS.

ENDCASE.

ENDMODULE. " USE

Read only

vijy_mukunthan
Active Contributor
0 Likes
2,005

Hi Charan

You can convert the xstring into bindary FM SCMS_XSTRING_TO_BINARY and then convert into pdf using FM CONVERT_OTF

Regards

vijay