CL_GUI_PDFVIEWER and files from the App server
Hi,
I would liek to use the class CL_GUI_PDFVIEWER to read files from the app server (transaction AL11) and then to present them.
it is easy to use the local machine files.
how can I use the method open_document with a file from there?
Thanks,
Itay
Thanks for the help.
I tried what you suggested but I get a dump for some reason.
Can you help?
This is the dump:
Exception condition "SYSTEM_FAILURE" raised.
Program SAPLOLEA
Include LOLEAU10
Row 358
Module type (FUNCTION)
Module Name AC_FLUSH_CALL_INTERNAL
This is the program:
REPORT zpdftest .
DATA: g_html_viewer TYPE REF TO cl_gui_html_viewer,
my_main_container TYPE REF TO cl_gui_custom_container,
entry1(100) TYPE c,
entry2(100) TYPE c.
DATA: okcode TYPE sy-ucomm,
gt_pdf TYPE STANDARD TABLE OF string,
wa_pdf TYPE string,
g_url(2048) TYPE c
START-OF-SELECTION.
SET SCREEN 100.
*& Module pbo_0100 OUTPUT
MODULE pbo_0100 OUTPUT.
SET PF-STATUS 'STATUS100'.
SET TITLEBAR 'TITLE100'.
IF my_main_container IS INITIAL.
CREATE OBJECT my_main_container
EXPORTING
container_name = 'CUSTOM_CNTL'
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
CHECK sy-subrc IS INITIAL.
CREATE OBJECT g_html_viewer
EXPORTING
parent = my_main_container
EXCEPTIONS
cntl_error = 1
cntl_install_error = 2
dp_install_error = 3
dp_error = 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.
DATA: lv_filename TYPE rlgrap-filename.
lv_filename = '/PBMGUS/UXA/ABAP/TEST.PDF'.
OPEN DATASET lv_filename FOR INPUT
IN BINARY MODE
WHILE sy-subrc IS INITIAL.
READ DATASET lv_filename INTO wa_pdf.
IF NOT sy-subrc IS INITIAL.
EXIT.
ENDIF.
APPEND wa_pdf TO gt_pdf.
ENDWHILE.
CLOSE DATASET lv_filename.
CALL METHOD g_html_viewer->load_data
EXPORTING
type = 'application'
subtype = 'pdf'
IMPORTING
assigned_url = g_url
CHANGING
data_table = gt_pdf
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_general = 2
cntl_error = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD g_html_viewer->show_url
EXPORTING
url = g_url
EXCEPTIONS
cntl_error = 1
cnht_error_not_allowed = 2
cnht_error_parameter = 3
dp_error_general = 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.
ENDIF.
ENDMODULE. " pbo_0100 OUTPUT
*& Module pai_0100 INPUT
MODULE pai_0100 INPUT.
CASE okcode.
WHEN 'BACK'.
LEAVE to screen 0.
WHEN OTHERS.
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CLEAR okcode.
ENDMODULE. " pai_0100 INPUT
Similar Messages
-
File from the Application server
Hi gurus,
I am working on a scenario where I need to get a file from the application server and for this I need to ask user to enter the location and that too at the selection screen and then I need to read this location using open data set and read data set in my program , once I am done with this I need to do some other validations. so can you please help me out how to achieve this.
Thanks
Rajeev GuptaHi
Declare the selection screen with file as parameter so that the user enter the application server file..
the use the OPEND DATASET as mentioned in below code and process
Refer this:
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
*& Report ZUPLOADTAB * &----
*& Example of Uploading tab delimited file *
REPORT zuploadtab .
PARAMETERS: p_infile LIKE rlgrap-filename
OBLIGATORY DEFAULT '/usr/sap/'..
DATA: ld_file LIKE rlgrap-filename.
*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5) type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.
*String value to data in initially.
DATA: wa_string(255) type c.
constants: con_tab TYPE x VALUE '09'.
*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.
Regards
Anji -
Upload tab-delimited file from the application server to an internal table
Hello SAPients.
I'm using OPEN DATASET..., READ DATASET..., CLOSE DATASET to upload a file from the application server (SunOS). I'm working with SAP 4.6C. I'm trying to upload a tab-delimited file to an internal table but when I try load it the fields are not correctly separated, in fact, they are all misplaced and the table shows '#' where supposedly there was a tab.
I tried to SPLIT the line using as separator a variable with reference to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB but for some reason that class doesn't exist in my system.
Do you know what I'm doing wrong? or Do you know a better method to upload a tab-delimited file into an internal table?
Thank you in advance for your help.Try:
REPORT ztest MESSAGE-ID 00.
PARAMETER: p_file LIKE rlgrap-filename OBLIGATORY.
DATA: BEGIN OF data_tab OCCURS 0,
data(4096),
END OF data_tab.
DATA: BEGIN OF vendor_file_x OCCURS 0.
* LFA1 Data
DATA: mandt LIKE bgr00-mandt,
lifnr LIKE blf00-lifnr,
anred LIKE blfa1-anred,
bahns LIKE blfa1-bahns,
bbbnr LIKE blfa1-bbbnr,
bbsnr LIKE blfa1-bbsnr,
begru LIKE blfa1-begru,
brsch LIKE blfa1-brsch,
bubkz LIKE blfa1-bubkz,
datlt LIKE blfa1-datlt,
dtams LIKE blfa1-dtams,
dtaws LIKE blfa1-dtaws,
erdat LIKE lfa1-erdat,
ernam LIKE lfa1-ernam,
esrnr LIKE blfa1-esrnr,
konzs LIKE blfa1-konzs,
ktokk LIKE lfa1-ktokk,
kunnr LIKE blfa1-kunnr,
land1 LIKE blfa1-land1,
lnrza LIKE blfa1-lnrza,
loevm LIKE blfa1-loevm,
name1 LIKE blfa1-name1,
name2 LIKE blfa1-name2,
name3 LIKE blfa1-name3,
name4 LIKE blfa1-name4,
ort01 LIKE blfa1-ort01,
ort02 LIKE blfa1-ort02,
pfach LIKE blfa1-pfach,
pstl2 LIKE blfa1-pstl2,
pstlz LIKE blfa1-pstlz,
regio LIKE blfa1-regio,
sortl LIKE blfa1-sortl,
sperr LIKE blfa1-sperr,
sperm LIKE blfa1-sperm,
spras LIKE blfa1-spras,
stcd1 LIKE blfa1-stcd1,
stcd2 LIKE blfa1-stcd2,
stkza LIKE blfa1-stkza,
stkzu LIKE blfa1-stkzu,
stras LIKE blfa1-stras,
telbx LIKE blfa1-telbx,
telf1 LIKE blfa1-telf1,
telf2 LIKE blfa1-telf2,
telfx LIKE blfa1-telfx,
teltx LIKE blfa1-teltx,
telx1 LIKE blfa1-telx1,
xcpdk LIKE lfa1-xcpdk,
xzemp LIKE blfa1-xzemp,
vbund LIKE blfa1-vbund,
fiskn LIKE blfa1-fiskn,
stceg LIKE blfa1-stceg,
stkzn LIKE blfa1-stkzn,
sperq LIKE blfa1-sperq,
adrnr LIKE lfa1-adrnr,
mcod1 LIKE lfa1-mcod1,
mcod2 LIKE lfa1-mcod2,
mcod3 LIKE lfa1-mcod3,
gbort LIKE blfa1-gbort,
gbdat LIKE blfa1-gbdat,
sexkz LIKE blfa1-sexkz,
kraus LIKE blfa1-kraus,
revdb LIKE blfa1-revdb,
qssys LIKE blfa1-qssys,
ktock LIKE blfa1-ktock,
pfort LIKE blfa1-pfort,
werks LIKE blfa1-werks,
ltsna LIKE blfa1-ltsna,
werkr LIKE blfa1-werkr,
plkal LIKE lfa1-plkal,
duefl LIKE lfa1-duefl,
txjcd LIKE blfa1-txjcd,
sperz LIKE lfa1-sperz,
scacd LIKE blfa1-scacd,
sfrgr LIKE blfa1-sfrgr,
lzone LIKE blfa1-lzone,
xlfza LIKE lfa1-xlfza,
dlgrp LIKE blfa1-dlgrp,
fityp LIKE blfa1-fityp,
stcdt LIKE blfa1-stcdt,
regss LIKE blfa1-regss,
actss LIKE blfa1-actss,
stcd3 LIKE blfa1-stcd3,
stcd4 LIKE blfa1-stcd4,
ipisp LIKE blfa1-ipisp,
taxbs LIKE blfa1-taxbs,
profs LIKE blfa1-profs,
stgdl LIKE blfa1-stgdl,
emnfr LIKE blfa1-emnfr,
lfurl LIKE blfa1-lfurl,
j_1kfrepre LIKE blfa1-j_1kfrepre,
j_1kftbus LIKE blfa1-j_1kftbus,
j_1kftind LIKE blfa1-j_1kftind,
confs LIKE lfa1-confs,
updat LIKE lfa1-updat,
uptim LIKE lfa1-uptim,
nodel LIKE blfa1-nodel.
DATA: END OF vendor_file_x.
FIELD-SYMBOLS: <field>,
<field_1>.
DATA: delim TYPE x VALUE '09'.
DATA: fld_chk(4096),
last_char,
quote_1 TYPE i,
quote_2 TYPE i,
fld_lth TYPE i,
columns TYPE i,
field_end TYPE i,
outp_rec TYPE i,
extras(3) TYPE c VALUE '.,"',
mixed_no(14) TYPE c VALUE '1234567890-.,"'.
OPEN DATASET p_file FOR INPUT.
DO.
READ DATASET p_file INTO data_tab-data.
IF sy-subrc = 0.
APPEND data_tab.
ELSE.
EXIT.
ENDIF.
ENDDO.
* count columns in output structure
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
columns = sy-index.
ENDDO.
* Assign elements of input file to internal table
CLEAR vendor_file_x.
IF columns > 0.
LOOP AT data_tab.
DO columns TIMES.
ASSIGN space TO <field>.
ASSIGN space TO <field_1>.
ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
SEARCH data_tab-data FOR delim.
IF sy-fdpos > 0.
field_end = sy-fdpos + 1.
ASSIGN data_tab-data(sy-fdpos) TO <field_1>.
* Check that numeric fields don't contain any embedded " or ,
IF <field_1> CO mixed_no AND
<field_1> CA extras.
TRANSLATE <field_1> USING '" , '.
CONDENSE <field_1> NO-GAPS.
ENDIF.
* If first and last characters are '"', remove both.
fld_chk = <field_1>.
IF NOT fld_chk IS INITIAL.
fld_lth = strlen( fld_chk ) - 1.
MOVE fld_chk+fld_lth(1) TO last_char.
IF fld_chk(1) = '"' AND
last_char = '"'.
MOVE space TO fld_chk+fld_lth(1).
SHIFT fld_chk.
MOVE fld_chk TO <field_1>.
ENDIF. " for if fld_chk(1)=" & last_char="
ENDIF. " for if not fld_chk is initial
* Replace "" with "
DO.
IF fld_chk CS '""'.
quote_1 = sy-fdpos.
quote_2 = sy-fdpos + 1.
MOVE fld_chk+quote_2 TO fld_chk+quote_1.
ELSE.
MOVE fld_chk TO <field_1>.
EXIT.
ENDIF.
ENDDO.
<field> = <field_1>.
ELSE.
field_end = 1.
ENDIF.
SHIFT data_tab-data LEFT BY field_end PLACES.
ENDDO.
APPEND vendor_file_x.
CLEAR vendor_file_x.
ENDLOOP.
ENDIF.
CLEAR data_tab.
REFRESH data_tab.
FREE data_tab.
Rob -
"Bad data format" when reading txt file from the presentation server
Hello,
I have a piece of code which reads a txt file from the presentation server to an internal table like below:
DATA : lv_filename type string.
lv_filename = 'C:\abap\Test.txt'. "I created a folder called abap under C:\
CALL method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = lv_filename
CHANGING
DATA_TAB = lt_tsd. " lt_tab has the exact same fields as the Test.txt's. Test.txt has only one line, tab delimited.
When running this code, exception BAD_DATA_FORMAT is issued.
Is it because of the file encoding or delimiter or other reason?
Thanks,
YangHello,
If its tab delimited then use the has_field_seperator parameter and check
DATA : lv_filename type string.
lv_filename = 'C:\abap\Test.txt'. "I created a folder called abap under C:\
CALL method CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = lv_filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = u2018Xu2019
CHANGING
DATA_TAB = lt_tsd.
Vikranth -
Reading file from the presentation server in the background
Hi,
I am trying to read a .csv file from the presentation server into an internal table in the background. what should I do for it? In the foreground it works fine.
I have declared a selection parameter 'p_file' that has the path of the file. It wokrs fine in the foreground and how to set it up in the background?
Any thoughts would be helpful. Thanks in advance,
VGhii
did you achieved the required functionality , i,e, accessing presentation server file i nbackground .
I too got the same requirement, can you explain the process.
There is no way you can do it... The best method is to put the file on Appln server and then call it in the background mode.
Regards,
Vishwa. -
I have uninstalled iPhoto and reinstalled from the app Store, but still don't have the cards, calendar etc option under Share. Any other suggestions please?
With iPhoto 9.5.1 I have those both places - under the file menu and in the Share section
LN -
how do I set up my email account on my iMac OS Yosemite 10.10.2 so that the emails are downloaded to my computer and removed from the ISP server?
When setting up the email using Apple 'Mail' (version 8.2 (2070.6)) I do not get an option to set up my email as using POP. I can go to Outlook from Microsoft and I get a chance to set my mail up using POP, however I would prefer to use the Apple supplied 'Mail' email programme as I'm using Office 365 and may not want to continue the subscription sometime in the future.
Any advice on setting Mail to POP would be appreciated. A not so Happy Wombat. -
I can't extract the msi and files from the 11.0.02.exe it is asking for a password!!!! Help
From where did you download the exe?
How exactly are you trying to extract it? -
hi ive got a ipod nano 7G and i have downloaded and game from the app store on to the computer but i dont know how to put it on my ipod!
thanks!Ipod nano 7th Gen is not compatible to any games in apps store. It is not an IOS device so no application can be installed in your nano. Cheers!
-
Accessing txt files in the App server from web application
Hi All,
We have a use case, where we need to access txt files from the ADF web application.
We will display to the user the path of the file and whenever he/she clicks, it should be downloaded automatically to the users machine.
Environments we need to develop: JDeveloper 10.1.3.4 and Oracle App Server 10.1.3.1
And our server has credentials and only those who have access to the server can access the files.
Point me or suggest me a good solution to this use case.
Regards,
Naga.Hi Joonas,
i was able to download the files, thanks a lot for your guidance. i will mark your answer as correct.
Can you let me know how to achieve the following usecase.
1. there will be multiple text files in the server i.e., out of our web application context like in some folder
2. And we need to give user a http link and if he clicks on the link that file should be downloaded automatically to his machine.
and we are using oracle app server 10.1.3.4, please point me to some document or example.
thank you.
naga. -
Error while extracting XML file from the application server
Hi ,
I am writing a XML file into the application server, after which when i try to extract the file to the local server using the report - RFASLDPC ,
the file is extracted, but with a '#' symbol at the first position.
Because of which the XML File does not open. But after i open the file in notepad and manually delete the '#' symbol and then reopen the file, it works fine.
Is there any way to remove the '#' symbol while extracting itself ??
Thanks in advance,
Vikas.Select the option "No Character Set Conversion" in stead of Code page 1100.
However, I still have troubles -> the downloaded xml file misses a space on several places. This causes errors too. -
How do I upload only a few lines of a file from the presentation server?
Hi there guys,
I'd like to upload the contents of a file on my HD (presentation server) to an internal table. I know this can be achieved by using the GUI_UPLOAD function module. But what if I only want to upload a part of the file, not the whole thing? Like the first 100 bytes or 10 lines or something like that. Some files are just way too big to upload them as a whole. I tried using the OPEN DATASET statement, but that seems to work only for files on the application server. If I try to open 'C: emp est.txt' (for example) with OPEN DATASET, I get an error. Do I have to put the filename differently or am I totally wrong with OPEN DATASET? I'm kinda stuck here and I'd appreciate your help.
Cheers,
Björn.Hi Shashi,
thanks for your reply. If I understand you correctly, this means I will have to wait for GUI_UPLOAD to upload the whole file and afterwards filter into another table. I don't want to upload the whole thing because it's that big, I'd like to only upload a portion of it in the first place. Can this be done?
Cheers,
Björn. -
HT1349 cannot get lion to download and install from the app store
the lion os app took 2 days to down load then did not install from the app store.
Do you mean the install button stays on install, or do you notice a loading bar under your Launchpad icon?
This may help...
http://asia.cnet.com/having-problems-installing-os-x-mavericks-look-here-6222279 2.htm -
How to delete File from the Application Server,ABAP
Hi Gurus,
I'm using DELETE DATASET Statement ,
Based on Date how can i delete files with in the period in the Application server
Any BAPI/FM for this Delete file based on some Date Period
Thanks in Advance.DATA: BEGIN OF file,
dirname(75) TYPE c, " name of directory. (possibly truncated.)
name(75) TYPE c, " name of entry. (possibly truncated.)
type(10) TYPE c, " type of entry.
len(8) TYPE p, " length in bytes.
owner(8) TYPE c, " owner of the entry.
mtime(6) TYPE p, " last modification date, seconds since 1970
mode(9) TYPE c, " like "rwx-r-x--x": protection mode.
useable(1) TYPE c,
subrc(4) TYPE c,
errno(3) TYPE c,
errmsg(40) TYPE c,
mod_date TYPE d,
mod_time(8) TYPE c, " hh:mm:ss
seen(1) TYPE c,
changed(1) TYPE c,
END OF file.
DATA: BEGIN OF file_list OCCURS 100,
dirname(75) TYPE c, " name of directory. (possibly truncated.)
name(75) TYPE c, " name of entry. (possibly truncated.)
type(10) TYPE c, " type of entry.
len(8) TYPE p, " length in bytes.
owner(8) TYPE c, " owner of the entry.
mtime(6) TYPE p, " last modification date, seconds since 1970
mode(9) TYPE c, " like "rwx-r-x--x": protection mode.
useable(1) TYPE c,
subrc(4) TYPE c,
errno(3) TYPE c,
errmsg(40) TYPE c,
mod_date TYPE d,
mod_time(8) TYPE c, " hh:mm:ss
seen(1) TYPE c,
changed(1) TYPE c,
END OF file_list.
DO.
CLEAR file.
CALL 'C_DIR_READ_NEXT'
ID 'TYPE' FIELD file-type
ID 'NAME' FIELD file-name
ID 'LEN' FIELD file-len
ID 'OWNER' FIELD file-owner
ID 'MTIME' FIELD file-mtime
ID 'MODE' FIELD file-mode
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
if sy-subrc eq 0.
MOVE-CORRESPONDING file TO file_list.
APPEND file_list.
else.
exit.
endif.
enddo.
sort file_list based on date and time ie, MOD_DATE and MOD_TIME fields
and delete the entries -
Moving of flat file from the application server after upload.
Hi All,
I am uploading data from a flat file placed on the application server by a BDC program.
After the BDC has created the session i want to transfer the flat file from that folder to another folder on the application server by changing the name of the flatfile.
Can any one suggest the best way of doing this particular scenario?
Thanks in advance.
Regards
Satish Nair.Here is a sample program.
report zrich_0001.
data: d1 type localfile value '/usr/sap/TST/SYS/Data1.txt',
d2 type localfile value '/usr/sap/TST/SYS/Data2.txt'.
data: begin of itab occurs 0,
rec(20) type c,
end of itab.
data: wa(20) type c.
start-of-selection.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset d1.
open dataset d2 for output in text mode.
loop at itab.
transfer itab to d2.
endloop.
close dataset d2.
delete dataset d1.
Regards,
Rich Heilman
Maybe you are looking for
-
Unable to open project after 6.0.2 update
Hi: I updated FCP Studio2 to the latest software (6.0.2) on Wednesday. I edited and worked without any issues on Thurday & Friday. Today, when I opened the same project I get the following message: "File's format is too new for this version of the ap
-
HOW TO CREATE A TABLE WITH 800 COLUMNS?
I have to create a table with 800 columns.I know the create statement to create a table but it will take more time. So tell me the other method.
-
Hi everybody, I work with HTML DB 1.6. My question is about Cursor Focus. In my page Cursor Focus is SET TO: First item on page My first item is a Select list, my second item is an other Select list and my third item is a Text area. My cursor is focu
-
Populate Sales order document field
I would like to populate the sales order document field in FS10N drilldown , with the appropriate sales order number . does anyone have any idea how to get this accomplished. Thank you
-
Actiontec MI424-WR Rev. E and Windows 8
Will this router I have funtion with W8. Thanks