on 03-21-2014 9:33 AM
HI,
I am trying to upload a png file (Proof of Delievery) through BAPI_EH_ADDEVENTMSG02.
Can someone kindly provide a sample example, what to fill in the tables TRACKFILEHEADER and TRACKFILEBIN to upload the signature.png from my system. Also Kindly suggest how to get the binary data from png file.
Thanks in advance:)
Hi Ratnakar,
you could look into class:
/SAPTRX/CL_TPEN_REQUEST_IMPL
Method:
PROCESS_ATTACHMENT
In this method the data for attachments coming from an ESA service is mapped to the Event Message BAPI.
FM:
SCMS_XSTRING_TO_BINARY
is used to convert XSTRING to binary data.
Best regards,
Steffen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ratnakar,
you can find more about the services in note 1124226.
But this service is just a wrapper for /SAPTRX/BAPI_EH_ADDEVENTMSG02.
So it will already sent a message and not just give you back the TRACKFILEHEADER and TRACKFILEBIN tables.
It depends from where you want to send the file attachment.
From extern you could use the service.
Best regards,
Steffen
Hi,
to upload a file from your PC and test it you can use.
In the Selection screen enter an existing Tacking Code Set and Tracking ID and choose your local file e.g. picture
REPORT Z_FILE_ATTACH.
* type declaration for bin and asc
types: begin of zzfilebin,
line type raw255,
end of zzfilebin.
types: begin of zzfileasc,
line type char255,
end of zzfileasc.
* Selection screen for event message information
parameters:
* Internal Event Code
p_evtid type /saptrx/ev_evtid,
* Tracking Code Set
p_trcod type /saptrx/trxcod,
* Tracking ID
p_trxid type /saptrx/trxid,
* Path to file
p_fnup type text100 default 'C:\test.jpg',
* File type (BIN or ASC)
p_ftyp type char10 default 'BIN',
p_hlen type i default '0'.
* data declaration
data:
lt_hdr type /saptrx/bapi_hdr_tabtyp,
lt_afh type /saptrx/bapi_afh_tabtyp,
lt_afb type /saptrx/bapi_afb_tabtyp,
lt_afc type /saptrx/bapi_afc_tabtyp,
lt_return type table of bapiret2,
ls_hdr like line of lt_hdr,
ls_afh like line of lt_afh,
ls_afb like line of lt_afb,
ls_afc like line of lt_afc,
lv_tst type tzntstmps,
lv_synch_flag type /saptrx/synchronous_flag value 'X',
ld_filename_up type string,
ld_filename_up2 type text100 ,
ld_filename_down type string,
ld_filelength_up type i,
ld_filelength_down type i,
lt_tabfil_bin type table of zzfilebin,
lt_tabfil_asc type table of zzfileasc,
ls_tabfil_bin like line of lt_tabfil_bin,
ls_tabfil_asc like line of lt_tabfil_asc,
lv_numlines type i,
lv_mod_numlines type i,
l_tempstring type string.
ld_filename_up = p_fnup.
* uploads file from PC harddisk
if p_ftyp = 'BIN'.
call function 'GUI_UPLOAD'
exporting
filename = ld_filename_up
* FILETYPE = 'ASC'
filetype = p_ftyp
* HAS_FIELD_SEPARATOR = 'X'
header_length = p_hlen
importing
filelength = ld_filelength_up
* HEADER =
tables
data_tab = lt_tabfil_bin
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
others = 17.
if sy-subrc <> 0.
message s398(00) with
'GUI_UPLOAD failed'
'SUBRC =' sy-subrc ''.
exit.
else.
message s398(00) with 'Upload ok:'
ld_filename_up 'Bytes:' ld_filelength_up.
endif.
else.
* TEXT FILE
call function 'GUI_UPLOAD'
exporting
filename = ld_filename_up
* FILETYPE = 'ASC'
filetype = p_ftyp
* HAS_FIELD_SEPARATOR = 'X'
header_length = p_hlen
importing
filelength = ld_filelength_up
* HEADER =
tables
data_tab = lt_tabfil_asc
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
others = 17.
if sy-subrc <> 0.
message s398(00) with
'GUI_UPLOAD failed'
'SUBRC =' sy-subrc ''.
exit.
else.
message s398(00) with 'Upload ok:'
ld_filename_up 'Bytes:' ld_filelength_up.
endif.
endif.
*** fill tables: header + file info
* header
ls_hdr-evtcnt = '1' .
ls_hdr-evtid = p_evtid.
ls_hdr-trxcod = p_trcod.
ls_hdr-trxid = p_trxid.
ls_hdr-evtdat = sy-datlo.
ls_hdr-evttim = sy-timlo.
ls_hdr-sndcod = 'US'.
ls_hdr-sndid = 'SENDER'.
ls_hdr-evttst = lv_tst.
append ls_hdr to lt_hdr .
* FILE
* Numlines
lv_mod_numlines = ld_filelength_up mod 255.
if lv_mod_numlines = 0.
lv_numlines = ld_filelength_up div 255.
else.
lv_numlines = ( ld_filelength_up div 255 ) + 1.
endif.
ls_afh-filename = 'picture.jpg'.
ls_afh-evtcnt = '1'.
ls_afh-fileclass = 'BIN'.
ls_afh-mimetype = 'application/postscript'.
*ls_afh-qualifier_code = 'DSIGN'.
*ls_afh-qualifier_text = 'Picture'.
ls_afh-filesize = ld_filelength_up.
ls_afh-numlines = lv_numlines.
append ls_afh to lt_afh .
if p_ftyp = 'BIN'.
* FILE IS BINARY: converts table in RAWstring
loop at lt_tabfil_bin into ls_tabfil_bin.
* save current string
ls_afb-evtcnt = '1'.
ls_afb-filename = 'picture.jpg'.
ls_afb-line = ls_tabfil_bin-line.
ls_afb-line_counter = sy-tabix.
append ls_afb to lt_afb.
endloop.
call function '/SAPTRX/BAPI_EH_ADDEVENTMSG_02'
exporting
synchronous = lv_synch_flag
tables
trackingheader = lt_hdr
trackfileheader = lt_afh
trackfilebin = lt_afb
return = lt_return.
else.
* FILE IS TEXT
loop at lt_tabfil_asc into ls_tabfil_asc.
* save current string
ls_afc-evtcnt = '1'.
ls_afc-filename = 'text.txt'.
ls_afc-line = ls_tabfil_asc-line.
ls_afc-line_counter = sy-tabix.
append ls_afc to lt_afc.
endloop.
call function '/SAPTRX/BAPI_EH_ADDEVENTMSG_02'
exporting
synchronous = lv_synch_flag
tables
trackingheader = lt_hdr
trackfileheader = lt_afh
trackfilechar = lt_afc
return = lt_return.
endif.
call function 'BAPI_TRANSACTION_COMMIT'.
User | Count |
---|---|
8 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.