A mystery to start.. (Do all ABAPers know Fixed Point Arithmetic)
What might be the result of this compose articulation.
DATA: v_kwert_n TYPE kwert. v_kwert_n = '1.234'. WRITE:/ 'From Program: ', v_kwert_n.
Did you figure it could be ‘1.234’? Or on the other hand assuming that you were infront of the framework and you ended up taking a gander at the information component KWERT and it has 2 decimal. So you figured it would be ‘1.23’. Let’s go into the practical on this question, do all ABAPers know Fixed Point Arithmetic?
Allow me to show what my result was.
Oopss!!! This isn’t the very thing you anticipated. Correct?
Presently, you would attempt to challenge this result by really, composing the above lines of code in your framework. What!!! You get an alternate result.
Your result for a similar code.
All in all, for what reason is it different in yours and mine? Allow me to acquaint you with the top story, ‘Fixed Point Number-crunching’ (FPA). My program had the Proper Point Number juggling (menu->go to->attribute) uncontrolled. Yours’ absolute requirement been checked naturally.
As indicated by SAP, Fixed point number-crunching:
Assuming that you mark this checkbox, all estimations in the program will utilize fixed point math.
In the event that you don’t choose this actually look at box, stuffed numbers (ABAP/4 sort P, Word reference types CURR, DEC or QUAN) will be treated as whole numbers when they are utilized in tasks, examinations, and computations, regardless of the quantity of decimal spots characterized. Transitional outcomes in math estimations will likewise be adjusted to the following entire number. The quantity of decimal spots characterized is possibly considered when you yield the response utilizing the Compose explanation.
As a program quality, the decent point mathematics decides if for quantities of type p the decimal point is regarded by tasks or not.
Presently, let us see the way of behaving of the beneath code.
* In calling Program DATA: v_kwert TYPE kwert, v_kwert_n TYPE kwert. v_kwert_n = ( 1000 * '1.234' ) / 1000. * Calling FM to multiply the same number with 1000 and divide by 1000 CALL FUNCTION 'Elearning' IMPORTING xkwert = v_kwert. WRITE:/ 'From Program: ', 20 v_kwert_n. WRITE:/ 'From FM: ', 20 v_kwert.
* In FM Elearning. FUNCTION Elearning. xkwert = ( 1000 * '1.234' ) / 1000. ENDFUNCTION.
Check, the numerical articulation is precise in the calling program and called FM. Yet, the result is unique, in light of the fact that the Program has Fixed Point Math unrestrained while the FM has it checked.
Mess about by turning the FPA on and off on the other hand in program and FM and see the result.
SAP unequivocally suggest not turning off the proper point number-crunching in any program.
Genuine Venture Situation: Really look at the down to earth issue, where the client has issue in computation in VOFM routine where the standard SAP program SAPLV61A doesn’t have Fixed Point Math checked.
In such cases, we ought to call a custom FM with Fixed Point Arithimetic checked and do the computation in the FM and pass the last worth to the primary program (VOFM).
With the above gyan (sanskrit word for information), let us check whether we could decide the right result of the beneath code (taken from SAP Help documentation)
CLASS cl_test DEFINITION. PUBLIC SECTION. CLASS-METHODS meth RETURNING value(p) TYPE string. ENDCLASS. CLASS cl_test IMPLEMENTATION. METHOD meth. p = '1000'. ENDMETHOD. ENDCLASS. * Calling in program START-OF-SELECTION. DATA v_pack TYPE p DECIMALS 2. v_pack = cl_test=>meth( ). write:/ v_pack.
The present Something worth mulling over.
I) What might be the result worth of variable v_pack assuming that the Decent Point Number juggling is checked?
ii) What might be the result worth of variable v_pack in the event that the Decent Point Number juggling isn’t checked?
Assuming that you enjoyed it, kindly offer it! Much obliged!
YOU MAY BE INTERESTED IN
SAP ALE IDoc Configuration Steps: Streamlining Communication
Adapting generative AI to business context
How to integrate sap with other systems ?