09-10-2008 2:32 PM
Hi all ,
My requirement is i have to display all the spool request no.'s for the particular user and from that user will select the particular spool no. . and that particular data has to convert into PDF and that PDF should go to mail id specified in selection screen.
now my prob. is when i am downloading the PDF on desktop it is opening with right data and when i am sending to mail id with the same internal table with PDF format , the file is corrupted and giving some error.
for ur reference here i am sending my code , please check and let me know .
thanks & regards,
Anil kumar .
TABLES: tsp01,
soextreci1.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-020.
SELECT-OPTIONS : so_date1 FOR sy-datum OBLIGATORY,
so_time1 FOR sy-uzeit,
so_name1 FOR sy-uname,
so_splno FOR tsp01-rqident.
so_email FOR soextreci1-receiver OBLIGATORY.
PARAMETER : so_email TYPE soextreci1-receiver OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
DATA : l_addrnumber TYPE adr7-addrnumber,
l_persnumber TYPE adr7-persnumber,
l_mail TYPE adr6-smtp_addr.
DATA : BEGIN OF it_tsp01 OCCURS 0,
rqident TYPE tsp01-rqident,
rqowner TYPE tsp01-rqowner,
rqcretime TYPE tsp01-rqcretime,
rqclient TYPE tsp01-rqclient,
rqo1name TYPE tsp01-rqo1name,
END OF it_tsp01.
DATA : l_date_low TYPE char8,
l_date_high TYPE char8,
l_time_low TYPE char8,
l_time_high TYPE char8,
l_final_low TYPE char16,
l_final_high TYPE char16,
markfield VALUE ' '.
DATA : BEGIN OF l_final OCCURS 0,
sig TYPE c,
opt TYPE char2,
low TYPE char16,
high TYPE char16,
END OF l_final.
*PARAMETERS:
spoolno LIKE tsp01-rqident,
download AS CHECKBOX DEFAULT 'X',
DATA : p_file TYPE rlgrap-filename VALUE 'C:\temp\file.pdf'."#EC NOTEXT
DATA otf LIKE itcoo OCCURS 100 WITH HEADER LINE.
DATA cancel.
DATA pdf LIKE tline OCCURS 100 WITH HEADER LINE.
DATA it_pdf LIKE pdf OCCURS 0 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.
AT SELECTION-SCREEN OUTPUT.
SELECT SINGLE addrnumber
persnumber
FROM adr7
INTO (l_addrnumber,l_persnumber)
WHERE uname = sy-uname.
SELECT SINGLE smtp_addr
FROM adr6
INTO l_mail
WHERE addrnumber = l_addrnumber
AND persnumber = l_persnumber.
so_date1-sign = so_name1-sign = 'I'. "so_email-sign = 'I'.
so_date1-option = so_name1-option = 'BT'. "so_email-option = 'BT'.
so_date1-low = so_date1-high = sy-datum.
so_name1-low = so_name1-high = sy-uname.
so_email-low = so_email-high = l_mail.
APPEND : so_date1,so_name1.",so_email.
START-OF-SELECTION.
IF so_date1-low IS NOT INITIAL.
l_date_low = so_date1-low.
ENDIF.
IF so_date1-high IS NOT INITIAL.
l_date_high = so_date1-high.
ENDIF.
IF so_time1-low IS NOT INITIAL.
l_time_low = so_time1-low.
l_time_low+6(2) = '00'.
ENDIF.
IF so_time1-high IS NOT INITIAL.
l_time_high = so_time1-high.
l_time_high+6(2) = '00'.
ENDIF.
IF l_time_low IS NOT INITIAL.
CONCATENATE l_date_low l_time_low INTO l_final_low.
ELSE.
CONCATENATE l_date_low '00000000' INTO l_final_low.
ENDIF.
IF l_time_high IS NOT INITIAL .
IF so_date1-high IS NOT INITIAL.
CONCATENATE l_date_high l_time_high INTO l_final_high.
ENDIF.
ELSE.
CONCATENATE l_date_low '23595959' INTO l_final_high.
ENDIF.
l_final-sig = so_date1-sign.
l_final-opt = so_date1-option.
l_final-low = l_final_low.
l_final-high = l_final_high.
APPEND l_final.
CLEAR l_final.
SELECT rqident
rqowner
rqcretime
rqclient
rqo1name
FROM tsp01 INTO TABLE it_tsp01
WHERE rqcretime IN l_final
AND rqowner IN so_name1.
IF sy-subrc NE 0.
MESSAGE 'No data for the entered values' TYPE 'E'.
EXIT.
ENDIF.
CLEAR : so_name1,so_name1[],it_tsp01.
SORT it_tsp01 BY rqident.
LOOP AT it_tsp01.
WRITE : /1 sy-vline,
3 markfield AS CHECKBOX,
5(16) it_tsp01-rqident, 22 sy-vline,
23(10) it_tsp01-rqowner, 34 sy-vline,
35(16) it_tsp01-rqcretime, 52 sy-vline.
HIDE it_tsp01-rqident.
AT LAST.
WRITE : /1(52) sy-uline.
ENDAT.
ENDLOOP.
TOP-OF-PAGE.
WRITE: /1(52) sy-uline.
WRITE: /1 sy-vline,
5(16) 'Spool No.' COLOR COL_POSITIVE CENTERED , 22 sy-vline,
23(10) 'User' COLOR COL_POSITIVE CENTERED , 34 sy-vline,
35(16) 'Date' COLOR COL_POSITIVE CENTERED , 52 sy-vline.
WRITE: /1(52) sy-uline.
END-OF-SELECTION.
SET PF-STATUS '/BAY4/PDF'.
DATA : l_rqident TYPE tsp01-rqident,
l_count TYPE i VALUE '0'.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'PDF'.
CLEAR l_count.
DO.
CLEAR : markfield.
READ LINE sy-index FIELD VALUE markfield.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CHECK markfield NE space.
IF l_count GT 0.
MESSAGE 'Please select only one check box' TYPE 'E'.
EXIT.
ENDIF.
l_rqident = it_tsp01-rqident.
l_count = l_count + 1.
ENDDO.
PERFORM get_pdf.
WHEN 'MAIL'.
CLEAR l_count.
DO.
CLEAR : markfield.
READ LINE sy-index FIELD VALUE markfield.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CHECK markfield NE space.
IF l_count GT 0.
MESSAGE 'Please select only one check box' TYPE 'E'.
EXIT.
ENDIF.
l_rqident = it_tsp01-rqident.
l_count = l_count + 1.
ENDDO.
PERFORM get_pdf.
PERFORM send_mail.
ENDCASE.
&----
*& Form get_pdf
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_pdf .
READ TABLE it_tsp01 WITH KEY rqident = l_rqident.
LOOP AT it_tsp01.
client = it_tsp01-rqclient.
name = it_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 = l_rqident
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.
ELSE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = l_rqident
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.
ENDIF.
PERFORM download_w_ext(rstxpdft) TABLES pdf
USING p_file
'.pdf'
'BIN'
numbytes
cancel.
ENDFORM. " get_pdf
&----
*& Form send_mail
&----
text
----
--> p1 text
<-- p2 text
----
FORM send_mail .
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0 WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0 WITH HEADER LINE.
*DATA: PIT_ATTACH LIKE table of IT_ATTACH.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA : w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: a TYPE string,
t TYPE string.
a = 'FILE.PDF'.
t_object_header = a .
APPEND t_object_header.
DATA: p_email TYPE string.
CONSTANTS:
con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
LOOP AT pdf.
TRANSLATE pdf USING ' ~'.
CONCATENATE pdf-tdformat pdf-tdline INTO it_attach SEPARATED BY space.
APPEND it_attach.
CLEAR : it_attach,pdf.
ENDLOOP.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam,
p_attdescription LIKE ld_attdescription,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
p_sender_address LIKE ld_sender_address,
ld_sender_address_type LIKE soextreci1-adr_typ,
p_sender_addres_type LIKE ld_sender_address_type,
ld_receiver LIKE sy-subrc.
RANGES : ld_email FOR somlreci1-receiver OCCURS 0.
ld_email[] = so_email[].
append ld_email.
ld_email = so_email.
ld_mtitle = 'PDF file for the Spool no'.
ld_format = 'pdf'.
ld_attfilename = 'filename'.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
object_header = t_object_header
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
SUBMIT rsconn01
WITH mode = 'INT'
WITH output = 'X'
AND
RETURN.
IF sy-subrc EQ 0.
MESSAGE 'PDF sent to specified mail id' TYPE 'I'.
LEAVE SCREEN.
ENDIF.
09-10-2008 2:40 PM
Hi,
Try this program, it works for me perfectly:
REPORT Z_SENDFAX line-size 46 no standard page heading message-id so.
data g_list_content type solix_tab.
data g_text_content type soli_tab.
parameters:spool like sy-spono.
parameters:rec_fax type sadrfd-rec_fax.
parameters:title like sadrfd-rec_title.
parameters:name1 like sadrfd-rec_name1.
parameters:cover type c.
PARAMETERS: Zvbeln LIKE likp-vbeln.
start-of-selection.
perform create_text_content changing g_text_content.
perform create_list_content changing g_list_content.
perform send using g_text_content
g_list_content.
&----
*& Form create_list_content
&----
*
----
form create_list_content changing list_content type solix_tab.
perform get_list_from_spool changing list_content.
endform."create_list_content''
&----
*& Form create_text_content''
&----
*''
----
form create_text_content changing text_content type soli_tab.
data:z_lin(200) type c.
append 'To,' to text_content.
concatenate 'To:' name1 into z_lin separated by space.
append z_lin to text_content.
concatenate 'End of delivery Notice for ' Zvbeln
into z_lin separated by space.
append z_lin to text_content.
convert the content from RAW to TXT''
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = text_content
objcont_new = text_content
EXCEPTIONS
others = 0.
endform."create_text_content''
&----
*& Form SEND''
&----
Create the list-document and send it via FAX, Mail and RML''
----
form send using text_content type soli_tab
list_content type solix_tab.
data:z_lin(200) type c.
structures and internal tables for the send data''
data document_data type sodocchgi1.
data packing_list type table of sopcklsti1.
data receivers type table of somlreci1.
data contents_txt type soli_tab.
data contents_hex type solix_tab.
data packlist_wa type sopcklsti1.
data receiver_wa type somlreci1.
data packlist_counter type i.
data sent_to_all type sonv-flag.
data msg_ex(200) type c.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
main document''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
document data contains information for the whole message''
document_data-obj_descr = 'Miscellaneous Delivery Notice'.
some text for the main document''
append 'Hi,' name1 to contents_txt.
concatenate 'To:' name1 into z_lin separated by space.
append z_lin to contents_txt.
concatenate 'Attached you will find the Delivery Notice for ' Zvbeln
into msg_ex separated by space.
append msg_ex to contents_txt.
append 'Attached you will find the Delivery Notice for ' Zvbeln to contents_txt.
packlist_counter = 1.
perform create_packlist_entry using contents_txt
'RAW'
changing packlist_wa
packlist_counter.
append packlist_wa to packing_list.
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
add a text attachment of type TXT''
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
perform create_packlist_entry using text_content
'TXT'
changing packlist_wa
packlist_counter.
append packlist_wa to packing_list.
append lines of text_content to contents_txt.
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
add the list attachment of type ALI''
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
packlist_counter = 1."because we will fill the hex table now''
perform create_packlist_entry using list_content
'ALI'
changing packlist_wa
packlist_counter.
append packlist_wa to packing_list.
append lines of list_content to contents_hex.
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
fill recipients tables''
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
perform create_fax_recipient changing receiver_wa.
append receiver_wa to receivers.
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
Send the document by calling the API1''
as of 6.10 either the flag 'commit_work' has to be set''
or a commit work statement has to be set somewhere after the call''
Sending won't work without this!''
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~''
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = sent_to_all
TABLES
packing_list = packing_list
contents_txt = contents_txt
contents_hex = contents_hex
receivers = receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
case sy-subrc.
when 0.
if sent_to_all is initial.
read table receivers index 1 into receiver_wa.
message i865 with receiver_wa-retrn_code.
else.
message s022.
endif.
when 1.
message i552.
when 2.
message i023 with document_data-obj_descr.
when 4.
message i471.
when others.
message i619.
endcase.
endform." SEND''
&----
*& Form USE_SUBMIT''
&----
<nowiki>* Use "submit <report> exporting list to memory"
----
form use_submit changing contents_hex type solix_tab.
data listobject type table of abaplist.
get the list object by calling the list in another report
F1 on submit gives more information
submit balvsd03 exporting list to memory and return.
import the list from memory and store it in table listobject
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
not_found = 1
others = 2.
if sy-subrc <> 0.
message e105 with 'LIST_FROM_MEMORY'.
endif.
free memory
CALL FUNCTION 'LIST_FREE_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
others = 1.
if sy-subrc <> 0.
message e105 with 'LIST_FREE_MEMORY'.
endif.
it's always necessary to compress the table.
SAPconnect will decompress it
CALL FUNCTION 'TABLE_COMPRESS'
TABLES
in = listobject
out = contents_hex
EXCEPTIONS
compress_error = 1
others = 2.
if sy-subrc <> 0.
message e105 with 'TABLE_COMPRESS'.
endif.
endform." USE_SUBMIT
&----
*& Form WRITE_A_LIST
&----
Create a new list within this report.
----
form write_a_list changing contents_hex type solix_tab.
data listobject type table of abaplist.
perform write_list.
Save the list and store table listobject
CALL FUNCTION 'SAVE_LIST'
EXPORTING
list_index = sy-lsind
TABLES
listobject = listobject
EXCEPTIONS
list_index_invalid = 1.
if sy-subrc = 1.
message e105 with 'SAVE_LIST'.
endif.
It's always necessary to compress the table
SAPconnect will decompress it
CALL FUNCTION 'TABLE_COMPRESS'
TABLES
in = listobject
out = contents_hex
EXCEPTIONS
compress_error = 1
others = 2.
if sy-subrc <> 0.
message e105 with 'TABLE_COMPRESS'.
endif.
endform." WRITE_A_LIST
&----
*& Form GET_LIST_FROM_SPOOL
&----
Get list from spool
----
form get_list_from_spool changing contents_hex type solix_tab.
data spool_number type rspoid.
data contents_bin type soli_tab.
data print_parameters type pri_params.
data valid type c.
write a list into spool
CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING
out_parameters = print_parameters
valid = valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
if sy-subrc <> 0.
message e105 with 'GET_PRINT_PARAMETERS'.
elseif valid is initial.
return.
endif.
new-page print on parameters print_parameters no dialog.
perform write_list.
new-page print off.
spool_number = spool.
DATA:REAL_TYPE LIKE SOODK-OBJTP.
DATA:BUFFER_PDF LIKE TLINE OCCURS 0 WITH HEADER LINE.
you can also send OTF documents from spool with this function
module. The importing parameter real_type gives you the doc type
that you have to give to the send interface. The parameter is not
used here
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = spool_number
desired_type = 'RAW'
IMPORTING
REAL_TYPE = REAL_TYPE
TABLES
buffer = contents_bin
BUFFER_PDF = BUFFER_PDF
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
others = 8.
*clear contents_bin[].
if sy-subrc <> 0.
message e105 with 'RSPO_RETURN_SPOOLJOB'.
endif.
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = contents_bin
objcont_new = contents_bin
EXCEPTIONS
others = 0.
data:TRANSFER_BIN TYPE SX_BOOLEAN." occurs 0.
data:CONTENT_BIN TYPE SOLIX_TAB." occurs 0.
data:OBJHEAD TYPE SOLI_TAB.
data:LEN TYPE SO_OBJ_LEN.
*len = '255'.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PRT'
EXPORTING
FORMAT_SRC = 'OTF'
FORMAT_DST = 'PRT'
devtype = 'POSTSCPT'
CHANGING
TRANSFER_BIN = TRANSFER_BIN
CONTENT_TXT = contents_bin
CONTENT_BIN = contents_hex
OBJHEAD = OBJHEAD
LEN = len.
*
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
FORMAT_SRC = 'OTF'
FORMAT_DST = 'PDF'
devtype = 'PRINTER'
CHANGING
TRANSFER_BIN = TRANSFER_BIN
CONTENT_TXT = contents_bin
CONTENT_BIN = contents_hex
OBJHEAD = OBJHEAD
LEN = len.
convert to hex table
CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
EXPORTING
ip_solitab = CONTENT_BIN
IMPORTING
ep_solixtab = contents_hex.
*
endform." GET_LIST_FROM_SPOOL
&----
*& Form WRITE_LIST
&----
Write a list of SAPconnect conversion rules
----
form write_list.
data lt_scarr type table of scarr.
data carr type scarr.
select * from scarr into table lt_scarr.
format color = 1.
uline at /1(46).
write: / sy-vline,
'CARRID', 10 sy-vline,
'CARRNAME', 35 sy-vline,
'CURRCODE', 46 sy-vline.
format color = 2.
uline at /1(46).
loop at lt_scarr into carr.
write: / sy-vline,
carr-carrid, 10 sy-vline,
carr-carrname, 35 sy-vline,
carr-currcode, 46 sy-vline.
endloop.
uline at /1(46).
new-line.
endform." WRITE_LIST
&----
*& Form create_packlist_entry
&----
text
----
form create_packlist_entry using contents type standard table
format type so_obj_tp
changing packlist_wa type sopcklsti1
packlist_counter type i.
data tab_lines type i.
clear packlist_wa.
DATA FORM2 TYPE so_obj_tp.
get the table length of the attachment
describe table contents lines tab_lines.
set binary flag for binary content to mark that this packlist entry
is meant for table contents_hex and not for contents_bin
FORM2 = FORMAT.
if format = 'ALI'.
FORM2 = 'PRT'.
FORM2 = 'PDF'.
packlist_wa-transf_bin = 'X'.
endif.
attchment's description and format
concatenate form2 'Document' into
packlist_wa-obj_descr separated by space.
packlist_wa-doc_type = form2.
describe start and length in contents_txt or contents_hex
which table is meant is decided by the transf_bin flag set above
packlist_wa-body_start = packlist_counter.
packlist_wa-body_num = tab_lines.
increase counter to have the starting line for the next attachment
packlist_counter = packlist_counter + tab_lines.
endform." create_packlist_entry
&----
*& Form create_int_recipient
&----
text
----
*form create_int_recipient changing receiver type somlreci1.
*
field-symbols <receiver> type c.
data recipient_int type sadrud.
*
clear receiver.
*
fill address type specific recipient structure
*
cast structure to generic receiver field
assign recipient_int to <receiver> casting.
receiver-receiver = <receiver>.
set address type for INT
receiver-rec_type = 'U'.
*
*endform."create_int_recipient
&----
*& Form create_fax_recipient
&----
text
----
form create_fax_recipient changing receiver type somlreci1.
field-symbols <receiver> type c.
data recipient_fax type sadrfd.
data name type soud3.
clear receiver.
name-sapnam = sy-uname.
CALL FUNCTION 'SO_NAME_CONVERT'
EXPORTING
name_in = name
IMPORTING
name_out = name
EXCEPTIONS
others = 1.
if sy-subrc <> 0.
name-adrname = sy-uname.
endif.
fill address type specific recipient structure
recipient_fax-rec_fax = rec_fax."'7152414031'.
recipient_fax-rec_state = 'US'.
recipient_fax-rec_title = title."'Mr.'.
recipient_fax-rec_name1 = name1."'Ytamar Fondeur'.
recipient_fax-send_nam = name-adrname.
recipient_fax-send_cover = cover.
recipient_fax-FORM_LANGU = sy-langu.
cast structure to generic receiver field
assign recipient_fax to <receiver> casting.
receiver-receiver = <receiver>.
set address type for FAX
receiver-rec_type = 'F'.
endform."create_fax_recipient
&----
*& Form create_rml_recipient
&----
text
----
form create_rml_recipient changing receiver type somlreci1.
field-symbols <receiver> type c.
data recipient_rml type sadr7d.
clear receiver.
fill address type specific recipient structure
recipient_rml-sdest = 'C11'.
recipient_rml-umand = '001'.
recipient_rml-uname = 'MYUSER'.
cast structure to generic receiver field
assign recipient_rml to <receiver> casting.
receiver-receiver = <receiver>.
set address type for RML
receiver-rec_type = 'R'.
endform."create_rml_recipient