Display PDF from application server in Webdyn Pro ABAP - pdf

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.

Related

After content stream recreation (using PDFbox) getting error in axesPDF (insert spaces)?

when I am recreating a pdf after some changes , if I use the output pdf in axesPDF to fix spaces issue I am getting "ERROR". The only difference I observed my input pdf have Array of tokens but my recreated pdf has Dictionary of elements. As shown in below. Does that cause the problem? How can I recreate similar structure? (Left one is input pdf right one output pdf after editing)
Input pdf
output pdf with changes
The code I am using to save the pdf is
PDStream newContents = new PDStream(document);
OutputStream out = newContents.createOutputStream(COSName.FLATE_DECODE);
ContentStreamWriter writer = new ContentStreamWriter(out);
writer.writeTokens(tokens);
out.close();
document.getPage(pg_ind).setContents(newContents);
newPDF.addPage(document.getPage(pg_ind));
newPDF.save()
Please help me on this. Thanks in advance.
Updating question along with error.
Another Input file
The error is
The button I used.
I am wondering this time even the content stream is in COSDictionary format it's giving error. Something else causing this.

Use output without conversion exit with SALV class

in SE16N in Technical Settings there is a Checkbox the OUTPUT WITHOUT CONVERSION EXIT.
In my programs I use the class CL_SALV_TABLE for creating the ALVs. Is it possible to put a checkbox in the program similar to SE16N and when the user enable it my ALV will display the data like the SE16N?
Thanks
Elias
This is what I wanted as I am using SALV extensively.
** Display the data Without Conversion
DATA: l_tabledescr_ref TYPE REF TO cl_abap_tabledescr,
l_descr_ref TYPE REF TO cl_abap_structdescr,
wa_table TYPE abap_compdescr.
IF p_woconv = 'X'.
TRY.
columns = oref_table->get_columns( ).
l_tabledescr_ref ?= cl_abap_typedescr=>describe_by_data( <fs_itab> ).
l_descr_ref ?= l_tabledescr_ref->get_table_line_type( ).
LOOP AT l_descr_ref->components INTO wa_table.
DATA(edit_mask) = columns->get_column( wa_table-name )->get_edit_mask( ).
IF edit_mask(2) = '=='.
columns->get_column( wa_table-name )->set_edit_mask( ' ' ).
ENDIF.
IF wa_table-type_kind = 'C' OR wa_table-type_kind = 'N'.
columns->get_column( wa_table-name )->set_leading_zero( ).
ENDIF.
ENDLOOP.
CATCH cx_salv_not_found.
ENDTRY.
ENDIF.
If someone has a better solution with SALV, I will be much obliged to share with us.
Thanks all for your answers.
Elias
Everything is possible in SAP, However I'm not sure if your request is possible using the class CL_SALV_TABLE. I recommend you to use the Class CL_GUI_ALV_GRID which is really dynamic and can be implemented to fit your scenario.
There is a lot of tutorials online but I'll try to make small summary
Create a Parent Container CL_GUI_CUSTOMCONTAINER
Create the ALV Grid and set the Parent.
Fetch Field catalogs (can also be dynamic to fit any table)
Create the Output table and pass the operations
Display ALV
Sure the Displayed table can be set according to the user's choice (Checkbox)
Please write down if you need more help

How to convert the spectrum type ("Spectrum" -> "Convert Data to")

Is there a manner in which one can convert the spectrum type, for instance to EELS, by DM scripting? This screenshot represents what I'm referring to. I'd like to import a dataset using the GMS 3.4 Python interface, and then turn that into a EELS dataset for further processing (ideally without having to manually interface with the screenshotted menu bar).
Yes there is.
The "type" is simply a meta-data tag
which you can easily set with the TagGroup commands.
There is, however, one complication:
Data "registers" itself with DM when it first appears. Changing the meta-tags manually doesn't change this registration. (The menu command, however, does.)
Thus, you will only see effect of the type change when
either:
You save, close and reopen the data
You clone the data, throw away the original, and display the clone
The second option might cause issues with data-linkage though, as the unique image ID of the data is newly created.
Example using the first method (requires save & load):
image img:=GetFrontImage()
TagGroup tg = img.ImageGetTagGroup()
tg.TagGroupSetTagAsString("Meta Data:Signal","EELS")
imageDocument doc = img.ImageGetOrCreateImageDocument()
doc.ImageDocumentSave(0)
string path = doc.ImageDocumentGetCurrentFile()
doc.ImageDocumentClose(0)
doc = NewImageDocumentFromFile(path)
doc.ImageDocumentShow()
An alternative option is to rely on the menu command. If it is present, then you can simply use the ChoseMenuItem() command to invoke it.
However, the command will only be available with the UI when the data you want to change is front-most (i.e. not a script window!) You will need to ensure by script, that this is the case. A simple ShowWindow() will do.
image img:=GetFrontImage()
img.ShowImage()
if ( !ChooseMenuItem("Spectrum","Convert Data To","None") )
Throw( "Conversion to none failed.")
if ( !ChooseMenuItem("Spectrum","Convert Data To","EDS") )
Throw( "Conversion to none failed.")
Disadvantage of this solution: You will get the user-prompts.

chronoforms v5 multi file upload...cannot choose multiple files

I am trying to configure this in v5 and cannot find any documentation. This is what I have so far...
followed the V4 documentation as close as possible, but cannot get the form to allow me to choose multiple files!
Under HTML Render I have Form Tag Attachment = enctype="multipart/form-data"
Under the designer tab I have file field element on the form. Under this I have
Field Name = file1[]
Field ID = file1
Multiple=Yes
Under the settings tab I have the files upload action in the on submit event. In the files upload action I have
Enabled=Yes
Files config = file1:jpg-png-gif-txt
Array fields = file1
is there anything else I need to do?
Turns out this is a bug and will be fixed in the next update. Workaround by creating a custom file upload element with the word multiple as a parameter.

Is it possible not to show dialog boxes in download function

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.