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

Problem with FB SO_DOCUMENT_SEND_API1

Former Member
0 Likes
1,520

Dear experts,

I try to sent a content of an internal table as an attached CSV-File in the email.

It works so far, but for some reason the content of the email body is the same as the content of the attached file even I refer the total different table as parameter for email body:

CSV-Content:

Email-Body:

Here is the code I made:

DATA: wa_docdata TYPE sodocchgi1,

         wa_objpack TYPE sopcklsti1 ,

         ta_objpack TYPE STANDARD TABLE OF sopcklsti1,

         wa_objtxt  TYPE solisti1,

         ta_objtxt  TYPE STANDARD TABLE OF solisti1,

         wa_reclist TYPE somlreci1,

         ta_reclist TYPE STANDARD TABLE OF somlreci1,

         wa_contents_bin TYPE solisti1,

         ta_contents_bin TYPE STANDARD TABLE OF solisti1,

         v_row TYPE so_text255,

         v_tablines_mail TYPE i,

         v_descript(255) TYPE c,

         wa_objhead TYPE solisti1,

         ta_objhead TYPE STANDARD TABLE OF solisti1,

         ta_zta_pfmaillist TYPE STANDARD TABLE OF zta_pfmaillist,

         wa_zta_pfmaillist LIKE LINE OF ta_zta_pfmaillist.

   wa_objtxt = 'Sehr geehrte Damen und Herren,'.

   APPEND wa_objtxt TO ta_objtxt.

   wa_objtxt = 'anbei finden Sie die Verzollungsdatei für die Schweiz:'.

   APPEND wa_objtxt TO ta_objtxt.

   CONCATENATE 'Lieferant:' wa_vstel-vstel wa_vstel-vtext

     INTO wa_objtxt.

   APPEND wa_objtxt TO ta_objtxt.

   wa_objtxt = 'Mit freundlichen Grüßen.'.

   APPEND wa_objtxt TO ta_objtxt.

   wa_objtxt = 'Ihr Manufactum Tem.'.

   APPEND wa_objtxt TO ta_objtxt.

   DESCRIBE TABLE ta_objtxt LINES v_tablines_mail.

   READ TABLE ta_objtxt

     INTO wa_objtxt

       INDEX v_tablines_mail.

clear ta_reclist.

   SELECT *

   FROM zta_pfmaillist

   INTO CORRESPONDING FIELDS OF TABLE ta_zta_pfmaillist.

   LOOP AT ta_ZTA_PFMAILLIST

     INTO wa_zta_pfmaillist.

     loop at ta_reclist into wa_reclist.

     move wa_zta_pfmaillist-receiver to wa_reclist-receiver.

     move wa_zta_pfmaillist-rec_type to wa_reclist-receiver.

     APPEND wa_reclist TO ta_reclist.

     endloop.

   ENDLOOP.

   v_descript = 'Pflanzenversand Zoll-Datei'.

   wa_docdata-obj_name  = v_attach_name.

   wa_docdata-obj_descr = v_descript.

   wa_docdata-obj_langu = sy-langu.

   wa_docdata-obj_sort = sy-datum.

   wa_docdata-obj_expdat = sy-datum + 30.

   wa_docdata-sensitivty = 'O'.

   wa_docdata-obj_prio   = '1'.

   wa_docdata-no_change  = 'X'.

   wa_docdata-proc_type  = 'T'.

   wa_docdata-proc_name  = 'SP01'.

   wa_docdata-proc_syst  = sy-sysid.

   wa_docdata-proc_clint = sy-mandt.

   wa_docdata-skip_scren = ' '.

   wa_docdata-to_do_out  = ' '.

   wa_docdata-free_del   = ' '.

   wa_docdata-doc_size   = ( v_tablines_mail - 1 ) * 255 + strlen( wa_objtxt ).

   wa_objpack-transf_bin = 'X'.

   wa_objpack-head_start = 1.

   wa_objpack-head_num = 1.

   wa_objpack-body_start = 1.

   wa_objpack-doc_type = 'RAW'.

   wa_objpack-body_num = v_tablines_mail.

   CONCATENATE v_attach_name '.csv'

     INTO wa_objpack-obj_name.

   CONCATENATE v_attach_name '.csv'

     INTO wa_objpack-obj_descr.

   APPEND wa_objpack TO ta_objpack.

   wa_objpack-doc_size = v_tablines_mail * 255.

   APPEND wa_objpack TO ta_objpack.

   wa_objhead = v_descript.

   APPEND wa_objhead TO ta_objhead.

   LOOP AT ta_ausgabe

     INTO wa_ausgabe.

     v_row = wa_ausgabe-fkimg.

     CONDENSE v_row.

     CONCATENATE wa_ausgabe-fkdat

                 v_row

                 wa_ausgabe-maktx

                 wa_ausgabe-matnr

                 wa_ausgabe-vbeln

                 wa_ausgabe-vkorg_auft

                 wa_ausgabe-vrkme

                " wa_ausgabe-vstel

                 INTO v_row SEPARATED BY ';'.

     CONCATENATE v_row wa_ausgabe-vstel INTO v_row.

     MOVE v_row TO wa_contents_bin.

     APPEND wa_contents_bin TO ta_contents_bin.

   ENDLOOP.

   CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

     EXPORTING

       document_data              = wa_docdata

       put_in_outbox              = 'X'

       commit_work                = 'X'

     TABLES

       object_header              = ta_objhead

       packing_list               = ta_objpack

       contents_bin               = ta_contents_bin

       contents_txt               = ta_objtxt

       receivers                  = ta_reclist

     EXCEPTIONS

       too_many_receivers         = 1

       document_not_sent          = 2

       document_type_not_exist    = 3

       operation_no_authorization = 4

       parameter_error            = 5

       x_error                    = 6

       enqueue_error              = 7

       OTHERS                     = 8.

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.

What can be areason for this?

BR

Denis

1 ACCEPTED SOLUTION
Read only

FredericGirod
Active Contributor
0 Likes
1,395

Hi,

please stop using this function module, and used the Oo method

http://scn.sap.com/docs/DOC-42070

regards

Fred

5 REPLIES 5
Read only

FredericGirod
Active Contributor
0 Likes
1,396

Hi,

please stop using this function module, and used the Oo method

http://scn.sap.com/docs/DOC-42070

regards

Fred

Read only

0 Likes
1,395

Hi Fred,

Thank you very much for the tipp, this method is much better than FB.

But in example you send the file should be uploaded manually an I need to sent the content of my internal table as a CSV-File.

Could you give a tipp in this case?

Regards


Denis

Read only

0 Likes
1,395

A CSV file is only a separated by ";" file. You will have to concatenate each column of the internal table separated by ";"  that's all

Fred

Read only

0 Likes
1,394

Yes, I know and i already did it:

LOOP AT ta_ausgabe

      INTO wa_ausgabe.

     v_menge = wa_ausgabe-fkimg.

     CONDENSE v_menge.

     CONCATENATE wa_ausgabe-vstel

                 wa_ausgabe-vkorg_auft

                 wa_ausgabe-fkdat

                 wa_ausgabe-matnr

                 wa_ausgabe-maktx

                 v_menge

                 INTO v_row SEPARATED BY ';'.

     CONCATENATE v_row wa_ausgabe-vrkme INTO v_row

     SEPARATED BY ';'.

     MOVE v_row TO wa_uebergabe.

     APPEND wa_uebergabe TO ta_uebergabe.

   ENDLOOP.


And don't use method  file_open_dialog but only  gui_upload:

CALL METHOD cl_gui_frontend_services=>gui_upload

     EXPORTING

       filename   = v_attach_name

       filetype   = 'BIN'

     IMPORTING

       filelength = v_length

    CHANGING

       data_tab   = ta_uebergabe

     EXCEPTIONS

       OTHERS     = 19.


But the attached file is still empty....


my internal table TA_UEBERGABE looks like this:

Read only

Former Member
0 Likes
1,394

Hi Denis,

you should add below code:

  wa_objtxt = 'Sehr geehrte Damen und Herren,'.

   APPEND wa_objtxt TO ta_objtxt.

   wa_objtxt = 'anbei finden Sie die Verzollungsdatei für die Schweiz:'.

   APPEND wa_objtxt TO ta_objtxt.

   CONCATENATE 'Lieferant:' wa_vstel-vstel wa_vstel-vtext

     INTO wa_objtxt.

   APPEND wa_objtxt TO ta_objtxt.

   wa_objtxt = 'Mit freundlichen Grüßen.'.

   APPEND wa_objtxt TO ta_objtxt.

   wa_objtxt = 'Ihr Manufactum Tem.'.

   APPEND wa_objtxt TO ta_objtxt.

* start like this*

CLEAR ltb_objtxt.

  DESCRIBE TABLE ltb_objtxt LINES lw_tab_lines.

  IF lw_tab_lines GT 0.

    READ TABLE ltb_objtxt INDEX lw_tab_lines.

    lwa_doc_chng-doc_size =

    ( lw_tab_lines - 1 ) * 255 + STRLEN( ltb_objtxt ).

    CLEAR ltb_objpack-transf_bin.

    ltb_objpack-body_start = 1.

    ltb_objpack-body_num = lw_tab_lines.

    ltb_objpack-doc_type = 'RAW'.

    APPEND ltb_objpack.

  ENDIF.  

* end *


Means you have two park list in 'ta_objpack' table.Refer this link in from 'f_send_pdf_by_email ',

Smartform Send via Email - ABAP Development - SCN Wiki


Anyway, prefer do as Fred said.


regards,

Archer