Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error while opening the ADOBE FORM via mail

pavneet_rana
Active Participant
0 Kudos
142

Hi to all,

I have created a program to attached ADOBE FORM to mail.

When I execute the program, it sends ADOBE FORM to my mail ID successfully.

But when I open my mail and try to open attached ADOBE FORM, it gives error

ADOBE READER COULD NOT OPEN u2018PDF FORM (1). PDFu2019 because it is either not a supported file type or because the file has been damaged ( for example, it was sent as an email attached and wasnu2019t correctly decoded).

Please can any tell me, what the problem is and what the solution is for that?

I shall be thankful to you for this.

Regards

Pavneet Rana

Edited by: pavneet rana on Aug 1, 2011 2:22 PM

3 REPLIES 3

Former Member
0 Kudos
91

Hi,

usually you have to attach the file in XSTRING format. Did you do this?

Post your code. Maybe this helps to find the problem.

BR,

Oliver

0 Kudos
91

Thanks for reply,

below is the code.

data:

l_fm_name TYPE rs38l_fnam,

l_formname TYPE fpname VALUE 'ZTESTF1' ,

fp_docparams TYPE sfpdocparams,

FP_FORMOUTPUT TYPE FPFORMOUTPUT,

fp_outputparams TYPE sfpoutputparams.

data: I_ATT_CONTENT_HEX type SOLIX_TAB.

START-OF-SELECTION.

data: st TYPE ZTABFM11.

data: it type table of sflight.

data: wa like LINE OF it.

data: wa_st like LINE OF ST.

fp_docparams-langu = 'E'.

fp_docparams-country = 'US'.

fp_docparams-fillable = 'X'.

fp_outputparams-nodialog = 'X'.

fp_outputparams-preview = 'X'.

fp_outputparams-device = 'LP01'.

fp_outputparams-getpdf = 'X' .

fp_outputparams-dest = 'LP01'.

fp_outputparams-reqimm = 'X'.

fp_outputparams-reqdel = 'X' .

fp_outputparams-xfpoutdev = 'LP01'.

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'

EXPORTING

i_name = l_formname

IMPORTING

e_funcname = l_fm_name.

  • E_INTERFACE_TYPE =

CALL FUNCTION 'FP_JOB_OPEN'

CHANGING

ie_outputparams = fp_outputparams

EXCEPTIONS

cancel = 1

usage_error = 2

system_error = 3

internal_error = 4

OTHERS = 5.

select * from sflight into TABLE it.

loop at it into wa.

wa_st-CARRID = wa-CARRID.

wa_st-CONNID = wa-CONNID.

wa_st-FLDATE = wa-FLDATE .

wa_st-PLANETYPE = wa-PLANETYPE.

append wa_st to st.

endloop.

CALL FUNCTION l_fm_name

EXPORTING

/1bcdwb/docparams = fp_docparams

st = st

IMPORTING

/1BCDWB/FORMOUTPUT = FP_FORMOUTPUT

EXCEPTIONS

usage_error = 1

system_error = 2

internal_error = 3

OTHERS = 4

.

CALL FUNCTION 'FP_JOB_CLOSE'

  • IMPORTING

  • E_RESULT = result

EXCEPTIONS

usage_error = 1

system_error = 2

internal_error = 3

OTHERS = 4

.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

BUFFER = FP_FORMOUTPUT-PDF

  • APPEND_TO_TABLE = ' '

  • IMPORTING

  • OUTPUT_LENGTH =

TABLES

BINARY_TAB = I_ATT_CONTENT_HEX .

CLASS cl_bcs DEFINITION LOAD.

DATA:

lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.

lo_send_request = cl_bcs=>create_persistent( ).

  • Message body and subject

DATA:

lt_message_body TYPE bcsy_text VALUE IS INITIAL,

lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.

APPEND 'Dear,' TO lt_message_body.

append ' ' to lt_message_body.

APPEND 'Fill the details.'

TO lt_message_body.

append ' ' to lt_message_body.

APPEND 'Thank You,' TO lt_message_body.

lo_document = cl_document_bcs=>create_document(

i_type = 'RAW'

i_text = lt_message_body

i_subject = 'flight details' ).

DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.

TRY.

lo_document->add_attachment(

EXPORTING

i_attachment_type = 'PDF'

i_attachment_subject = 'flight details'

  • I_ATTACHMENT_SIZE =

  • I_ATTACHMENT_LANGUAGE = SPACE

  • I_ATT_CONTENT_TEXT =

  • I_ATTACHMENT_HEADER =

I_ATT_CONTENT_HEX = I_ATT_CONTENT_HEX ).

CATCH cx_document_bcs INTO lx_document_bcs.

ENDTRY.

  • Add attachment

  • Pass the document to send request

lo_send_request->set_document( lo_document ).

  • Create sender

DATA:

lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,

l_send type ADR6-SMTP_ADDR value 'mail id '.

  • lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).

lo_sender = cl_sapuser_bcs=>create( sy-uname ).

  • Set sender

lo_send_request->set_sender(

EXPORTING

i_sender = lo_sender ).

  • Create recipient

DATA:

lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.

  • lo_recipient = cl_sapuser_bcs=>create( sy-uname ).

lo_recipient = cl_cam_address_bcs=>create_internet_address( l_send ).

    • Set recipient

lo_send_request->add_recipient(

EXPORTING

i_recipient = lo_recipient

i_express = 'X' ).

  • lo_send_request->add_recipient(

  • EXPORTING

  • i_recipient = lo_recipient

  • i_express = 'X' ).

  • Send email

DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.

lo_send_request->send(

EXPORTING

i_with_error_screen = 'X'

RECEIVING

result = lv_sent_to_all ).

COMMIT WORK.

message 'Form sucessfuly send to person' type 'I'.

plesase can any one, provide the soultion.

i shall be thankful toy you for this.

regards

pavneet rana

0 Kudos
91

Hi,

looks good so far.

Did you try to save the pdf into a file instead of sending it? Maybe your smartfform is corrupt?!

Here is another example of what you are trying. Maybe you can compare yours to that:

http://mysapcom.weebly.com/1/archives/06-2009/1.html

Best regards,

Oliver