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

data from a field into a structure

Former Member
0 Likes
819

Hi all,

There is field in a structure which contains data in the form of a flat file. I need to break this data and fill it in the respective fields of another structure.

Please suggest some fucntion module for the same or may b some ways to do this..

Thanks

Deepti

Hi all,

There is field in a structure which contains data in the form of a flat file. I need to break this data and fill it in the respective fields of another structure.

Please suggest some fucntion module for the same or may b some ways to do this..

Thanks

Deepti

5 REPLIES 5
Read only

former_member212005
Active Contributor
0 Likes
782

Deepti............what u can do is...

SPLIT the data into the fields of structure


SPLIT lv_string2 AT cl_abap_char_utilities=>horizontal_tab      "if its TAB separated records i.e. 'xls'.
INTO ls_struct-field1 ls_struct-field2.

SPLIT lv_string2 AT ','      "if its comma separated records i.e. 'csv'.
INTO ls_struct-field1 ls_struct-field2.

Read only

Former Member
0 Likes
782

The data in the field PRELP-DATA1 needs to be seperated...

Read only

Former Member
0 Likes
782

Please look at the sample below code

<< Please respect the 2,500 character posting limit. Post only the relevant portion of your code >>

in the above code iam spliting the line and assiging into wa_mat and alter appending into

internal table it_mat.

Please create a similar program like this

let me know if youneed further information.

Regards

Satish Boguda

Edited by: Rob Burbank on Dec 31, 2009 11:29 PM

Read only

Former Member
0 Likes
782

Hi Deepti ,

If you are knowing the how the data is stored in the file i.e no , name , length , order and type of fields then just declare type in same format .

After this you can move the values of fields into the workarea or internal table.

Hope this helps you.

Read only

Sm1tje
Active Contributor
0 Likes
782

There is no function module, so you will have to do this 'manually'. But you do need some additional info on the fields contained in your field of the structure. The most important thing is the length of all individual fields from this structure field. Using the length you have to move them one by one to your new data field. Second thing that could be of importance is the field definition (Type), for example is it a character field, numeric field or maybe a date. If you have determined this, what is the format of this date, is it YYYYMMDD or DDMMYYYY etc.

Example.

The field of your structure is of type string (undefined length) and has 3 fields without separator.

Vohra Deepthi 20091231

As you can see, this is Lastname (length 10), Firstname (length 10) and current date.

Variables to declare:

data: lvc_firstname(10) type c,

lvc_lastname(10) type c,

lvd_current_date type d.

Move the fields from structure to variables:

lvc_lastname = structure-field+0(10).

lvc_firstname = structure-field+10(10).

lvd_current_date = structure-field+20(8).