‎2008 Dec 24 8:08 AM
hi,
i have to upload file which has header in the first line.
and from second line the actual data will be there which is to be uploaded.
now the problem is hove to move this file data to internal table with header,
can any one has code plz send me.
‎2008 Dec 24 8:20 AM
Hi,
Once you upload the file using GUI_UPLOAD , the data will sit in Internal table.
Then use statement
DELETE itab INDEX 1. so it will remove the first record(header).
Regards
Eswar
‎2008 Dec 24 9:18 AM
Hi,
If you are using GUI_UPLOAD function then first uplaod the file into an interbal table and late delete the first row form the table.
Or if you are uploading data from Excel file usinf below fiunction, then pass Row value as 2. Then function will ignore the first row while uploading the data.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = infile
i_begin_col = '1'
i_begin_row = 2
i_end_col = '6'
i_end_row = end_row
TABLES
intern = excel_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
IF sy-subrc 0.
ENDIF.
Regards,
Piyush
‎2008 Dec 24 10:24 AM
if the first row has field names in the file and then the actual data from 2nd row how to pass the file data into internal table as the field names has more length than the actual data.
‎2008 Dec 24 10:29 AM
If you r upload data fromexcel Sheet, use below function:
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = infile
i_begin_col = '1'
i_begin_row = 2 " 2 value will start reading the file from 2nd row.
i_end_col = '6'
i_end_row = end_row
TABLES
intern = excel_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
IF sy-subrc 0.
ENDIF.
or if you are uploading from text file and using GUI_UPLOAD file,
then use an ubternal table with column data type as String. After uploading the data delet the first line from internal table.
Let me know where you are facing the problem.
Regards,
Piyush
‎2008 Dec 24 10:29 AM
hi,
try this Fm...
DATA l_count TYPE sy-tabix.
CONSTANTS: lc_begin_col TYPE i VALUE '1',
lc_begin_row TYPE i VALUE '2',
lc_end_col TYPE i VALUE '2',
lc_end_row TYPE i VALUE '3000'.
* Begin of CALK912848 - Carlos Werberich - 16Sep08
CLEAR p_i_excel_data. REFRESH p_i_excel_data.
* End of CALK912848 - Carlos Werberich - 16Sep08
* Function module to read excel file and convert it into internal table
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_p_file
i_begin_col = lc_begin_col
i_begin_row = lc_begin_row
i_end_col = lc_end_col
i_end_row = lc_end_row
TABLES
intern = i_data
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
* Error in file upload
IF sy-subrc NE 0 .
MESSAGE text-006 TYPE 'E'.
EXIT.
ENDIF.
IF i_data[] IS INITIAL .
MESSAGE text-007 TYPE 'E'.
EXIT.
ELSE.
SORT i_data BY row col .
* Loop to fill data in Internal Table
LOOP AT i_data .
MOVE i_data-col TO l_count .
ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO .
AT END OF row .
* Append data into internal table
APPEND p_i_excel_data.
CLEAR p_i_excel_data.
ENDAT .
ENDLOOP .
ENDIF
‎2008 Dec 24 10:57 AM
Hi,
my requirement is I have to provide both presentation and application server option in my selection screen.If the presentation server option is selected then user can select the file type like Text or Excel.
Also it would be better if we can add the logic to upload the file with dynamic columns so that this upload Program can be reused.
The first row of the file contain the field name always. The data will start from the second row.If it is excel we will provide row as 2.Whereas with txt file what we hav to do?
‎2008 Dec 24 11:24 AM
hi,
when read the data from Dataset ...
Open dataset file....
Do.
Check sy-index Ne 1.
READ DATASET file INTO itab.
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND itatab.
ENDIF.
Enddo.