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

ABAP Character Data Type Multiplication Issue difference in ITG vs Dev Environments.

Former Member
0 Likes
3,446

Hello Folks,

My problem is very simple but hey I have tried everything and dont know why I have an issue and what is the possible solution. Let me create the scenario:-

SAP Dev Box:

data: prctg type char15.

prctg = '0.065'.

prctg = prctg * 100000.

i see prctg value to be: 6500. Which is good.

SAP ITG Box:

data: prctg type char15.

prctg = '0.065'.

prctg = prctg * 100000.

i see prctg value to be: 65000. Which is absurd and wrong!!!!

.

Question: How can 2 environments behave differently? What is the solution to have the same result as the DEV Box using a reliable method please.

Thanks alot!!!! Yet I have had no one resolve this issue for me in my workplace so I came here desparately!!

Salman

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,970

Guys I have tried all combinations above and nothing has worked. But I have managed to isolate the issue and maybe you people can advice....

The issue described is not happening if i create a simple program TES1 between DEV and ITG. Both behave similarly and correctly.

The issue is only coming while using the exit: FV64A301

So when I have the above piece of code in that exit its acting weird. But if i have the same piece of code outside the exit in a new program it works....Is that an exit specific issue?

16 REPLIES 16
Read only

Former Member
0 Likes
2,970

I'd have to start with, why are you doing math with a char type?  At the very least, you should cast it to a numeric type.

Neal

Read only

0 Likes
2,970

We want the end result in character only due to limitation of the interface. Please suggest me something that will work in both ITG and DEV consistently. Right now i am getting mad!!! Please help....

Read only

0 Likes
2,970

Hi Neal,

I am also from Salman's  team. The issue is even more weird.

I have two numbers:

data : var1 type p decimals 4,

          var2 type p decimals 3.

var2 = 0.065.

var1 = var2.

Thus the value in var1 after assignment becomes 0.0065 !!

But again in Dev system it is working fine.

Can anyone please suggest us a solution. We have tried everything.

Saurabh.

Read only

0 Likes
2,970

Hi

  • I Agree with Neal. Why cant you make you use of a numeric type.
  • Even though it is not a good programming, what you can do is declare the prctg with type 'I' OR 'P' or 'F' and try writing it to the character field.

Eg: DATA VAL1 TYPE C,

                    VAL2 TYPE I.

                   VAL2 = 34.56.

                 WRITE VAL2 TO VAL1.

Regards,

Philip

Read only

0 Likes
2,970

Then you cast it into numeric, and then back to char when you are finished.  Cast is a relative term here.  a = b is in effect a cast if they are of different data types.

Read only

0 Likes
2,970

p types should always have 2 lengths.  Field length  and decimal length.

So,

data : var1 type p length 5 decimals 4,

          var2 type p length 4 decimals 3.

Note the difference in length.  That allows roughly  the same sized number in each.

Neal

Read only

0 Likes
2,970

This does seem the simplest solution, but its always good to know why other things weren't working.

Neal

Read only

0 Likes
2,970

Hi,

This does not work as as the integer variable basically rounds the decimals to the nearest integer...

I also tried with declaring it as P or F but still no luck

Read only

0 Likes
2,970

Tried this also. Doesnt work...Same issue as i had listed in the original question.

Read only

Former Member
0 Likes
2,970

Hi Salman,

Please check and make identical ur user settings in both the systems.

Chack all setting in (SHIFT + F12).

Hope this will resolve ur issue.

Thanks,

Read only

0 Likes
2,970

Hi Salman,

Did you try out the solution which I suggested?

Regards,

Philip.

Read only

0 Likes
2,970

I will try all of the solutions and report back urgently...Thanks alot Guys!

Read only

Former Member
0 Likes
2,971

Guys I have tried all combinations above and nothing has worked. But I have managed to isolate the issue and maybe you people can advice....

The issue described is not happening if i create a simple program TES1 between DEV and ITG. Both behave similarly and correctly.

The issue is only coming while using the exit: FV64A301

So when I have the above piece of code in that exit its acting weird. But if i have the same piece of code outside the exit in a new program it works....Is that an exit specific issue?

Read only

0 Likes
2,970

Salman

What is the exact settings you have in user profile plus what exact output you are getting..Carefully check your decimal and thousand separators. Please add debugging screen shots and sample code details

Nabheet

Read only

0 Likes
2,970

Hi,

It's to do with deactivated 'Fixed point arithmetic' in V61A, where FV64A301 is ultimately included, I believe:

My guess is that in the system, where it is working, someone has activated 'Fixed point arithmetic' in V61A via repair or otherwise.

You can verify if the issue is inactive Fixed point arithmetic, by reproducing (inactivating it in Program attributes) in your test program.

Are you coding your business logic directly in enhancement implementations? If yes, why don't you modularize your business logic in, say, a class method? Or at least a custom Function module? 😐 Define some kind of interface (I don't mean ABAP OO Interface, but interface in general - what SAP data you need to pass, what data you need to return or change), and encapsulate your logic in a separate procedure, which you then can call from Enhancement implementation...

Just because you see too many to count lazy SAP programmers programming ridiculous "naked" (not modularized) enhancement implementations in the middle of existing Function modules and other modularization units, doesn't mean it's a good thing to do... It makes original code more unreadable than it already was and what if you or someone else needs to reuse that business logic...? And as added benefit, you'll encounter less galling issues like this...

cheers

Jānis

Read only

0 Likes
2,970

Great Idea Janis. I did exactly that you mentioned and it worked. Your idea not only helped to solve the issue but also made me make code cleaner. I basically in the Standard 301 exit created a custom function and for that the Arithmetic flag was ticked on and it worked like a charm!!!! thanks again!!