SELECT statement with WHERE clause results in an ERROR
I am using following select statement in a program line within a SmartForm which results in an error.
INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1
WHERE VBELN = '220'
AND PARVW = 'SP'.
If I modify this statement as below then it is working fine.
INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1.
Can anyone please suggest me what is the problem with above statement.
Matthew Billingham replied
Thank-you - now you've been explicit, I can make suggestions. Next time, try to give sufficient information without being promted.
If you look at the domains VBELN and PARVW, you'll see they both have conversion routines - ALPHA and PARVW respectively. Use those conversion routines before doing the select.
DATA: l_vbeln TYPE vbeln, l_parvw TYPE parvw. l_vbeln = '220'. l_parvw = 'SP'. CALL FUNCTION MODULE 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING INPUT = l_vbeln IMPORTING OUTPUT = l_vbeln. CALL FUNCTION MODULE 'CONVERSION_EXIT_PARVW_INPUT' EXPORTING INPUT = l_parvw IMPORTING OUTPUT = l_parvw. SELECT * FROM VBPA INTO CORRESPONDING FIELDS OF TABLE T_KUNNR1 WHERE VBELN EQ l_vbeln AND PARVW EQ l_parvw.
So, the vbeln value was held internally with leading zeros, AND the parvw value 'SP' is held internally as 'AG'. But don't ever select using "AG", always use the conversion exits.