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

convert internal table to file csv

former_member810309
Participant
0 Likes
2,892

hi all,

plz help.

i have an internal table (gt_data_scv) wich contains data separated by ' ; ' like :

1 Comp ; NFly ; Date ; Price ; TypePlane

2 AA ; 0017 ; 20220121 ; 422.12 ; 747-400

3 AA ; 0017 ; 20211230 ; 237 ; A319

...................

i want to convert this internal table to csv fil without download it, i'm using the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' after this.

hi all,

plz help.

i have an internal table (gt_data_scv) wich contains data separated by ' ; ' like :

1 Comp ; NFly ; Date ; Price ; TypePlane

2 AA ; 0017 ; 20220121 ; 422.12 ; 747-400

3 AA ; 0017 ; 20211230 ; 237 ; A319

...................

i want to convert this internal table to csv fil without download it, i'm using the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' after this.

6 REPLIES 6
Read only

Tukutupap
Participant
2,700

I feel you, its so hard when you come across something that nobody has ever done before and you cant find anything online. What a pain!

PS: checks this out.

Read only

0 Likes
2,700

all I find on the net is the conversion with download, my case is different. thank you for your help, glad you're here

Read only

thkolz
Contributor
2,700

Beside it's a standard ABAP problem, you should better use class to send your mail.
Here's one example method to send xstring data:

METHOD send_xstring_as_mail.

DATA:
r_request TYPE REF TO cl_bcs,
r_document TYPE REF TO cl_document_bcs,
t_file_content TYPE solix_tab,
t_att_head TYPE soli_tab,
v_text_line TYPE soli,
v_xstring_size TYPE so_obj_len.

TRY.
r_request = cl_bcs=>create_persistent( ).

v_xstring_size = xstrlen( i_xstring ).
t_file_content = cl_document_bcs=>xstring_to_solix( ip_xstring = i_xstring ).

r_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_subject = |{ sy-sysid }-{ sy-mandt }: { i_subject }|
i_text = it_mail_text
).

CONCATENATE '&SO_FILENAME=' i_file_name INTO v_text_line.
APPEND v_text_line TO t_att_head.

r_document->add_attachment(
EXPORTING
i_attachment_type = 'BIN'
i_attachment_subject = CONV so_obj_des( i_file_name )
i_attachment_size = v_xstring_size
i_att_content_hex = t_file_content
i_attachment_header = t_att_head
).

r_request->set_document( r_document ).

* Get mail recipient
DATA(t_receivers) = zcl_bc_util=>get_mail_receivers( i_repid ).

LOOP AT t_receivers ASSIGNING FIELD-SYMBOL(<fs_receivers>).

DATA(r_receiver) = cl_cam_address_bcs=>create_internet_address(
i_address_string = CONV ad_smtpadr( <fs_receivers>-receiver )
).

r_request->add_recipient( i_recipient = r_receiver ).

ENDLOOP.

DATA(v_result) = r_request->send( ).

IF i_do_commit EQ abap_true.
COMMIT WORK.
ENDIF.

CATCH cx_send_req_bcs
cx_document_bcs
cx_address_bcs INTO DATA(r_exc).

MESSAGE r_exc->get_text( ) TYPE 'E'.
ENDTRY.

ENDMETHOD.
    CLASS-METHODS send_xstring_as_mail
IMPORTING
!i_repid TYPE repid
!i_subject TYPE so_obj_des
!i_file_name TYPE string
!i_xstring TYPE xstring
!i_do_commit TYPE boole_d DEFAULT abap_true
!it_mail_text TYPE bcsy_text.
Read only

0 Likes
2,700

hi, thanks for your help
can i do it with the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' ?

Read only

matt
Active Contributor
2,700

chkoupi
SO_NEW_DOCUMENT_ATT_SEND_API1 is old, limited and hard to get working.

CL_BCS etc. are easy to use and have greater scope.

Use CL_BCS...

Read only

0 Likes
2,700

@Mathew

thanks you 🙂