2009 Dec 31 1:03 PM
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
2009 Dec 31 1:22 PM
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.
2009 Dec 31 1:37 PM
2009 Dec 31 2:51 PM
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
2009 Dec 31 3:09 PM
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.
2009 Dec 31 3:11 PM
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).
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |