I'd like to attach a picture to an email. The picture was sent by API from a mobile application. The picture received is of string type (base64) and is to be displayed in the email body (HTML). The problem is, the email is succesfully sent but the picture is not displayed.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = i_pict
IMPORTING
buffer = p_bmp_xstream
EXCEPTIONS
failed = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PT_SOLIX = CL_BCS_CONVERT=>XSTRING_TO_SOLIX( P_BMP_XSTREAM ).
What I tried is convert it first into XSTRING then convert it in SOLIX.
I have come across the same kind of requirement before and I took help from this link below and it worked for me.
There are two important things to do to show an image along with the email text (note : the image must not be passed as an attachment, that would force the user to open the attachment to see the image):
Your text must be passed in HTML format
Inside HTML, you may define the image with base64 as follows : <img src="data:image/gif;base64,iVBORw0KG...> (iVBORw0KG... to be replaced by your image base64 characters)
The main method used in the link below to create the email is :
cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = table_of_HTML_code
... ).
Take a look at the below link, if it doesn't help lets discuss further.
http://saptechnical.com/Tutorials/ABAP/email/Index.htm
Related
I am posting the results of automated tests to an offline forum. It would be nice to include PASS/FAIL in the forum post title but I'm having some difficulties retrieving the ${TEST STATUS} value - (obviously a hard-coded value works fine) .
I've defined the following in common-variables.robot as:
${FORUM_TEST_RESULT}....${TEST STATUS}
then on publish-results.robot
Input Text....//*[#id="title"]....${FORUM_TEST_RESULT}
The error I get is: variable ${FORUM_TEST_RESULT} not found
I can see here: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#listener-interface that ${TEST STATUS} can only be used as part of Teardown.
I'm not sure how to collect the value of ${TEST STATUS} in the context of my RF script.
e.g the very last thing my script does is post to a forum:
Input Text....//*[#id="title"]....${FORUM_TEST_RESULT}
but before that I obviously need to populate ${FORUM_TEST_RESULT} with the value of ${TEST STATUS) which you can only get on Teardown? Hope this makes sense.
Input Text is a keyword of Selenium2Library that types the given text into the text field of a web page. You need to start a browser session first and open the right page an then possibly wait for the element to become visible, for example like this:
Open Browser [URL of your site]
Wait Until Element Is Visible //*[#id="title"]
Input Text //*[#id="title"] ${FORUM_TEST_RESULT}
If you want to retrieve a text from a page (as your coment suggests) then you need to use the keyword Get Text which returns the text of the element identified by locator.
Get Text locator
I'm working on a report which contains actions allowing the user to reach a a new page. In this new page pdf stored on the application server has to be displayed.
On the PDF view I created an interactive form linked with my context (PDF_DATA-PDF : xstring)
gv_filepath = '/tmp/test.pdf'.
" Open the file in binary mode
OPEN DATASET gv_filepath FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
READ DATASET gv_filepath INTO gv_filedata.
IF sy-subrc = 0.
CLOSE DATASET gv_filepath. "Close the file
" Convert the file from hex-string to Binary format
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = gv_filedata
IMPORTING
output_length = gv_filesize
TABLES
binary_tab = gt_bin_data.
Here, I don't know what to do ....
lo_node = wd_context->get_child_node( 'PDF_DATA' ).
lo_node->set_attribute( name = 'PDF' value = ?).
wd_comp_controller->gestion_affichage( ).
ENDIF.
ENDIF.
Please suggest how do I handle this?
There are a couple of ways to implement this:
Use a FileDownload element and perform the operations you described above in the Supply method of the context element. That's probably the easiest way to implement this, but it might have the drawback that the file is not displayed, but offered for download instead. It's worth giving it a try though since it's very easy to implement.
Create a new ICF service (not a WebDynpro application!) that will return the PDF file with an appropriate MIME type when requested. Then, open a new browser window with the URL of that service.
As before, but use an IFrame element to display the PDF file in-place. Be aware that the usage of this element is discouraged (although probably only to push customers towards EP...?).
To display a PDF file in Web Dynpro ABAP page,
Add the InteractiveForm control to the View
Bind the pdfSource property to the Context node containing the PDF content
Load the PDF file to the context node
Here is an example with screen shots
Well i solved my problem with my colleague, thank you
I just have to add the following code after the OPEN DATASET
CLEAR l_len.
CLEAR l_data_tab.
DO.
READ DATASET gv_filepath INTO l_data actual LENGTH l_len.
IF sy-subrc <> 0.
IF l_len > 0.
file_size = file_size + l_len.
APPEND l_data to l_data_tab.
ENDIF.
EXIT.
ENDIF.
file_size = file_size + l_len.
APPEND l_data to l_data_tab.
ENDDO.
I'm super new to html
All I need is the code for a field where a User can type his Staff Number and then a button which takes him to a URL that is made up of his Staff Number somewhere in the path.
Eg:
The User enters '123' in the text field and when clicking the 'Submit' button must be taken to this document:
www.mysite.com/Staff123.pdf
Not sure about the syntax but with an example I would be able to edit to suit what I need if I can get the code to create both the text field as well as the button.
Thanks a lot
You need to create a form in html. Basically, a form is a block which let user input some values (text, password, email, date, integer, file, ...) and that send these values, once submitted through a submit button, to a certain file that will process these datas.
A classic example is the login form that you can see on nearly each site you know.
It could be like that:
<form action="processing_script.php" method="post">
<input type="email" name="user_mail" placeholder="Please enter your mail here">
<input type="password" name="user_password" placeholder="Please enter your password here">
<input type="submit" value="Click here to send the form">
</form>
You can see some attributes used in this example, I will describe each of them:
action attribute for form tag: it's the script that will receive and process the values from this form.
method attribute for form tag: it's the way that values will be sended to the destination script. It can be etheir "post" or "get". The post method will send the values through http headers, so it's hidden for users (but it can be seen with tools like Wireshark). The get method will send values through the adress bar like this (this is the url you see once you submitted the form): http://yourWebsite.com/processing_script.php?user_mail=johndoe#liamg.com&user_password=mYp#$$W0rD
type attribute for form tag: it depends on the type of data you want the user to inquire. Your web browser will use this attribute to determine which way he will show the input to the user. For example, user will see a little calendar widget if you wrote type="date". The browser will also do some basic verification on the data type when the user will click the submit button (in fact, the browser will not let someone validate the form if for example the input type is "email" and the value entered by the user is "zertredfgt#" or "erfthrefbgthre", but it will pass if the mail is "johndoe#liamg.com"). Type can be email, text, date, password, file, submit, and some others.
name attribute for input tag: it's the name of the variable that will be used in the destination script to access to the value entered by user in the field of the form.
placeholder attribute for input tag: it's the text shown in the fields when they're still empty. The text is not in black, it's some kind of grey.
The last thing to explain is the :
it's displayed as a button, and the text on it comes from the value attribute.
In your case, I think you only need to use some JavaScript:
Create a JavaScript method that will redirect you to the right pdf url based on what is entered in a text input.
Create a small form, without action or method fields.
Create an input type text (for the staff number) with a good attribute name like this: name="staffNumber".
Create a button (not a submit button) like this:
To redirect to a specific url in JavaScript, you want to read this: How do I redirect to another webpage?
To read the value from an input in JavaScript, you can proceed like that:
...
var staff_number = getElementsByName("staffNumber")[0].value;
...
To create the full url of the right PDF, just use the concatenation operator (it's + in JavaScript), so something like that should work:
...
var base_url = "http://youWebsite.com/Staff";
var file_extension = ".pdf";
var full_url = base_url + staff_number.toString() + file_extension;
...
(the .toString() is a method that ensure it's processed as a string, to concatenate and avoid some strange addition that could occur I guess)
I think you've got everything you need to create exactly what you need.
Please keep us up to date when you've tried !
I'm using "DOWNLOAD" function of abap to download something as txt file. But "DOWNLOAD" function shows some dialog boxes that shows where the file is being downloaded and asks if there is another file with the same name I want to replace.
There is silent parameter for that function to import but it doesn't change anything when I assign 'm' or 's' or 'x' to that.
Here is what I do;
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = fn
filetype = 'ASC'
silent = 'M'
TABLES
data_tab = itab.
GUI_DOWNLOAD (obsolete) is ok without dialog boxes but I can not silence 'DOWNLOAD' function. Anyone knows how to achieve that ?
Thanks.
Rather than the function modules you mention, you should use the methods of class cl_gui_frontend_services.
The following snippet shows you an example call to cl_gui_frontend_services=>gui_download.
types: t_line type c length 100.
data: lt_tab type table of t_line.
append 'test' to lt_tab.
call method cl_gui_frontend_services=>gui_download
exporting
filename = 'C:\temp\file.txt'
changing
data_tab = lt_tab[].
This downloads the file to the specified location without a dialog. For showing a file selection dialog if you choose, there is cl_gui_frontend_services=>file_open_dialog or cl_gui_frontend_services=>file_save_dialog.
Notes:
You should check the return codes from the method calls. I just omitted them here for brevity, but failure to include them may result in a short dump.
I have a PDF form which contains some fields as below
PDF download link
input text field name as "name"
input checkbox field name as "language"
input radio button field name as "sex"
select combobox field name as "job"
submit button action as HTML format, and submit URL to http://local.test.com/servlet1
and servlet1 which has code as blow
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
for(Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
String paraName = (String) e.nextElement();
String paramValue = URLDecoder.decode(new String(request.getParameter(paraName).getBytes("iso-8859-1")), "UTF-8");
System.out.println(paraName + "=" + paramValue);
}
}
than I input some data in the PDF form and click submit, and I got System output as below
SystemOut O sex=M
SystemOut O input7=eric
SystemOut O input34=zhTW
SystemOut O job=1
the field of "sex"(radio button) and "job"(select combo) are OK, but why the field name of "name"(input text) and "language"(checkbox) are changed to "inputXX"?
And I try to use
request.getParameter("name")
and I just got null...
Is there any suggestion?
many thanks...
I inspected your form, and I see the field with name "name" as well as submit buttons that post the data to an URL. One of those submit buttons limits the number of parameters sent to the server.
I didn't see any immediate error, but I suggest that you use the following Servlet to debug your application: http://itextpdf.com/examples/iia.php?id=169
This servlet will show all the parameters as a query string in case of a GET request (but at first sight, the PDF is configured to POST the data); in case of a POST, it will display all the data that is sent. This way, you can figure out what goes wrong.
Keep us posted.
The PDF file was translated from HTML file by Acrobat X Pro, and I noticed some fileds such as "name"...
<input id="name" type='text'>
than I update HTML file
<input name="name" type='text'>
and translated to PDF again and submit, everything is OK now ~ :)
When exporting the value of the text field name using the identifier input7, the PDF viewer just does what it is asked to do as the field dictionary of the name field contains an entry requesting the field value to be exported using the key input7. The same goes for some other fields, too.
In detail the field dictionary (object 106 0) contains the following entries:
/Ff 4194306
/F 4
/Type /Annot
/Subtype /Widget
/T name
/AP Dictionary
/P 42 0 R
/MK Dictionary
/BS Dictionary
/FT /Tx
/Rect [54.8909, 688.564, 161.891, 705.564]
/DA /Helv 0 Tf 0 g
/TM input7
Have a look at the last entry. The /TM key is defined as (cf. ISO 32000-1:2008 section 12.7.3.1):
text string (Optional; PDF 1.3) The mapping name that shall be used
when exporting interactive form field data from the document
If you do not want the field value to be exported with that input7 key, remove that /TM entry from the field definition.