on 2016 May 20 10:56 AM
Hello Friends,
Can anyone suggest me How to transfer PO attachments to Application server path suppose say /tmp/ in SRM?
Is there any useful FM exist or any other way to do so?
I want to do it programmatically, please guide me.
Regards,
Keyur Pawar
Request clarification before answering.
Hi,
Use FM BBP_PD_PO_GETDETAIL to get the PO attachments. Parameter ET_ATTACH
Then FM SDOK_PHIO_LOAD_CONTENT to load the content where:
OBJECT_ID-CLASS = ET_ATTACH-PHIO_CLASS
OBJECT_ID-OBJID = ET_ATTACH-PHIO_OBJID
Then use OPENDATASET to transfer the fle to your application server.
Regards,
Ricardo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try with this code that i have just written;
REPORT ztest_ric4.
PARAMETERS:
pa_objid TYPE crmt_object_id_db OBLIGATORY.
START-OF-SELECTION.
DATA:
lv_path TYPE fileextern,
ls_object_id TYPE sdokobject,
lt_attach TYPE bbpt_pds_att_t,
lt_file_content TYPE bbpt_att_cont.
FIELD-SYMBOLS:
<ls_attach> TYPE bbp_pds_att_t,
<ls_file_content> TYPE sdokcntbin.
CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
EXPORTING
i_object_id = pa_objid
IMPORTING
et_attach = lt_attach.
LOOP AT lt_attach
ASSIGNING <ls_attach>.
ls_object_id-class = <ls_attach>-phio_class.
ls_object_id-objid = <ls_attach>-phio_objid.
* Read file content;
CLEAR lt_file_content.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = ls_object_id
TABLES
file_content_binary = lt_file_content
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
CONCATENATE '/tmp/' <ls_attach>-phio_fname INTO lv_path.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
activity = 'WRITE'
filename = lv_path
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc EQ 0.
* Transfer the file to server;
OPEN DATASET lv_path FOR OUTPUT IN BINARY MODE.
IF sy-subrc EQ 0.
LOOP AT lt_file_content
ASSIGNING <ls_file_content>.
TRANSFER <ls_file_content>-line TO lv_path.
ENDLOOP.
CLOSE DATASET lv_path.
ENDIF.
ENDIF.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.