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

Attachment in ABAP program

Former Member
0 Likes
679

Hi Everyone,

I want a program for attaching an excel sheet or word document in Tr Code qm03 .

Points would be awarded for suitable answers.

Its very urgent.

Thanks in advance

Srinivas

Hi Everyone,

I want a program for attaching an excel sheet or word document in Tr Code qm03 .

Points would be awarded for suitable answers.

Its very urgent.

Thanks in advance

Srinivas

2 REPLIES 2
Read only

Former Member
0 Likes
496

Hi,

You can use the FM in the FG SKWV_KWUI_DOCUMENT (provided by BASIS) to do so.

Best Regards,

Saurabh

Read only

Former Member
0 Likes
496

May be this code will help u to achieve the same. In this code I am uploading PDF file from presentation server and attaching it in lineitem level to GOS in FB02.

Similarly u can do the same for qm02 for a particular notification no.

&----


*& Report Z_GOS_DEMO_JG

*&

&----


*&

*&

&----


report z_gos_demo_jg.

type-pools:sbdst.

data: i_file type standard table of char134 initial size 0.

data: l_hstring(1022) type x.

data: l_cstring(255) type c.

data: w_file(134) type c.

data: wa_buffer type string.

data: l_classname type sbdst_classname.

data: i_component type sbdst_components.

data: w_component type bapicompon.

data: i_signature type sbdst_signature.

data: w_signature type bapisignat.

data: i_content type sbdst_content.

data: w_content type bapiconten.

data: l_file type string.

data: objkey type sbdst_object_key.

l_file = 'C:\TEST.PDF'.

field-symbols: <dummy>.

call method cl_gui_frontend_services=>gui_upload

exporting

filename = l_file

filetype = 'ASC'

  • has_field_separator = SPACE

  • header_length = 0

  • read_by_line = 'X'

  • dat_mode = SPACE

  • codepage = SPACE

  • ignore_cerr = ABAP_TRUE

  • replacement = '#'

  • virus_scan_profile =

  • IMPORTING

  • filelength =

  • header =

changing

data_tab = i_file

exceptions

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

not_supported_by_gui = 17

error_no_gui = 18

others = 19

.

if sy-subrc = 0.

loop at i_file into w_file.

*Replacing space by ~

translate w_file using '~'.

concatenate wa_buffer w_file into wa_buffer.

endloop.

*Replacing ~ by space

translate wa_buffer using '~'.

do.

l_cstring = wa_buffer.

assign l_cstring to <dummy> type 'X'.

check sy-subrc = 0.

move <dummy> to l_hstring.

  • APPENDing 255 Characters as a record

  • APPEND wa_record TO i_record.

move l_hstring to w_content-line.

append w_content to i_content.

shift wa_buffer left by 255 places.

  • SHIFT wa_buffer LEFT BY 1022 PLACES.

if wa_buffer is initial.

exit.

endif.

enddo.

endif.

l_classname = 'BSEG'.

objkey = '100000000018482007001'.

w_component-doc_count = 1.

w_component-comp_count = 1.

w_component-comp_id = '100000000018482007001'.

*W_COMPONENT-COMP_SIZE

select single mimetype from toadd into w_component-mimetype

where doc_type = 'PDF'.

append w_component to i_component.

w_signature-doc_count = 1.

  • W_SIGNATURE-DOC_ID = 'MESSAGE' .

w_signature-doc_ver_no = 2.

  • W_SIGNATURE-DOC_VAR_ID

  • W_SIGNATURE-DOC_VAR_TG

w_signature-comp_count = 1.

w_signature-prop_name = 'DESCRIPTION'.

w_signature-prop_value = 'FILE'.

append w_signature to i_signature.

call method cl_bds_document_set=>create_with_table

exporting

  • logical_system =

classname = l_classname

classtype = 'BO'

client = sy-mandt

components = i_component

content = i_content

changing

object_key = objkey

signature = i_signature

  • EXCEPTIONS

  • internal_error = 1

  • error_kpro = 2

  • parameter_error = 3

  • not_authorized = 4

  • not_allowed = 5

  • nothing_found = 6

  • others = 7

.

if sy-subrc = 0.

commit work.

endif.