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

Formula Calculation

Former Member
0 Likes
734

Dear ABAP experts

how to calculate below requirement...

ENGLISH NAME

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Eg. If Employee Name is RALPH MARSHALL KING

Then R M K will be decoded and calculated as follows.

(812) +(311) +(1*10) = 139

ARABIC NAME

For Arabic name , we have different method for arriving at the decoded values. In this case also we will be dealing with the 1st , 16th and 31st characters of the name. The decoded values for each of the three characters are derived as follows.

Step 1 . Get the ASCII (three digit number ) value for the individual character.

Step 2 . Get the MOD(ASCII , 10) i.e. the remainder of of the ASCII value after dividing by 10 .

Step 3 . Use the value of step 2 for calculating PART-C.

Eg. If Employee Name is يم عبدالله عبدالرحمن الخضير

Then the name will be decoded and calculated as follows.

Step 1 - The Ascii value for each of the three characters are obtained as follows.

Ascii u2013(1st) = 238

Ascii - (16th ) = 243

Ascii - (31st) = 032

Step 2 - The MOD(Ascii value,10) for each of the three characters are obtained as follows.

MOD(238,10 ) = 8

MOD(243,10 ) = 3

MOD (032,10 ) = 2

Step 3 - The PART-C is calculated as follows.

(812) +(311) +(2*10) = 149

Thanks in advance

4 REPLIES 4
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
684

But looks like you have closed the same thread as "solved".

Read only

Former Member
0 Likes
684

Yes,suhas i have closed it as "Solved" for the first requirment,but not for the second

Thier werent any replies to my next one .so i have opened this. It would be great if you help me in solving this new one .

Thanks

harish

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
684

Hello Harish,

Here is the code you can use for the English name:


PARAMETERS: p_name TYPE string OBLIGATORY.

DATA: itab TYPE STANDARD TABLE OF string,
      wa TYPE string,
      v_init TYPE char1,
      v_off TYPE i,
      v_fact TYPE i,
      v_code_const TYPE i VALUE 12, "Coding constant
      v_code TYPE i. "Code for the name

SPLIT p_name AT ` ` INTO TABLE itab."Split the name at spaces

IF itab IS NOT INITIAL.
  LOOP AT itab INTO wa.
    v_init = wa+0(1).
*   Get the offset of the first found occurence
    FIND v_init IN sy-abcde IGNORING CASE MATCH OFFSET v_off.
    v_off = v_off + 1. "Add 1 to get the position index
    v_fact = v_off MOD 10. "Get the multiplication factor
    v_code = v_code + v_fact * v_code_const.

    v_code_const = v_code_const - 1.
    CLEAR: v_off, v_fact.
  ENDLOOP.
ENDIF.

WRITE:
/ 'English Name:', 15 p_name,
/ 'Decode Value:', 15 v_code.

For the Arabic name, i have a doubt. How do you get the ASCII value for the arabic characters as mentioned in your post ?

If i use the method CL_ABAP_CONV_OUT_CE=>UCCPI i get different values for the arabic characters

BR,

Suhas

Read only

Former Member
0 Likes
684

Solved