10-02-2008 12:40 PM
Dear All,
Scenario: We have a customer invoice with an invoice number.
We need to develop a program in which the user will enter the invoice number on the screen and in the next field will give the path of the scanned document of the same customer invoice.
This docuement needs to be stored in SAP agaisnt this invoce number and later can also be retrieved from another program or we can use the same by giving the invoice number.
Regards,
Fawaz
10-02-2008 12:44 PM
10-02-2008 12:57 PM
Hi Himanshu,
Actally I am looking for a function module which i can use in my prog which will be executed by the end users regularly to upload and download files to Application server and not a one time upload....using SE78.
Thanks & Regards,
Fawaz
10-02-2008 12:58 PM
Ok, you can make a program that automatically inserts your image files into SAP system without going to se78 manually.
Check this commented example:
0 - Data declaration
TYPE-POOLS: sbdst.
DATA: bds_object TYPE REF TO cl_bds_document_set,
bds_components TYPE sbdst_components,
wa_bds_components TYPE LINE OF sbdst_components,
bds_signature TYPE sbdst_signature,
wa_bds_signature TYPE LINE OF sbdst_signature,
bds_properties TYPE sbdst_properties,
wa_bds_properties TYPE LINE OF sbdst_properties,
wa_stxbitmaps TYPE stxbitmaps,
BEGIN OF bitmap OCCURS 0,
l(64) TYPE x,
END OF bitmap,
bytecount TYPE i,
dpi TYPE stxbitmaps-resolution,
bds_bytecount TYPE i,
width_tw TYPE stxbitmaps-widthtw,
height_tw TYPE stxbitmaps-heighttw,
width_pix TYPE stxbitmaps-widthpix,
height_pix TYPE stxbitmaps-heightpix,
bds_content TYPE sbdst_content,
docid TYPE stxbitmaps-docid.
1 - Lock graphics
CALL FUNCTION 'ENQUEUE_ESSGRABDS'
EXPORTING
tdobject = 'GRAPHICS'
tdname = nome
tdid = 'BMAP'
tdbtype = 'BCOL'
EXCEPTIONS
foreign_lock = 1
OTHERS = 2.
2 - Get File
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'BIN'
IMPORTING
filelength = bytecount
TABLES
data_tab = bitmap
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
...
OTHERS = 17.
IF sy-subrc NE 0.
CALL FUNCTION 'DEQUEUE_ESSGRABDS'
EXPORTING
tdobject = 'GRAPHICS'
tdname = nome
tdid = 'BMAP'
tdbtype = 'BCOL'.
EXIT.
ENDIF.
3 - Convert file to desired format
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP_BDS'
EXPORTING
color = 'X'
format = 'BMP'
resident = space
bitmap_bytecount = bytecount
compress_bitmap = space
IMPORTING
width_tw = width_tw
height_tw = height_tw
width_pix = width_pix
height_pix = height_pix
dpi = dpi
bds_bytecount = bds_bytecount
TABLES
bitmap_file = bitmap
bitmap_file_bds = bds_content
EXCEPTIONS
format_not_supported = 1
no_bmp_file = 2
bmperr_invalid_format = 3
bmperr_no_colortable = 4
bmperr_unsup_compression = 5
bmperr_corrupt_rle_data = 6
OTHERS = 7.
IF sy-subrc NE 0.
CALL FUNCTION 'DEQUEUE_ESSGRABDS'
EXPORTING
tdobject = 'GRAPHICS'
tdname = nome
tdid = 'BMAP'
tdbtype = 'BCOL'.
EXIT.
ENDIF.
4 - Create object of image
CREATE OBJECT bds_object.
wa_bds_components-doc_count = '1'.
wa_bds_components-comp_count = '1'.
wa_bds_components-mimetype = 'application/octet-stream'.
wa_bds_components-comp_size = bds_bytecount.
APPEND wa_bds_components TO bds_components.
wa_bds_signature-doc_count = '1'.
APPEND wa_bds_signature TO bds_signature.
CALL METHOD bds_object->create_with_table
EXPORTING
classname = 'DEVC_STXD_BITMAP'
classtype = 'OT'
components = bds_components
content = bds_content
CHANGING
signature = bds_signature
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
CALL FUNCTION 'DEQUEUE_ESSGRABDS'
EXPORTING
tdobject = 'GRAPHICS'
tdname = nome
tdid = 'BMAP'
tdbtype = 'BCOL'.
EXIT.
ENDIF.
READ TABLE bds_signature INDEX 1 INTO wa_bds_signature
TRANSPORTING doc_id.
CHECK sy-subrc = 0.
docid = wa_bds_signature-doc_id.
5 - Save IMAGE
wa_stxbitmaps-tdname = nome.
wa_stxbitmaps-tdobject = 'GRAPHICS'.
wa_stxbitmaps-tdid = 'BMAP'.
wa_stxbitmaps-tdbtype = 'BCOL'.
wa_stxbitmaps-docid = docid.
wa_stxbitmaps-widthpix = width_pix.
wa_stxbitmaps-heightpix = height_pix.
wa_stxbitmaps-widthtw = width_tw.
wa_stxbitmaps-heighttw = height_tw.
wa_stxbitmaps-resolution = dpi.
wa_stxbitmaps-resident = space.
wa_stxbitmaps-autoheight = space.
INSERT into stxbitmaps values wa_stxbitmaps.
IF sy-subrc NE 0.
CALL FUNCTION 'DEQUEUE_ESSGRABDS'
EXPORTING
tdobject = 'GRAPHICS'
tdname = nome
tdid = 'BMAP'
tdbtype = 'BCOL'.
EXIT.
ENDIF.
6 - Save attributes
wa_bds_properties-prop_name = 'DESCRIPTION'.
wa_bds_properties-prop_value = 'Foto Cartão Voluntário'.
APPEND wa_bds_properties TO bds_properties.
CALL METHOD bds_object->change_properties
EXPORTING
classname = 'DEVC_STXD_BITMAP'
classtype = 'OT'
doc_id = docid
doc_ver_no = '1'
doc_var_id = '1'
CHANGING
properties = bds_properties
EXCEPTIONS
OTHERS = 1.
7 - Unlock Grahics
CALL FUNCTION 'DEQUEUE_ESSGRABDS'
EXPORTING
tdobject = 'GRAPHICS'
tdname = nome
tdid = 'BMAP'
tdbtype = 'BCOL'.
Regards,
Valter Oliveira.