12-13-2011 8:43 AM
Hi Team,
I have written a SELECT statement on MARA table as below.
TRY.
SELECT matnr zzwftag FROM mara CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE gt_mara WHERE
mandt = sy-mandt AND
zzwftag NE space
AND zzwftag IS NOT NULL
AND zzwftag NE '#'
AND zzwftag NE '%#%'
AND zzwftag NE ' '
AND zzwftag NOT LIKE '%/%'(012).
CATCH cx_sy_dynamic_osql_error.
MESSAGE 'Error While Fetching Data from MARA'(044) TYPE 'S'(040) DISPLAY LIKE 'W'(041).
ENDTRY.
IF NOT gt_mara[] IS INITIAL.
DELETE gt_mara[] WHERE zzwftag EQ '#'
OR zzwftag IS INITIAL
OR zzwftag EQ space
OR zzwftag EQ ' '.
ENDIF.
Observations: 1. In
the resulting internal table I am seeing '#' values for fields zzwftag which are actually empty when I see the record in SE11 in MARA(ALV display). It shows '#' in it in SE16 display(We can choose User parameters and hence mode of display in SE11)
The requirement is to avoid those records where zzwftag is initial i.e. blank. I tried to delete invalid records but to no avail.
Please suggest any way where I can get the Select correct.
Regards,
Amit
12-13-2011 9:03 AM
Hello Amit,
Try to see in debugging mode how it stored the '#' value.
Else there is no problem in ur code its perfectly fine.
DELETE gt_mara[] WHERE zzwftag EQ '#'.
must work,if values is exactly # in the DB. check it out in debugging.
thanks
~Raj
12-13-2011 9:06 AM
Hi Raj,
In the debug the Field value is shown as '#' only.
Regards,
Amit
12-14-2011 7:26 AM
Try with This and check once...
DELETE gt_mara[] WHERE zzwftag EQ cl_abap_char_utilities=>horizontal_tab.
Regards,
gurpreet
12-14-2011 11:42 AM
If these customfields are added just now can you please check if the initialize checkbox in append structer is check while adding and if it is not checked it can store junk values for old material data.
If checkbox is not checked please check it and activate again.
Nabheet
12-14-2011 1:06 PM
There are some characters like horizontal tabs and line breakers that are shown as "#", but they are not really this character... # is just used because the debugger couldn't display the real value.
Check the hexadecimal values for the field that has #, you'll probably see values that correspond to the attributes in class cl_abap_char_utilities . Use those static attributes to filter your internal tables records.
12-31-2011 3:36 AM
Please do not use so many not conditions in one query....
Using so many negative conditions results in bad data.
Instead use delete statements later this would not confuse the system.
Also if you are using sy-mandt then i think you should not use client specified system will take care of it.
TRY.
SELECT matnr zzwftag FROM mara CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE gt_mara WHERE
mandt = sy-mandt AND
zzwftag NE space.
CATCH cx_sy_dynamic_osql_error.
MESSAGE 'Error While Fetching Data from MARA'(044) TYPE 'S'(040) DISPLAY LIKE 'W'(041).
ENDTRY.
IF NOT gt_mara[] IS INITIAL.
DELETE gt_mara[] WHERE zzwftag EQ '#'
OR zzwftag IS INITIAL
OR zzwftag EQ space
OR zzwftag EQ ' '.
delete gt_mara[] where zzwflag eq '%#%'.
ENDIF.