Go Back   Wiki NewForum > Career Forum > Tech Forum & Tutorial > SAP Forum > SAP ABAP HR Forum

Sponsored Links

SAP ABAP HR Forum End-to-End Implementation Process

Reply
Views: 536  
Thread Tools Rate Thread Display Modes
  #1  
Old 05-22-2009, 06:06 AM
bholus7 bholus7 is offline
Banned
 
Join Date:
Apr 2009
Posts: 1,322
Default Sample Coding For Converting Into PDF Format

Sample Coding For Converting Into PDF Format

data: cparam type ssfctrlop,
outop type ssfcompop,
fm_name type rs38l_fnam.

DATA : tab_otf_data TYPE ssfcrescl,
* pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
file_size TYPE i,
bin_filesize TYPE i,
FILE_NAME type string,
File_path type string,
FULL_PATH type string.

outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = SPACE.
cparam-getotf = 'X'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSF_EXPLORE' " give your form name
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
* EXCEPTIONS
* NO_FORM = 1
* NO_FUNCTION_MODULE = 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.
CALL FUNCTION FM_NAME
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = cparam
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
OUTPUT_OPTIONS = outop
USER_SETTINGS = SPACE
IMPORTING
* DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = tab_otf_data

* JOB_OUTPUT_OPTIONS =
TABLES
it_zpur_details = it_final " here give your final internal table
* 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.

TAB_OTF_FINAL[] = tab_otf_data-otfdata.

data : i_tline TYPE TABLE OF tline WITH HEADER LINE,
v_len_in LIKE sood-objlen.

daTA : p_file LIKE rlgrap-filename VALUE 'C:\Documents and Settings\desktop\test.pdf''.
data : file type string.
file = p_file.

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 256
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = BIN_FILESIZE "bin_filesize
* BIN_FILE =
TABLES
otf = TAB_OTF_FINAL[]
lines = I_TLINE[] "i_tline[]
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 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.

data : wf_len_in1 like line of it_final.
wf_len_in1 = it_final.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = BIN_FILESIZE "bin_filesize "wf_len_in1
filename = 'C:\Documents and Settings\desktop\test.pdf'
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
** IMPORTING
** FILELENGTH = file_size
tables
data_tab = I_TLINE[] "i_tline
* FIELDNAMES =
* 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 eq 0.
write : 'successfully downloaded'.
else.
write : 'error in downloading'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Reply With Quote
Reply

New topics in SAP ABAP HR Forum

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2019, vBulletin Solutions, Inc.