cancel
Showing results for 
Search instead for 
Did you mean: 

How to send the generated spool to vendor

Former Member
0 Kudos

Hi Friends,

I have generated a Purchase order, its working fine and my new requirement is i want to send that spool dynamically to vendor i soon as i generate Purchase order.

Can any one help me.

Regards,

DVNS

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

How do you want to send it to the vendor? You can convert the spool request to PDF and mail it or directly send the PO as a PDF attachement to the vendor via e-mail or send it as a fax. The first option will have to be done programatically whereas the rest 2 can be achieved with the standard functionality.

Cheers!

Former Member
0 Kudos

Hi Anurag,

I want to send by email as pdf, programatically i have done that but i am not able to open that pdf file. I am getting error as file has damaged.

kindly help me,

Regards,

DVNS

Former Member
0 Kudos

Hi,

There might be a problem with the way you are creating the mail. If you are sending the mail to an external email id, and using FM SO_NEW_DOCUMENT_ATT_SEND_API1, while creating the parameter packing_list-doc_type, use value 'RAW' and not as 'PDF'. If you are sending to SAP inbox, then the required drivers might not be installed on your app server to open a PDF file.

Hope this solves your problem.

Cheers!

Former Member
0 Kudos

HI Anurag,

thanks for ur replay.

I am using doc_type, as 'RAW' it self

and i am testing it by giving receiver as my mail id. I am receiving that mail but not able to open that.

can u kindly suggest

Regards,

DVNS

Former Member
0 Kudos

Hi!

Find below the code that I used for a similar case. This works fine. Form convert_pdf is used to convert the spool to PDF and form pdf_attach_email to attach and send the mail. I think this is all I can provide.

A better option could be to use the std functionality by using transmission medium 5 for the output type and everything would be handled automatically.

FORM convert_pdf.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = gv_spool

no_dialog = ' '

IMPORTING

pdf_bytecount = gv_numbytes

pdf_spoolid = gv_pdfspoolid

btc_jobname = gv_jobname

btc_jobcount = gv_jobcount

TABLES

pdf = gt_pdf.

ENDFORM. " CONVERT_PDF

*----


FORM pdf_attach_email.

  • Title and Description

CLEAR gs_docdata.

gs_docdata-obj_name = 'Delivery Advice'(005).

  • Subject of the email

gs_docdata-obj_descr = 'Subject Delivery Advice'(004).

gs_docdata-obj_prio = 1.

CLEAR gt_objbin.

REFRESH gt_objbin.

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = gt_pdf

t_target_tab = gt_objbin.

  • Filling the contents into internal table obtxt,

*whose contents will be displayed as the body of email

DESCRIBE TABLE gt_objbin LINES gv_lin1.

IF gv_lin1 GT 0.

gt_objtxt-line = 'General shipment Details'(003).

APPEND gt_objtxt.

CLEAR gt_objtxt.

ENDIF.

DESCRIBE TABLE gt_objtxt LINES gv_tab_lines.

  • creation of the entry for the compressed document

CLEAR gt_objpack.

gt_objpack-transf_bin = ' ' .

gt_objpack-head_start = 1.

gt_objpack-head_num = 0.

gt_objpack-body_start = 1.

gt_objpack-body_num = gv_tab_lines.

gt_objpack-doc_type = 'RAW'.

gt_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gt_objtxt ).

APPEND gt_objpack.

  • creation of the entry for the attachment

DESCRIBE TABLE gt_objbin LINES gv_tab_lines.

CLEAR gt_objpack.

gt_objpack-transf_bin = 'X'.

gt_objpack-head_start = 1.

gt_objpack-head_num = 1.

gt_objpack-body_start = 1.

gt_objpack-body_num = gv_tab_lines.

gt_objpack-doc_type = 'RAW'. "Added RFC 43845

CONCATENATE 'Document'(002) '.PDF' INTO gt_objpack-obj_name.

gt_objpack-obj_descr = gt_objpack-obj_name.

gt_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gt_objbin ).

APPEND gt_objpack.

DESCRIBE TABLE gt_objtxt LINES gv_tab_lines.

  • Calculating doc. size which is email

gs_docdata-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gt_objbin ).

*creating the Recipients list which are to be emailed

CLEAR wa_reclist.

REFRESH gt_reclist.

SELECT adrnr FROM kna1 INTO kna1-adrnr up to 1 rows

WHERE kunnr = likp-kunnr.

endselect.

if sy-subrc eq 0.

SELECT smtp_addr FROM adr6 INTO adr6-smtp_addr up to 1 rows

WHERE addrnumber = kna1-adrnr.

endselect.

if sy-subrc eq 0.

WA_RECLIST-RECEIVER = adr6-SMTP_ADDR.

endif.

endif.

wa_reclist-rec_type = 'U'.

wa_reclist-copy = ''.

wa_reclist-blind_copy = ''.

APPEND wa_reclist TO gt_reclist.

CLEAR wa_reclist.

  • Mail is sent using the below called F.M.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gs_docdata

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = gt_objpack

contents_bin = gt_objbin

contents_txt = gt_objtxt

receivers = gt_reclist.

ENDFORM. " pDF_ATTACH_EMAIL