Smartform pdf or mail
Hi All,
In smartForm how to send mail and how to convert it in to pdf file .can any one write the pseudocode?
Thanks in Advance,
Hi Chalapathi,
1.[Convert Smartform into PDF and Download.|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f26944450]
2.Sending mai with PDF attachement.
Check the following program.
Declaration part and send_mai subroutine have to be considered.
After getting PDF from above link use SEND_MAI portion. in that convert_spool_2_pdf TABLES i_attachment subroutine should not be considered as we already got PDF. just change receiver address and run the program. It runs perfectly. only needs to be clubed.
REPORT zvenkat_mai_pdf_attach.
" Data retrieval related declarations
"Variables
DATA:
g_spool_no TYPE TSP01-RQIDENT.
"Types
TYPES:
BEGIN OF t_emp_dat,
pernr TYPE pa0001-pernr,
persg TYPE pa0001-persg,
persk TYPE pa0001-persk,
plans TYPE pa0001-plans,
stell TYPE pa0001-stell,
END OF t_emp_dat.
"Work area
DATA:
w_emp_data TYPE t_emp_dat.
"Internal tables
DATA:
i_emp_data TYPE STANDARD TABLE OF t_emp_dat.
" Mai related declarations
"Variables
DATA :
g_sent_to_all TYPE sonv-flag,
g_tab_lines TYPE i.
"Types
TYPES:
t_document_data TYPE sodocchgi1,
t_packing_list TYPE sopcklsti1,
t_attachment TYPE solisti1,
t_body_msg TYPE solisti1,
t_receivers TYPE somlreci1,
t_pdf TYPE tline.
"Workareas
DATA :
w_document_data TYPE t_document_data,
w_packing_list TYPE t_packing_list,
w_attachment TYPE t_attachment,
w_body_msg TYPE t_body_msg,
w_receivers TYPE t_receivers,
w_pdf TYPE t_pdf.
"Internal Tables
DATA :
i_document_data TYPE STANDARD TABLE OF t_document_data,
i_packing_list TYPE STANDARD TABLE OF t_packing_list,
i_attachment TYPE STANDARD TABLE OF t_attachment,
i_body_msg TYPE STANDARD TABLE OF t_body_msg,
i_receivers TYPE STANDARD TABLE OF t_receivers,
i_pdf TYPE STANDARD TABLE OF t_pdf.
"Top-of-page.
TOP-OF-PAGE.
PERFORM top_of_page.
"Start-of-selection.
START-OF-SELECTION.
PERFORM get_data.
IF i_emp_data[] IS INITIAL.
PERFORM test_data.
ENDIF.
PERFORM do_print_n_get_spoolno.
"End-of-selection.
END-OF-SELECTION.
PERFORM send_mai.
*& Form top_of_page
FORM top_of_page.
DATA: inc_colnum TYPE i.
ULINE.
inc_colnum = sy-linsz - 60.
WRITE: / 'Report: ', sy-repid(18).
WRITE AT 30(inc_colnum) sy-title CENTERED.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Page: ', (11) sy-pagno RIGHT-JUSTIFIED.
WRITE: / 'Client: ', sy-mandt.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Date: ', sy-datum.
WRITE: / 'User : ', sy-uname.
inc_colnum = sy-linsz - 60.
WRITE AT 30(inc_colnum) 'Company Confidential' CENTERED.
inc_colnum = sy-linsz - 20.
WRITE: AT inc_colnum 'Time: ', (10) sy-uzeit RIGHT-JUSTIFIED.
ULINE .
SKIP.
ULINE AT /(127).
WRITE:/ sy-vline,'pernr' COLOR COL_HEADING,13
sy-vline,'persg' COLOR COL_HEADING,20
sy-vline,'persk' COLOR COL_HEADING,26
sy-vline,'plans' COLOR COL_HEADING,35
sy-vline,'stell' COLOR COL_HEADING,46
sy-vline.
ULINE AT /(46).
ENDFORM. "top_of_page
"Form get_data from PA0001
FORM get_data.
SELECT pernr
persg
persk
plans
stell
FROM pa0001
INTO CORRESPONDING FIELDS OF TABLE i_emp_data
UP TO 4 ROWS.
ENDFORM. " get_data
"Form do_print_n_get_spoolno
FORM do_print_n_get_spoolno.
"Display Output
LOOP AT i_emp_data INTO w_emp_data .
AT FIRST.
PERFORM get_print_parameters.
ENDAT.
WRITE:/ sy-vline,w_emp_data-pernr,13
sy-vline,w_emp_data-persg,20
sy-vline,w_emp_data-persk,26
sy-vline,w_emp_data-plans,35
sy-vline,w_emp_data-stell,46
sy-vline.
ULINE AT /(46).
AT LAST.
g_spool_no = sy-spono.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
ENDAT.
ENDLOOP.
ENDFORM. "do_print_n_get_spoolno
"Form send_mai
"PACKING LIST
"This table requires information about how the data in the
"tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are to
"be distributed to the documents and its attachments.The first
"row is for the document, the following rows are each for one
"attachment.
FORM send_mai .
"Subject of the mai.
w_document_data-obj_name = 'MAI_TO_HEAD'.
w_document_data-obj_descr = 'Regarding Mai Program by SAP ABAP'.
"Body of the mai
PERFORM build_body_of_mai
USING:space,
'Hi,',
'I am fine. How are you? How are you doing ? ',
'This program has been created to send simple mai',
'with Subject,Body with Address of the sender. ',
'Regards,',
'Venkat.O,',
'SAP HR Technical Consultant.'.
"Convert ABAP Spool job to PDF
PERFORM convert_spool_2_pdf TABLES i_attachment.
"Write Packing List for Body
DESCRIBE TABLE i_body_msg LINES g_tab_lines.
w_packing_list-head_start = 1.
w_packing_list-head_num = 0.
w_packing_list-body_start = 1.
w_packing_list-body_num = g_tab_lines.
w_packing_list-doc_type = 'RAW'.
APPEND w_packing_list TO i_packing_list.
CLEAR w_packing_list.
"Write Packing List for Attachment
w_packing_list-transf_bin = 'X'.
w_packing_list-head_start = 1.
w_packing_list-head_num = 1.
w_packing_list-body_start = 1.
DESCRIBE TABLE i_attachment LINES w_packing_list-body_num.
w_packing_list-doc_type = 'PDF'.
w_packing_list-obj_descr = 'PDF Attachment'.
w_packing_list-obj_name = 'PDF_ATTACHMENT'.
w_packing_list-doc_size = w_packing_list-body_num * 255.
APPEND w_packing_list TO i_packing_list.
CLEAR w_packing_list.
"Fill the document data and get size of attachment
w_document_data-obj_langu = sy-langu.
READ TABLE i_attachment INTO w_attachment INDEX g_tab_lines.
w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_attachment ).
"Receivers List.
w_receivers-rec_type = 'U'. "Internet address
w_receivers-receiver = mai_id. "here mai Id should be given
w_receivers-com_type = 'INT'.
w_receivers-notif_del = 'X'.
w_receivers-notif_ndel = 'X'.
APPEND w_receivers TO i_receivers .
CLEAR:w_receivers.
"Function module to send mai to Recipients
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_document_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = g_sent_to_all
TABLES
packing_list = i_packing_list
contents_bin = i_attachment
contents_txt = i_body_msg
receivers = i_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.
IF sy-subrc = 0 .
MESSAGE i303(me) WITH 'Mai has been Successfully Sent.'.
ELSE.
WAIT UP TO 2 SECONDS.
"This program starts the SAPconnect send process.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
I hope that it helps u .
Regards,
Venkat.O
Similar Messages
-
hi experts,
i want to learn how to send a pdf as mail. can any one plz help me. plz give me step by step procedure.
thanks in advance for ur responce.this code will help you.
create your own smartfrom first..
*& Report YSMARTFORM_EMAIL
REPORT YSMARTFORM_EMAIL.
TABLES: VBAK.
Constants *
CONSTANTS:
C_X TYPE C VALUE 'X', " Value X
C_0 TYPE C VALUE '0', " Value 0
C_1 TYPE C VALUE '1'. " Value 1
Work Variables declaration *
DATA:
W_UCOMM LIKE SY-UCOMM, " Function code
W_TABLN TYPE I, " Lines
W_LINE TYPE SO_TEXT255, " Line of text
W_EADDR(60) TYPE C. " FieldLength for Email
DATA: VBAP_TAB LIKE VBAP OCCURS 0 WITH HEADER LINE.
DATA: W_FUNMOD TYPE RS38L_FNAM.
Structure to hold the Attributes of new Document
DATA: FS_DOCDATA TYPE SODOCCHGI1.
Internal table for storing OTF data form Smart-Form
DATA: BEGIN OF FS_OTF_DATA.
INCLUDE STRUCTURE ITCOO.
DATA: END OF FS_OTF_DATA,
T_OTF_DATA LIKE STANDARD TABLE OF FS_OTF_DATA.
Internal table for storing PDF data form Smart-Form
DATA: BEGIN OF FS_PDF_DATA.
INCLUDE STRUCTURE TLINE.
DATA: END OF FS_PDF_DATA,
T_PDF_DATA LIKE STANDARD TABLE OF FS_PDF_DATA.
Internal table to hold the attachment data text of the email
DATA: BEGIN OF FS_ATTACH_DATA.
INCLUDE STRUCTURE SOLISTI1.
DATA: END OF FS_ATTACH_DATA,
T_ATTACH_DATA LIKE STANDARD TABLE OF FS_ATTACH_DATA.
Internal table to hold Message body of the email
DATA: BEGIN OF FS_MESSBODY.
INCLUDE STRUCTURE SOLISTI1.
DATA: END OF FS_MESSBODY,
T_MESSBODY LIKE STANDARD TABLE OF FS_MESSBODY.
Internal table for packing list for main document
DATA: BEGIN OF FS_OBJPACK.
INCLUDE STRUCTURE SOPCKLSTI1.
DATA: END OF FS_OBJPACK,
T_OBJPACK LIKE STANDARD TABLE OF FS_OBJPACK.
Internal table for header text of the attachment
DATA: BEGIN OF FS_OBJHEAD.
INCLUDE STRUCTURE SOLISTI1.
DATA: END OF FS_OBJHEAD,
T_OBJHEAD LIKE STANDARD TABLE OF FS_OBJHEAD.
Internal table receiver information
DATA: BEGIN OF FS_RECEIVER.
INCLUDE STRUCTURE SOMLRECI1.
DATA: END OF FS_RECEIVER,
T_RECEIVER LIKE STANDARD TABLE OF FS_RECEIVER.
*Internal table to store data upto 255 lines
DATA: BEGIN OF FS_OBJCONT.
INCLUDE STRUCTURE SOLI.
DATA: END OF FS_OBJCONT,
T_OBJCONT LIKE STANDARD TABLE OF FS_OBJCONT.
*DATA : P_VBELN LIKE VBAK-VBELN.
DATA: P_EADDR(60) TYPE C
VALUE '[email protected]'.
PARAMETERS : P_VBELN LIKE VBAK-VBELN.
*PARAMETERS:
P_EADDR(60) TYPE C. " Email address
SELECT SINGLE *
FROM VBAK
WHERE VBELN EQ P_VBELN.
SELECT *
FROM VBAP
INTO TABLE VBAP_TAB
WHERE VBELN EQ P_VBELN.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'YSMARTFORM_EMAIL'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = W_FUNMOD
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3 .
IF SY-SUBRC <> 0.
Do nothing
ENDIF.
DATA: FS_CONT_PARM TYPE SSFCTRLOP,
T_JOB_INFO TYPE SSFCRESCL.
CLEAR FS_CONT_PARM.
FS_CONT_PARM-GETOTF = 'X'.
FS_CONT_PARM-NO_DIALOG = 'X'.
FS_CONT_PARM-PREVIEW = ''.
CALL FUNCTION W_FUNMOD
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = FS_CONT_PARM
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
VBAK = VBAK
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = T_JOB_INFO
JOB_OUTPUT_OPTIONS =
TABLES
VBAP = VBAP_TAB
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.
PERFORM CONVERT_OTF_TO_PDF.
*& Form convert_otf_to_pdf
text
--> p1 text
<-- p2 text
FORM CONVERT_OTF_TO_PDF .
DATA: LV_BYTES TYPE P.
IF FS_CONT_PARM-GETOTF EQ 'X'.
REFRESH T_OTF_DATA.
CLEAR FS_OTF_DATA.
LOOP AT T_JOB_INFO-OTFDATA INTO FS_OTF_DATA.
APPEND FS_OTF_DATA TO T_OTF_DATA.
CLEAR FS_OTF_DATA.
ENDLOOP. " LOOP AT t_outtab-otfdata
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 255
IMPORTING
BIN_FILESIZE = LV_BYTES
TABLES
OTF = T_OTF_DATA
LINES = T_PDF_DATA
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
IF SY-SUBRC EQ 0 AND LV_BYTES IS NOT INITIAL.
PERFORM TABLE_SHIFT.
To send the output by email
PERFORM SET_UP_EMAIL.
PERFORM SEND_MAIL.
ENDIF. " IF sy-subrc EQ space.
ENDIF. " IF gs_control_pars-getotf
ENDFORM. " convert_otf_to_pdf
Form set_up_email *
This subroutine is used to set mail attributes *
There are no interface parameters to be passed to this subroutine. *
FORM SET_UP_EMAIL .
To setup attributes of the document
PERFORM SET_EMAIL_HEADER.
To set body of email
PERFORM SET_EMAILBODY.
To convert output table data with tab delimiter
PERFORM PREPARE_OUTPUT_DATA_FOR_ATTACH.
To set the Receipents
PERFORM SET_RECEIPENTS.
ENDFORM. " Set_up_email
Form set_email_header *
This subroutine is used to Setup the attributes of the Document *
There are no interface parameters to be passed to this subroutine. *
FORM SET_EMAIL_HEADER.
CONSTANTS :
LC_P TYPE C VALUE 'P', " Production system name
LC_F TYPE C VALUE 'F', " Sensitivity
LC_OBJNAME(6) TYPE C " Object name
VALUE 'SAPRPT'.
CLEAR FS_DOCDATA.
Populate the subject/generic message attributes
FS_DOCDATA-DOC_SIZE = 1.
FS_DOCDATA-OBJ_LANGU = SY-LANGU.
FS_DOCDATA-OBJ_NAME = LC_OBJNAME.
FS_DOCDATA-SENSITIVTY = LC_F.
IF SY-SYSID+0(1) NE LC_P.
CONCATENATE 'Test mail'(003)
'Sales Order Details'(002)
INTO FS_DOCDATA-OBJ_DESCR
SEPARATED BY SPACE.
ELSE.
MOVE TEXT-002 TO FS_DOCDATA-OBJ_DESCR.
ENDIF. " IF sy-sysid+0(1)...
ENDFORM. " Set_email_header
Form set_emailbody *
This subroutine is used to set body of an email *
There are no interface parameters to be passed to this subroutine. *
FORM SET_EMAILBODY.
CONSTANTS:
LC_DOC_TYPE(3) TYPE C VALUE 'RAW'. " Document type
REFRESH : T_OBJPACK,
T_MESSBODY.
CLEAR : FS_OBJPACK,
FS_MESSBODY.
MOVE:
'Hi,'(004) TO FS_MESSBODY-LINE.
APPEND FS_MESSBODY TO T_MESSBODY.
CLEAR FS_MESSBODY.
MOVE:
'The attachment contains sales order details.'(005)
'www.google.com'
TO FS_MESSBODY-LINE.
APPEND FS_MESSBODY TO T_MESSBODY.
CLEAR W_TABLN.
DESCRIBE TABLE T_MESSBODY LINES W_TABLN.
CLEAR FS_MESSBODY.
READ TABLE T_MESSBODY INTO FS_MESSBODY INDEX W_TABLN.
FS_DOCDATA-DOC_SIZE = ( W_TABLN - 1 ) * 255 + STRLEN( W_LINE ).
MOVE:
SPACE TO FS_OBJPACK-TRANSF_BIN,
C_1 TO FS_OBJPACK-HEAD_START,
C_0 TO FS_OBJPACK-HEAD_NUM,
C_1 TO FS_OBJPACK-BODY_START,
W_TABLN TO FS_OBJPACK-BODY_NUM,
LC_DOC_TYPE TO FS_OBJPACK-DOC_TYPE.
APPEND FS_OBJPACK TO T_OBJPACK.
ENDFORM. " Set_emailbody
Form prepare_output_data_for_attach *
To convert the output table data with comma delimiter *
There are no interface parameters to be passed to this subroutine. *
FORM PREPARE_OUTPUT_DATA_FOR_ATTACH.
CONSTANTS:
LC_DOC_TYPE(3) TYPE C VALUE 'PDF', " Document type
LC_OBJNAME(6) TYPE C VALUE 'SAPRPT'. " Object name
REFRESH T_OBJHEAD.
REFRESH T_ATTACH_DATA[].
CLEAR FS_ATTACH_DATA.
T_ATTACH_DATA[] = T_OBJCONT[].
DESCRIBE TABLE T_ATTACH_DATA LINES W_TABLN.
FS_DOCDATA-DOC_SIZE = ( W_TABLN - 1 ) * 255 + STRLEN( W_LINE ).
FS_OBJPACK-BODY_NUM = W_TABLN.
FS_OBJPACK-DOC_SIZE = W_TABLN * 255.
FS_OBJPACK-TRANSF_BIN = C_X.
FS_OBJPACK-HEAD_START = C_1.
FS_OBJPACK-HEAD_NUM = C_1.
FS_OBJPACK-BODY_START = C_1.
FS_OBJPACK-DOC_TYPE = LC_DOC_TYPE.
FS_OBJPACK-OBJ_NAME = 'Attachment'.
FS_OBJPACK-OBJ_DESCR = 'Sales Order Details.PDF'(007).
APPEND FS_OBJPACK TO T_OBJPACK.
ENDFORM. " Prepare_output_data_for_attach
Form set_receipents *
This subroutine is used to set the Receipents *
There are no interface parameters to be passed to this subroutine. *
FORM SET_RECEIPENTS .
CONSTANTS
LC_REC_TYPE TYPE C VALUE 'U'. " Receipent type
REFRESH T_RECEIVER.
IF P_EADDR IS NOT INITIAL.
MOVE:
P_EADDR TO FS_RECEIVER-RECEIVER,
LC_REC_TYPE TO FS_RECEIVER-REC_TYPE.
APPEND FS_RECEIVER TO T_RECEIVER.
ENDIF. " IF P_EMAIL IS NOT.....
ENDFORM. " Set_receipents
Form send_mail *
This subroutine is used to send output by email *
There are no interface parameters to be passed to this subroutine. *
FORM SEND_MAIL.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = FS_DOCDATA
PUT_IN_OUTBOX = C_X
SENDER_ADDRESS = SY-UNAME
SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = C_X
TABLES
PACKING_LIST = T_OBJPACK
OBJECT_HEADER = T_OBJHEAD
CONTENTS_BIN = T_ATTACH_DATA
CONTENTS_TXT = T_MESSBODY
RECEIVERS = T_RECEIVER
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.
IF SY-SUBRC NE 0.
MESSAGE I007(CLAIM).
ELSE.
MESSAGE S592(EI).
ENDIF. " IF sy-subrc NE 0.
ENDFORM. " Send_mail
*& Form table_shift
The PDF file that is generated out of the above function module
cannot be transported as it needs to be of 255 chars.Hence
converting the file to get a 255 char single line,internal table.
*There are no interface parameters to be passed to this subroutine
FORM TABLE_SHIFT .
CONSTANTS:
CNV_HEXCONST_ZERO TYPE X VALUE '00'.
DATA:
LV_BIG_LINES(268) TYPE C
OCCURS 0 WITH HEADER LINE.
DATA:
LFL_FLAG TYPE C,
LV_LEFT_T(268) TYPE C,
LV_LEFT_I TYPE I,
TV_LEFT_I TYPE I,
LV_CURR_I TYPE I.
FIELD-SYMBOLS: <F>.
Get the lines into a table of 268 char as the first step to put it in
the pdf file of 255 chars
CLEAR LFL_FLAG.
LOOP AT T_PDF_DATA INTO FS_PDF_DATA.
IF LFL_FLAG EQ ' '.
CLEAR LV_BIG_LINES WITH CNV_HEXCONST_ZERO.
ASSIGN LV_BIG_LINES(134) TO <F>.
<F> = FS_PDF_DATA.
LFL_FLAG = 'X'.
ELSE.
LV_BIG_LINES+134 = FS_PDF_DATA.
APPEND LV_BIG_LINES.
CLEAR: LFL_FLAG.
ENDIF. " If lfl_flag = ''..
ENDLOOP. " Loop at t_pdf
IF LFL_FLAG EQ 'X'.
APPEND LV_BIG_LINES.
ENDIF. " If lflf_flag eq 'X'..
Next fill it into a 255 char table
CLEAR: LV_LEFT_T, LV_LEFT_I, TV_LEFT_I.
LV_CURR_I = 255.
LOOP AT LV_BIG_LINES.
IF LV_LEFT_I NE 0.
IF LV_CURR_I NE 0.
FS_OBJCONT(LV_LEFT_I) = LV_LEFT_T(LV_LEFT_I).
FS_OBJCONT+LV_LEFT_I(LV_CURR_I) = LV_BIG_LINES(LV_CURR_I).
ELSE.
FS_OBJCONT = LV_LEFT_T(LV_LEFT_I).
ENDIF. " IF lv_curr_i NE 0
ELSE.
FS_OBJCONT = LV_BIG_LINES(LV_CURR_I).
ENDIF. " IF lv_left_i NE 0
APPEND FS_OBJCONT TO T_OBJCONT.
TV_LEFT_I = 268 - LV_CURR_I.
IF TV_LEFT_I > 255.
FS_OBJCONT = LV_BIG_LINES+LV_CURR_I(255).
APPEND FS_OBJCONT TO T_OBJCONT.
LV_LEFT_I = TV_LEFT_I - 255.
TV_LEFT_I = 255 + LV_CURR_I.
LV_CURR_I = 255 - LV_LEFT_I.
LV_LEFT_T = LV_BIG_LINES+TV_LEFT_I.
ELSE.
LV_LEFT_T = LV_BIG_LINES+LV_CURR_I.
LV_LEFT_I = 268 - LV_CURR_I.
LV_CURR_I = 255 - LV_LEFT_I.
ENDIF. " IF tv_left_i > 255
ENDLOOP. " LOOP AT lv_big_lines.
CLEAR FS_OBJCONT WITH CNV_HEXCONST_ZERO.
ASSIGN FS_OBJCONT(LV_LEFT_I) TO <F>.
<F> = LV_LEFT_T(LV_LEFT_I).
APPEND FS_OBJCONT TO T_OBJCONT.
ENDFORM. " Table_shift -
Sending SmartForm as E-mail attachment, with email subject and content
Hi,
I'm, e-mailing a SmartForm using the SmartForm parameters (MAIL_RECIPIENT, MAIL_SENDER and MAIL_APPL_OBJ) using control device 'MAIL'.
Create MAIL_RECEPIENT (swotobjid): CREATE_RECIPIENT_OBJ_PPF
Create MAIL_SENDER (swotobjid): CREATE_SENDER_OBJECT_PPF
Create MAIL_APPL_OBJ: This works a little different. The sender needs to have an SAP Office Inbox (SO_USER_AUTOMATIC_INSERT) where a folder is to be created using the marco's swc_create_object and swc_object_to_persistent (INCLUDE <cntn01>).
Everything works fine.
The mail is being send and the SmartForm can be accessed as attachment, the E-Mail subject (as the name of the attachment) is taken from the title of the SmartForm (output_options-tdtitle).
QUESTION *
No they want to change the E-mail subject en change the content(body) of the mail.
Is this possible within the options of the MAIL_APPL_OBJ.
Or do have to rebuild the SmartForm program, get the SmartForm as OTF, rebuild as PDF en mail the PDF to the recepient using the SO_NEW_DOCUMENT_ATT_SEND_API1.
I was thinking of creating a container and set the elements of that container (swc_set_table ?) but I don't no in the end if this woll work.Refer the following Blog-
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417300)ID0426134050DB01517382336190791762End?blog=/pub/wlg/1798
generate filename as yesterday's yyyymmdd format, and it must send file with same name with yyyymmdd
You need to use the following UDF to generate yesterday's date-
Imports: java.text.;java.util.;
public String yesterday(Container container)
long oneDay = (long) 1000.0 * 60 * 60 * 24;
DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
java.util.Date today = new java.util.Date(System.currentTimeMillis());
java.util.Date yesterday = new java.util.Date(System.currentTimeMillis()-oneDay);
String b = dateFormat.format(yesterday);
return b;
Map this with Content_Disposition as mentioned in wiki.
XI 3.0 message must be executed one a day automatically (for example at 9.00 Am).
Use 'Availability Time planning' for CC as mentioned above.
http://help.sap.com/saphelp_nw70/helpdata/EN/45/06bd029da31122e10000000a11466f/content.htm -
How to send a smartform result through mail?
How to send a smartform result through mail?
HI,
YOu can convert the output of Smartform into a attachment say PDF file & then send it across through mail.
Refer following program:
<a href="http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm">http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm</a>
Best regards,
Prashant -
Error send a smartform PDF by Email to Vendor
Hi Expert,
Please help me.........................
I want to send a PO (Smartform) as Email to Vendor.
In SAPScript the PO send by Email is working fine, but in Smartforms it is not working.
Normally, I will use via Smartforms the Program = YBAA_FM06P, FORM routine = ENTRY_NEU, PDF/Smartform Form = ZYBAA_MMPO1.
A communication strategy has communication type as INT has been defined.
This communication strategy has been set as default in the output type ZNEU. The transmission medium has been set to 5 (External Send) and the partner function as VN (Vendor).
The e-mail address of the vendor has also been maintained.
In transaction MN04, i have also made an entry for output type ZNEU and set the document type as NB.
But message output do not create.
How to send a smartform PDF by Email to vendor?
Thanks,Hi,
I can convert the PO output in to PDF from SOST I can sent it to external vendor using the Mail triggering configuration settings but meassage output do not create.
Please tell me how can I do.
Thank, -
hi friends,
i want convert the alv report to pdf and mail the same pdf.
have used function REUSE_ALV_LIST_DISPLAY to display alv report.
i am using CONVERT_ABAPSPOOLJOB_2_PDF to convert the alv report to pdf.
now i need to mail the pdf implicitly to the email address.
i have used some function to mail the pdf but it is asking for the path which has to be hard coded.
the path cannot be hard coded.
cant use F4_GETFILENAME or gui_upload to attach the file or to get the path because the pdf has to be sent directly to some email address.
thanks.
regards,
akshay ruia.Please refer the link below.............
Sample Program To Convert Smartform To PDF Document & Mail It To The Concerned As An Attachment.
[http://www.abapmadeeasy.com/2011/02/sap-abap-sample-program-to-convert.html|http://www.abapmadeeasy.com/2011/02/sap-abap-sample-program-to-convert.html]
Regards,
Uttam Agrawal
http://www.abapmadeeasy.com
Edited by: uttamagrawal on Feb 22, 2011 9:19 AM -
Hi, im tring to use the SO_DOCUMENT_SEND_API1 FM to send a smartform output by mail. Im able to convert the smartform output to pdf and save it to teh hard drive and works great but when i try to send the pdf doc by mail it comes corrupted... can anyone help me on this... heres a piece of my code
call function 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
others = 4.
* Fehlerhandling
if sy-subrc <> 0.
endif.
******* I THINK THE ERROR MAYBE ON THIS PIECE OF CODE ************
loop at i_tline.
translate i_tline using ' ~'.
concatenate wa_buffer i_tline into wa_buffer.
endloop.
translate wa_buffer using '~ '.
do.
i_record = wa_buffer.
append i_record.
shift wa_buffer left by 255 places.
if wa_buffer is initial.
exit.
endif.
enddo.
***************** it message ****************************************
refresh it_message.
it_message = 'Em anexo vai a tabela interna de utilizadores '.
APPEND it_message.
it_message = 'Clique no link '.
APPEND it_message.
**************** Assunto do Email *****************
* Fill the document data and get size of attachment
CLEAR w_doc_data.
DESCRIBE TABLE It_message LINES x.
READ TABLE It_message INDEX x.
w_doc_data-DOC_SIZE =
( x - 1 ) * 255 + STRLEN( It_message ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = 'ASSUNTO EMAIL'.
w_doc_data-sensitivty = 'F'.
************************ fim assunto email *********************
data linha type i.
data lv_cntl type i.
CLEAR t_attachment.
REFRESH t_attachment.
************************** Mensagem ******************
* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
clear t_packing_list-transf_bin.
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.
***************************-Filling the attch table with data *************************
CLEAR : L_TABLE_LINES.
* clear wa_objhead.
* loop at i_record.
t_attachment[] = i_tline[].
* append t_attachment.
* endloop.
* 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 L_TABLE_LINES.
t_packing_list-body_num = L_TABLE_LINES.
t_packing_list-obj_descr = 'output'.
t_packing_list-doc_type = 'BIN'.
t_packing_list-doc_size = L_TABLE_LINES * 255.
t_packing_list-obj_langu = sy-langu.
t_packing_list-obj_name = 'Teste'.
APPEND t_packing_list.
*************** Endereços de email dos destinatários *************************
CLEAR receivers.
REFRESH receivers.
receivers-receiver = '[email protected]'.
receivers-rec_type = 'U'.
receivers-com_type = 'INT'.
receivers-notif_del = 'X'.
receivers-EXPRESS = 'X'.
* receivers-notif_ndel = 'X'.
APPEND receivers.
************************Fim de email dos Dest. ******************************
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
* NEW_OBJECT_ID =
* SENDER_ID =
TABLES
PACKING_LIST = t_packing_list
* OBJECT_HEADER = wa_objhead
CONTENTS_BIN = t_attachment
CONTENTS_TXT = it_message
* CONTENTS_HEX = contents_hex
* OBJECT_PARA =
* OBJECT_PARB =
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.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
wait up to 2 seconds.
if sy-subrc eq 0.
submit rsconn01 "with mode = 'INT'
*with output = 'X'
and return.
endif.Hi Joao,
Try using this code .
*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
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 ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
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,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
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
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.
ENDFORM.
Hope this resolves your query.
Reward all the helpful answers.
Regards -
Problem in Sending PDF as Mail
We are currently upgrading from 4.7 to ECC 6 and we have a program which sends a smartform as PDF in Mail.
In the pre upgrade system its working fine and in post upgrade system, we could not able to open the PDF attachment.
It throwing an error saying the file could be damaged or lost. We are using CONVERT_OTF and SO_DOCUMENT_SEND_API1 function module to send the mail.
Anyone has faced a similar kind of issue before?
Any pointers would be great.
THanks,
ArunHi,
Use FM CONVERT_OTF_2_PDF
i_otf = ls_job_info-otfdata.
ls_job_info is a importing parameter obtained from your Smartform Function module.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = w_bin_filesize
TABLES
otf = i_otf
doctab_archive = i_docs
lines = i_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3. -
Problems sending a PDF via mail
Hi !! I have a report, runs in background, which obtains some information from sap tables and then generates an ALV. As it is executed in background, the ALV creates an spool order. After this, I convert this spool into a PDF object . And then I need to send a mail to an specific user with some text in its body and this PDF as attach. If I don't attach the PDF, the mail is sent ok. The problem is when I try to attach the PDF.. Here is my code so anybody can help me please... REPORT zautorizaciones_spool . TABLES : usr02, agr_texts, agr_users, adr6, usr21, adrp, itcpo, tsp01. TYPE-POOLS : slis. DATA: BEGIN OF i_tabla OCCURS 0, agr_name LIKE agr_texts-agr_name, text LIKE agr_texts-text, uname LIKE agr_users-uname, name_text LIKE adrp-name_text, END OF i_tabla. * Spool IDs TYPES: BEGIN OF t_tbtcp. INCLUDE STRUCTURE tbtcp. TYPES: END OF t_tbtcp. DATA: fieldcat TYPE slis_t_fieldcat_alv, fieldcat_ln LIKE LINE OF fieldcat, sortcat TYPE slis_t_sortinfo_alv. DATA: col_pos TYPE i, spos TYPE i. DATA: v_buffer TYPE string. DATA: BEGIN OF it_email OCCURS 0, smtp_addr LIKE adr6-smtp_addr. DATA: END OF it_email. DATA: mi_rqident LIKE tsp01-rqident, mi_bytecount TYPE i, mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE. DATA: it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE, objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE, objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE, objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE, doc_chng LIKE sodocchgi1, tab_lines LIKE sy-tabix, reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE, it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE. DATA: gd_eventid LIKE tbtcm-eventid, gd_eventparm LIKE tbtcm-eventparm, gd_external_program_active LIKE tbtcm-xpgactive, gd_jobcount LIKE tbtcm-jobcount, gd_jobname LIKE tbtcm-jobname, gd_stepcount LIKE tbtcm-stepcount, it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0, wa_tbtcp TYPE t_tbtcp. CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV'. *----
Pantalla de selección *----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. SELECT-OPTIONS: s_ustyp FOR usr02-ustyp, s_nomrol FOR agr_texts-agr_name, s_uflag FOR usr02-uflag, s_class FOR usr02-class, s_line FOR agr_texts-line, s_todat FOR agr_users-to_dat, s_spras FOR agr_texts-spras, s_gltgb FOR usr02-gltgb, s_correo FOR adr6-smtp_addr. SELECTION-SCREEN END OF BLOCK b1. *----
INITIALIZATION *----------------------------------------------------------------------
INITIALIZATION. CLEAR i_tabla. REFRESH i_tabla. *----
START-OF-SELECTION *----------------------------------------------------------------------
START-OF-SELECTION. PERFORM obtener_datos. IF NOT i_tabla[] IS INITIAL. IF sy-batch IS INITIAL. PERFORM listado. SKIP. WRITE:/ 'Para que la orden spool pueda ser creada, el programa', 'se debe de ejecutar en fondo.'. ELSE. MESSAGE s000(z2) WITH 'batch'. PERFORM listado. PERFORM get_job_details. PERFORM get_spool_number USING SY-REPID sy-uname CHANGING mi_rqident. PERFORM conver_spool_pdf. PERFORM enviar_mail. PERFORM delete_spool. IF sy-sysid = c_dev. WAIT UP TO 5 SECONDS. SUBMIT rsconn01 WITH mode = 'INT' WITH output = 'X' AND RETURN. ENDIF. ENDIF. ENDIF. *----
END-OF-SELECTION *---------------------------------------------------------------------
END-OF-SELECTION. *&----
*& Form obtener_datos *&--------------------------------------------------------------------
FORM obtener_datos. SELECT agr_textsagr_name agr_textstext agr_usersuname adrpname_text APPENDING CORRESPONDING FIELDS OF TABLE i_tabla FROM ( agr_users INNER JOIN usr02 ON usr02bname = agr_usersuname INNER JOIN agr_texts ON agr_textsagr_name = agr_usersagr_name INNER JOIN usr21 ON usr21bname = usr02bname INNER JOIN adrp ON adrppersnumber = usr21persnumber ) WHERE agr_usersagr_name IN s_nomrol AND agr_usersto_dat IN s_todat AND usr02class IN s_class AND usr02gltgb IN s_gltgb AND usr02uflag IN s_uflag AND usr02ustyp IN s_ustyp AND agr_textsline IN s_line AND agr_textsspras IN s_spras. ENDFORM *&--------------------------------------------------------------------
*& Form listado *&--------------------------------------------------------------------
FORM listado. PERFORM crear_catalogo. PERFORM imprimir. ENDFORM. *&--------------------------------------------------------------------
*& Form crear_catalogo *&--------------------------------------------------------------------
FORM crear_catalogo. PERFORM build_fieldcat USING : 'AGR_TEXTS' 'AGR_NAME' '' '' '' '30' '' 'L' 'Papel', 'AGR_TEXTS' 'TEXT' '' '' '' '80' '' 'L' 'Denominación papel', 'AGR_USERS' 'UNAME' '' '' '' '12' '' 'L' 'Usuario', 'NAME_TEXT' 'NAME_TEXT' '' '' '' '80' '' 'L' 'Nombre completo'. ENDFORM. *&--------------------------------------------------------------------
*& Form build_fieldcat *&--------------------------------------------------------------------
FORM build_fieldcat USING tabname fieldname key no_out hotspot outputlen do_sum ddictxt seltext_l. ADD 1 TO col_pos. fieldcat_ln-ref_tabname = tabname. fieldcat_ln-fieldname = fieldname. fieldcat_ln-key = key. fieldcat_ln-col_pos = col_pos. fieldcat_ln-no_out = no_out. fieldcat_ln-hotspot = hotspot. fieldcat_ln-do_sum = do_sum. fieldcat_ln-ddictxt = ddictxt. fieldcat_ln-seltext_l = seltext_l. fieldcat_ln-seltext_m = seltext_l. fieldcat_ln-seltext_s = seltext_l. IF NOT outputlen IS INITIAL. fieldcat_ln-outputlen = outputlen. ENDIF. APPEND fieldcat_ln TO fieldcat. CLEAR fieldcat_ln. ENDFORM. *&--------------------------------------------------------------------
*& Form imprimir *&--------------------------------------------------------------------
FORM imprimir. DATA : prg LIKE sy-repid. prg = sy-repid. DATA : salida TYPE slis_exit_by_user. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = prg i_callback_user_command = 'ALV_USER_COMMAND' it_fieldcat = fieldcat it_sort = sortcat i_save = 'A' IMPORTING es_exit_caused_by_user = salida TABLES t_outtab = i_tabla EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM. *&--------------------------------------------------------------------
*& Form informar_cuerpo *&--------------------------------------------------------------------
FORM informar_cuerpo. objtxt-line = 'Estimado propietario de datos.'. APPEND objtxt. CLEAR objtxt. APPEND objtxt. CLEAR objtxt. CONCATENATE 'En el marco de la auditoría SOX, y para asegurar el cumplimiento' 'de uno de sus controles, le adjuntamos un/os informes para...' INTO objtxt-line SEPARATED BY space. APPEND objtxt. CLEAR objtxt. ENDFORM. " informar_cuerpo *&--------------------------------------------------------------------
*& Form enviar_mail *&--------------------------------------------------------------------
FORM enviar_mail. DATA: w_cnt TYPE i, t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE, cont type i. doc_chng-obj_name = 'Probando envio mail'. doc_chng-obj_descr = 'Probando asunto mail'. PERFORM informar_cuerpo. READ TABLE it_mess_att INDEX w_cnt. MESSAGE s000(z2) WITH 'w_cnt' w_cnt. MESSAGE s000(z2) WITH 'sy-subrc' sy-subrc. DESCRIBE TABLE objtxt LINES tab_lines. doc_chng-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ). CLEAR t_attachment. REFRESH t_attachment. t_attachment[] = it_mess_att[]. CLEAR objpack-transf_bin. objpack-head_start = 1. objpack-head_num = 0. objpack-body_start = 1. objpack-body_num = tab_lines. objpack-doc_type = 'RAW'. objpack-obj_descr = doc_chng-obj_descr. DESCRIBE TABLE t_attachment LINES objpack-body_num. objpack-doc_type = 'PDF'. objpack-obj_descr = 'OBJ_Descr'. objpack-obj_name = 'obj_name'. objpack-doc_size = objpack-body_num * 255. APPEND objpack. objhead = 'Envio mail'. READ TABLE objtxt INDEX tab_lines. IF sy-subrc = 0. MESSAGE s000(z2) WITH 'objtxt' tab_lines. ENDIF. reclist-receiver = p_mail. reclist-rec_type = 'U'. reclist-express = 'X'. reclist-com_type = 'INT'. APPEND reclist. CLEAR reclist. CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' EXPORTING document_data = doc_chng TABLES packing_list = objpack object_header = objhead contents_bin = objbin contents_txt = objtxt receivers = reclist 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. MESSAGE s000(z2) WITH 'sy-subrc' sy-subrc. ENDFORM. " enviar_mail *&--------------------------------------------------------------------
*& Form get_spool_number *&--------------------------------------------------------------------
FORM get_spool_number USING f_repid f_uname CHANGING f_rqident. DATA: lc_rq2name LIKE tsp01-rq2name. CHECK NOT ( gd_jobname IS INITIAL ). CHECK NOT ( gd_jobcount IS INITIAL ). SELECT * FROM tbtcp INTO TABLE it_tbtcp WHERE jobname = gd_jobname AND jobcount = gd_jobcount AND stepcount = gd_stepcount AND listident <> '0000000000' ORDER BY jobname jobcount stepcount. CLEAR wa_tbtcp. READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1. IF sy-subrc = 0. f_rqident = wa_tbtcp-listident. MESSAGE s000(z2) WITH 'Se ha creado la orden spool' f_rqident. ELSE. MESSAGE s000(z2) WITH 'No se ha recuperado ninguna orden spool'. ENDIF. ENDFORM. " get_spool_number *&--------------------------------------------------------------------
*& Form informar_destinatario *&--------------------------------------------------------------------
FORM informar_destinatario USING p_correo. it_receivers-receiver = p_correo. it_receivers-rec_type = 'U'. it_receivers-express = 'X'. it_receivers-com_type = 'INT'. APPEND it_receivers. CLEAR it_receivers. ENDFORM. " informar_destinatario *&--------------------------------------------------------------------
*& Form get_job_details *&--------------------------------------------------------------------
FORM get_job_details. CALL FUNCTION 'GET_JOB_RUNTIME_INFO' IMPORTING eventid = gd_eventid eventparm = gd_eventparm external_program_active = gd_external_program_active jobcount = gd_jobcount jobname = gd_jobname stepcount = gd_stepcount EXCEPTIONS no_runtime_info = 1 OTHERS = 2. MESSAGE s000(z2) WITH 'job: ' gd_jobname. ENDFORM. " get_job_details *&--------------------------------------------------------------------
*& Form conver_spool_pdf *&--------------------------------------------------------------------
FORM conver_spool_pdf. CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF' EXPORTING src_spoolid = mi_rqident no_dialog = ' ' dst_device = 'LOCL' IMPORTING pdf_bytecount = mi_bytecount TABLES pdf = mtab_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 OTHERS = 12. CHECK sy-subrc = 0. LOOP AT mtab_pdf. TRANSLATE mtab_pdf USING ' '. CONCATENATE v_buffer mtab_pdf INTO v_buffer. ENDLOOP. TRANSLATE v_buffer USING ' '. DO. it_mess_att = v_buffer. APPEND it_mess_att. SHIFT v_buffer LEFT BY 255 PLACES. IF v_buffer IS INITIAL. EXIT. ENDIF. ENDDO. ENDFORM. " conver_spool_pdf *&--------------------------------------------------------------------
*& Form delete_spool *&----
FORM delete_spool. DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char, ld_status LIKE sy-subrc. CLEAR: ld_spool_nr, ld_status. ld_spool_nr = mi_rqident. CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ' EXPORTING spoolid = ld_spool_nr IMPORTING status = ld_status. ENDFORM. " delete_spool I don't know where the error can be and I've been working on it for 2 days... Do I have to download the PDF to a file ??? In that case, how do I attach then the file ?? Thanks a lot in advance, Regards !!Sorry, I wrote it as the code appears in SAP and didn't know I can format it..I hope I've done it ok now..
As I run the report through a job, I do it like this:
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS no_runtime_info = 1
OTHERS = 2.
Then I get the spool:
DATA: lc_rq2name LIKE tsp01-rq2name.
SELECT * FROM tbtcp INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident '0000000000'
ORDER BY jobname jobcount stepcount.
CLEAR wa_tbtcp.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
f_rqident = wa_tbtcp-listident.
After this I create the PDF:
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = mi_rqident
no_dialog = ' '
dst_device = 'LOCL'
IMPORTING
pdf_bytecount = mi_bytecount
TABLES
pdf = mtab_pdf.
LOOP AT mtab_pdf.
TRANSLATE mtab_pdf USING ' ~'.
CONCATENATE
v_buffer
mtab_pdf
INTO v_buffer.
ENDLOOP.
TRANSLATE v_buffer USING '~ '.
DO.
it_mess_att = v_buffer.
APPEND it_mess_att.
SHIFT v_buffer LEFT BY 255 PLACES.
ENDDO.
To send the mail..
DATA: w_cnt TYPE i
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
cont type i.
doc_chng-obj_name = 'Probando envio mail'.
doc_chng-obj_descr = 'Probando asunto mail'.
READ TABLE it_mess_att INDEX w_cnt.
DESCRIBE TABLE objtxt LINES tab_lines.
doc_chng-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ).
CLEAR t_attachment.
REFRESH t_attachment. t_attachment[] = it_mess_att[].
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
objpack-obj_descr = doc_chng-obj_descr.
DESCRIBE TABLE t_attachment LINES objpack-body_num.
objpack-doc_type = 'PDF'.
objpack-obj_descr = 'OBJ_Descr'.
objpack-obj_name = 'obj_name'.
objpack-doc_size = objpack-body_num * 255.
APPEND objpack. objhead = 'Envio mail'.
READ TABLE objtxt INDEX tab_lines.
reclist-receiver = p_mail.
reclist-rec_type = 'U'.
reclist-express = 'X'.
reclist-com_type = 'INT'.
APPEND reclist.
CLEAR reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist .
Edited by: poketina on Nov 19, 2009 4:51 PM
Sorry, i don't know how to give format.... -
Converting report to PDF and mailing
Hi every one,
I've gone through various threads and i'm aware of the Functional module's used to
convert the report to pdf and mail it back.Like CONVERT_OTFSPOOLJOB_2_PDF, CONVERT_OTF_2_PDF and for mailing we have SEND_NEW_DOCUMENT_ATT_SEND_API1.
I've worked with this but my problem is i'm not able to convet the report output to pdf.When i'm doing this i'm getting the output of my functional module converted to pdf like the number of header and item records available for the given data in the selection screen.
Since all the threads i've gone through is converting the single internal table which has the output to pdf.
But i've got the REUSE_ALV_HIERSQL_LIST_DISPLAY, hierarchial report which as known has got two internal tables.How to the same to this kind of report....More over is it possible to convert report to pdf in online without transfering it to spool and getting the spool id to convert it to pdf.........
Any help or suggestions will surely be rewarded......
Thanks in Advance.....Here is the complete code for you;
It Converts spool request into PDF document and emails it.
<b>http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm</b>
Regards,
Vishal -
Report output to convert to pdf and mail it to recepient
Hi
I'm using the below coding for converting the output of the program to pdf and then mail it to the recepient.The coding works for background processsing only can i do the same for online.In the write statement i'm using the sy-repid my program name and when i get the pdf mail i'm getting the name of the program but instead i need to get the output of my program.Can any one help me in correcting the coding to get the output in pdf format.I know where i'm going wrong but this is the first time i'm working with this so new to this....It would be better if i could run the program and get the convertions into pdf through mail instead of background processing.....Please change the coding below to get the same.....
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE sy-repid.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool'
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Branch Revenue'.
gd_attachment_desc = 'Branch Revenue'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Branch Revenue,Profit and Commissions'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Branch Revenue'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
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 ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
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,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
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
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.
ENDFORM.
Thanks in advance.....Hi
Below is the code I was used to convert the sap script( Sales Order) to convert to PDf and send as an attachment.
Dev/UDD Id : EUR-770416 *
Author : M.Sreeram Kumar *
Date : 08-Apr-07 *
Request : DU1K933766
Description: Send an order confirmation to the multiple user in a *
PDF format via Email. *
Change Log *
Author : *
Date : *
Description : *
Request : *
Print of an order confirmation by SAPscript
REPORT zrep_email LINE-COUNT 100 MESSAGE-ID vn.
TABLES: komk, "Communicationarea for conditions
komp, "Communicationarea for conditions
komvd, "Communicationarea for conditions
vbco3, "Communicationarea for view
vbdka, "Headerview
vbdpa, "Itemview
vbdpau, "Subitemnumbers
conf_out, "Configuration data
sadr, "Addresses
tvag, "Reason for rejection
vedka, "Servicecontract head data
vedpa, "Servicecontract position data
vedkn, "Servicecontract head notice data
vedpn, "Servicecontract pos. notice data
vbpa, "Sales Document: Partner
kna1, "General Data in Customer Master
riserls, "Serialnumbers
komser, "Serialnumbers for print
tvbur, "Sales office
tvko, "Sales organisation
adrs, "Communicationarea for Address
fpltdr. "billing schedules
INCLUDE zrep_rvadtabl.
*INCLUDE yzrvadtabl.
*INCLUDE RVADTABL.
INCLUDE zrep_rvdirekt.
*INCLUDE yzrvdirekt.
*INCLUDE RVDIREKT.
INCLUDE zrep_vedadata.
*INCLUDE yzvedadata.
*INCLUDE VEDADATA.
DATA: retcode LIKE sy-subrc. "Returncode
DATA: repeat(1) TYPE c.
DATA: xscreen(1) TYPE c. "Output on printer or screen
DATA: BEGIN OF steu, "Controldata for output
vdkex(1) TYPE c,
vdpex(1) TYPE c,
kbkex(1) TYPE c,
kbpex(1) TYPE c,
END OF steu.
DATA: BEGIN OF tvbdpa OCCURS 0. "Internal table for items
INCLUDE STRUCTURE vbdpa.
DATA: END OF tvbdpa.
DATA: BEGIN OF tkomv OCCURS 50.
INCLUDE STRUCTURE komv.
DATA: END OF tkomv.
DATA: BEGIN OF tkomvd OCCURS 50.
INCLUDE STRUCTURE komvd.
DATA: END OF tkomvd.
DATA: BEGIN OF tvbdpau OCCURS 5.
INCLUDE STRUCTURE vbdpau.
DATA: END OF tvbdpau.
DATA: BEGIN OF tkomcon OCCURS 50.
INCLUDE STRUCTURE conf_out.
DATA: END OF tkomcon.
DATA: BEGIN OF tkomservh OCCURS 1.
INCLUDE STRUCTURE vedka.
DATA: END OF tkomservh.
DATA: BEGIN OF tkomservp OCCURS 5.
INCLUDE STRUCTURE vedpa.
DATA: END OF tkomservp.
DATA: BEGIN OF tkomservhn OCCURS 5.
INCLUDE STRUCTURE vedkn.
DATA: END OF tkomservhn.
DATA: BEGIN OF tkomservpn OCCURS 5.
INCLUDE STRUCTURE vedpn.
DATA: END OF tkomservpn.
DATA: BEGIN OF tkomser OCCURS 5.
INCLUDE STRUCTURE riserls.
DATA: END OF tkomser.
DATA: BEGIN OF tkomser_print OCCURS 5.
INCLUDE STRUCTURE komser.
DATA: END OF tkomser_print.
DATA: BEGIN OF tfpltdr OCCURS 5.
INCLUDE STRUCTURE fpltdr.
DATA: END OF tfpltdr.
DATA: pr_kappl(01) TYPE c VALUE 'V'. "Application for pricing
DATA: BEGIN OF char_val OCCURS 0,
atnam LIKE cabn-atnam,
atwrt LIKE ausp-atwrt,
END OF char_val.
FORM entry USING return_code us_screen.
CLEAR retcode.
xscreen = us_screen.
PERFORM processing.
IF retcode NE 0.
return_code = 1.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "ENTRY
FORM PROCESSING *
FORM processing.
PERFORM get_data.
CHECK retcode = 0.
PERFORM form_open USING xscreen vbdka-land1.
CHECK retcode = 0.
PERFORM logo_selection.
PERFORM form_title_print.
CHECK retcode = 0.
PERFORM write_header_info.
PERFORM validity_print.
CHECK retcode = 0.
PERFORM header_data_print.
CHECK retcode = 0.
PERFORM header_serv_print.
CHECK retcode = 0.
PERFORM header_notice_print.
CHECK retcode = 0.
PERFORM header_inter_print.
CHECK retcode = 0.
PERFORM header_text_print.
CHECK retcode = 0.
PERFORM item_print.
CHECK retcode = 0.
PERFORM end_print.
CHECK retcode = 0.
PERFORM form_close.
CHECK retcode = 0.
PERFORM zemail_process.
ENDFORM. "PROCESSING
S U B R O U T I N E S *
FORM ALTERNATIVE_ITEM *
A text is printed, if the item is an alternative item. *
FORM alternative_item.
CHECK vbdpa-grpos CN '0'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ALTERNATIVE_ITEM'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ALTERNATIVE_ITEM
FORM CHECK_REPEAT *
A text is printed, if it is a repeat print for the document. *
FORM check_repeat.
CLEAR repeat.
SELECT * INTO *nast FROM nast WHERE kappl = nast-kappl
AND objky = nast-objky
AND kschl = nast-kschl
AND spras = nast-spras
AND parnr = nast-parnr
AND parvw = nast-parvw
AND nacha BETWEEN '1' AND '4'.
CHECK *nast-vstat = '1'.
repeat = 'X'.
EXIT.
ENDSELECT.
ENDFORM. "CHECK_REPEAT
FORM DELIVERY_DATE *
If the delivery date in the item is different to the header *
date and there are no scheduled quantities, the delivery date *
is printed in the item block. *
FORM delivery_date.
IF vbdka-lfdat = space AND
vbdpa-lfdat NE space AND
vbdpa-etenr_da = space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_DELIVERY_DATE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "DELIVERY_DATE
FORM DIFFERENT_CONSIGNEE *
If the consignee in the item is different to the header con- *
signee, it is printed by this routine. *
FORM different_consignee.
CHECK vbdka-name1_we NE vbdpa-name1_we
OR vbdka-name2_we NE vbdpa-name2_we
OR vbdka-name3_we NE vbdpa-name3_we
OR vbdka-name4_we NE vbdpa-name4_we.
CHECK vbdpa-name1_we NE space
OR vbdpa-name2_we NE space
OR vbdpa-name3_we NE space
OR vbdpa-name4_we NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_CONSIGNEE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "DIFFERENT_CONSIGNEE
FORM DIFFERENT_REFERENCE_NO *
If the reference number in the item is different to the header*
reference number, it is printed by this routine. *
FORM different_reference_no.
CHECK vbdpa-vbeln_vang NE vbdka-vbeln_vang
OR vbdpa-vbtyp_vang NE vbdka-vbtyp_vang.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_REFERENCE_NO'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "DIFFERENT_REFERENCE_NO
FORM DIFFERENT_TERMS *
If the terms in the item are different to the header terms, *
they are printed by this routine. *
FORM different_terms.
DATA: us_vposn LIKE vedpa-vposn.
DATA: us_text(1) TYPE c. "Flag for Noticetext was printed
IF vbdpa-zterm NE vbdka-zterm AND
vbdpa-zterm NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_PAYMENT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
IF vbdpa-inco1 NE space.
IF vbdpa-inco1 NE vbdka-inco1 OR
vbdpa-inco2 NE vbdka-inco2.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_DELIVERY'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDIF.
Print different validity-data for the position
READ TABLE tkomservp WITH KEY vbdpa-posnr.
IF sy-subrc EQ 0.
vedpa = tkomservp.
IF vedpa-vbegdat NE space AND
vedpa-venddat NE space AND
NOT vedpa-vbegdat IS INITIAL AND
NOT vedpa-venddat IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV1'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSEIF vedpa-vbegdat NE space AND
NOT vedpa-vbegdat IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV2'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_SERV3'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDIF.
Notice-rules for the positions.
MOVE vbdpa-posnr TO us_vposn.
CLEAR us_text.
LOOP AT tkomservpn WHERE vposn = us_vposn.
vedpn = tkomservpn.
IF us_text IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_NOTTXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
us_text = charx.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TERMS_OF_NOTICE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDLOOP.
IF NOT us_text IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'EMPTY_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "DIFFERENT_TERMS
FORM END_PRINT *
FORM end_print.
PERFORM get_header_prices.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'PROTECT'.
PERFORM header_price_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'END_VALUES'.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SUPPLEMENT_TEXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "END_PRINT
FORM FORM_CLOSE *
End of printing the form *
FORM form_close.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
otfdata = t_otfdata
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 1.
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 sy-subrc NE 0.
PERFORM protocol_update.
retcode = 1.
ENDIF.
SET COUNTRY space.
ENDFORM. "FORM_CLOSE
FORM FORM_OPEN *
Start of printing the form *
--> US_SCREEN Output on screen *
' ' = printer *
'X' = screen *
--> US_COUNTRY County for telecommunication and SET COUNTRY *
FORM form_open USING us_screen us_country.
INCLUDE zrep_rvadopfo.
INCLUDE yzrvadopfo.
INCLUDE RVADOPFO.
ENDFORM. "FORM_OPEN
FORM FORM_TITLE_PRINT *
Printing of the form title depending of the field VBTYP *
FORM form_title_print.
CASE vbdka-vbtyp.
WHEN 'A'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_A'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'B'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_B'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'C'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_C'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'E'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_E'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'F'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_F'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'G'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_F'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'H'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_H'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'K'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_K'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN 'L'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_L'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
WHEN OTHERS.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE_OTHERS'
window = 'TITLE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDCASE.
IF repeat NE space.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'REPEAT'
window = 'REPEAT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "FORM_TITLE_PRINT
FORM GET_DATA *
General provision of data for the form *
FORM get_data.
DATA: us_veda_vbeln LIKE veda-vbeln.
DATA: us_veda_posnr_low LIKE veda-vposn.
CALL FUNCTION 'RV_PRICE_PRINT_REFRESH'
TABLES
tkomv = tkomv.
CLEAR komk.
CLEAR komp.
vbco3-mandt = sy-mandt.
vbco3-spras = nast-spras.
vbco3-vbeln = nast-objky.
vbco3-kunde = nast-parnr.
vbco3-parvw = nast-parvw.
CALL FUNCTION 'RV_DOCUMENT_PRINT_VIEW'
EXPORTING
comwa = vbco3
IMPORTING
kopf = vbdka
TABLES
pos = tvbdpa.
Fetch servicecontract-data and notice-data for head and position.
us_veda_vbeln = vbdka-vbeln.
us_veda_posnr_low = posnr_low.
CALL FUNCTION 'SD_VEDA_GET_PRINT_DATA'
EXPORTING
i_document_number = us_veda_vbeln
i_language = sy-langu
i_posnr_low = us_veda_posnr_low
TABLES
print_data_pos = tkomservp
print_data_head = tkomservh
print_notice_pos = tkomservpn
print_notice_head = tkomservhn.
PERFORM get_controll_data.
PERFORM sender.
PERFORM check_repeat.
PERFORM tvbdpau_create.
ENDFORM. "GET_DATA
FORM GET_ITEM_BILLING_SCHEDULES *
In this routine the billing schedules are fetched from the *
database. *
FORM get_item_billing_schedules.
REFRESH tfpltdr.
CHECK NOT vbdpa-fplnr IS INITIAL.
CALL FUNCTION 'BILLING_SCHED_PRINTVIEW_READ'
EXPORTING
i_fplnr = vbdpa-fplnr
i_language = nast-spras
TABLES
zfpltdr = tfpltdr.
ENDFORM. "GET_ITEM_BILLING_SCHEDULES
*& Form ITEM_BILLING_SCHEDULES_PRINT
This routine prints the billing shedules of a salesdocument *
position. *
FORM item_billing_schedules_print.
DATA: first_line(1) TYPE c.
first_line = charx.
LOOP AT tfpltdr.
fpltdr = tfpltdr.
Output of the following printlines
IF NOT fpltdr-perio IS INITIAL.
periodische Fakturen
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERIODIC'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
bei periodischen nur eine Zeile
EXIT.
ELSEIF fpltdr-fareg CA '14'.
prozentuale Teilfakturierung
IF NOT first_line IS INITIAL.
CLEAR first_line.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERCENT_HEADER'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_PERCENT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ELSEIF fpltdr-fareg CA '235'.
wertmäßige Teilfakturierung
IF NOT first_line IS INITIAL.
CLEAR first_line.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_VALUE_HEADER'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_BILLING_SCHEDULE_VALUE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ELSEIF fpltdr-fareg CA '3'.
Schlußrechnung
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_BILLING_SCHEDULES_PRINT
*eject
FORM GET_ITEM_CHARACTERISTICS *
In this routine the configuration data item is fetched from *
the database. *
FORM get_item_characteristics.
REFRESH tkomcon.
CHECK NOT vbdpa-cuobj IS INITIAL.
CALL FUNCTION 'CUD0_GET_CONFIGURATION' "#EC EXISTS
EXPORTING
instance = vbdpa-cuobj
language = nast-spras
TABLES
configuration = tkomcon
EXCEPTIONS
OTHERS = 4.
ENDFORM. "GET_ITEM_CHARACTERISTICS
FORM GET_ITEM_PRICES *
In this routine the price data for the item is fetched from *
the database. *
FORM get_item_prices.
CLEAR: komp,
tkomv.
IF komk-knumv NE vbdka-knumv.
CLEAR komk.
komk-mandt = sy-mandt.
komk-kalsm = vbdka-kalsm.
komk-kappl = pr_kappl.
komk-waerk = vbdka-waerk.
komk-knumv = vbdka-knumv.
komk-vbtyp = vbdka-vbtyp.
ENDIF.
komp-kposn = vbdpa-posnr.
CALL FUNCTION 'RV_PRICE_PRINT_ITEM'
EXPORTING
comm_head_i = komk
comm_item_i = komp
language = nast-spras
IMPORTING
comm_head_e = komk
comm_item_e = komp
TABLES
tkomv = tkomv
tkomvd = tkomvd.
ENDFORM. "GET_ITEM_PRICES
FORM GET_HEADER_PRICES *
In this routine the price data for the header is fetched from *
the database. *
FORM get_header_prices.
CALL FUNCTION 'RV_PRICE_PRINT_HEAD'
EXPORTING
comm_head_i = komk
language = nast-spras
IMPORTING
comm_head_e = komk
TABLES
tkomv = tkomv
tkomvd = tkomvd.
ENDFORM. "GET_HEADER_PRICES
*& Form HEADER_DATA_PRINT
Printing of header data like terms, weights .... *
FORM header_data_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_DATA'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. " HEADER_DATA_PRINT
FORM HEADER_PRICE_PRINT *
Printout of the header prices *
FORM header_price_print.
LOOP AT tkomvd.
AT FIRST.
IF komk-supos NE 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_SUM'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'UNDER_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDAT.
komvd = tkomvd.
IF komvd-koaid = 'D'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TAX_LINE'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SUM_LINE'.
ENDIF.
ENDLOOP.
DESCRIBE TABLE tkomvd LINES sy-tfill.
IF sy-tfill = 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'UNDER_LINE'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDFORM. "HEADER_PRICE_PRINT
FORM HEADER_TEXT_PRINT *
Printout of the headertexts *
FORM header_text_print.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEADER_TEXT'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "HEADER_TEXT_PRINT
FORM ITEM_CHARACERISTICS_PRINT *
Printout of the item characteristics -> configuration *
FORM item_characteristics_print.
LOOP AT tkomcon.
conf_out = tkomcon.
IF sy-tabix = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_CONFIGURATION_HEADER'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_CONFIGURATION'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_CHARACTERISTICS_PRINT
FORM ITEM_DELIVERY_CONFIRMATION *
If the delivery date is not confirmed, a text is printed *
FORM item_delivery_confirmation.
CHECK vbdpa-lfdat = space.
CHECK vbdpa-kwmeng NE 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_DELIVERY_CONFIRMATION'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_DELIVERY_CONFIRMATION
FORM ITEM_PRICE_PRINT *
Printout of the item prices *
FORM item_price_print.
LOOP AT tkomvd.
komvd = tkomvd.
IF sy-tabix = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_PRICE_QUANTITY'.
ELSE.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE_PRICE_TEXT'.
ENDIF.
ENDLOOP.
ENDFORM. "ITEM_PRICE_PRINT
FORM ITEM_PRINT *
Printout of the items *
FORM item_print.
DATA: da_subrc LIKE sy-subrc,
da_dragr LIKE tvag-dragr.
CALL FUNCTION 'WRITE_FORM' "First header
EXPORTING element = 'ITEM_HEADER'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
CALL FUNCTION 'WRITE_FORM' "Activate header
EXPORTING element = 'ITEM_HEADER'
type = 'TOP'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
LOOP AT tvbdpa.
vbdpa = tvbdpa.
TVAG lesen um festzustellen ob abgesagte Positionen gedruckt werden
sollen
PERFORM tvag_select(sapmv45a) USING vbdpa-abgru
da_dragr
space
da_subrc.
IF da_dragr EQ space. "Print rejected item?
IF vbdpa-posnr_neu NE space. "Item
PERFORM get_item_serials.
PERFORM get_item_characteristics.
PERFORM get_item_billing_schedules.
PERFORM get_item_prices.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'PROTECT'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE'.
PERFORM item_rejected.
PERFORM item_price_print.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'ENDPROTECT'.
PERFORM item_text_print.
PERFORM item_serials_print.
PERFORM item_characteristics_print.
PERFORM alternative_item.
PERFORM delivery_date.
PERFORM item_delivery_confirmation.
PERFORM item_billing_schedules_print.
PERFORM different_reference_no.
PERFORM different_terms.
PERFORM different_consignee.
PERFORM schedule_header.
PERFORM main_item.
ELSE.
PERFORM schedule_print.
ENDIF.
ENDIF.
ENDLOOP.
CALL FUNCTION 'WRITE_FORM' "Deactivate Header
EXPORTING element = 'ITEM_HEADER'
function = 'DELETE'
type = 'TOP'
EXCEPTIONS OTHERS = 1.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_PRINT
FORM ITEM_REJECTED *
A text is printed, if the item is rejected *
FORM item_rejected.
CHECK NOT vbdpa-abgru IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_REJECTED'
EXCEPTIONS
element = 1
window = 2.
IF sy-subrc NE 0.
PERFORM protocol_update.
ENDIF.
ENDFORM. "ITEM_REJECTED
FORM MAIN_ITEM *
A text is printed, if the item is a main item * -
Since downloading iOS on my new iPad, I cannot downlaod more than one pdf from mail into iBooks. I have to shut down my iPad and restart it to save a second pdf. Wasn't a problem with the old operating system. Any suggestions?
It seems that I have solved my issue by performing a full factory reset (erasing all content, something which I had hoped to avoid) restoring from an iCloud backup did not alleviate the issue, I had to set up as a new iPad.
Hopefully anyone else else who has this issue in the future will be able to find this. -
How can we send Smartform to exteral mail through SCOT Transaction
Hi,
i want the configuration details in <b>SCOT</b> transaction to send a <b>Smartform to external mail id</b>
Reg,
Hariharanur Smartform is sending Request to SAP -SCOT or not ?
u have to do settings in the both sides
1.Sending Request from Smartform to SAP ( i.e SCOT )
2.SAP will process this request to send to Outlook Servert based on the settings of STMP in SCOT .
Regards
Prabhu -
When I download pdf files in Safari I get a black screen. However, if I open a pdf in Mail it is viewable in Preview. What is wrong?
Back up all data.
Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
/Library/Internet Plug-ins
In the Finder, select
Go ▹ Go to Folder
from the menu bar, or press the key combination shift-command-G. Paste (command-V) into the text box that opens, then press return.
From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
I've seen an unconfirmed report that the "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you might need to remove it as well, if applicable.
If you still have the issue, repeat with this line:
~/Library/Internet Plug-ins
If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again. -
Program to send Purchase Order SmartForm by e-mail
Hi,
I need a program to send my Purchase Order SmartForm by e-mail. With the program I use, the output keeps appearing in my spool list in stead of in SOST... Does anyone have a sample code that I can use?
I am working in a ECC 6.0 system. Package SMB40 is nog available in this system.
Thanks!
PatrickHi Patrick.
By a simple search on this forum i found this.
Maybe you can use it
check this code tutorial on how to send smartform output thru email.
https://wiki.sdn.sap.com/wiki/display/Snippets/emailsendthroughoutputcontrols
success., Gr., Frank
Maybe you are looking for
-
Incorrect Status in Pricing issue_short dump
Hi, All of sudden when we create sc non catalog, its giving short dump. Its uncaught exception ie Its CX_BBP_PD_ABORT exception..only error message that i found relevant is " incorrect status in pricing".. I checked IPC and its active and running..
-
Is it possible to change the look of an ImageIcon? (grey it out)?
I'm making this card game. Ive got a sequence of cards (the player hand) in a JLayeredPane and theyre displaying nicely. Theyre displaying just as the card look in microsoft hearts. Ive added mouselisteners to all of the cards and what I want to happ
-
How do i know what gen of ipad i have?
How do i know what gen of ipad i have?
-
Hi Guys, What version of NW (Java stack only) do I need to install so that I can install GRC AC 5.3 SP13 on that? Thanks, Shankam
-
How Undo functionality can be Created for curves or Line in Swing?
Please Help! How Undo functionality can be Created for curves or Line in Swing GUI. In the Java Tutorial, Undo with Text is given. But on implementing the SIMILAR logic of Undo with Text, some Errors come with Undo is to be Created on Swing GUI on th