05-07-2010 12:52 PM
Hello Everyone,
I am bit new to ABAP. My requirement is to convert a smartform in to a PDF and then EMAIL it. Could any one please explain me the process of achieving this. I have already done my research regarding this and found some Function modules that we can use. But, I was not successful in getting my desired output.
I am creating the smartform using "SSF_FUNCTION_MODULE_NAME" FM and then passed the returning smartform name to the following code.
CALL FUNCTION lf_fm_name
EXPORTING
control_parameters = ls_control_param
output_options = ls_composer_param
user_settings = 'X'
is_inv = wa_inv
IMPORTING
job_output_info = ls_job_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
Now, how do I convert this smartform to a PDF and Email. Could someone please give me some code to do this. I would greatly appreciate your help.
Regards,
Gopal.
05-07-2010 12:55 PM
Check for the Wiki:
[Convert Smartform to PDF in 3 simple steps|http://wiki.sdn.sap.com/wiki/display/Snippets/ConvertSmartformtoPDFformat]
05-07-2010 12:55 PM
Check for the Wiki:
[Convert Smartform to PDF in 3 simple steps|http://wiki.sdn.sap.com/wiki/display/Snippets/ConvertSmartformtoPDFformat]
05-07-2010 12:58 PM
Use the search tool in the wiki section of sdn, you may find sample in code gallerry like [Email from SAP|http://wiki.sdn.sap.com/wiki/display/Snippets/EmailfromSAP]
Regards,
Raymond
05-07-2010 5:12 PM
Hello,
Thanks a lot for your replies. when I open the attached PDF, it is giving an error message "There was an error opening this document. There was a problem reading this document(110)". I haven't got a clue of why I am getting this error message. Could you PLZ help me in resolving this issue. I would greatly appreciate your help.
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.
REFRESH: RECLIST, OBJTXT, OBJBIN, OBJPACK.
CLEAR WA_OBJHEAD.
OBJBIN[] = I_RECORD[].
DESCRIBE TABLE OBJTXT LINES tab_lines.
READ TABLE OBJTXT INDEX tab_lines.
doc_chng-obj_name = 'Invoice'.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
* Main Text of the email
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'.
append objpack.
* Attachment
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
DESCRIBE TABLE OBJBIN LINES v_tab_lines.
OBJPACK-DOC_SIZE = v_tab_lines * 255 .
OBJPACK-BODY_NUM = v_tab_lines.
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-OBJ_NAME = 'Invoice Attachment'.
OBJPACK-OBJ_DESCR = 'This is a test!'.
APPEND OBJPACK.
CLEAR RECLIST.
RECLIST-RECEIVER = wa_kun_email.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = doc_chng
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = I_RECORD
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.
Regards,
Gopal.
05-10-2010 9:30 AM
Hello,
Could anyone please help me in resolving this issue. I would appreciate your help.
Regards,
Gopal.