on 09-26-2014 4:05 PM
Hi Experts,
I have created the custom business object with attachment using [DependentObject(AttachmentFolder)] node Attachment at root level in my custom business object i have add 2 actions 1) Generate PDF 2) Send Email with Attachment.
I have created the PDF form using create form and i have also design and Activate , Deploy Business Configuration.
my current functionality i have make preview button and it is working fine.
But
I want to generate PDF with content and after generating that pdf add under the AttachmentFolder component in my BO.
also i want to send email with attached pdf from AttachmentFolder component in my BO on action Send Email with Attachment.
To generate PDF using absl i have write code under the action Generate PDF
var FormTemplateLanguage = "E";
var PDF : BinaryObject;
var FormTemplateCode : OutputRequestFormTemplateCode;
FormTemplateCode.content = "Y1CRFP9I_P0FOT"; //Code is Form Template Header Code
// Reuse Service Call
PDF = OutputManagementUtilities.GetPDF(this,FormTemplateCode,FormTemplateLanguage);
I am using the yello highlighted code under the absl.
When i click on generate PDF button i can not see any pdf document in attachment component.
Can anyone help me why the above code is not add the pdf into the attachment component as shown above?
1) What are the steps required when i click on button "Generate PDF" the pdf create with content and add under the Attachment component ?
2) If my business object is below then how to use the attachment component ( Add generated PDF , read PDF to send email with attachment ) etc...
element data1 : LANGUAGEINDEPENDENT_MEDIUM_Text; | ||
element data2 : LANGUAGEINDEPENDENT_MEDIUM_Text; | ||
element data3 : LANGUAGEINDEPENDENT_MEDIUM_Text; | ||
element CFlag : Indicator; |
[DependentObject(AttachmentFolder)] node Attachment; | ||
action GeneratPDF; | ||
action SendEmail; |
3) I can able to Add any document from the Attachment component how to disable the "Add" button from the Attachment component because this component only for display
Kindly help me solve the above issue.
Many Thanks,
Mithun
Hi Mithun,
Re: 1.
We use the following code:
var ATTACHMENT_TYPE_DOCUMENT : DocumentTypeCode;
ATTACHMENT_TYPE_DOCUMENT.content = "10001";
if (this.AttachmentFolder.DocumentList.Where(n => n.AlternativeName == documentAlternativeName).Count() == 0) {
// create PDF
var FormTemplateLanguage = "E";
var FormTemplateCode : OutputRequestFormTemplateCode;
FormTemplateCode.content = SOLUTION_ID + "_SUFFIX";
var pdfDocument = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);
if (!pdfDocument.content.IsInitial()) {
Trace.Info("document successfully created");
if (!this.ItemAttachmentFolder.IsSet()) {
Trace.Info("attachment folder not existent, thus create it");
this.AttachmentFolder.Create();
}
var description : Description;
description.content = "";
description.languageCode = LanguageCode.ParseFromString("EN");
this.AttachmentFolder.CreateFile(ATTACHMENT_TYPE_DOCUMENT, documentName, documentAlternativeName, description, pdfDocument);
}
}
Re: 2.
I do not know, how to send an attachment via email and would be highly interested how this would work.
Re: 3.
Use the readonly view:
/SAP_BYD_APPLICATION_UI/Reuse/Attachments/documentlistreadonly.EC.uicomponent
Best regards,
Ludger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, Alessandro.
Furthermore, we were wondering how we could send a generic file (a binary file) as a payload of a XML SOAP Request message, and let it be received by a WebService deployed via SDK.
Fortunately, the following thread could give us some information on Base64 encoding/decoding in the SDK, which could be useful for sending any file in a XML payload (as a long Base64 string):
http://scn.sap.com/thread/3485097
Any observation?
Cheers,
Davide
BO
ABAP
*&---------------------------------------------------------------------*
*& Report ZAM_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zam_test.
DATA lo_proxy TYPE REF TO zam_co_yqbast56y_manage_attach.
DATA: ls_input TYPE zam_attachments_processor_cre5,
ls_output TYPE zam_attachments_processor_cre6.
DATA: ls_input_exc TYPE zam_attachments_processoradda3,
ls_output_exc TYPE zam_attachments_processoradda4.
DATA ls_attachments_list TYPE LINE OF zam_attachments_processor__tab.
TRY.
CREATE OBJECT lo_proxy
* EXPORTING
* logical_port_name =
.
CATCH cx_ai_system_fault .
ENDTRY.
"----------------------------------------Creation
DATA: lo_excel TYPE REF TO zcl_excel,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
CREATE OBJECT lo_excel.
" Get active sheet
lo_worksheet = lo_excel->get_active_worksheet( ).
* lo_worksheet->set_title( ip_title = 'Sheet1' ).
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
lo_worksheet->set_cell( ip_column = 'B' ip_row = 3 ip_value = sy-datum ).
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = sy-uzeit ).
lo_hyperlink = zcl_excel_hyperlink=>create_external_link( iv_url = 'http://www.abap2xlsx.org' ).
lo_worksheet->set_cell( ip_column = 'B' ip_row = 4 ip_value = 'Click here to visit abap2xlsx homepage' ip_hyperlink = lo_hyperlink ).
column_dimension = lo_worksheet->get_column_dimension( ip_column = 'B' ).
column_dimension->set_width( ip_width = 11 ).
DATA: cl_writer TYPE REF TO zif_excel_writer.
CREATE OBJECT cl_writer TYPE zcl_excel_writer_2007.
DATA lv_xdata TYPE XSTRING.
lv_xdata = cl_writer->write_file( lo_excel ).
*cl_output->t_rawdata = cl_bcs_convert=>xstring_to_solix( iv_xstring = cl_output->xdata ).
"--------------------------------------------
ls_input-attachments_processor_create_r-attachments_processor-object_type = 'VisitReport'.
ls_input-attachments_processor_create_r-attachments_processor-op_id = 'APTAR_TEST_ATTA'.
ls_attachments_list-name = 'test_atta_1.xlsx'.
ls_attachments_list-binary_object-content = lv_xdata.
APPEND ls_attachments_list TO ls_input-attachments_processor_create_r-attachments_processor-attachments_list.
ls_attachments_list-name = 'test_atta_2.pdf'.
ls_attachments_list-binary_object-content = 'test_atta_2'.
APPEND ls_attachments_list TO ls_input-attachments_processor_create_r-attachments_processor-attachments_list.
TRY.
CALL METHOD lo_proxy->create
EXPORTING
input = ls_input
IMPORTING
output = ls_output.
CATCH cx_ai_system_fault .
CATCH zam_cx_standard_fault_message .
CATCH cx_ai_application_fault .
ENDTRY.
ls_input_exc-attachments_processoraddattach-attachments_processor-sap_uuid = ls_output-attachments_processor_create_c-attachments_processor-sap_uuid. "'00163E09254E1EE48EB6C6F4DE51C473'.
TRY.
CALL METHOD lo_proxy->addattachments
EXPORTING
input = ls_input_exc
IMPORTING
output = ls_output_exc.
CATCH cx_ai_system_fault .
CATCH zam_cx_standard_fault_message .
CATCH cx_ai_application_fault .
ENDTRY.
Hello Alessandro,
I have read the above comments regarding the read BinaryString from ABAP.
I have change my BO as below
businessobject mycustomBO (
element data1 : LANGUAGEINDEPENDENT_MEDIUM_Text;
element data2 : LANGUAGEINDEPENDENT_MEDIUM_Text;
element data3 : LANGUAGEINDEPENDENT_MEDIUM_Text;
element Pdfcontent : BinaryObject
[DependentObject(AttachmentFolder)] node Attachment;
action attaction;
}
I have consumed ABAP web service and getting Xstring as well as Base64 string format output.
for creation of PDF I am using below code in ABSL:
var ATTACHMENT_TYPE_DOCUMENT : DocumentTypeCode;
var documentName : LANGUAGEINDEPENDENT_Name;
var documentAlternativeName : LANGUAGEINDEPENDENT_Name;
var DocDesc : Description;
var DocBInary : BinaryObject.content;
ATTACHMENT_TYPE_DOCUMENT.content = "10001";
documentName = "ECCorder.pdf";
documentAlternativeName = "";
DocDesc.content = "";
var scenario = "SalesOrderPDFScenario";
var requeecc : SalesOrder_WS.ZknkSalesOrder.Request;
var respons : SalesOrder_WS.ZknkSalesOrder.Response;
var SorderTable : SalesOrder_WS.ZknkSalesOrder.Request.SalesOrders.item;
requeecc.SalesOrders.item.Add(SorderTable);
requeecc.CustomerNumber = "";
requeecc.ISpool = "19855";
respons = SalesOrder_WS.ZknkSalesOrder(requeecc,"",scenario);
DocBInary = Binary.ParseFromString(respons.OB64string);
this.Pdfcontent.content = DocBInary;
this.Pdfcontent.mimeCode = "application/pdf";
//this.Pdfcontent.fileName = documentName;
//DocBInary.content = respons.OB64string;
this.Attachment.CreateFile(ATTACHMENT_TYPE_DOCUMENT, documentName, documentAlternativeName, DocDesc, this.Pdfcontent);
But yet we are not getting any PDF under the Attachments. Kindly suggest what must be missing here.
I have also raised a discussion for same
Regards,
Chandan
Hi Fred.
Determining the solution ID dynamically was indeed tricky.
Thanks to the helpful SCN we found a way.
You need an instance of a custom BO from the solution:
var type = customBoInstance.GetObjectNodeReference().ObjectTypeCode;
var solutionId = type.content.Substring(1, 8);
Best regards,
Ludger
--
Custom Development with All4Cloud.de
Hello Sir,
Thanks a lot to Ludger and Alessandro.
I can able to generate the PDF using the above ABSL code and display under the Attachment component..
Also as per the Alessandro comments i can able to send email with attachment that are exist under the Attachment component.
Again thank for your help.
Many Thanks,
Mithun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi SARUCHI PATHELA,
If you are creating PDF using template than use code provided by Ludger and Alessandro because I achieve my requirement with same code.
Check all parameters while create / generate PDF file.
Also can you give me brief idea about your requirement.
Regards,
Mithun
My requirement is to add a button on Tickets WC view in WC service. Button is Send Email. On click of that button an email should be triggered with an attachment of custom pdf form.
1. I have made a custom pdf form and created a EC and a button preview on it and On click of that button I am able to see my form.
2. But when I tried the same thing with Send Email button where I have created an action Send_Email which populates the Email Body with HTML text and in attachments I am passing the group code of my form I am not able to open the same. It does not gets opened up and gives some decoding issue
I am attaching screenshots for action send_email. Am I missing something?
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.