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: 

FM to upload flat file from Application server

Former Member
0 Kudos
148

Hi,

I have to upload data into an Internal table from Application Server. Is there any FM to do the same. please help me its urgent..

Regards,

5 REPLIES 5

Former Member
0 Kudos
121

To upload file from PC :

**Internal table matching columns in XLS

DATA: BEGIN OF itab OCCURS 0,

field1(10) TYPE c,

field2(10) TYPE c,

END OF itab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'E:\Vaibhav\PivotTableEg.xls'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = ' '

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = ' '

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

CHECK_BOM = ' '

NO_AUTH_CHECK = ' '

IMPORTING

FILELENGTH =

HEADER =

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.

Reward points..

Former Member
0 Kudos
121

Hi,

Check this code. It might help you.


TYPES : BEGIN OF x_file,
matnr like mara-matnr, "Material Number
werks like mard-werks, "Plant
budat(10) type c, "Posting Date
bldat(10) type c, "Document Date
bmeng like stko-bmeng, "Base Quantity
bom_matnr like mara-matnr, "Material Number
bom_bmeng like stko-bmeng, "Base QUantity
END OF x_file.

Data : it_file TYPE STANDARD TABLE OF x_file INITIAL SIZE 0,
wa_file TYPE x_file.


FORM dataset_open USING p_filename.

OPEN DATASET p_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string,wa_file.
READ DATASET p_filename INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO : wa_file-matnr
wa_file-werks
wa_file-bmeng
wa_file-budat
wa_file-bldat
wa_file-bom_matnr
wa_file-bom_bmeng.

APPEND wa_file TO it_file.
ENDIF.
ENDDO.
CLOSE DATASET p_file.
ENDIF.

ENDFORM. " dataset_open

Regards,

Omkar.

gopi_narendra
Active Contributor
0 Kudos
121

You can not do that using FM's, rather you need to use the statements

Open Dataset, read dataset, transfer, and close dataset statements to write the data from app server file to internal table.

You can either use the tcode CG3Y to download file data on appl server to your local PC.

Regards

Gopi

Former Member
0 Kudos
121

Hai Saritha

Just USe This Function Module C13Z_APPL_TO_FRONT_END

it Will just ASk For File paths.

If Found Helpfull.

Do Reward.

Regards.

Eshwar.

Former Member
0 Kudos
121

Hi saritha,

use this FM

call function 'F4_DXFILENAME_TOPRECURSION'

exporting

i_location_flag = 'A'

i_server = 'RPMSAP3_RES_00'

  • I_PATH =

filemask = '.'

fileoperation = 'R'

importing

  • O_LOCATION_FLAG =

  • O_SERVER =

o_path = p_file_path

  • ABEND_FLAG =

exceptions

rfc_error = 1

error_with_gui = 2

others = 3

.

reward points if helpful,

kushagra