cancel
Showing results for 
Search instead for 
Did you mean: 

Help with transformation formula/routine!

Former Member
0 Kudos

Hi all!

I'm preparing data for a report which will be used as an import template for another external program.

We have all these account numbers in SAP R/3 and BI that is made up of 6 digits.

I have to translate them in to the format needed for my report.

Only problem is - there is a lot of accounts.

For example - account 500000-519999 is going to be translated in to number 5010, so all of those numbers will receive the same account in the report.

How do one go about writing such a transformation routine or formula for this? Is there a way to include an array in to a formula like "IF ZACCOUNT = {500000-519999}, "5010", "NOT ASSIGNED" "

Something like that?

Thankful for every bit of help that I can receive on this!

Accepted Solutions (1)

Accepted Solutions (1)

dennis_scoville4
Active Contributor
0 Kudos

Try one of these routines, depending on your scenario:

7.x Code - Transformation


CONSTANTS: c_5010(4) TYPE c VALUE '5010',
           c_na(12) TYPE c VALUE 'NOT ASSIGNED'.

IF source_fields-/bic/zaccount BETWEEN 500000 AND 519999.
  result = c_5010.
ELSE.
  result = c_na.
ENDIF.

3.x Code - Start Routine of Update Rules


 CONSTANTS: c_5010(4) TYPE c VALUE '5010',
           c_na(12) TYPE c VALUE 'NOT ASSIGNED'.

DATA: l_tabix TYPE sy-tabix.

LOOP AT data_package.

  l_tabix = sy-tabix.

  IF data_package-/bic/zaccount BETWEEN 500000 AND 519999.
    data_package-/bic/zreport_account = c_5010.
  ELSE.
    data_package-/bic/zreport_account = c_na.
  ENDIF.

  MODIFY
    data_package
  INDEX
    l_tabix.

ENDLOOP.

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks guys. I will look in to this asap. Will return to distribute points, SDN forums at its best!

//Anders

Former Member
0 Kudos

Hello Anders,

I guess your requirement is you have account numbers from 500000-519999 and you want to write a hard coded value of 5010 if this is the case and the rest as "#".

I am assuming that you are writing this in your start routine.

ranges: r_source like <same properties as your account number>.

R_source-LOW = '500000'.

R_SOURCE-SIGN = 'I'.

R_SOURCE-OPTION = 'EQ'.

append R_SOURCE.

R_SOURCE-LOW = '519999'.

R_SOURCE-SIGN = 'I'.

R_SOURCE-OPTION = 'EQ'.

append R_SOURCE.

loop at data_package.

if data_package-acnt number in r_source.

data_package-acnt number = '5010'.

modify data_package-acnt number.

else.

data_package-acnt number = '#'.

endif.

endloop.

This must be the logic if I understood your requirement correctly.

Regards,

Kris...

Edited by: Krishna Kirit on Oct 1, 2009 7:29 PM

Edited by: Krishna Kirit on Oct 1, 2009 7:29 PM