Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Error with data transfer in functional module

Hi all,

I need to upload file to the employee through BDS. (oaor transcation). i am using functional module

function zin_bds_dms_upload.

*"----

-


""Local Interface:

*" IMPORTING

*" VALUE(P_CLASS) TYPE BDN_CON-CLASSNAME

*" VALUE(P_OBJCT) TYPE BDN_CON-OBJKEY

*" VALUE(P_DESCR) TYPE BDN_CON-DESCRIPT

*" REFERENCE(P_PATH) TYPE SAPB-SAPFILES

*"----

-


data: begin of i_bds_conn occurs 10, " ITAB for the actual

bdn_tab_i type num08,

client type mandt,

classname type seoclsname,

classtype type bds_clstyp,

objkey type bds_typeid,

log_system type swo_typeid,

loio_id type char42,

doc_ver_no type num08,

doc_var_id type num08,

doc_var_tg type bds_var_tg,

descript type sdok_descr,

langu type spras,

comp_id type bds_compid,

mimetype type bds_mimetp,

crea_user type sdok_crusr,

crea_time type sdok_crtst,

chng_user type sdok_chusr,

chng_time type sdok_chtst,

contrep type bds_conrep,

docuclass type sdok_prv_m,

doc_type type sdok_prv_s,

expirytime type sdok_prv_m,

bds_docid type sdok_prv_l,

loio_id_to type sdok_loid,

rela_id type bds_relaid,

state type sdok_phsta,

bds_status type bds_state,

stor_tab type saearstat,

bdn_tab_d type bar_keep,

note_type type bds_state,

objecttext type toasp-objecttext,

objecttext2 type toasd-objecttext,

objecttext3 type toasr-objecttext,

ntext type tojtt-ntext,

end of i_bds_conn.

data: begin of bds_doctype_list occurs 10,

mandt type mandt,

classname type bapibds01-classname,

contrep type bapibds01-contrep,

docuclass type bapibds01-doc_class,

docuclass_text type toasd-objecttext,

doc_type type bapibds01-doc_type,

doc_type_text type toasp-objecttext,

appl_type type toadd-appl_type,

appl_type_text(50) type c,

standard type toadv-standard,

check_box type toadv-standard,

end of bds_doctype_list.

data: file_extension type toadd-doc_type, " file-extension

i_files type bapifiles occurs 1 with header line,

i_signature type bapisignat occurs 1 with header line,

logical_system type bds_conn00-log_system.

data: classname_select type bdn_con-classname,

classtype_select type bdn_con-classtype,

objkey_select type bdn_con-objkey,

mask(20) type c,

answer type c,

mimetype type toadd-mimetype,

i_toadd type toadd,

file_path type sapb-sapfiles,

filename_all type sapb-sapfiles,

file_path_memory(250) type c, " path für SAP memory

file_path_length type i, " length of the file_path

file_name type sapb-sapfiles.

classname_select = p_class.

classtype_select = 'BO'.

objkey_select = p_objct.

filename_all = p_path.

get parameter id 'OAP' field file_path.

if sy-subrc <> 0. " no file_path found.

file_path = space.

endif.

concatenate ',.' '' ',.' '' '.' into mask.

  • -- split filename -- *

perform split_path(oaall) using filename_all file_path file_name.

  • -- set new file_path to SAP memory -- *

file_path_length = strlen( file_path ).

if file_path <> space and file_path_length < 250.

file_path_memory = file_path.

set parameter id 'OAP' field file_path_memory.

else.

file_path_memory = space.

set parameter id 'OAP' field file_path_memory.

endif.

  • -- check documentclass -- *

perform get_file_extension using file_name

file_extension.

  • -- check file extension -- *

if file_extension = space.

  • -> if no docuclass is found from the document

  • -> default docuclass from the doctype!

file_extension = bds_doctype_list-docuclass.

endif.

  • -- get the mimetype of the docuclass -- *

perform mimetype_get(oaall) using file_extension

changing i_toadd.

move i_toadd-mimetype to mimetype.

  • -- fill file and signature structure -- *

clear: i_files, i_signature.

refresh : i_files, i_signature.

i_files-doc_count = 1.

i_files-directory = file_path.

i_files-filename = file_name.

i_files-mimetype = mimetype.

append i_files.

i_signature-doc_count = 1.

i_signature-prop_name = 'BDS_DOCUMENTCLASS'.

i_signature-prop_value = file_extension.

append i_signature.

i_signature-prop_name = 'BDS_CONTREP'.

if bds_doctype_list-contrep = space.

i_signature-prop_value = ' '. "#EC NOTEXT

else.

i_signature-prop_value = bds_doctype_list-contrep.

endif.

append i_signature.

i_signature-prop_name = 'BDS_DOCUMENTTYPE'.

i_signature-prop_value = bds_doctype_list-doc_type.

append i_signature.

i_signature-prop_name = 'DESCRIPTION'.

i_signature-prop_value = p_descr.

append i_signature.

i_signature-prop_name = 'LANGUAGE'.

i_signature-prop_value = sy-langu.

append i_signature.

  • -- create new document via KPro -- *

call function 'BDS_BUSINESSDOCUMENT_CREATEF'

exporting

logical_system = logical_system

classname = classname_select

classtype = classtype_select

client = sy-mandt

object_key = objkey_select

tables

files = i_files

signature = i_signature

exceptions

internal_error = 1

others = 2.

endfunction.

*&----


*

*& Form GET_FILE_EXTENSION

*&----


*

  • try to get the extension of the uploaded file

*----


*

form get_file_extension using file_name file_extension.

  • -- data declaration ------------------------------------------------ *

data: length type i,

single_c type c.

data: begin of bds_doctype_list occurs 10,

mandt type mandt,

classname type bapibds01-classname,

contrep type bapibds01-contrep,

docuclass type bapibds01-doc_class,

docuclass_text type toasd-objecttext,

doc_type type bapibds01-doc_type,

doc_type_text type toasp-objecttext,

appl_type type toadd-appl_type,

appl_type_text(50) type c,

standard type toadv-standard,

check_box type toadv-standard,

end of bds_doctype_list.

  • -------------------------------------------------------------------- *

clear: single_c.

length = strlen( file_name ).

if length > 0.

while length > 0.

single_c = file_name+length(1).

if single_c co '.'.

length = length + 1.

exit.

else.

length = length - 1.

endif.

endwhile.

if length > 0.

file_extension = file_name+length.

else.

file_extension = space.

endif.

else.

file_extension = space.

endif.

if file_extension <> space.

set locale language sy-langu.

translate file_extension to upper case. "#EC TRANSLANG

set locale language space.

endif.

endform. "get_file_extension

example : class = PREL

object = pernr_no

desc = 'leav application'

p_path = file_path

******************************************************************************************************************************************************

I used this in abap program then it is uploading fine but when used in the web dynpro file is not uploading. On debugging it is showing error in function module SDOK_PHIOS_CHECKIN

error key 5 ie error in transfer.

So please suggest how to upload in web dynpro abap.

Edited by: Bhavya belagal on Dec 22, 2010 11:55 AM

Edited by: Bhavya belagal on Dec 22, 2010 12:09 PM

Former Member
Not what you were looking for? View more on this topic or Ask a question