ABAP顾问
分类:
2009-04-09 17:37:13
REPORT z_barry_mm03_gos .
TABLES: srgbtbrel, sood, soc3 .
DATA: itab_srgb LIKE TABLE OF srgbtbrel WITH HEADER LINE .
DATA: sortfield LIKE soc3-srtfd.
DATA: folder_id LIKE soodk ,
object_id LIKE soodk ,
objcont TYPE TABLE OF soli .
PARAMETERS: matnr LIKE mara-matnr .
AT SELECTION-SCREEN OUTPUT.
CALL FUNCTION 'SWU_OBJECT_REFRESH'
* EXPORTING
* OBJTYPE = 'BUS1001006'
.
IF NOT matnr IS INITIAL.
CALL FUNCTION 'SWU_OBJECT_PUBLISH'
EXPORTING
objtype = 'BUS1001006'
objkey = matnr
EXCEPTIONS
objtype_not_found = 1
OTHERS = 2.
ENDIF.
START-OF-SELECTION.
SELECT * FROM srgbtbrel INTO TABLE itab_srgb
WHERE instid_a = matnr AND
typeid_a = 'BUS1001006' AND
catid_a = 'BO' AND
reltype = 'NOTE' AND
logsys_a = '' .
LOOP AT itab_srgb .
SELECT SINGLE * FROM sood
WHERE objtp = itab_srgb-instid_b+17(3) AND
objyr = itab_srgb-instid_b+20(2) AND
objno = itab_srgb-instid_b+22(12).
WRITE : / sood-file_ext ,
sood-objdes ,
sood-cronam ,
sood-crdat .
HIDE: itab_srgb-instid_b .
ENDLOOP .
AT LINE-SELECTION .
PERFORM downtxt.
*&---------------------------------------------------------------------*
*& Form showpic
*&---------------------------------------------------------------------*
FORM downtxt .
**方法一
CONCATENATE itab_srgb-instid_b+17(3) itab_srgb-instid_b+20(2)
itab_srgb-instid_b+22(12) INTO sortfield .
IMPORT objcont_tab = objcont FROM DATABASE soc3(dt) ID sortfield.
**方法二
* folder_id = itab_srgb-instid_b+0(17).
* object_id = itab_srgb-instid_b+17(17).
* CALL FUNCTION 'SO_OBJECT_READ'
* EXPORTING
* folder_id = folder_id
* object_id = object_id
* TABLES
* objcont = objcont.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'c:\mm03.txt'
filetype = 'ASC'
TABLES
data_tab = objcont.
ENDFORM. "downtxt
如果需要得到图片等二进制类型的附件,需要再用SO_KPRO_DATA_FROM_OBJCONT_GET、SO_LOIO_PHIO_GET、SDOK_PHIO_LOAD_CONTENT等几个函数
SAP GOS: