Register Login

Can not converted to be a charter-type field

Updated May 18, 2018

Hi,

&------------ --------- -------- ------------ --------- --------- ----------
*& Report ZT11
*&


&------------ --------- -------- ------------ --------- --------- ----------
*&
*&
&------------ --------- -------- ------------ --------- --------- ----------

REPORT ZT11.
DATA: aa type lfa1.

tables lfa1.
select * from lfa1 into aa where lifnr > 'Z' .
write / aa.
endselect.
if sy-subrc 0.
write / 'No records found'.
endif.
error is
'AA' can not converted to a character-type field.



Thanks


Comments

  • 12 May 2010 5:09 am Shalesh Singh Visen
    Do it this way!
    when u r writing aa you have to specify the variables like aa-variabl1, aa-variable2 ans so on.

    REPORT zt11.
    DATA: aa TYPE lfa1.

    TABLES lfa1.

    SELECT * FROM lfa1 INTO aa WHERE lifnr > 'Z'.
    WRITE :/ aa-lifnr, aa-name1. " variables of LFA1. this will solve your problem.
    ENDSELECT.

    IF sy-subrc = 0.
    WRITE / 'No records found'.
    ENDIF.
  • 12 May 2010 5:09 am Shalesh Singh Visen
    You declared AA as a table type instead of as a table field.

    It should be declared like:
    DATA: AA like Tablename-fieldname .

    for example: Data: AA like LFA1-LIFNR.
  • 12 May 2010 5:10 am Shalesh Singh Visen
    Try this now.

    REPORT ZT11.
    DATA: aa like lfa1.

    tables lfa1.
    select * from lfa1 into aa where lifnr > 'Z' .
    write / aa-lifnr.
    endselect.
    if sy-subrc <> 0.
    write / 'No records found'.
    endif.
  • 12 May 2010 5:10 am Shalesh Singh Visen
    try..writing individual fields of the structure.. like
    write: / aa-field1, aa-field2..
    dis way..
    and if dis doesnt work..you can declare a character or string variable and pass the values of individual fields of the structure to the variable and den write the character/string variable..maybe dis way..
    DATA: aa type lfa1,
    lv_string type string.

    tables lfa1.
    select * from lfa1 into aa where lifnr > 'Z' .
    lv_string = aa-field1
    write lv_string.
    clear lv_string.
    lv_string = aa-field2."use dis code only for the non-character fields of the struture..rest u "can directly write as aa-fieldname.
    endselect.
  • 12 May 2010 5:10 am Shalesh Singh Visen
    try the below solution. It will work.

    &------------ --------- -------- ------------ --------- --------- ----------
    *& Report ZT11
    *&


    &------------ --------- -------- ------------ --------- --------- ----------
    *&
    *&
    &------------ --------- -------- ------------ --------- --------- ----------

    REPORT ZT11.
    DATA: aa type lfa1.

    tables lfa1.
    select * from lfa1 into aa where lifnr > 'Z' .

    if sy-subrc = 0.
    write / aa-lifnr, aa-land1, ........ [Write all the fields u want to print in the output here]

    endselect.

    You should not use the statement write: aa.
    if sy-subrc 0.
    write / 'No records found'.
    endif.
  • 15 Mar 2013 5:25 pm Guest
    "WA_LFA1 Cannot be converted to a character-type field" -- I'm getting this error message while executing the below program. Any help with this would be much appreciated. Thanks

    DATA BEGIN OF WA_LFA1.
    INCLUDE STRUCTURE LFA1.
    DATA END OF WA_LFA1.

    DATA IT_LFA1 LIKE TABLE OF WA_LFA1.

    SELECT * FROM LFA1 INTO TABLE IT_LFA1.

    LOOP AT IT_LFA1 INTO WA_LFA1.

    WRITE WA_LFA1.

    ENDLOOP.

    **** I implemented the same logic by using T001 table and didn't get this error . I'm getting the above when I was working LFA1 table ****

    Many thanks.

×