Skip to Content
author's profile photo Former Member
Former Member

Select on MARA resulting into # values in internal table for one field

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 09: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 14, 2011 at 07:26 AM

    Try with This and check once...

    DELETE gt_mara[] WHERE zzwftag EQ cl_abap_char_utilities=>horizontal_tab.

    Regards,

    gurpreet

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 14, 2011 at 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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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.

  • author's profile photo Former Member
    Former Member
    Posted on Dec 31, 2011 at 03: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.