‎2008 Apr 23 6:31 AM
Hi Friends,
I am writing a code where i am getting a data from data base table into a internal table ( structure of internal table same as database table ) and then from internal table moving the data into a different table (defined in the program) this defined program has less number of fields. Like internal table has 10 fields where as this defined table has 8 fields. Data type of the fields are not same.
so i want to know whether data type creates problem while loading and if yes then how shall i move the data into the defined table.
Thanks,
Nagesh.
‎2008 Apr 23 6:52 AM
Hi Nagesh,
I think data type might be different in your case, but not the the lengths, i hope. If the lengths are also different, then there ids no point in moving the data in Internal Table to another table, as u lose some of the information i.e the value will be truncated.
As well as the MOVE statement, which converts the value of the source field into the data type of the target field, there is also a statement WRITE TO, which converts the contents of the source field into a field with type C.
WRITE <f1> TO <f2> .
This statement converts the contents of a data object <f1> to type C, and places the string in the variable <f2>.
For example, if u have some Quantity fields or Currency fields in ur internal table & if the target field in ur Table is of Char type, then u can use WRITE...TO... command for the conversion.
WRITE wa_table-field1 TO v_char1.
Then, u insert v_char1 into ur table. If u need to convert any type of field value to Char type, this would be helpful.
If u want further information about this, go for F1 Help on WRITE...TO...statement.....
Dont forget to reward if helpful.....
Pavan.
‎2008 Apr 23 6:39 AM
Hi,
Data type matters sometime, but length matters the most.
for eg: if ur inserting any numeric (internal table) field to charcter type (table) it will accept. Its always advised to have same data type.
SOMETIMES IT MIGHT THROW RUNTIME ERROR, DUE TO CONVERSION PROBLEM.
REWARD IF USEFUL
‎2008 Apr 23 6:52 AM
Hi Nagesh,
I think data type might be different in your case, but not the the lengths, i hope. If the lengths are also different, then there ids no point in moving the data in Internal Table to another table, as u lose some of the information i.e the value will be truncated.
As well as the MOVE statement, which converts the value of the source field into the data type of the target field, there is also a statement WRITE TO, which converts the contents of the source field into a field with type C.
WRITE <f1> TO <f2> .
This statement converts the contents of a data object <f1> to type C, and places the string in the variable <f2>.
For example, if u have some Quantity fields or Currency fields in ur internal table & if the target field in ur Table is of Char type, then u can use WRITE...TO... command for the conversion.
WRITE wa_table-field1 TO v_char1.
Then, u insert v_char1 into ur table. If u need to convert any type of field value to Char type, this would be helpful.
If u want further information about this, go for F1 Help on WRITE...TO...statement.....
Dont forget to reward if helpful.....
Pavan.