04-02-2014 10:14 AM
Hi,
I have created 3 copies in smartform. While converting to pdf using pdf! only first copy is showing. What to do?
04-02-2014 10:28 AM
Hi,
Are the copies generated in single spool or 3 diff spool.
Chances are 3 different spools are generated. In that case then u need to convert each using the FM.
Regards
Sree
04-02-2014 1:27 PM
Hi
If you are using PDF! in the command line, then you will only one copy will be displayed. This is irrespective of number of copies.
PDF! is used to call the Adobe Reader application. This intern will have an option to print with number of copies.
If you require copies as well, then create a spool with the copies and then use standard program RSTXPDFT4, and give the spool, path to get the PDF.
Thanks,
Rajesh
04-02-2014 3:33 PM
Instead of print previewing the smartform, get the OTF by setting get_otf = X while calling smartform.
Append lines of OTF to another internal table 3 times for 3 copies.
Then call FM SSFDISPLAY_OTF and pass the OTF that has 3 times the regular data.
OTF and PDF! would then give you desired pages.
04-03-2014 9:28 PM
Hi Manish,
Am also facing the same situation. Have created 3 copies 1.Original 2.Transport 3.Duplicate
While printing am getting all the 3 copies using tdcopies = 3. But when ever am trying to convert PDF am getting the First one Original copy as PDF. Could you please elaborate the procedure to achieve this.Please see the bellow snippet you can understand what am doing exactly.
REPORT ZTEST_SF_TO_PDF_EX1.
PARAMETER: PO_NO1 TYPE EBELN DEFAULT 4500006370.
* Internal table declaration
DATA:
it_otf TYPE STANDARD TABLE OF itcoo,
it_otf2 TYPE STANDARD TABLE OF itcoo,
it_docs TYPE STANDARD TABLE OF docs,
it_lines TYPE STANDARD TABLE OF tline.
* Declaration of local variables.
DATA:
st_job_output_info TYPE ssfcrescl,
st_document_output_info TYPE ssfcrespd,
st_job_output_options TYPE ssfcresop,
st_output_options TYPE ssfcompop,
st_control_parameters TYPE ssfctrlop,
v_len_in TYPE so_obj_len,
v_language TYPE sflangu VALUE 'E',
v_e_devtype TYPE rspoptype,
v_bin_filesize TYPE i,
v_name TYPE string,
v_path TYPE string,
v_fullpath TYPE string,
v_filter TYPE string,
v_uact TYPE i,
v_guiobj TYPE REF TO cl_gui_frontend_services,
v_filename TYPE string,
v_fm_name TYPE rs38l_fnam.
CONSTANTS c_formname TYPE tdsfname VALUE 'ZTEST_SF_EX1'.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = v_language
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = v_e_devtype
.
st_output_options-tdcopies = 3.
st_output_options-tdprinter = v_e_devtype.
*st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
*.................GET SMARTFORM FUNCTION MODULE NAME.................*
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = c_formname
IMPORTING
FM_NAME = v_fm_name
.
*...........................CALL SMARTFORM............................*
CALL FUNCTION v_fm_name
EXPORTING
control_parameters = st_control_parameters
output_options = st_output_options
PO_NO = PO_NO1
IMPORTING
document_output_info = st_document_output_info
job_output_info = st_job_output_info
job_output_options = st_job_output_options
.
*.........................CONVERT TO OTF TO PDF.......................*
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = v_bin_filesize
TABLES
otf = st_job_output_info-otfdata
doctab_archive = it_docs
lines = it_lines
.
*........................GET THE FILE NAME TO STORE....................*
CONCATENATE 'smrt' '.pdf' INTO v_name.
CREATE OBJECT v_guiobj.
CALL METHOD v_guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = v_name
file_filter = v_filter
CHANGING
filename = v_name
path = v_path
fullpath = v_fullpath
user_action = v_uact.
IF v_uact = v_guiobj->action_cancel.
EXIT.
ENDIF.
*..................................DOWNLOAD AS FILE....................*
MOVE v_fullpath TO v_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_bin_filesize
filename = v_filename
filetype = 'BIN'
TABLES
data_tab = it_lines
.
Thanks in Advance,
PoornaChand M
04-04-2014 2:21 AM
So st_job_output_info-otfdata has the one set of OTF content, and you pass it to FM CONVERT_OTF_2_PDF.
You can:
DATA lt_otf TYPE TABLE OF itcoo. "or a type that matching your OTF itab
DO st_output_options-tdcopies TIMES.
APPEND LINES OF st_job_output_info-otfdata TO lt_otf.
ENDDO.
Now lt_otf has multiple sets of same data.
Pass lt_otf to CONVERT_OTF or CONVERT_OTF_2_PDF.
CONVERT_OTF should be preferred over CONVERT_OTF_2_PDF, there are samples available.
04-04-2014 1:44 PM
Hi Manish,
Thanks for your response. Am getting the 3 copies of Original only not the remaining two copies of Transport and Duplicate. I have mentioned in my SMARTFORM like this
Have created a Copy Window in that i created 3 text files with the text
1. Original and the condition is SFSY-COPYCOUNT = 1
2. Transport and the condition is SFSY-COPYCOUNT = 2
3. Duplicate and the condition is SFSY-COPYCOUNT = 3
Have tried with FM - 'CONVERT_OTF' also.
Thanks in Advance
PoornaChand M
04-04-2014 3:36 PM
I was thinking of exact copy of original, and not the smartform copies concept.
I tried getting regular otf and creating pdf out of spool, it looks like otf has only the original, not the copies.
If there is no other way, you can apply a workaround.
Pass the loop index to smartform, so that on 3 calls, smartform has a variable whose value changes from 1 to 3. Use this variable instead of sfsy-copycount, and change window type from copies to secondary.
I guess you can either change window type (I have tested this), or create a new secondary window and leave the copies window unchanged.
For regular printing, copies concept will work and give you 3 copies on preview or spool.
For getting OTF for pdf creation, secondary window will work and give you 3 different OTF.
This way you call the smartform 3 times, and and every time different copy is returned as OTF based on the loop index.
Append all these OTF into single OTF and then use CONVERT_OTF.
04-08-2014 2:44 PM
Hi Manish,
Thank you for your help it's working good for me. But i don't know whether am doing the right process or not. For 3 times am calling the SMARTFORM thrice if it is 5 times should call it 5 times. If you have any idea of alternate solution please let me know. i can try in that way too.
Thanks,
PoornaChand M
04-08-2014 3:31 PM
There might be a better way to do it, I don't know.
You can wait a few more days for others to post better ways.
04-17-2014 2:35 PM
Hi Manish,
After creating the PDF using 'CONVERT_OTF' Function module wold like to ZIP all the 3 PDF files it's creating the ZIP file with in that PDF files too. It's showing the size of the PDF but it's not opening the file. It's simply saying that "Not a supported file type or file has been damaged" (was not correctly decoded). Could you please help me to get out of this.
*.........................CONVERT TO OTF TO PDF.......................*
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = W_BIN_FILESIZE
TABLES
OTF = IT_OTF "T_OTF
LINES = T_PDF_TAB
.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = content_s
MIMETYPE = space
IMPORTING
buffer = content_x
.
"Declarations
DATA:zip TYPE REF TO cl_abap_zip.
DATA:zip_file TYPE xstring.
DATA:binary_tab TYPE STANDARD TABLE OF x255.
DATA:name TYPE string VALUE 'Invoice.PDF'.
CREATE OBJECT zip.
zip->add( name = name
content = content_x ).
zip_file = zip->save( ).
CLEAR T_PDF_TAB[].
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = zip_file
TABLES
binary_tab = binary_tab.
cl_gui_frontend_services=>gui_download(
EXPORTING
filename = 'D:\PDFZIP.ZIP'
filetype = 'BIN'
CHANGING
data_tab = binary_tab ).
Thanks in Advance
PoornaChand M
04-17-2014 2:55 PM
I don't see T_PDF_TAB being used anywhere during zip creation. Can you post full code?
04-17-2014 3:00 PM
DATA : ANS(6) TYPE C.
DATA : WS_UCOMM LIKE SY-UCOMM,
FORM_NAME TYPE RS38L_FNAM,
WA_CTRLOP TYPE SSFCTRLOP,
WA_OUTOPT TYPE SSFCOMPOP,
IT_OTF TYPE STANDARD TABLE OF ITCOO.
DATA : T_OTFDATA TYPE SSFCRESCL,
T_PDF_TAB LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA : T_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE.
DATA : W_FILESIZE TYPE I.
DATA : W_BIN_FILESIZE TYPE I.
DATA: t_data_tab TYPE TABLE OF x255,
buffer_x TYPE xstring,
buffer_zip TYPE xstring.
DATA: zip_tool TYPE REF TO cl_abap_zip.
*.................GET SMARTFORM FUNCTION MODULE NAME.................*
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZTEST_SF_EX1'
IMPORTING
FM_NAME = FORM_NAME
.
CLEAR wa_outopt.
*WA_CTRLOP-PREVIEW = 'X'.
*WA_CTRLOP-NO_DIALOG = 'X'.
*WA_OUTOPT-TDNOPREV = 'X'.
WA_OUTOPT-TDCOPIES = 3.
*...........................CALL SMARTFORM............................*
CALL FUNCTION FORM_NAME
EXPORTING
CONTROL_PARAMETERS = WA_CTRLOP
OUTPUT_OPTIONS = WA_OUTOPT
USER_SETTINGS = 'X'
PO_NO = '4500006370'
IMPORTING
JOB_OUTPUT_INFO = T_OTFDATA
.
*...........................POP UP CONFIRMATION WINDOW............................*
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
DEFAULTOPTION = 'Y'
TEXTLINE1 = 'DO YOU TO DOWNLOAD PREVIEW TO PDF FILE ?'
TEXTLINE2 = 'PRESS YES TO DOWNLOAD AND NO OR CANCEL TO EXIT !'
TITEL = 'DOWNLOAD TO PDF FILE ON PRESENTATION SERVER'
CANCEL_DISPLAY = 'X'
IMPORTING
ANSWER = ANS.
CASE ANS.
WHEN 'J'.
PERFORM DWTOPDF.
WHEN 'N'.
BACK.
* WHEN OTHERS.
* LEAVE PROGRAM.
ENDCASE.
FORM DWTOPDF .
WA_CTRLOP-GETOTF = 'X'.
*WA_CTRLOP-PREVIEW = ' '.
WA_CTRLOP-NO_DIALOG = 'X'.
*...........................CALL SMARTFORM............................*
CALL FUNCTION FORM_NAME
EXPORTING
CONTROL_PARAMETERS = WA_CTRLOP
OUTPUT_OPTIONS = WA_OUTOPT
USER_SETTINGS = 'X'
PO_NO = '4500006370'
IMPORTING
JOB_OUTPUT_INFO = T_OTFDATA
.
*T_OTF[] = T_OTFDATA-OTFDATA[].
DO WA_OUTOPT-TDCOPIES TIMES.
APPEND LINES OF T_OTFDATA-OTFDATA TO IT_OTF.
ENDDO.
*.........................CONVERT TO OTF TO PDF.......................*
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = W_BIN_FILESIZE
TABLES
OTF = IT_OTF "T_OTF
LINES = T_PDF_TAB
.
"Declarations
DATA:input_length TYPE i.
DATA:content_x TYPE xstring.
DATA:content_s TYPE string.
LOOP AT T_PDF_TAB.
CONCATENATE content_s T_PDF_TAB-tdline INTO content_s.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = content_s
MIMETYPE = space
IMPORTING
buffer = content_x
.
"Declarations
DATA:zip TYPE REF TO cl_abap_zip.
DATA:zip_file TYPE xstring.
DATA:binary_tab TYPE STANDARD TABLE OF x255.
DATA:name TYPE string VALUE 'Invoice.PDF'.
CREATE OBJECT zip.
zip->add( name = name
content = content_x ).
zip_file = zip->save( ).
CLEAR T_PDF_TAB[].
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = zip_file
TABLES
binary_tab = binary_tab.
cl_gui_frontend_services=>gui_download(
EXPORTING
filename = 'D:\PDFZIP.ZIP'
filetype = 'BIN'
CHANGING
data_tab = binary_tab ).
Thanks,
PoornaChand M
04-17-2014 3:17 PM
CONVERT_OTF has formal parameter BIN_FILE type xstring.
Getting BIN_FILE directly will save you the trouble of converting table to string to xstring.
Download the pdf first and see if logic is working.
Then troubleshoot the zip logic by referring to code snippets present on wiki/scn/internet.
I guess when you use SCMS_XSTRING_TO_BINARY to convert zip xstring to binary, you should user parameter OUTPUT_LENGTH to get zip file length too. This needs to be passed while calling GUI_DOWNLOAD as BIN_FILESIZE.
Refer Zip any file via ABAP using CL_ABAP_ZIP for more information.