2013 Jun 05 5:53 AM
Hi...
In my code i used the function module CONVERT_OTFSPOOLJOB_2_PDF for converting spool to pdf format.....but iam getting runtime error .
this is my code
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = i_itcpp
* NO_DIALOG =
* DST_DEVICE =
* PDF_DESTINATION =
* NO_BACKGROUND =
* IMPORTING
* PDF_BYTECOUNT =
* PDF_SPOOLID =
* OTF_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
* BIN_FILE =
TABLES
PDF = it_pdf_output
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2013 Jun 07 7:58 AM
Hi Everyone,
Thanx for all your replies. Bcs of ur help i completed my object. Here iam providing for future refrence.
REPORT ZPHF_VMS .
* ----------------------------------------------------------------------*
* & TABLE DECLARATION *
* ----------------------------------------------------------------------*
TABLES : LFA1, ITCPO. "Vendor Master (General Section)
* ----------------------------------------------------------------------*
* & DATA DECLARATION *
* ----------------------------------------------------------------------*
DATA : V_LIFNR TYPE LIFNR.
DATA : I_ITCPP TYPE ITCPP.
DATA :W_ERREUR TYPE I VALUE 0.
DATA : STRUCT TYPE ITCPO.
DATA: GD_RECSIZE TYPE I.
DATA: PDFTAB TYPE TABLE OF TLINE WITH HEADER LINE,
DATAB TYPE TABLE OF ITCOO WITH HEADER LINE.
DATA: BINFILESIZE TYPE I,
FILE_NAME TYPE STRING,
FILE_PATH TYPE STRING,
FULL_PATH TYPE STRING.
DATA : p_email1 TYPE SZA1_D0100-SMTP_ADDR.
* ----------------------------------------------------------------------*
* & TYPE DECLARATION *
* ----------------------------------------------------------------------*
TYPES : BEGIN OF TY_LFA1,
LIFNR TYPE LIFNR,
LAND1 TYPE LAND1_GP,
NAME1 TYPE NAME1_GP,
NAME2 TYPE NAME2_GP,
NAME3 TYPE NAME3_GP,
NAME4 TYPE NAME4_GP,
ORT01 TYPE ORT01_GP,
ORT02 TYPE ORT02_GP,
PFACH TYPE PFACH,
PSTL2 TYPE PSTL2,
PSTLZ TYPE PSTLZ,
REGIO TYPE REGIO,
SORTL TYPE SORTL,
STRAS TYPE STRAS_GP,
SPRAS TYPE SPRAS,
ADRNR TYPE ADRNR,
END OF TY_LFA1.
* ----------------------------------------------------------------------*
* & Binary store for PDF *
* ----------------------------------------------------------------------*
DATA: BEGIN OF IT_PDF_OUTPUT OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA: END OF IT_PDF_OUTPUT.
* ----------------------------------------------------------------------*
* & INTERNAL TABLE DECLARATION *
* ----------------------------------------------------------------------*
DATA : IT_LFA1 TYPE STANDARD TABLE OF TY_LFA1,
WA_LFA1 TYPE TY_LFA1.
DATA : T_OTF TYPE TABLE OF ITCOO. "OTF Structure
* ----------------------------------------------------------------------*
* & Selection Screen DECLARATION *
* ----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_LIFNR FOR V_LIFNR.
PARAMETERS : P_EMAIL LIKE p_email1.
SELECTION-SCREEN END OF BLOCK B1.
* ----------------------------------------------------------------------*
* & Start of selection *
* ----------------------------------------------------------------------*
SELECT LIFNR
LAND1
NAME1
NAME2
NAME3
NAME4
ORT01
ORT02
PFACH
PSTL2
PSTLZ
REGIO
SORTL
STRAS
SPRAS
ADRNR
FROM LFA1
INTO TABLE IT_LFA1
WHERE LIFNR IN S_LIFNR
AND SPRAS = SY-LANGU. "Message language
PERFORM TRAITEMENT.
PERFORM CONVERSION.
* PERFORM process_email.
* &---------------------------------------------------------------------*
* & Form TRAITEMENT
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM TRAITEMENT .
PERFORM OPEN_FORM.
PERFORM WRITE_FORM.
PERFORM CLOSE_FORM.
ENDFORM. " TRAITEMENT
* &---------------------------------------------------------------------*
* & Form OPEN_FORM
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM OPEN_FORM .
ITCPO-TDGETOTF = 'X'.
STRUCT-TDDEST = 'LP01'.
*To specify no Print Preview
STRUCT-TDNOPREV = 'X'.
*To access the SAP Script output in OTF format
STRUCT-TDGETOTF = 'X'.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = SPACE
FORM = 'ZPHF_VMS1'
LANGUAGE = sy-langu "Message language
OPTIONS = STRUCT
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = '*'
* SPONUMIV =
* IMPORTING
* LANGUAGE = sy-langu
* NEW_ARCHIVE_PARAMS =
* RESULT =
* EXCEPTIONS
* CANCELED = 1
* DEVICE = 2
* FORM = 3
* OPTIONS = 4
* UNCLOSED = 5
* MAIL_OPTIONS = 6
* ARCHIVE_ERROR = 7
* INVALID_FAX_NUMBER = 8
* MORE_PARAMS_NEEDED_IN_BATCH = 9
* SPOOL_ERROR = 10
* CODEPAGE = 11
* OTHERS = 12
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " OPEN_FORM
* &---------------------------------------------------------------------*
* & Form WRITE_FORM
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM WRITE_FORM .
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HEADER1'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'HEADER'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'LINE'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'LINE_HD'.
LOOP AT IT_LFA1 INTO WA_LFA1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN1'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'.
ENDLOOP.
ENDFORM. " WRITE_FORM
* &---------------------------------------------------------------------*
* & Form CLOSE_FORM
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM CLOSE_FORM .
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = I_ITCPP
* RDI_RESULT =
TABLES
OTFDATA = T_OTF
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
W_ERREUR = W_ERREUR + 1.
ENDIF.
ENDFORM. " CLOSE_FORM
* &---------------------------------------------------------------------*
* & Form CONVERSION spool to pdf format
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM CONVERSION .
DATA: l_xstring TYPE xstring.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
IMPORTING
BIN_FILESIZE = BINFILESIZE
BIN_FILE = l_xstring
TABLES
OTF = T_OTF
LINES = PDFTAB[]
* EXCEPTIONS
* ERR_MAX_LINEWIDTH = 1
* ERR_FORMAT = 2
* ERR_CONV_NOT_POSSIBLE = 3
* ERR_BAD_OTF = 4
* OTHERS = 5
.
IF sy-subrc = 0.
DATA send_request TYPE REF TO cl_bcs.
DATA document TYPE REF TO cl_document_bcs.
DATA recipient TYPE REF TO if_recipient_bcs.
DATA bcs_exception TYPE REF TO cx_bcs.
DATA pdf_size TYPE so_obj_len.
DATA pdf_content TYPE solix_tab.
DATA pdf_xstring TYPE xstring.
DATA sent_to_all TYPE os_boolean.
DATA: l_document TYPE REF TO cl_document_bcs. " Mail body
TRY.
*-------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
*-------- create and set document -------------------------------
pdf_content = cl_bcs_convert=>xstring_to_solix( l_xstring ).
pdf_size = BINFILESIZE . "v_len_in.
DATA:l_text TYPE bcsy_text. " Mail body
APPEND 'Hi,' TO l_text.
APPEND 'The vendor master details are attached for further reference.' to l_text.
Append 'Regards,' to l_text.
APPEND 'Meenakshi.' to l_text.
* append 'Hello world!' to text.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = l_text
i_length = '12'
i_subject = 'Vendor Master details') .
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = 'My attachment'
i_att_content_hex = pdf_content.
* add document object to send request
send_request->set_document( document ).
* --------- add recipient (e-mail address) -----------------------
* create recipient object
recipient = cl_cam_address_bcs=>create_internet_address( p_email ).
* add recipient object to send request
send_request->add_recipient( recipient ).
SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
* ---------- send document ---------------------------------------
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
IF sent_to_all IS INITIAL.
MESSAGE i500(sbcoms) WITH p_email.
ELSE.
MESSAGE s022(so).
ENDIF.
* ------------ exception handling ----------------------------------
* replace this rudimentary exception handling with your own one !!!
CATCH cx_bcs INTO bcs_exception.
MESSAGE i865(so) WITH bcs_exception->error_type.
ENDTRY.
ENDIF.
thanq
2013 Jun 05 6:01 AM
Hi meenakshi,
What is the error you are getting?
For reference regarding the fm CONVERT_OTFSPOOLJOB_2_PDF check report RSTXPDFT4.
Regards,
Madhumahesh.
2013 Jun 05 11:18 AM
HI Madhu,
thanx for ur reply......the reference program is useful using this conversion i need to send a mail by attaching the pdf
2013 Jun 05 6:02 AM
Hi Meenakshi,
What is the run-time error while executing the program?
With Regards,
Gurulakshmi
2013 Jun 05 6:05 AM
2013 Jun 05 6:07 AM
2013 Jun 05 6:09 AM
HI,
May be you have passed wrong parameters. Check declaration for i_itcpp and it_pdf_output.
Value of SRC_SPOOLID should be spool number (LIKE TSP01-RQIDENT) and it_pdf_output should be table of TLINE.
Regards,
Mordhwaj
2013 Jun 05 6:15 AM
Hi Gowtham,
Yes u r right . It_pdf_output is in table TLINE only but i changed the i_itcpp to i_itcpp-TDSPOOLID. Now iam getting the output but not in pdf format normal otf only then showing error message as 'spool request 0 does not exists.'.
Regards,
Meenakshi
2013 Jun 05 6:19 AM
Hi Gowtham...
the above statement was for print preview only but when i click print button it s showing the message PDF DATA OF LENGTH 809468 CREATED. So where i can view the pdf format....in sp01 i didnt notice any change.
2013 Jun 05 8:01 AM
Hi meenakshi,
your requirement is sending the mail right you cant view the spool in pdf but using that pdfdata you can send the attachment to mail using the function module.
2013 Jun 05 9:42 AM
2013 Jun 05 10:01 AM
Hi Gowtham,,
Now i can view the output in spo1 after all the changes but not in pdf format
2013 Jun 05 6:21 AM
Hi!
Please check the following:
1. If data type of 'i_itcpp' is "TSP01-RQIDENT". Else it will throw an error.
2. If " it_pdf_output" is of TYPE TABLE OF TLINE.
Also what is your Output device? This parameter will be passed in export parameter 'DST_DEVICE'.
So your this piece of code should be something like this:
DATA: i_itcpp TYPE TSP01-RQIDENT,
it_pdf_output TYPE TABLE OF TLINE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = i_itcpp
DST_DEVICE = 'LP01'
TABLES
PDF = it_pdf_output
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
KS
2013 Jun 05 6:32 AM
Hi Ks,
Thanx for ur reply but same runtime error only.....wen i debug and saw the spoolid in itcpp is showing 0.
2013 Jun 05 7:08 AM
hmm,
we need some value in i_itcpp before calling this FM..
This is done in FM 'JOB_OPEN':
NAME LIKE tbtcjob-jobname VALUE 'TRANSFER DATA',
NUMBER LIKE tbtcjob-jobcount,
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = NAME
IMPORTING
JOBCOUNT = NUMBER
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
WA_JOB-JOBCOUNT = NUMBER.
APPEND WA_JOB TO IT_JOB. "Appending Job number to an internal field.
After that you can be calling a program using submit or anything else..
Then close the job:
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = NUMBER
JOBNAME = NAME
STRTIMMED = 'X'
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
OTHERS = 8.
* ENDIF.
ENDLOOP.
And then:
LOOP AT IT_NUM INTO WA_NUM.
i_itcpp = WA_NUM-LISTIDENT.
And now call FM '
'CONVERT_OTFSPOOLJOB_2_PDF' with i_itcpp. (same as before)..
ENDLOOP.
Regards,
KS.
2013 Jun 05 7:16 AM
HI KS,
This is new to me.....after 'JOB_OPEN' fm wat i need to call...?
Then y the need to call the function module 'job_open, job_submit and job_cloe'
regards,
meenakshi
2013 Jun 05 7:58 AM
Hi Meenakshi,
I saw your code... All you need to do in your existing code is uncomment 'TABLES' parameter and then pass all parameters in UPPERCASE... If still it doesnt work, we will see what to do next...
Regards,
KS
2013 Jun 05 6:29 AM
Hi Meenakshi,
You were passing everything correct. If suppose the run time error is like type conflict then you should pass the parameter as the same type as function module(CONVERT_OTFSPOOLJOB_2_PDF).For types refer Modhwaj post.
If not go to st22 it will give you the proper solution.
You could not fix the problem kindly post the run time error.
I hope this will help you.
Warm Regards,
John.
2013 Jun 05 6:37 AM
For this function module CONVERT_OTFSPOOLJOB_2_PDF in exporting parameters need to pass DST_DEVICE also.
DST_DEVICE = 'LP01' "Device Type
2013 Jun 05 7:14 AM
2013 Jun 05 9:43 AM
Hi,
Try using below code.
DATA : print_params LIKE pri_params,
mc_valid TYPE c.
data: spoolid type sy-spono,
lt_data TYPE TABLE OF tline.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
* ARCHIVE_ID = C_CHAR_UNKNOWN
* ARCHIVE_INFO = C_CHAR_UNKNOWN
* ARCHIVE_MODE = C_CHAR_UNKNOWN
* ARCHIVE_TEXT = C_CHAR_UNKNOWN
* AR_OBJECT = C_CHAR_UNKNOWN
* ARCHIVE_REPORT = C_CHAR_UNKNOWN
authority = space
copies = 1
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
* IN_ARCHIVE_PARAMETERS = ' '
* IN_PARAMETERS = ' '
* LAYOUT = C_CHAR_UNKNOWN
* LINE_COUNT = C_INT_UNKNOWN
* LINE_SIZE = C_INT_UNKNOWN
* LIST_NAME = C_CHAR_UNKNOWN
* LIST_TEXT = C_CHAR_UNKNOWN
* MODE = ' '
new_list_id = 'X'
* protect_list = 'X'
no_dialog = 'X'
* RECEIVER = C_CHAR_UNKNOWN
* RELEASE = C_CHAR_UNKNOWN
* REPORT = C_CHAR_UNKNOWN
* sap_cover_page = 'X'
* HOST_COVER_PAGE = C_CHAR_UNKNOWN
* PRIORITY = C_NUM1_UNKNOWN
* SAP_OBJECT = C_CHAR_UNKNOWN
* TYPE = C_CHAR_UNKNOWN
user = sy-uname
* USE_OLD_LAYOUT = ' '
* UC_DISPLAY_MODE = C_CHAR_UNKNOWN
* DRAFT = C_CHAR_UNKNOWN
* ABAP_LIST = ' '
* USE_ARCHIVENAME_DEF = ' '
* DEFAULT_SPOOL_SIZE = C_CHAR_UNKNOWN
* WITH_STRUCTURE = C_CHAR_UNKNOWN
* SUPPRESS_SHADING = C_CHAR_UNKNOWN
* PO_FAX_STORE = ' '
* NO_FRAMES = C_CHAR_UNKNOWN
IMPORTING
* OUT_ARCHIVE_PARAMETERS =
out_parameters = print_params
valid = mc_valid
* VALID_FOR_SPOOL_CREATION =
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
print_params-pdest = 'LP01'.
print_params-linsz = 100.
print_params-paart = 'DINA4'.
NEW-PAGE PRINT ON PARAMETERS print_params NO DIALOG NO-TITLE NO-HEADING.
loop at t_data into wa_data.
write:/ wa_data-field1,
wa_data-field2.
endloop.
NEW-PAGE PRINT OFF.
spoolid = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spoolid
* NO_DIALOG =
dst_device = 'LP01'
* PDF_DESTINATION =
* NO_BACKGROUND =
* GET_SIZE_FROM_FORMAT =
* IMPORTING
* PDF_BYTECOUNT =
* PDF_SPOOLID =
* LIST_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
* BIN_FILE =
TABLES
pdf = lt_data
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = filename
filetype = 'BIN'
TABLES
data_tab = lt_data.
2013 Jun 05 6:40 AM
Hi Meenakshi,
Please share the error description that you are getting.
Regards,
DN.
2013 Jun 05 7:11 AM
Hi everyone,,
Finally my code is
FORM OPEN_FORM .
itcpo-tdgetotf = 'X'.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'ZPHF_VMS1'
* LANGUAGE = sy-langu "Message language
OPTIONS = itcpo
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = '*'
* SPONUMIV =
* IMPORTING
* LANGUAGE = sy-langu
* NEW_ARCHIVE_PARAMS =
* RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " OPEN_FORM
* &---------------------------------------------------------------------*
* & Form WRITE_FORM
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM WRITE_FORM .
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HEADER1'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'HEADER'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'LINE'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'LINE_HD'.
LOOP AT IT_LFA1 INTO WA_LFA1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN1'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'.
ENDLOOP.
ENDFORM. " WRITE_FORM
* &---------------------------------------------------------------------*
* & Form CLOSE_FORM
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM CLOSE_FORM .
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = i_itcpp
* RDI_RESULT =
* TABLES
OTFDATA = t_otf
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
* w_erreur = w_erreur + 1.
ENDIF.
ENDFORM. " CLOSE_FORM
* &---------------------------------------------------------------------*
* & Form CONVERSION spool to pdf format
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM CONVERSION .
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = i_itcpp
* NO_DIALOG =
DST_DEVICE = 'Lp01'
* PDF_DESTINATION =
* NO_BACKGROUND =
* IMPORTING
* PDF_BYTECOUNT =
* PDF_SPOOLID =
* OTF_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
* BIN_FILE =
TABLES
PDF = it_pdf_output
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
And the error in runtime is 'Function parameter "OTFDATA" is unknown.' Pls help me in this otf format
2013 Jun 05 7:26 AM
Hi,
I see your interface parameter TABLES commented but the parameter itself ( OTFDATA) left un-commented...
Also,
please check t_otf declaration as:
t_otf LIKE ITCOO.
Regards,
KS
2013 Jun 05 7:42 AM
Hi meena,
FORM CLOSE_FORM .
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = i_itcpp
* RDI_RESULT =
* TABLES ***************************************Why should you command this ?
OTFDATA = t_otf
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
* w_erreur = w_erreur + 1.
ENDIF.
ENDFORM. " CLOSE_FORM
And also check the entire single quotes word should be capital if not it will through the run time error. Because as you know already ABAP is a case sensitive only with in single quotes.
Warm Regards,
John.
2013 Jun 05 7:53 AM
Hi Meemakshi,
Un-comment the TABLES statement in the shown place
Also pass the character input parameters in capitals.
For example, you have passed 'Lp01', instead, pass 'LP01'.
With Regards,
Gurulakshmi
2013 Jun 05 8:46 AM
Hi Guru,
Changes where made but still getting the runtime error as 'Type conflict when calling a function module (field length).'
2013 Jun 05 8:47 AM
HI KS,
Made the change but still continuing with the runtime error saying 'Type conflict when calling a function module (field length).
The call to the function module "CLOSE_FORM" is incorrect:
In the function module interface, you can specify only
fields of a specific type and length under "RESULT".
Although the currently specified field
"I_ITCPP" is the correct type, its length is incorrect.'
This is the message in runtime
2013 Jun 05 10:00 AM
Hi KS,
Now i can able to view the output in sp01 without any runtime error...wen i give input it showed the message pdf 32554 is created wen i viewed in sp01 i can view th o/p but i didnt see it in pdf format..........
2013 Jun 05 8:00 AM
Hi meenakshi,
Is ur fuction module returning a spoolids.
If yes.
then try this
submit rstxpdft4 with spoolno = 'ur spool id here'.
then it will automatically converted to pdf and ask for saving.
try this.
Thanks,
nike
2013 Jun 05 8:23 AM
Hello,
No need to use fm for PDF ,if only want to save in desktop,try with PDF!
Thanks,
sam
2013 Jun 05 8:45 AM
Hi Sam,
No sam....need the spool to send a mail so only converting it to pdf format
2013 Jun 05 8:25 AM
Hi meenakshi,
IF you are able to get the spool id (generally job_output_info from smart form export parameter)
Try this
DATA: wa_spoolids TYPE tsfspoolid,
wa_spoolnum TYPE rspoid.
DATA
: content_bin TYPE solix_tab.
DATA: i_soli TYPE STANDARD TABLE OF soli,
w_soli TYPE soli.
: i_soli_tab TYPE soli_tab,
wa_soli_tab TYPE soli.
DATA
MOVE
job_output_info-spoolids[] TO wa_spoolids.
READ TABLE wa_spoolids INTO wa_spoolnum INDEX 1.
IF sy-subrc = 0.
DATA: id TYPE tsp01-rqident.
MOVE wa_spoolnum TO id.
ENDIF.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = id
desired_type = 'OTF'
TABLES
buffer = i_soli
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT i_soli INTO w_soli.
APPEND w_soli TO i_soli_tab[].
ENDLOOP.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = 'OTF'
format_dst = 'PDF'
CHANGING
transfer_bin = boolean
content_txt = i_soli_tab
content_bin = content_bin
objhead = objhead
len = length.
Content_bin contains your pdf doc in raw format
2013 Jun 05 8:39 AM
Hi Meenakshi,
Here is another method to download smartform as PDF.
(1)Call the smartform with no dialog option. (Spool will be created)
scontrol_param-no_dialog = 'X'.
(2)Then,
select rqident rqcretime from TSP01 into table ispool
where rqowner = sy-uname.
sort ispool by rqcretime DESCENDING ."Latest spool id
read table ispool INDEX 1.
rsp-selname = 'SPOOLNO'.
rsp-kind = 'P'.
rsp-sign = 'I'.
rsp-option = 'EQ'.
rsp-low = ispool-rqident.
append rsp.
submit RSTXPDFT4 with selection-table rsp AND RETURN. "Std program with input as spool no and outputs the pdf file
2013 Jun 05 8:45 AM
2013 Jun 05 8:55 AM
2013 Jun 05 10:06 AM
Hi Meena,
To avoid the type conflict,
Check the passed parameter in function module have the same type as function module.
Warm Regards,
John.
2013 Jun 05 10:24 AM
Hi Everyone....
Now iam getting the ouput without any run time error but wen i debug the values are not fetching for t_otf and it_pdf_output. And in I_ITCPP the TDSPOOLID is 0.
2013 Jun 05 11:08 AM
Good!
Atleast we are getting print preview... Now can you just check what your local printer is : example "LP01"
In FM "OPEN FORM" can you pass 'LP01' to DEVICE and then see if spool number is getting generated...
Regards,
KS
2013 Jun 05 12:38 PM
Hi Meena,
Do the following,
or
Do like below,
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = pass your parameter
no_dialog = 'X'
TABLES
pdf = pass table data
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 8
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 10
OTHERS = 11.
For your reference go through the following link http://scn.sap.com/message/167020#167020
http://scn.sap.com/thread/374712
Hope this will solve your problem.
Don't forget to reward if it's helpful to you.
Warm Regards,
John.