Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with junk characters

Former Member
0 Likes
2,695

Hi All,

Im facing a problem with a junk characters.

Here is the problem:

IF flg_xwia = 'X' AND NOT bkpf-bukrs IS initial.

PERFORM read_t001 USING bkpf-bukrs.

ENDIF.

In the above condition the bkpf-bukrs is getting "####' value..hence the perform is executed.

In that perform a select query is written to fetch some data from t001, with bkpf-bukrs in where condition. As it fails(bcause bkpf-bukrs has junk value), the system displays a error message, which does not happen.

So I have changed the code like below:

IF flg_xwia = 'X' AND bkpf-bukrs NE '####'.

PERFORM read_t001 USING bkpf-bukrs.

ENDIF.

Problem is the system still executing the perform statement...It means its not comparing the bkpf-bukrs value with '####'.

(but bkpf-bukrs still has the value '####')

So again changed the code like below:

DATA: w_flag type C.

Clear w_flag.

IF bkpf-bukrs = '####'.

w_flag = 'X'.

ENDIF.

IF w_flag is INITIAL.

IF flg_xwia = 'X' AND NOT bkpf-bukrs IS initial.

PERFORM read_t001 USING bkpf-bukrs.

ENDIF.

ENDIF.

Still the same problem...the IF condition above isnt executed and flag never set to 'X'.

Please suggest me..hw to validate this?

Thanks,

Priya

19 REPLIES 19
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,612

Hello Priya,

Check in the debug mode what is the hex-value for '####'? I think these are some garbled characters & not mere '#'s.

BR,

Suhas

Read only

Former Member
0 Likes
2,612

Suhas,

Thanks for ur reply!

Yes, I believe that..the value of bkpf-bukrs is not just '#(Ash)', its getting some garbled value.

Earlier in 4.7 version, it was written like below:

IF flg_xwia = 'X' AND bkpf-bukrs NE hex00

PERFORM read_t001 USING bkpf-bukrs.

ENDIF.

The value of hex00 was also '####', so the perform statement was never executed.

Now, the system got upgraded to ECC6, and in unicode checks its got modified to :

IF flg_xwia = 'X' AND NOT bkpf-bukrs IS initial.

PERFORM read_t001 USING bkpf-bukrs.

ENDIF.

I chkd the Hex value here...it has '00000000'.

Help me how to resolve the issue?

Thanks in advance,

Priya

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
2,612

IF flg_xwia = 'X' AND NOT bkpf-bukrs IS initial.

PERFORM read_t001 USING bkpf-bukrs.

ENDIF.

Clear the work area before loop and also you can try using.

IF flg_xwia = 'X' .

if bkpf-bukrs is not initial.

Read only

0 Likes
2,612

Hi Sandeep,

That doesnt work out..since bkpf-bukrs was not initial( it has some garbage value).

Can anyone pls help me how to validate the junk value..

Requirement: Suppose the value of bkpf-bukrs has some junk value then it should not execute the following statement.

Pls suggest.

Rgs,

Priya

Read only

0 Likes
2,612

Hi priya,

I tried to simulate back your question...

1. How did you query your BKPF-BUKRS? Or how was it fill up in the first place?

2. Did you clear BKPF before you do a SELECT or query on it?

Cos in my test, even if i unable to query a value out, my BKPF-BUKRS stays blank.

William Wilstroth
Read only

0 Likes
2,612

Hi Priya,

Try the reverse. Check if BKPF-BUKRS contains only A-Z or Numbers. If yes then proceed with your logic.

Regards,

Immanuel.

Read only

0 Likes
2,612

Hi,

What are the junk values you are getting.. if it is onl;y # then you can use "CA" contains any '#' then don't execute. something like this.

Regards,

Nagaraj

Read only

0 Likes
2,612

HI ,

CHECK THAT GARBAGE VALUE WITH

cl_abap_char_utilities=>HORIZONTAL_TAB

Also check from where you are getting

bkpf-bukrs '####' .

or check data type .

Regards

Deepak

Edited by: Deepak Dhamat on Oct 22, 2010 8:23 AM

Read only

0 Likes
2,612

Hi Immanuel,

This looks interesting.

Could you pls provide me an example to check the if conditon, like you said.

Thnks,

Priya

Read only

0 Likes
2,612

Hi Priya ,

First try to find the root Cause , then find solution .

Regards

Deepak.

Read only

0 Likes
2,612

Hi Priya,

If the character cannot be identified then we can go by the characters which will be allowed for that field.

I hope your company codes will contain only Alphanumeric values. So we can check if that field contains only Alphabets and numerics. You can further filter by the pattern used for company codes in your organisation. In my organisation only numerics are used. So I can check only if BKPF-BUKRS contains numerics. Something like below.


IF bkpf-bukrs CO '0123456789'.

* Your Logic *

ENDIF.

Also check the source for this BKPF-BUKRS. If you are getting this value from external sources then you can validate like above. But if you are fetching somewhere from within SAP itself then better check the fetching logic first.

Hope this helps :).

Regards,

Immanuel.

Read only

0 Likes
2,612

Hi Immanuel,

Thanks for your information.

In my company the company code is always an alpha-numeric.

Pls suggest hw to check with CO. ( need to keep all alphabets or what?

-Priya

Read only

0 Likes
2,612

Hi Priya,

Why don't you use the other approach which i suggested.

For your question yes you have to check alphabets as well.

Regards,

Nagaraj

Read only

0 Likes
2,612

Hi Priya,

We have the system variable SY-ABCDE. You can make use of it. If your company codes are alphanumeric then need to check if BKPF-BUKRS contains only combination of SY-ABCDE and '012456789'. I am not familiar with the REGEX technique mentioned by Pavan. IF using CO is tedious then can try the REGEX technique.

Regards,

Immanuel.

Read only

0 Likes
2,612

Hi,

Have chkd lyk that earlier.

But it not considering '#' as Ash in our keyboard. Hope it is some junk value which looks similar to '#'.

-Priya

Read only

0 Likes
2,612

Like someone else already mentioned: find out what is causing this error, where do the junk characters come from. Once you know that you can solve it. Now you just have people spamming solutions and they all don't work.

Read only

0 Likes
2,612

HI,

Have you checked from where ur getting the BUKRS before the perform, check with a watchpoint and also do check in the table BKPF for tat document what BUKRS you have . Do check this first .

And for the existing logic if it is not a performance issue then u can do add this logic b4 the perform

Select from T001 with BUKRS = BKPF-BUKRS

if sy-subrc eq 0.

PERFORM read_t001 USING bkpf-bukrs.

endif.

Regards,

Madhukar Shetty

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,612

Hello Priya,

I agree with Maen. If you check BKPF-BUKRS has T001 as a check table. I'm sure you don't have any CoCd defined as '####' (hex value '00000000'). How are you getting the value in BKPF-BUKRS? Any select query, input file, idoc etc.?

I would suggest you check why the input to BKPF-BUKRS rather than trying to implement some 'crappy' solution based on some assumption.

BR,

Suhas

Read only

Former Member
0 Likes
2,612

Hello,

If you are pretty sure that BUKRS will not have any special characters other than numbers and Lower and upper case letters, you can use the below condition.

FIND REGEX '^[:alnum:]' IN BUKRS.
IF sy-subrc EQ 0.
* Something which is not a letter oder number was found
ENDIF.

Want to find out more type REGEX and press F1.

Hope it Helps!

Regards,

Pavan.

Edited by: Pavankumar Adiraju on Oct 22, 2010 8:21 AM