cancel
Showing results for 
Search instead for 
Did you mean: 

Reg:Uploading file in GOS

former_member197425
Active Participant
0 Kudos

Dear All,

I got a requirement to develop a webdynpro screen having project-id as input and for each project a document is to be uploaded it should reflect in CJ20n tcode as an attachement i.e i need to store in GOS . I used FileUpload UI element

i am getting data source in Xstring format now how i need to store this GOS with respective to a Project-id ???

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Nandi,

You'll need to debug some of the GOS functions to find the parameters CJ20n uses to upload the file. This thread outlines all the functions you'll need - post again if you have any trouble getting it set up.

Otto,

GUI_UPLOAD doesn't work in WD4A...

Answers (1)

Answers (1)

OttoGold
Active Contributor
0 Kudos

Hello,

adapt yourself the following code, Otto

include <cntn01>.

swc_container lt_message_container.

*top dec.

type-pools: slis, abap, truxs.

data: "g_objid type objid,

gt_filename type standard table of dxfilep with header line,

wa_filename type dxfilep,

gt_bin type solix occurs 0,

wa_bin type solix,

g_filename type string,

l_obj type swc_object,

gs_obja type borident,

gs_objb type borident,

gs_binrel type gbinrel,

gt_binatt type standard table of brelattr,

g_attsize type wsrm_error-wsrm_direction.

selection-screen begin of block b0 with frame title text-001.

parameters: p_file type rlgrap-filename,

p_belnr type bkpf-belnr.

selection-screen end of block b0.

----


  • AT SELECTION-SCREEN on <parameters> *

----


at selection-screen on p_file.

if p_file is initial.

message e999(yfimc01) with 'Please select the file path'. "#EC NOTEXT

endif.

----


  • AT SELECTION-SCREEN on HELP-REQUEST|VALUE-REQUEST *

----


at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = 'P_FILE'

importing

file_name = p_file.

start-of-selection.

  • this step can be replace to get file from app server as well.

*uploading file:&nbsp;EXT&nbsp;is&nbsp;TXT.

move p_file to g_filename.

call function 'GUI_UPLOAD'

exporting

filename = g_filename

filetype = 'BIN'

importing

filelength = g_attsize

tables

data_tab = gt_bin

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.

else.

*file Uploaded successfully.

*convert uploaded file contents into BIN format.

data: l_seq type i.

swc_container l_cont.

swc_create_object l_obj 'MESSAGE' ''.

swc_set_element l_cont 'NO_DIALOG' 'X'.

swc_set_element l_cont 'DOCUMENTTITLE' g_filename.

swc_set_table l_cont 'Content_Hex' gt_bin.

swc_set_element l_cont 'DOCUMENTTYPE' 'TXT'.

swc_set_element l_cont 'DOCUMENTSIZE' g_attsize.

swc_refresh_object l_obj.

swc_call_method l_obj 'CREATE' l_cont.

swc_get_object_key l_obj gs_objb-objkey.

gs_objb-objtype = 'MESSAGE'. "type of attach document

gs_obja-objtype = 'BKPF'. "BO of SAP Document.

concatenate '0001' "company code

p_belnr "FI Document

'2009' "fiscal year

into

gs_obja-objkey.

call function 'BINARY_RELATION_CREATE_COMMIT'

exporting

obj_rolea = gs_obja

obj_roleb = gs_objb

relationtype = 'ATTA'

importing

binrel = gs_binrel

tables

binrel_attrib = gt_binatt

exceptions

no_model = 1

internal_error = 2

unknown = 3

others = 4.

if sy-subrc eq 0.

message s043(sgos_msg).

endif.

endif.