Application Development and Automation 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: 
Read only

OTF attachment in IW21

Former Member
0 Likes
1,538

Hi Experts,

I am getting an OTF attachment to SAP inbox while executing IW21 Tcode.Is this a smartform or SAP Script?

Can I make any changes in its display?I want to send a mail along with this modified OTF format.I have written code for triggering mail using BAdi.But was unable to find this OTF form.

Can any one help me in finding this form and making necessary display changes to send it to as an attachment to the users?

Regards,

Sam

Hi Experts,

I am getting an OTF attachment to SAP inbox while executing IW21 Tcode.Is this a smartform or SAP Script?

Can I make any changes in its display?I want to send a mail along with this modified OTF format.I have written code for triggering mail using BAdi.But was unable to find this OTF form.

Can any one help me in finding this form and making necessary display changes to send it to as an attachment to the users?

Regards,

Sam

13 REPLIES 13
Read only

Former Member
0 Likes
1,465

Hi,

Did you goto main program of IW21 and check if they are calling any script or smartform from the standard print program?

I think you should get your answer by analyzing the print program for IW21.

Thanks,

Archana

Read only

0 Likes
1,465

Hi Archana,

While executing IW21, SAP script QM_REPLY is getting called.

can u explain me how to call a smartform instead of displaying this standard script?

Can I make necessary changes to the display of this script using any BAdis?

Regards,

Sam

Read only

0 Likes
1,465

Hi,

You will have to first copy standard print program into custome program. Then comment script calling code from your custom print program.

Then, use FM 'SSF_FUNCTION_MODULE_NAME' to call smartform,

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
       EXPORTING
             formname           =  'ZSF_ADDRESS'
       IMPORTING
             fm_name            = w_fmname
       EXCEPTIONS
              no_form            = 1
              no_function_module = 2.
   CALL FUNCTION w_fmname
         EXPORTING
             im_t_adrc         = t_adrc
             im_s_addrnum_high = s_addrno-high
             im_s_addrnum_low  = s_addrno-low
         EXCEPTIONS
             formatting_error  = 1
             internal_error    = 2
             send_error        = 3
            user_canceled      = 4.

Refer below link to get more idea.

[http://wiki.sdn.sap.com/wiki/display/Snippets/MassAddressorLabelPrintinginSMARTFORMS]

Thanks,

Archana

Edited by: Archana Pawar on Aug 30, 2010 12:16 PM

Read only

0 Likes
1,465

Hi Archana,

Thanx a lot for ur reply.

Instead of modifying the existing script,I created a new Smartform and trying to attach it with the mail.I converted this smartform into Pdf format using CONVERT_OTF Function.While I am trying to send this attachment with mail,this attachment is not getting opened properly(Error:File was not properly decoded).

Can u help me to resolve this issue?

I am using bcs class for sending email notification.

Regards,

Sam

Read only

0 Likes
1,465

Hi,

How are you calling FM 'CONVERT_OTF'?

You can use 'CONVERT_OTF' or 'CONVERT_OTF_2_PDF'. You will need to call it as below:

call function 'CONVERT_OTF_2_PDF' 
importing 
   bin_filesize             = lv_len_in 
   BIN_FILE                 = V_PDF_XSTRING
tables 
   otf = gs_return-otfdata[] 
   doctab_archive = it_docs[] 
   lines = lt_tline[] .
 
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        BUFFER     = V_PDF_XSTRING
      TABLES
        BINARY_TAB = I_CONTENT_BIN.

Then use 'I_CONTENT_BIN' table to send PDF. It will work.

Thanks,

Archana

Read only

0 Likes
1,465

Hi Archana,

I am calling the function modules as given below

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZEHS_WELDREPORTNEW'

IMPORTING

fm_name = w_fmname

EXCEPTIONS

no_form = 1

no_function_module = 2.

CALL FUNCTION w_fmname

EXPORTING

control_parameters = ssfctrlop

output_options = ssfcompop

IMPORTING

job_output_info = it_otf_data

TABLES

IT_WELDHIST = IT_WELDHIST

it_otf_final[] = it_otf_data-otfdata[]

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

BIN_FILESIZE = bin_filesize

BIN_FILE = '255'

TABLES

OTF = it_otf_final

DOCTAB_ARCHIVE = it_pdfdata[]

LINES = it_pdfdata[].

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

BUFFER = it_otf_data

TABLES

BINARY_TAB = it_pdfdata.

What to mention in BIN_FILE of 'CONVERT_OTF_2_PDF' FM?

Pls help me to resolve this issue.

Regards,

Sam

Read only

0 Likes
1,465

Hi,

You will have to declare a variable of type XSTRING.

data: V_PDF_XSTRING    TYPE        XSTRING.

call function 'CONVERT_OTF_2_PDF' 
importing 
   bin_filesize             = lv_len_in 
   BIN_FILE                 = V_PDF_XSTRING
tables 
   otf = gs_return-otfdata[] 
   doctab_archive = it_docs[] 
   lines = lt_tline[] .

This FM will fetch the PDF converted data in the form of xstring into 'V_PDF_XSTRING' as well as in table lines.

You need to use 'V_PDF_XSTRING' to convert it into binary format as i have explained above.

Thanks,

Archana

Read only

Former Member
0 Likes
1,465

see example


FORM GET_SF .
*u2022 Generate Function Module name
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      FORMNAME           = 'Ytest'
    IMPORTING
      FM_NAME            = GV_FORM_NAME
    EXCEPTIONS
      NO_FORM            = 1
      NO_FUNCTION_MODULE = 2
      OTHERS             = 3.
  IF SY-SUBRC  <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
*u2022 Assigning values to Form Control Structure and Form Composer
  IF R_OUT <> 'X'.
    GS_CTRLOP-GETOTF = 'X'.
    GS_CTRLOP-NO_DIALOG = 'X'.
    GS_OUTOPT-TDNOPREV = 'X'.
  ENDIF.

  CALL FUNCTION GV_FORM_NAME
    EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
      CONTROL_PARAMETERS         = GS_CTRLOP
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
      OUTPUT_OPTIONS             = GS_OUTOPT
      USER_SETTINGS              = 'X'
      TEMP_VBELN                 =  P_VBELN
   IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            = GS_OTFDATA
*   JOB_OUTPUT_OPTIONS         =
   EXCEPTIONS
     FORMATTING_ERROR           = 1
     INTERNAL_ERROR             = 2
     SEND_ERROR                 = 3
     USER_CANCELED              = 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.

ENDFORM.                    " GET_SF




Edited by: kk.adhvaryu on Sep 3, 2010 7:53 AM

Edited by: kk.adhvaryu on Sep 3, 2010 7:55 AM

Edited by: kk.adhvaryu on Sep 3, 2010 7:56 AM

Read only

Former Member
0 Likes
1,465

FORM CONVERT_OTF .

 data  :GV_BIN_FILESIZE TYPE I.
*u2022 Assigning the OTFDATA to OTF Structure table
  CLEAR GT_OTF.
  GT_OTF[] = GS_OTFDATA-OTFDATA[].
*u2022 Convert the OTF DATA to SAP Script Text lines
  CLEAR GT_PDF_TAB.

  CALL FUNCTION 'CONVERT_OTF'
   EXPORTING
     FORMAT                      = 'PDF'
     MAX_LINEWIDTH               = 132
*   ARCHIVE_INDEX               = ' '
*   COPYNUMBER                  = 0
*   ASCII_BIDI_VIS2LOG          = ' '
*   PDF_DELETE_OTFTAB           = ' '
   IMPORTING
     BIN_FILESIZE                = GV_BIN_FILESIZE
*   BIN_FILE                    =
    TABLES
      OTF                         = GT_OTF
      LINES                       = GT_PDF_TAB
   EXCEPTIONS
     ERR_MAX_LINEWIDTH           = 1
     ERR_FORMAT                  = 2
     ERR_CONV_NOT_POSSIBLE       = 3
     ERR_BAD_OTF                 = 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.
Read only

0 Likes
1,465

Hi K.K,

Thanx for ur inputs.

I tried above method.Eventhough I was unable to open the pdf attachment in mail.

Following is my code

Data:it_otfdata TYPE STANDARD TABLE OF itcoo,

wa_otfdata LIKE LINE OF it_otfdata,

V_PDF_XSTRING TYPE XSTRING.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = bin_filesize

TABLES

otf = it_otfdata

lines = it_lines132

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

Later I used following functions also

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

TABLES

content_in = it_lines132

content_out = it_lines255

EXCEPTIONS

err_line_width_src_too_long = 1

err_line_width_dst_too_long = 2

err_conv_failed = 3

OTHERS = 4.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

BUFFER = V_PDF_XSTRING

TABLES

BINARY_TAB = it_otfdata.

But I am getting error message:Acrobat could not open pdf because it is either not a supported file type or because the file has been corrupted.

I am using following steps to send attachment through mail

document = cl_document_bcs=>create_document(

i_type = 'PDF'

i_hex = pdf_content

i_text = text

i_length = '12'

i_subject = 'Subject').

CALL METHOD send_request->edit(

i_hide_note = 'X'

i_starting_at_x = 12

i_starting_at_y = 5

i_ending_at_x = 97

i_ending_at_y = 22 ).

call method send_request->send.

Regards,

Sam

Edited by: sam24 on Sep 5, 2010 2:49 PM

Read only

0 Likes
1,465

u have to update your Acrobat version because of i also face same problem but when i update version i can able to open file

Edited by: kk.adhvaryu on Sep 6, 2010 7:46 AM

Read only

0 Likes
1,465

Hi K.K,

Presently I am using Acrobat 6.Which version I have to install for viewing this attachment.

In our organization,most of the users are using the same version.Isn't there any other alternative?

I tried opening the attachment in Acrobat 9 and was unsuccessful.

Regards,

Sam

Edited by: sam24 on Sep 6, 2010 8:35 AM

Read only

Former Member
0 Likes
1,465

First u use CALL FUNCTION 'CONVERT_OTF'

then after for send mail u use

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1 'that it no need other FM