2008 Aug 25 12:20 PM
Hi, i am uploading data from a text file to an internal table itab.
one of the field in the text file is in the format of p(7,2).
while uploading , this is not not getting uploaded correctly,
for ex instead of uploading 00008.00 in the itab, it gives a strange value of 30303030382>3.03. how to correct this?
pls help
Hi, i am uploading data from a text file to an internal table itab.
one of the field in the text file is in the format of p(7,2).
while uploading , this is not not getting uploaded correctly,
for ex instead of uploading 00008.00 in the itab, it gives a strange value of 30303030382>3.03. how to correct this?
pls help
2008 Aug 25 12:22 PM
hi
try to upload the text file by putting that field in single Quotes like this
for ex instead of uploading '00008.00'Regards
Pavan
2008 Aug 25 3:46 PM
Hi,
Declare the field of type p(7,2) as char type in your internal table and check .
regards
padma
2008 Aug 25 9:19 PM
Hi,
Use GUI_DOWNLOAD to get the file content into a string type table. (Ensure you are using text file tab delimited)
Then use SPLIT statement to put in the records in the internal table.
You can use the same data type in an internal table.
Remember to put the right delimiter(tab) while using SPLIT statement.
Thanks,
Kartavya
2008 Aug 26 6:12 AM
Hello Rahul,
Do the following:
types: begin of ty_upload,
string type string,
end of ty_upload.
types: begin of ty_fields,
text1(20),
wert type p decimals 2,
text2(20),
:
:
end of ty_fields.
data: it_upload type table of ty_upload,
it_fields type table of ty_fields,
wa_upload type ty_upload,
wa_fields type ty_fields.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\aa_upload.txt'
FILETYPE = 'ASC'
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = it_upload
EXCEPTIONS
FILE_OPEN_ERROR = 1
:
:
:
.
Populate the internal table it_fields accordingly in a loop run, e.g.
loop at it_upload into wa_upload.
wa_fields-text1 = wa_upload-string(20).
wa_fields-wert = wa_upload-string+20(10).
wa_fields-text2 = wa_upload-string+30.
:
:
append wa_fields to it_fields.
endloop.
When your offsets are set correctly, there shouldn't be any problem.
Regards,
Heinz
2008 Aug 26 11:12 AM
@ heinz :
can u please give me an example of a value of type p decimals 2 as to how it should be present in the text file?
i guess m not putting correct value in the correct format in the text file in the first place!
thx
2008 Aug 26 5:33 PM
Hi Rahul,
the lines in the flat file should be character only and can look like
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
Material 1234567.12 ; For Rahul
He has to pay 567.77 ; immediately
My Friend 34567.88 ; is a hero
The values in position 21 to 30 (that's OFFSET 20 and 29 respectively) have to contain decimals, period and space only (otherwise they can't be converted to TYPE P DECIMALS 2).
When you use these lines (without ruler line) and my previously provided code you will get proper P Decimal 2 values.
Regards,
Heinz