Archived discussions are read-only. Learn more about SAP Q&A

How to check data type of the field symbol at run time

Hi,

My code is as following:

LOOP AT <fs> ASSIGNING <wa_covp_ext>.

ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.

IF sy-subrc = 0.

ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.

IF sy-subrc = 0.

SELECT SINGLE sname INTO <f_zzname> FROM pa0001

WHERE pernr = <f_pernr>

AND endda GE sy-datum

AND begda LE sy-datum.

ENDIF.

ENDIF.

ENDLOOP.

This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.

How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.

Not what you were looking for? View more on this topic or Ask a question