Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload photos which exist at server to HR infotype?

Former Member
0 Kudos

hi:

How to upload photos which exist at server to HR infotype?

thanksss.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

function 'ARCHIV_CREATE_DIALOG_META' just can upload local photos,and function 'ARCHIV_CREATE_TABLE' can read server photo but can't be show at infotype.

3 REPLIES 3

Former Member
0 Kudos

function 'ARCHIV_CREATE_DIALOG_META' just can upload local photos,and function 'ARCHIV_CREATE_TABLE' can read server photo but can't be show at infotype.

0 Kudos

HI Qi

I am using the FM 'ARCHIV_CREATE_TABLE' to store the PDF file as archive in R/3. How ever I need to store it against a Infotype. I hope you have already worked on uploading the Photo and storing againes a Infotype.

Your help is much appriciated.

PS. I dint have your email. So thought this is the only way to communicate with you.Apologies if im replying to a answered thread.

DATA lv_pernr TYPE string.

lv_pernr = '00002757'.

DATA lo_api_controller TYPE REF TO if_wd_controller.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

DATA: docu_oknd TYPE saeobjart,

docu_oid TYPE saeobjid.

CONSTANTS: docu_otyp TYPE saeanwdid VALUE 'PREL'.

  • CONCATENATE lv_pernr '9102' INTO docu_oid.

docu_oid = lv_pernr.

docu_oknd = 'ZHRILPCERT'.

DATA : docu_ext TYPE saedoktyp.

DATA: docu_data TYPE TABLE OF docs,

toadttab TYPE toadt.

docu_ext = 'PDF'.

CALL FUNCTION 'ARCHIV_CREATE_TABLE'

EXPORTING

ar_object = docu_oknd

object_id = docu_oid

sap_object = docu_otyp

flength = file_len

doc_type = docu_ext

  • DOCUMENT =

  • MANDT = SY-MANDT

IMPORTING

outdoc = toadttab

TABLES

  • ARCHIVOBJECT = docu_data

binarchivobject = lt_ctx_binary_data

EXCEPTIONS

error_archiv = 1

error_communicationtable = 2

error_connectiontable = 3

error_kernel = 4

error_parameter = 5

error_user_exit = 6

error_mandant = 7

OTHERS = 8

.

Former Member
0 Kudos

Hi,

For this requirement please refer the below code this is the BDC to upload photos

report name message-id zhr_msg.

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

    • I N T E R N A L T A B L E S

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

data : begin of itab occurs 0,

matnr type matnr, "rp50g-pernr(8),

fname like sapb-sappfad,

end of itab.

data : begin of wa,

objid like sapb-sapobjid,

fname like sapb-sappfad, "File name (Complete Path)

end of wa.

data : begin of ptab occurs 0,

matnr type persno,

end of ptab.

data : filename type string.

----


  • SELECTION-SCREEN *

----


selection-screen begin of block b1 with frame.

parameters: fol type char200 obligatory.

parameters: fol1 type string.

selection-screen end of block b1.

----


initialization.

----


fol = 'C:\'.

  • FILENAME = 'C:\PHOTO.TXT'.

at selection-screen on value-request for fol.

call function 'TMP_GUI_BROWSE_FOR_FOLDER'

exporting

window_title = 'Photo Folder *.JPG'

initial_folder = 'C:\'

importing

selected_folder = fol

exceptions

cntl_error = 1

others = 2.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

at selection-screen on value-request for fol1.

call function 'WS_FILENAME_GET'

exporting

def_filename = ' '

def_path = '.'

mask = ' '

mode = 'O'

  • TITLE = 'for excel'

importing

filename = fol1

  • RC =

exceptions

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

others = 5

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

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

  • S T A R T - O F - S E L E C T I O N

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

start-of-selection.

filename = fol1.

data : files type sdokpath occurs 0 with header line.

data : files1 type sdokpath occurs 0 with header line.

if fol ne space.

concatenate fol '\' into fol.

endif.

call function 'GUI_UPLOAD'

exporting

filename = filename

filetype = 'ASC'

has_field_separator = 'X'

tables

data_tab = itab

exceptions

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

others = 17

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

call function 'TMP_GUI_DIRECTORY_LIST_FILES'

exporting

directory = fol

filter = '*.JPG'

tables

file_table = files

dir_table = files1

exceptions

cntl_error = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

exit.

endif.

data : f1(50), f2(3).

data : htype like dd01v-datatype.

  • image upload

data : l_lines type i.

describe table itab lines l_lines.

loop at itab.

  • PERFORM SAPGUI_PROGRESS_P USING SY-TABIX L_LINES 'UPLOAD' 'progressing' 5.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = itab-matnr

IMPORTING

OUTPUT = itab-matnr

.

clear wa.

wa-objid = itab-matnr.

  • CONCATENATE FOL '\' ITAB-PERNR '.JPG' INTO WA-FNAME.

concatenate fol itab-fname '.JPG' into wa-fname.

condense wa-fname.

call function 'ARCHIV_CREATE_DIALOG_META'

exporting

ar_object = 'CAF_JP'

object_id = wa-objid

sap_object = 'BUS1001006'

file = wa-fname

COMMIT_FLAG = 'X'

exceptions

error_archiv = 01

error_communicationtable = 02

error_connectiontable = 03

error_kernel = 04

error_parameter = 05

error_scanqueue = 06

others = 7.

commit work.

if sy-subrc = 0.

format color 5 intensified off.

write : / 'Success :', wa-objid.

  • ADD 1 TO SS.

else.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  • ADD 1 TO FF.

ptab-matnr = wa-objid.

append ptab.

endif.

endloop.

Regards

amudha