04-16-2009 3:18 PM
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.
04-16-2009 3:28 PM
check this ...
write describe statement ...
field-symbols : <f_zzname> .
data : sname like pa0001-sname,
typ(10).
assign sname to <f_zzname>.
describe field <f_zzname> type typ.
write : typ. <-- typ contains character type in this case ..
U can check if typ is of character(C) if so .. write the select statement ...
04-16-2009 5:23 PM
Hi Srini,
Thanks for your reply. I tried this logic, but the describe statement returns the type,length and decimals ONLY IF the field is character data type. In my code, the field symbol has values either character 30 or packed decimal length 8 decimals 2. When field symbol has packed decimal, the describe statement gives dump.
04-16-2009 5:27 PM
04-16-2009 6:53 PM
09-21-2016 12:06 PM
Ashwini Kalyankar wrote:
Is there any FM which can be used for this purpose?
No. There is a class.
09-21-2016 12:43 PM
Hi,
When you are sure which field u want to fetch (SNAME in this case), why not declare the field symbol of the same type.
Why to assign the component and all.
Hope this helps.