Application Development and Automation 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: 
Read only

Problem uploading a text file

Former Member
0 Likes
823

Hi All,

I'm trying to upload data from a file in the application server. The file that I read is a 'dat' file and the length for each field is preserved meaning if the currency key field is of length 5 and the file has 'USD' it is filled with spaces for the remaining 2.

I have an internal table t_data which has all the records from the file. I loop through t_data into wa_data. Then I move the contents of my wa_data to the structure work area wa_struct1 which has all my table fields(same length as the fields in the file and all the fields are standard SAP fields).

However the structure wa_struct1 always gets some junk values in fields like exchange rate and amount field (simply it doesn't like any packed number). Because of this all the other fields that come after these fields have the data messed up.

Also I thought maybe it's because of the character to Packed conversion, but then I use a MOVE statement and I'm pretty sure a conversion exists between these two data types. Also the SAP document for conversion between two data types say the source fields can be blank when converting from character to packed and in my case it is sometimes blank and sometimes filled with value. In both cases I always get a junk value like 2020.2020222. Please give me some suggestions. Thanks in advance.

Regards,

Saravana.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
797

HI,

from application server you will get as a string.. then you split at comma and store into internal table right.. in this internal table first take it as a charater for the currency and quantity fields after splitting.. you can use the move command and get it done.;

Thanks

mahesh

5 REPLIES 5
Read only

Former Member
0 Likes
798

HI,

from application server you will get as a string.. then you split at comma and store into internal table right.. in this internal table first take it as a charater for the currency and quantity fields after splitting.. you can use the move command and get it done.;

Thanks

mahesh

Read only

0 Likes
797

Hi Mahesh,

I don't have any field separator in my file. As I said I go by the length of each field. I'm able to successfully load data into my internal table which is of type character. But I get problem only when moving the data from this text field to the actual fields in another structure wa_struct1(which has the standard SAP fields). Thanks for your reply though.

Regards,

Saravana.

Read only

0 Likes
797

Hi

Probably you need to move field by field:

MOVE: FILE-FIELD1 TO WA_STRUC-FIELD1,

......................................................,

FILE-FIELDN TO WA_STRUC-FIELDN.

Probably some value has to be converted before moving to SAP structure.

Max

Read only

0 Likes
797

Hi Max,

I've kept that as the last option. I have around 20 fields in the header structure and around 40 fields in the item structure. Meanwhile I'll try to figure out some way. I even tried ASSIGN with CASTING but doesn't seem to like it either.

Regards,

Saravana.

Read only

0 Likes
797

Thanks Max and Mahesh, I solved the issue. I needed an intermediate structure to port my line type data into fields of type character and then used a MOVE-CORRESPONDING to move it to the structure that had the standard fields. I have awarded points for both of you guys, just for trying to help me.

Regards,

Saravana.