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

SELECT .... INTO CORRESPONDING - Internal table

Former Member
0 Likes
1,426

How do everyone,

I have the following work areas and internal table defintion:

TYPES: BEGIN OF equi_rec,

equnr, " Registration

herst, " Make

typbz, " Model

zzdept, " Department

zzoperator, " Operator

zzregdate, " Registration Date

END OF equi_rec.

DATA: equi_wa TYPE equi_rec,

equi_tab TYPE TABLE OF equi_rec.

In the code:

SELECT *

INTO CORRESPONDING FIELDS OF TABLE equi_tab

FROM

equi.

The ABAP is falling over at runtime. I have since found out that if

I comment out the ZZREGDATE in the EQUI_REC above, the program works.

The ZZREGDATE is defined as a date in the dicionary.

Can anyone tell me why the program is falling over when I am trying to

move the date field??

Any help much apprectaied.

Thanks in advance

Andy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,084

Hi,

Here is the answer ..

TYPES: BEGIN OF equi_rec,

equnr, " Registration

herst, " Make

typbz, " Model

zzdept, " Department

zzoperator, " Operator

zzregdate, " Registration Date

END OF equi_rec.

If you declare like above, then all the fields will have Charecter type and length is 1, so the EQUNR, HERST and all other fields is charecter type then it is storing the first charecter in this Internal table, but the ZZREGDATE is the date field and it will not store the first charecter from the date field, because if you use the MOVE-CORRESPONDING then you need to write the same type, so that it is giving the dump ..

after writing the TYPE for ZZREGDATE then the program will run properly, but all the fields will store only the first charecter from the table values,

you need to give the correct TYPE to all the fields from the data dictionary inorder to store the total value

Reward points for all the helpful answers

Regards

Sudheer

9 REPLIES 9
Read only

prabhu_s2
Active Contributor
0 Likes
1,084

it shud work. check for the declaration and is the declaration valid in table aswell?

Read only

Former Member
0 Likes
1,084

Hi,

You need to assign the data dictonary types to the Internal table fields

TYPES: BEGIN OF equi_rec,

equnr type EQUNR, " Registration " Here i assigned the EQUNR data element

herst, " Make

typbz, " Model

zzdept, " Department

zzoperator, " Operator

zzregdate, " Registration Date

END OF equi_rec.

In the same way, attach to all the fields

Regards

Sudheer

Read only

Former Member
0 Likes
1,084

can u please paste ur code so that i can help u...

thanks,

maheedhar

Read only

Former Member
0 Likes
1,084

In you types definition how are you defining zzregdate (i.e. TYPE, LIKE) ? Is it defined or referenced to a date field?

Read only

Former Member
0 Likes
1,084

Did you specify the type of the fields in your table equi_rec?

like


equinr      type table-equinr,
zzregdate type table-date

And instead of using into corresponding field of table .... identify the fields you want to select which is more faster.

Then try your program again.

Read only

0 Likes
1,084

Thanks for replying everyone.

The strange thing is that I have a similar piece of code:

TYPES: BEGIN OF viqmel_rec,

aufnr,

equnr,

qmtxt,

kunum,

END OF viqmel_rec.

DATA: viqmel_wa TYPE viqmel_rec,

viqmel_tab TYPE TABLE OF viqmel_rec.

and if I write:

SELECT *

INTO CORRESPONDING FIELDS OF TABLE viqmel_tab

FROM

viqmel.

The program works.

I have now since found out that the problem is ZZREGDATE if I comment

out this in the table delcaration the program works. Why shoud it fail

on a date field??

Read only

0 Likes
1,084

Ignore my last response.

I have the solution by having to declare the field as a date

i.e. ZZREGDATE like equi-zzregdate

So my question now is Why do you have to define the date fields

and not the other fields???

Read only

Former Member
0 Likes
1,085

Hi,

Here is the answer ..

TYPES: BEGIN OF equi_rec,

equnr, " Registration

herst, " Make

typbz, " Model

zzdept, " Department

zzoperator, " Operator

zzregdate, " Registration Date

END OF equi_rec.

If you declare like above, then all the fields will have Charecter type and length is 1, so the EQUNR, HERST and all other fields is charecter type then it is storing the first charecter in this Internal table, but the ZZREGDATE is the date field and it will not store the first charecter from the date field, because if you use the MOVE-CORRESPONDING then you need to write the same type, so that it is giving the dump ..

after writing the TYPE for ZZREGDATE then the program will run properly, but all the fields will store only the first charecter from the table values,

you need to give the correct TYPE to all the fields from the data dictionary inorder to store the total value

Reward points for all the helpful answers

Regards

Sudheer

Read only

0 Likes
1,084

Top man Sudheer, many thanks for the explantion.

Cheers

Andy