Application Development and Automation 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: 
Read only

Replacement for Upload FM.

Former Member
0 Likes
1,593

hi,

Kindly tell me what is the replacement for the UPLOAD Func. Module.

If it is GUI_UPLOAD.

Then what is the replacement code for this

CALL FUNCTION 'UPLOAD'

EXPORTING

filename = p_xtract

filetype = 'DAT'

item = 'Upload SBA Input File'(005)

IMPORTING

act_filename = p_xtract1

TABLES

data_tab = itab_data

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_table_width = 4

invalid_type = 5

no_batch = 6

unknown_error = 7

OTHERS = 8.

Especially for the Export parameter 'ITEM' and the Importing parameter 'act_filename'.

Kindly guide me on this...

Regds,

Rajesh P

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,357

Hi Rajesh,

1. Especially for the Export parameter 'ITEM' and the Importing parameter 'act_filename'.

I wrote one INDEPENDENT subroutine (FORM)

in which we pass the

internal table, and

one changing variable for <b>ACTUAL FILENAME</b> (act_Filename)

2. It will show the file open dialog,

and upload that file in the

specified internal table.

3. It will also return the selected file name.

4. Especially for the Export parameter 'ITEM'

But, this parameter for ITEM,

(for displaying the text in the file open dialog box)

is not available in this code.

5. Just copy paste in new program.

(u can use the INDEPENDENT form in your program,

and modify if u require)

6.

report abc.

*----


data : filename like IBIPPARMS-PATH.

data : t001 like table of t001 with header line.

perform myupload tables t001 changing filename.

*----


  • MYUPLOAD

*----


form myupload tables itab changing pfilename.

data : filename like IBIPPARMS-PATH.

data : fname type string.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

FILE_NAME = filename.

.

*----


fname = filename.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = fname

TABLES

DATA_TAB = itab.

endform. "myupload

regards,

amit m.

8 REPLIES 8
Read only

dani_mn
Active Contributor
0 Likes
1,357

HI,

Use FM GUI_UPLOAD

Regards

Wasim Ahmed

Read only

Former Member
0 Likes
1,357

Check the following Code

tables : mara.

data : begin of it_mara occurs 0,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

maktx like makt-maktx,

meins like mara-meins,

end of it_mara.

start-of-selection.

perform upload_data.

&----


*& Form upload_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_data .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'c:\mat_bdc.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = it_mara.

IF SY-SUBRC = 0.

SORT IT_MARA BY MATNR.

ENDIF.

ENDFORM. " upload_data

flat file structure is

PRANIT_011;C;COUP;This is Testing material;kg

PRANIT_012;C;COUP;This is Testing material;kg

PRANIT_013;C;COUP;This is Testing material;kg

PRANIT_014;C;COUP;This is Testing material;kg

PRANIT_015;C;COUP;This is Testing material;kg

Read only

Former Member
0 Likes
1,357

Rajesh,

To be sure that it will be in line with the new OO concepts.

Use the method CL_GUI_FRONTEND_SERVICES->FILE_OPEN_DIALOG and the item that you were referring, I guess is nothing but a title of the open file window, which can be WINDOW_TITLE in the the case of the method.

Once the user selects the file, you can call the GUI_UPLOAD method of the same class.

Regards,

Ravi

Read only

0 Likes
1,357

Hi Ravi,

Can u guide me exactly what to do.

Regds,

Rajesh P

Read only

0 Likes
1,357

Rajesh,

Where exactly were you using the UPLOAD function?

At the same place, you will have to call two methods now.

1. To get the file selected by the user, call the FILE_OPEN_DIALOG, the user will select a file which will be the output of the method.

2. Use the file selected and pass that to the parameter as the GUI_UPLOAD METHOD.

Here is a sample code


CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
*  EXPORTING
*    WINDOW_TITLE            =
*    DEFAULT_EXTENSION       =
*    DEFAULT_FILENAME        =
*    FILE_FILTER             =
*    INITIAL_DIRECTORY       =
*    MULTISELECTION          =
*    WITH_ENCODING           =
  CHANGING
    FILE_TABLE              =
    RC                      =
*    USER_ACTION             =
*    FILE_ENCODING           =
*  EXCEPTIONS
*    FILE_OPEN_DIALOG_FAILED = 1
*    CNTL_ERROR              = 2
*    ERROR_NO_GUI            = 3
*    NOT_SUPPORTED_BY_GUI    = 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.

READ TABLE FILE_TABLE INDEX 1.
W_FILE = FILE_TABLE-FILENAME.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
  EXPORTING
     FILENAME                = W_FILE
*    FILETYPE                = 'ASC'
*    HAS_FIELD_SEPARATOR     = SPACE
*    HEADER_LENGTH           = 0
*    DAT_MODE                = SPACE
*    CODEPAGE                = SPACE
*    IGNORE_CERR             = ABAP_TRUE
*    REPLACEMENT             = '#'
*    READ_BY_LINE            = 'X'
*  IMPORTING
*    FILELENGTH              =
*    HEADER                  =
  CHANGING
    DATA_TAB                =
*  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
*    NOT_SUPPORTED_BY_GUI    = 17
*    ERROR_NO_GUI            = 18
*    others                  = 19
        .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

.

Regards,

Ravi

Message was edited by: Ravikumar Allampallam

Read only

0 Likes
1,357

hi,

Then what to do for this

The Export parameter 'ITEM' and the Importing parameter 'act_filename'.

Read only

Former Member
0 Likes
1,358

Hi Rajesh,

1. Especially for the Export parameter 'ITEM' and the Importing parameter 'act_filename'.

I wrote one INDEPENDENT subroutine (FORM)

in which we pass the

internal table, and

one changing variable for <b>ACTUAL FILENAME</b> (act_Filename)

2. It will show the file open dialog,

and upload that file in the

specified internal table.

3. It will also return the selected file name.

4. Especially for the Export parameter 'ITEM'

But, this parameter for ITEM,

(for displaying the text in the file open dialog box)

is not available in this code.

5. Just copy paste in new program.

(u can use the INDEPENDENT form in your program,

and modify if u require)

6.

report abc.

*----


data : filename like IBIPPARMS-PATH.

data : t001 like table of t001 with header line.

perform myupload tables t001 changing filename.

*----


  • MYUPLOAD

*----


form myupload tables itab changing pfilename.

data : filename like IBIPPARMS-PATH.

data : fname type string.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

FILE_NAME = filename.

.

*----


fname = filename.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = fname

TABLES

DATA_TAB = itab.

endform. "myupload

regards,

amit m.

Read only

Former Member
0 Likes
1,357

Hai Rajesh

data: ld_transdir(255),

ld_file(255),

ld_transfile like e070-trkorr,

ld_filelen like sy-tabix,

ld_len like sy-tabix,

begin of ld_line,

nam(16),

cont(1024) type x,

end of ld_line,

lt_tab like ld_line occurs 0,

ld_fil type string,

ld_path type string,

ld_full type string,

ld_idx like sy-index,

ld_tmp(255),

lt_fil type filetable,

ld_rc like sy-subrc.

data: ld_no like sy-subrc.

if sy-index = 1.

ld_fil = ld_transfile.

call method cl_gui_frontend_services=>file_open_dialog

EXPORTING

window_title = 'woher'

default_extension = ''

default_filename = ld_fil

file_filter = '.'

initial_directory = 'c:\xxx'

multiselection = 'N'

CHANGING

file_table = lt_fil

user_action = ld_rc

rc = ld_no.

if ld_no <> 1. ld_rc = 1. endif.

if ld_rc <> 0. exit. endif.

endif.

read table lt_fil index 1 into ld_full.

if sy-subrc <> 0. ld_rc = 1. exit. endif.

ld_tmp = ld_full.

search ld_tmp for '...'.

if sy-subrc = 0.

ld_idx = sy-fdpos - 7.

endif.

if sy-index = 1. move 'K' to ld_tmp+ld_idx(1). endif.

if sy-index = 2. move 'R' to ld_tmp+ld_idx(1). endif.

if sy-index = 3. move 'D' to ld_tmp+ld_idx(1). endif.

ld_full = ld_tmp.

if not ld_tmp cs ld_transfile.

write: / ld_tmp.

write: /5 'file will be renamed to', ld_transfile.

endif.

call method cl_gui_frontend_services=>gui_upload

EXPORTING

filename = ld_full

filetype = 'BIN'

IMPORTING

filelength = ld_filelen

CHANGING

data_tab = lt_tab

EXCEPTIONS

file_open_error = 1.

if sy-subrc = 1. ld_rc = 1. endif.

Thanks & reagrds

Sreeni