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

Regarding sales order print program

sreeramkumar_madisetty
Active Contributor
0 Likes
416

Hi Folks

I have the below requirement:

I am having the script for sales order and concerned print program( RVADOR01 )as well.

With the current print program mail is sending to the concerned customer by configuring the output type as "External send" at nace transaction code.

Now the requirement is:

The result has to be converted to the PDF format and to be send not only to the customer but also to the 4 hard coded persons(Email of the persons are given).

So can you please kindly suggest me where exactly I have to change the code in standard program.

If you send me the code, it will be a great help for me.

Points are surely given for correct and accurate answers.

    • <b>I need complete procedure so please don't suggest me the Function Modules to convert into PDF like that...This is my sincere request.</b>

thanks in advance.

Regards,

Sreeram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
381

Hi Sreeram,

I can give better answer of your queries. First you use mentioned below codes in the driver program of RVADOR01.

&----


*& Report Z_MAIL_SEND

*

*&

*

&----


*&

*

*&

*

&----


REPORT z_mail_send .

    • Spool request

PARAMETERS:

spoolno LIKE tsp01-rqident,

ebeln LIKE ekko-ebeln.

    • Spool to PDF data

DATA: numbytes TYPE i,

pdfspoolid LIKE tsp01-rqident,

jobname LIKE tbtcjob-jobname,

jobcount LIKE tbtcjob-jobcount,

p_frgab type t161f-frgab.

DATA: submit_return_code TYPE sy-subrc.

DATA: memory_id(10)." LIKE itcpp-tdspoolid.

    • Download data

DATA i_pdf LIKE tline OCCURS 100 WITH HEADER LINE.

DATA otf LIKE itcoo OCCURS 1000 WITH HEADER LINE.

DATA lines LIKE tline OCCURS 100 WITH HEADER LINE.

DATA: filesize TYPE i VALUE '8866',

fullpath TYPE string

VALUE 'C:\purchase.pdf'.

DATA : s_otf_tab TYPE soli,

otf_tab TYPE soli OCCURS 0,

gd_buffer TYPE string.

    • Send mail data

DATA: document_data LIKE sodocchgi1,

contents_txt LIKE solisti1 OCCURS 0 WITH HEADER LINE.

  • it_mess_att LIKE SOLIx OCCURS 0 WITH HEADER LINE,

DATA: it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,

count TYPE i,

objbin TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,

objhead TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE.

DATA: objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

  • object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,

reclist TYPE STANDARD TABLE OF somlreci1 WITH HEADER LINE.

DATA tdspoolid TYPE itcpp-tdspoolid.

START-OF-SELECTION.

IMPORT tdspoolid FROM MEMORY ID 'memory_id1'.

import p_frgab from memory id 'memory_id4'.

spoolno = tdspoolid.

PERFORM convert_to_pdf.

PERFORM download_pdf.

PERFORM send_mail.

&----


*& Form convert_to_pdf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM convert_to_pdf .

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = spoolno

no_dialog = ' '

  • DST_DEVICE = 'PDF1'

  • PDF_DESTINATION =

IMPORTING

pdf_bytecount = numbytes

pdf_spoolid = pdfspoolid

  • OTF_PAGECOUNT =

btc_jobname = jobname

btc_jobcount = jobcount

TABLES

pdf = i_pdf

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.

CASE sy-subrc.

  • WHEN 0.

  • WRITE: / 'Converted OTF to PDF successfully'(001)

  • COLOR COL_POSITIVE.

WHEN OTHERS.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDCASE.

LOOP AT i_pdf .

s_otf_tab-line = i_pdf-tdline.

APPEND s_otf_tab TO otf_tab .

ENDLOOP.

DESCRIBE TABLE i_pdf LINES count.

LOOP AT i_pdf.

TRANSLATE i_pdf USING ' ~'.

CONCATENATE gd_buffer i_pdf INTO gd_buffer.

ENDLOOP.

TRANSLATE gd_buffer USING '~ '.

DO.

it_mess_att = gd_buffer.

APPEND it_mess_att.

SHIFT gd_buffer LEFT BY 255 PLACES.

IF gd_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

ENDFORM. " convert_to_pdf

&----


*& Form download_pdf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM download_pdf .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = filesize

filename = fullpath

filetype = 'BIN'

  • APPEND = ' '

  • CODEPAGE = ' '

  • NO_BYTEORDER_MARK = ' '

  • IMPORTING

  • FILELENGTH = c

TABLES

data_tab = i_pdf

  • FORMAT_TAB =

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6.

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. " download_pdf

&----


*& Form send_mail

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM send_mail .

  • Sends PDF to external Mail

document_data-obj_name = 'Credit Note-MRL'.

document_data-obj_descr =

'Warranty Credit Note - Mahindra Renault Ltd. Automotive Sector.'.

  • Append the body of the mail

CONCATENATE 'Attention: '

'Enclosed is a PDF copy of the Realease Note of PR'

INTO contents_txt.

APPEND contents_txt.

contents_txt = ''.

APPEND contents_txt.

  • objtxt = 'Enclosed is a PDF copy of the Credit Note .'.

  • APPEND objtxt.

CONCATENATE 'Credit Note number is: ' ebeln INTO contents_txt.

APPEND contents_txt.

contents_txt = ''.

APPEND contents_txt.

contents_txt = ''.

APPEND contents_txt.

DESCRIBE TABLE contents_txt LINES count.

READ TABLE contents_txt INDEX count.

document_data-doc_size = ( count - 1 ) * 255 + STRLEN( contents_txt )

.

  • Creation of the entry for the compressed document

objpack-transf_bin = space.

objpack-head_start = 1.

objpack-head_num = 4.

objpack-body_start = 1.

objpack-body_num = count.

objpack-doc_type = 'RAW'.

APPEND objpack.

LOOP AT it_mess_att .

objbin-line = it_mess_att.

APPEND objbin.

ENDLOOP.

DESCRIBE TABLE objbin LINES count.

objhead = 'PR.txt'.

APPEND objhead.

  • Creation of the entry for the compressed attachment

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-body_num = count.

objpack-doc_type = 'PDF'.

CONCATENATE 'IV' ebeln INTO objpack-obj_name.

CONCATENATE 'MRL Credit Note - ' ebeln INTO objpack-obj_descr.

objpack-doc_size = count * 255.

APPEND objpack.

  • Completing the recipient list - Internet User

if P_FRGAB = 'S1' OR P_FRGAB = 'R1'.

reclist-receiver = 'namjoshi.satish@mahindra.com'.

ELSE.

RECLIST-RECEIVER = 'namjoshi.satish@mahindra.com'.

endif.

reclist-rec_type = 'U'.

reclist-com_type = ' '.

APPEND reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = document_data

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = objpack

object_header = objhead

contents_bin = it_mess_att

contents_txt = contents_txt

receivers = reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

ENDFORM. " send_mail

If you have any further queries please ask me.

Please don't forget to give reward points for each query.

Thanks and Regards,

Rohan

Message was edited by:

Rohan Kumar

2 REPLIES 2
Read only

Former Member
0 Likes
382

Hi Sreeram,

I can give better answer of your queries. First you use mentioned below codes in the driver program of RVADOR01.

&----


*& Report Z_MAIL_SEND

*

*&

*

&----


*&

*

*&

*

&----


REPORT z_mail_send .

    • Spool request

PARAMETERS:

spoolno LIKE tsp01-rqident,

ebeln LIKE ekko-ebeln.

    • Spool to PDF data

DATA: numbytes TYPE i,

pdfspoolid LIKE tsp01-rqident,

jobname LIKE tbtcjob-jobname,

jobcount LIKE tbtcjob-jobcount,

p_frgab type t161f-frgab.

DATA: submit_return_code TYPE sy-subrc.

DATA: memory_id(10)." LIKE itcpp-tdspoolid.

    • Download data

DATA i_pdf LIKE tline OCCURS 100 WITH HEADER LINE.

DATA otf LIKE itcoo OCCURS 1000 WITH HEADER LINE.

DATA lines LIKE tline OCCURS 100 WITH HEADER LINE.

DATA: filesize TYPE i VALUE '8866',

fullpath TYPE string

VALUE 'C:\purchase.pdf'.

DATA : s_otf_tab TYPE soli,

otf_tab TYPE soli OCCURS 0,

gd_buffer TYPE string.

    • Send mail data

DATA: document_data LIKE sodocchgi1,

contents_txt LIKE solisti1 OCCURS 0 WITH HEADER LINE.

  • it_mess_att LIKE SOLIx OCCURS 0 WITH HEADER LINE,

DATA: it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,

count TYPE i,

objbin TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,

objhead TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE.

DATA: objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

  • object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,

reclist TYPE STANDARD TABLE OF somlreci1 WITH HEADER LINE.

DATA tdspoolid TYPE itcpp-tdspoolid.

START-OF-SELECTION.

IMPORT tdspoolid FROM MEMORY ID 'memory_id1'.

import p_frgab from memory id 'memory_id4'.

spoolno = tdspoolid.

PERFORM convert_to_pdf.

PERFORM download_pdf.

PERFORM send_mail.

&----


*& Form convert_to_pdf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM convert_to_pdf .

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = spoolno

no_dialog = ' '

  • DST_DEVICE = 'PDF1'

  • PDF_DESTINATION =

IMPORTING

pdf_bytecount = numbytes

pdf_spoolid = pdfspoolid

  • OTF_PAGECOUNT =

btc_jobname = jobname

btc_jobcount = jobcount

TABLES

pdf = i_pdf

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.

CASE sy-subrc.

  • WHEN 0.

  • WRITE: / 'Converted OTF to PDF successfully'(001)

  • COLOR COL_POSITIVE.

WHEN OTHERS.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDCASE.

LOOP AT i_pdf .

s_otf_tab-line = i_pdf-tdline.

APPEND s_otf_tab TO otf_tab .

ENDLOOP.

DESCRIBE TABLE i_pdf LINES count.

LOOP AT i_pdf.

TRANSLATE i_pdf USING ' ~'.

CONCATENATE gd_buffer i_pdf INTO gd_buffer.

ENDLOOP.

TRANSLATE gd_buffer USING '~ '.

DO.

it_mess_att = gd_buffer.

APPEND it_mess_att.

SHIFT gd_buffer LEFT BY 255 PLACES.

IF gd_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

ENDFORM. " convert_to_pdf

&----


*& Form download_pdf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM download_pdf .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = filesize

filename = fullpath

filetype = 'BIN'

  • APPEND = ' '

  • CODEPAGE = ' '

  • NO_BYTEORDER_MARK = ' '

  • IMPORTING

  • FILELENGTH = c

TABLES

data_tab = i_pdf

  • FORMAT_TAB =

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6.

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. " download_pdf

&----


*& Form send_mail

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM send_mail .

  • Sends PDF to external Mail

document_data-obj_name = 'Credit Note-MRL'.

document_data-obj_descr =

'Warranty Credit Note - Mahindra Renault Ltd. Automotive Sector.'.

  • Append the body of the mail

CONCATENATE 'Attention: '

'Enclosed is a PDF copy of the Realease Note of PR'

INTO contents_txt.

APPEND contents_txt.

contents_txt = ''.

APPEND contents_txt.

  • objtxt = 'Enclosed is a PDF copy of the Credit Note .'.

  • APPEND objtxt.

CONCATENATE 'Credit Note number is: ' ebeln INTO contents_txt.

APPEND contents_txt.

contents_txt = ''.

APPEND contents_txt.

contents_txt = ''.

APPEND contents_txt.

DESCRIBE TABLE contents_txt LINES count.

READ TABLE contents_txt INDEX count.

document_data-doc_size = ( count - 1 ) * 255 + STRLEN( contents_txt )

.

  • Creation of the entry for the compressed document

objpack-transf_bin = space.

objpack-head_start = 1.

objpack-head_num = 4.

objpack-body_start = 1.

objpack-body_num = count.

objpack-doc_type = 'RAW'.

APPEND objpack.

LOOP AT it_mess_att .

objbin-line = it_mess_att.

APPEND objbin.

ENDLOOP.

DESCRIBE TABLE objbin LINES count.

objhead = 'PR.txt'.

APPEND objhead.

  • Creation of the entry for the compressed attachment

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-body_num = count.

objpack-doc_type = 'PDF'.

CONCATENATE 'IV' ebeln INTO objpack-obj_name.

CONCATENATE 'MRL Credit Note - ' ebeln INTO objpack-obj_descr.

objpack-doc_size = count * 255.

APPEND objpack.

  • Completing the recipient list - Internet User

if P_FRGAB = 'S1' OR P_FRGAB = 'R1'.

reclist-receiver = 'namjoshi.satish@mahindra.com'.

ELSE.

RECLIST-RECEIVER = 'namjoshi.satish@mahindra.com'.

endif.

reclist-rec_type = 'U'.

reclist-com_type = ' '.

APPEND reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = document_data

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = objpack

object_header = objhead

contents_bin = it_mess_att

contents_txt = contents_txt

receivers = reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

ENDFORM. " send_mail

If you have any further queries please ask me.

Please don't forget to give reward points for each query.

Thanks and Regards,

Rohan

Message was edited by:

Rohan Kumar

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
381

Hi

It's Answered.