09-26-2008 7:27 AM
Hi All,
I am trying to upload a file which tab separated containing customer and bank details and my file structure somewhat in the following manner.
10 21169 abcde xyz kdHDHLk gdh ghgah (Customer Details)
20 21169 DE 20050000 01122334 (bank details for customer 21169)
20 21169 DE 23022200 1122334455
(bank details for customer 21169)
20 21169 DE 23984899 223344556 (bank details).
But when I am trying to intial upload the details to an internal table using GUI_upload FM and display to check if it is loading correctly or not it is not giving me any o/p.
I am copying the code which I am trying to execute. Please tell me what way I need to modify the code so that it executes correctly.
parameters: p_file type rlgrap-filename.
data: begin of wa_file,
text(256) type c,
end of wa_file.
data: it_file like table of wa_file.
types: begin of ty_kna1,
kunnr type kunnr,
name1 type name1,
sortl type sortl,
stras type stras,
ort01 type ort01,
land1 type land1,
spras type spras,
end of ty_kna1.
data: it_kna1 type standard table of ty_kna1,
wa_kna1 type ty_kna1.
types: begin of ty_knbk,
kunnr type kunnr,
banks type knbk-banks,
bankl type knbk-bankl,
bankn type knbk-bankn,
end of ty_knbk.
data: it_knbk type standard table of ty_knbk,
wa_knbk type ty_knbk.
data: v_id(2).
At Selection-Screen on Value-Request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = p_file
.
Start-of-Selection.
data: p_file1 type string.
p_file1 = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = p_file1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = it_file
* 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.
constants: c_tab type X value '09'.
loop at it_file into wa_file.
if wa_file+0(2) = '10'.
split wa_file at 'c_tab'
into v_id
wa_kna1-kunnr
wa_kna1-name1
wa_kna1-sortl
wa_kna1-stras
wa_kna1-ort01
wa_kna1-land1
wa_kna1-spras.
append wa_kna1 to it_kna1.
elseif wa_file+0(2) = '20'.
split wa_file at 'c_tab'
into v_id
wa_knbk-kunnr
wa_knbk-banks
wa_knbk-bankl
wa_knbk-bankn.
append wa_knbk to it_knbk.
endif.
endloop.
write:/ 'Customer Master General Data'.
uline.
loop at it_kna1 into wa_kna1.
write:/ wa_kna1-kunnr,
wa_kna1-name1,
wa_kna1-sortl,
wa_kna1-stras,
wa_kna1-ort01,
wa_kna1-land1,
wa_kna1-spras.
endloop.
clear wa_kna1.
skip 2.
write:/ 'Customer Master Bank Data'.
uline.
loop at it_knbk into wa_knbk.
write:/ wa_knbk-kunnr,
wa_knbk-banks,
wa_knbk-bankl,
wa_knbk-bankn.
endloop.
clear wa_knbk.
Regards,
MD
09-26-2008 7:34 AM
Declare Class cl_abap_char_utilities
Use File type as 'DBF'
Has_field_seperator = w_tab in FM GUI_UPLOAD
DATA: w_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = w_file
filetype = 'DBF'
append = ' '
write_field_separator = w_tab
TABLES
data_tab = it_extractchar
fieldnames = it_header
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
OTHERS = 22