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

field symbol type any conversion error

k_gjergja
Participant
0 Likes
3,818

Hello

I have  a field symbol

field-symbols:<wf_file> TYPE any. ,and the table  WT_file like  alsmex_tabline

(data : WT_file like  alsmex_tabline  occurs ) the field  wt_file-value  is of type CHAR 50 .

Later in a code  i have loop in  the table wt_file  moving the values to field  symbol

at the moment when wt_file-value = /1.3831  I have short dump because of the conversion issue .

Bach slash is there because  later is used as operand for division with 1.3831.

I am surprised because  field symbol is declared as  TYPE ANY .

Could i solve it if i declare field simbol as the same type as the table  wt_file is ?

Thanks

Krsto


LOOP AT wt_file.


wv_cnt = wt_file-col.
CONCATENATE 'WT_FINAL-FLD' wv_cnt INTO wlv_name.
ASSIGN (wlv_name) TO <wf_file>.
MOVE : wt_file-value TO <wf_file>.   " short dump when /1.3831
AT END OF row.
APPEND wt_final.
CLEAR  wt_final.
CLEAR  wv_cnt.
ENDAT.


ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,189

Hi Krsto,

Can you try by  ASSIGN statment instead of moving the value. It shoudl work.

19 REPLIES 19
Read only

Former Member
0 Likes
3,189

Hi Krsto,

You should :

CONCATENATE 'FLD' wv_cnt INTO wlv_name.

ASSIGN COMPONENT wlv_name OF STRUCTURE wt_final TO <wf_file>.

regards,

Archer

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,189
ASSIGN (wlv_name) TO <wf_file>.
MOVE : wt_file-value TO <wf_file>.   " short dump when /1.3831

You should always check if the assignment is successful by checking the SY-SUBRC (or IS ASSIGNED, my personal choice).

BR,

Suhas

Read only

0 Likes
3,189

This message was moderated.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,189

Please read the post before posting a solution. The problem says:

" short dump when /1.3831

In the code there was no check after the ASSIGN statement that's what i was pointing out.

Read only

matt
Active Contributor
0 Likes
3,189

I prefer to check sy-subrc. Semantically IS ASSIGNED would be better, but consider:

ASSIGN (this) TO <fs>.

....

ASSIGN (that) TO <fs>. <------------ this could fail

IF <fs> IS ASSIGNED. <--------- but if the first one assign worked, then this will be true

do stuff.

ENDIF.

Read only

0 Likes
3,189

This message was moderated.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,189

Valid point, but i have this habit of UNASSIGNing the field-symbol before every assignment (maybe an overkill)

ASSIGN (this) TO <fs>.

....

UNASSIGN <fs>. <------- Unassign the FS

ASSIGN (that) TO <fs>. <------------ this could fail

IF <fs> IS ASSIGNED. <--------- but if the first one assign worked, then this will be true

do stuff.

ENDIF.

Read only

0 Likes
3,189

I definitely think sy-subrc is more useful. Anyway Krsto assigned some points to himself so I think he finally understood his error.

Read only

0 Likes
3,189

Fortunately you cannot assign points to yourself, as this would result in SY-SUBRC = 4 or even a non-catchable IMMODEST_BEHAVIOUR short dump.

Thomas

Read only

Former Member
0 Likes
3,190

Hi Krsto,

Can you try by  ASSIGN statment instead of moving the value. It shoudl work.

Read only

Former Member
0 Likes
3,189

Hi Krsto,

it won't be of type any after the assign, so what type was field wt_final-fld... at the moment of short dump and what value was in wt_file-value?

regards,

Edgar

Read only

0 Likes
3,189

Hi ,

The value was /1.3831

Thanks

Read only

0 Likes
3,189

Ok but what type is variable wt_final-fld?

If it's a numeric type then your dump is normal.

Again, your field symbol is NOT of type any at the dump moment.

Read only

0 Likes
3,189

wt_final-value  is char 50

Read only

0 Likes
3,189

Hi

If you are using same field symbol in two places, did you un assign first after the use.

The issue may be due to that. Just athought.

Regards

Sree

Read only

0 Likes
3,189

That's irrelevant Krsto,

It's when you assign the variable that you typify it:

ASSIGN (wlv_name) TO <wf_file>.

In this moment wlv_name is the name of the variable 'WT_FINAL-FLD' and some number.

What type is this variable? It's not the same as WT_FINAL-VALUE.

Regards,

Edgar

Read only

gaurab_banerji
Active Participant
0 Likes
3,189

Have you declared the field symbol <wf_file> with TYPE ANY or any numeric data type?

It probably got type casted to Numeric and thats why it cannot accept  a character one (due to the slash /) now.

Read only

gaurab_banerji
Active Participant
0 Likes
3,189

Is the problem solved? kindly let us know.

Read only

0 Likes
3,189

Hi ,

Not yet , I sent proposal . The program is not in  my ownership. I will let you know .

Thanks