Adjuntar archivos a una Orden de Compra julio 26, 2011
Posted by gstortoni in Uncategorized.trackback
El siguiente código permite seleccionar un archivo y adjuntarlo a una orden de compra.
report zmmadjuntar_documentos .
parameter p_mandt like sy-mandt default sy-mandt .
parameter p_ebeln type ebeln .
parameter p_path like ibipparms-path memory id ad_local_path .
parameter p_name(30) default ’Prueba Adjunto’ lower case .
data w_prog like sy-repid .
data w_dynnr like sy-dynnr .
data w_attachement type borident .
initialization .
w_prog = sy-repid .
w_dynnr = sy-dynnr .
data lo_container type ref to cl_gui_container .
at selection-screen on value-request for p_path .
call function ’F4_FILENAME’
exporting
program_name = w_prog
dynpro_number = w_dynnr
field_name = ’P_PATH’
importing
file_name = p_path.
start-of-selection .
data ws_borident like borident .
ws_borident-objkey = p_ebeln.
ws_borident-objtype = ’BUS2012′.
data w_document like sood4 .
data : begin of wt_files occurs 0 .
data fname(128) .
data end of wt_files.
wt_files-fname = p_path .
append wt_files .
data folder_id like soodk .
call function ’SO_FOLDER_ROOT_ID_GET’
exporting
region = ’B’
importing
folder_id = folder_id
exceptions
others = 1.
w_document-foltp = folder_id-objtp .
w_document-folyr = folder_id-objyr .
w_document-folno = folder_id-objno .
w_document-objdes = p_name .
w_document-objnam = p_name .
data w_h_data like sood2 ..
data w_fol_data like sofm2.
data w_rec_data like soos6 .
w_h_data-objdes = p_name .
call function ’SO_DOCUMENT_REPOSITORY_MANAGER’
exporting
method = ’IMPORTFROMPC’
ref_document = w_document
tables
files = wt_files
changing
document = w_document
header_data = w_h_data
folmem_data = w_fol_data
receive_data = w_rec_data.
.
if w_document-okcode = ’CREA’ or w_document-okcode = ’CHNG’.
w_attachement-objtype = ’MESSAGE’.
w_attachement-objkey = w_document(34).
call function ’BINARY_RELATION_CREATE_COMMIT’
exporting
obj_rolea = ws_borident
obj_roleb = w_attachement
relationtype = ’ATTA’
exceptions
no_model = 1
internal_error = 2
unknown = 3
others = 4.
if sy-subrc = 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
commit work.
endif.
endif .
Transacción: ME23N
Suerte y que les Sirva



Comentarios»
No comments yet — be the first.