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: 

Internal table data send to SAP inbox,in '.CSV' file format.

Former Member
0 Kudos
667

Hi,

Please let me know, how we send the internal table data to SAP inbox in '.CSV' file format(as a attachment).

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
86

Hi,

    • Create Message Attachment

    • Write Packing List (Attachment)

DESCRIBE TABLE lt_objbin LINES l_tab_lines.

CLEAR lt_objbin.

READ TABLE lt_objbin INDEX l_tab_lines.

lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).

lt_objpack-transf_bin = 'X'.

lt_objpack-head_start = 1.

lt_objpack-head_num = 0.

lt_objpack-body_start = 1.

lt_objpack-body_num = l_tab_lines.

lt_objpack-doc_type = 'CSV'.

lt_objpack-obj_name = 'ATTACHMENT'.

lt_objpack-obj_descr = ws_subject. "'Detail List'. "#EC *

APPEND lt_objpack.

  • Send Message

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = ls_docdata

commit_work = 'X'

put_in_outbox = ''

TABLES

packing_list = lt_objpack

object_header = lt_objhead

contents_bin = lt_objbin "Data for attachment

contents_txt = lt_objtxt "Message body

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

Regards,

Subramanian

2 REPLIES 2

Former Member
0 Kudos
87

Hi,

    • Create Message Attachment

    • Write Packing List (Attachment)

DESCRIBE TABLE lt_objbin LINES l_tab_lines.

CLEAR lt_objbin.

READ TABLE lt_objbin INDEX l_tab_lines.

lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).

lt_objpack-transf_bin = 'X'.

lt_objpack-head_start = 1.

lt_objpack-head_num = 0.

lt_objpack-body_start = 1.

lt_objpack-body_num = l_tab_lines.

lt_objpack-doc_type = 'CSV'.

lt_objpack-obj_name = 'ATTACHMENT'.

lt_objpack-obj_descr = ws_subject. "'Detail List'. "#EC *

APPEND lt_objpack.

  • Send Message

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = ls_docdata

commit_work = 'X'

put_in_outbox = ''

TABLES

packing_list = lt_objpack

object_header = lt_objhead

contents_bin = lt_objbin "Data for attachment

contents_txt = lt_objtxt "Message body

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

Regards,

Subramanian

Former Member
0 Kudos
86

Try this FM:

FUNCTION Z_SEND_MAIL_FOR_SPOOLLIST.

*"----


""Local interface:

*" IMPORTING

*" REFERENCE(SPOOLNUMBER) LIKE SY-SPONO DEFAULT SY-SPONO

*" REFERENCE(MAILNAME) LIKE SOOD1-OBJNAM DEFAULT 'NOTE'

*" REFERENCE(SUBJECT) LIKE SOOD1-OBJDES

*" REFERENCE(RECEPIENT) LIKE SY-UNAME DEFAULT SY-UNAME

*" REFERENCE(DLI) LIKE SOOS1-DLINAM OPTIONAL

*" TABLES

*" TEXT STRUCTURE SOLI

*" EXCEPTIONS

*" ERROR

*"----


DATA: OBJECT_HD_CHANGE LIKE SOOD1 OCCURS 0 WITH HEADER LINE,

OBJPARA LIKE SELC OCCURS 0 WITH HEADER LINE,

RECEIVERS LIKE SOOS1 OCCURS 0 WITH HEADER LINE.

OBJECT_HD_CHANGE-OBJLA = SY-LANGU.

OBJECT_HD_CHANGE-OBJNAM = MAILNAME.

OBJECT_HD_CHANGE-OBJDES = SUBJECT.

OBJECT_HD_CHANGE-OBJSNS = 'F'.

OBJECT_HD_CHANGE-VMTYP = 'T'.

OBJECT_HD_CHANGE-SKIPS = 'X'.

OBJECT_HD_CHANGE-ACNAM = 'SP01'.

OBJECT_HD_CHANGE-OBJCP = 'X'.

OBJECT_HD_CHANGE-OBJPRI = '1'.

*OBJECT_HD_CHANGE-ACOUT = 'X'.

RECEIVERS-RCDAT = SY-DATUM.

RECEIVERS-RCTIM = SY-UZEIT.

IF DLI IS INITIAL.

RECEIVERS-RECNAM = RECEPIENT.

RECEIVERS-RTUNAM = RECEPIENT.

ELSE.

RECEIVERS-RECNAM = DLI.

RECEIVERS-ADR_NAME = DLI.

RECEIVERS-RECESC = 'C'.

ENDIF.

RECEIVERS-SNDEX = 'X'. " Express-Mail

*RECEIVERS-SNDPRI = 'X'.

move 'B' TO RECEIVERS-RECESC.

move '1' TO RECEIVERS-ACONE.

RECEIVERS-DELIVER = 'X'.

*RECEIVERS-NOT_DELI = 'X'.

RECEIVERS-READ = 'X'.

RECEIVERS-MAILSTATUS = 'E'.

APPEND RECEIVERS.

OBJPARA-NAME = 'SPI'.

OBJPARA-LOW = SPOOLNUMBER.

APPEND OBJPARA.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

OBJECT_HD_CHANGE = OBJECT_HD_CHANGE

OBJECT_TYPE = 'RAW'

OWNER = SY-UNAME

TABLES

OBJCONT = TEXT

OBJPARA = OBJPARA

RECEIVERS = RECEIVERS

EXCEPTIONS

OTHERS = 01.

IF SY-SUBRC NE 0.

  • RAISE ERROR.

ENDIF.

COMMIT WORK.

CALL FUNCTION 'SO_DEQUEUE_UPDATE_LOCKS'.

ENDFUNCTION.