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: 

issue with data populated in excel attachment

Former Member
0 Kudos

Hi Folks,

Im an emailing the report output as excel attachement. In the excel file, im getting only the header line and NOT the details, pls help me where im going wrong.

regds,

BG

7 REPLIES 7

Former Member
0 Kudos

Hello,

I think you need to post your code..then only the problem can be analyzed.

Thanks/Regards,

Himanshu

0 Kudos

hi pls find the code im using as below.

TYPES : BEGIN OF ty_output,

no(18) TYPE c,

soh(13) TYPE c,

qty(13) TYPE c,

matnr TYPE mara-matnr,

maktx TYPE makt-maktx,

labst TYPE mard-labst,

avl_qty TYPE bapicm61v-wkbst,

END OF ty_output.

DATA:

docdata LIKE sodocchgi1,

objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,

objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,

objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,

reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE,

tab_lines TYPE sy-tabix.

DATA: lv_labst(13) TYPE c,

lv_avl_qty(13) TYPE c,

t_output TYPE STANDARD TABLE OF ty_output,

wa_output LIKE LINE OF t_output.

CONSTANTS: con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,

con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.

  • Body

docdata-obj_name = 'Mail_Excel_File'.

docdata-obj_descr = 'Excel file attachment'.

objtxt = 'Attached is the sample Excel file'.

APPEND objtxt.

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.

docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).

CLEAR objpack-transf_bin.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'RAW'.

APPEND objpack.

  • Attachment

*i_data-a = 'Sample'.

*i_data-b = 'File'.

*CONCATENATE i_data-a i_data-b INTO objbin.

*APPEND objbin.

CONCATENATE 'NO 'SOH'

'QTY' 'MATNR ' 'MAKTX'

'LABST' 'AVL_QTY' INTO objbin SEPARATED BY con_tab.

CONCATENATE con_cret objbin INTO objbin.

APPEND objbinst.

CLEAR objbin.ut

wa_output-no = '123456'.

wa_output-soh = '39000'.

wa_output-qty = '39000'.

wa_output-matnr = '123-456'.

wa_output-maktx = 'test'.

lv_labst = '39,000'.

lv_avl_qty = '39,000'.

CONCATENATE wa_output-no wa_output-soh

wa_output-qty wa_output-matnr

wa_output-maktx lv_labst

lv_avl_qty

INTO objbin SEPARATED BY con_tab.

CONCATENATE con_cret objbin INTO objbin.

APPEND objbin.

CLEAR objbin.

DESCRIBE TABLE objbin LINES tab_lines.

objpack-doc_size = tab_lines * 255.

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'XLS'.

docdata-obj_name = 'Excel_File_Attachment'.

objpack-obj_descr = 'Excel File Attachment'.

APPEND objpack.

  • Create the list of recipients

reclist-receiver = mail address.

reclist-rec_type = 'U'.

reclist-express = 'X'.

APPEND reclist.

  • Send the e-mail

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = docdata

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = objpack

contents_bin = objbin

contents_txt = objtxt

receivers = 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.

COMMIT WORK.

0 Kudos

Hi

see the sampe program here http://www.erpgenie.com/sap/abap/code/abap58.htm

Prabhudas

0 Kudos

Hello,

By using exactly ur code, i am getting the data as well as the header in the excel. Just that the first row is coming to be blank

The data that i am getting in the attachment is:

NO SOH QTY MATNR MAKTX LABST AVL_QTY

123456 39000 39000 123-456 test 39,000 39,000

0 Kudos

oops! im not getting it.. what could be the problem?

0 Kudos

Hello,

I just made two corrections in the code which i think were typing errors:

Attachment

*i_data-a = 'Sample'.

*i_data-b = 'File'.

*CONCATENATE i_data-a i_data-b INTO objbin.

*APPEND objbin.

CONCATENATE 'NO 'SOH'

'QTY' 'MATNR ' 'MAKTX'

'LABST' 'AVL_QTY' INTO objbin SEPARATED BY con_tab.

CONCATENATE con_cret objbin INTO objbin.

APPEND objbinst. --> It should be objbin

CLEAR objbin.ut ---> it should again be just objbin

Rest all the code was same.

Dont know, can it be a version difference?? I am working on ECC6.0.. I dont think so but cant say about the same.

Regards,

Himanshu

Former Member
0 Kudos

Hi,

see the sample code in wiki attachment...

http://wiki.sdn.sap.com/wiki/display/Snippets/Howtosendreportoutputasscreenshotinthebodyofthe+mail

http://www.erpgenie.com/sap/abap/code/abap58.htm

Prabhudas