*&---------------------------------------------------------------------*
*& Report ZBW_IO_TEMP_TEST
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
report zbw_io_temp_test.
data: begin of data_final occurs 0.
include structure bapi6108.
data: end of data_final.
data: begin of ret_mess occurs 0.
include structure bapiret2.
data: end of ret_mess.
*data : la_conv_tab like line of lt_conv_tab.
data: begin of itab occurs 0,
f1(10000) type c,
end of itab.
data: begin of data_iobj occurs 0.
include structure bapi6108io.
data: end of data_iobj.
data: begin of io_err occurs 0.
include structure bapi6108io.
data: end of io_err.
parameters: lp_file type rlgrap-filename obligatory. " To get the file location
data : temp_ch type string,
names type c length 1000.
data : str3 type string, str4 type string, str5 type string, str6 type string,
str7 type string,
str8 type string, str9 type string, str10 type string, str11 type string, str12 type string,
str13 type string,
data_final_1 TYPE STANDARD TABLE OF bapi6108 WITH HEADER LINE.
*---------------------------------------------------------------------
* AT SELECTION SCREEN ON VALUE REQUEST
*---------------------------------------------------------------------
at selection-screen on value-request for lp_file.
perform help_local_file using lp_file.
start-of-selection.
temp_ch = lp_file.
call function 'GUI_UPLOAD'
exporting
filename = temp_ch
filetype = 'ASC'
* HAS_FIELD_SEPARATOR = ' '
header_length = 0
read_by_line = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* 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 = 1.
message 'FILE IS OPEN; PLEASE CHECK THE FILE.' type 'I'.
*WITH "FILE IS OPEN; PLEASE CHECK THE FILE.".
exit.
elseif sy-subrc = 2.
message 'ERROR WHILE READING THE FILE' type 'I'.
exit.
elseif sy-subrc = 13.
message 'ACCESS DENIED.' type 'I'.
exit.
endif.
loop at itab from 2.
names = itab-f1.
" if there are many columns to be split then make use of the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE'
split names at ',' into str3 str4 str5 str6 str7 str8 str9 str10 str11 str12 str13.
IF str5 = 'CHA'.
data_final-infoarea = str3.
data_final-infoobject = str4.
data_iobj-infoobject = str4.
data_final-type = str5.
data_final-textshort = str6.
data_final-textlong = str7.
data_final-datatp = str8.
data_final-intlen = str9.
data_final-outputlen = str10.
data_final-convexit = str11.
data_final-lowercase = str12.
data_final-mastauthfl = ''.
data_final-attribfl = ''.
data_final-NOVALFL = 'X'.
else.
data_final-infoarea = str3.
data_final-infoobject = str4.
data_iobj-infoobject = str4.
data_final-type = str5.
data_final-textshort = str6.
data_final-textlong = str7.
data_final-KYFTP = str8.
data_final-intlen = str9.
data_final-outputlen = str10.
endif.
append data_final to data_final. " Default header area to Internal table
endloop.
loop at data_final into data_final.
CLEAR : data_final_1[], data_final_1.
move-corresponding data_final to data_final_1.
append data_final_1 to data_final_1[].
call function 'BAPI_IOBJ_CREATE'
exporting
details = data_final_1
importing
* infoobject =
return = ret_mess
* tables
* compounds = data_compound
* attributes = data_attributes
* navigationattributes = data_navigation
* atrnavinfoprovider =
* hierarchycharacteristics =
* elimination =
* returntable =
.
clear : data_iobj[].
data_iobj-infoobject = data_final-infoobject.
append data_iobj to data_iobj[].
call function 'BAPI_IOBJ_ACTIVATE_MULTIPLE'
tables
infoobjects = data_iobj[]
infoobjects_error = io_err.
if sy-subrc <> 0.
endif.
endloop.
form help_local_file using filename type dxfile-filename.
data: lt_file_table type filetable,
la_file_table like line of lt_file_table,
l_rc type i,
l_pcdsn type cffile-filename.
refresh lt_file_table.
clear la_file_table.
call method cl_gui_frontend_services=>file_open_dialog
changing
file_table = lt_file_table
rc = l_rc.
read table lt_file_table into la_file_table index 1.
l_pcdsn = la_file_table-filename.
move l_pcdsn to filename.
endform.
I prepared a CSV file with just one InfoObject "YTEMP_1" and ran the program.
The CSV file prepared must be entered using F4 help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |