Application Development 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: 

ABAP Routine

former_member206475
Active Participant
0 Kudos

Dear All,

I have a scenario in BI to implement ABAP.

Master data table:

GL Account     Cost Center

111                    ???315*

222                    ?????315**

333                    ?315*****

As we see that the cost center is stored in strange manner.

Now we have Transaction data coming as below:

Cost center

9993150

8153150

93150

Now as we see the pattern '315' is what we have to focus. For Cost center ???315* matches with the 9993150 and 8153150 so 111 will be picked for these two Transaction CCs. The CC ?315* matches with 93150 so 333 will be picked from master data.

I am not able to conclude how to apply routine here. its complex scenario i know. Not sure if i can use 'Contain Pattern' or what abap statement.

Please suggest.

Zabi

5 REPLIES 5

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Syed,

I think, it's better you find why the cost center is stored that way ??Is it stored that way or there is something wrong that is why the values or coming like that,,

And please elaborate the question by giving a larger scene of your problem.

Regards,

Ajit

sachin_yadav3
Active Participant
0 Kudos

Hi Ajit,

you can use Contain string operator i.e CS. It will work.

Regards

Sachin

Former Member
0 Kudos

Hello Syed,

There are some string comparing operators in SAP. Please try those to implement according to your requirement... Here you can find those ..Comparing Strings (SAP Library - ABAP Programming (BC-ABA))

you need to pass your data in some string type variable then try those operators.

shaik_sajid
Active Contributor
0 Kudos

Hi,

Ask your BW Consultant as to why the data of costcenter is not loaded correctly into the masterdata .

you need to investigate this along with the BW consultant.

1. See how the data is stored in Costcenter infoobject master table.

2. If data is stored like '???' then test the dataSource which loads the master data in ECC system via tcode RSA3.

Regards

Shaik

former_member219162
Contributor
0 Kudos

Hello Syed,

Please try out with CP (Contains Pattern operator). Here you have to convert "?" to "+" for the pattern. You can copy paste the code and then do a debug. You will get to understand.

DATA: BEGIN OF i_master OCCURS 0,

       gl_account      TYPE string,

       cost_center     TYPE string,

      END OF i_master.

   

PARAMETERS: srch_str     TYPE string.

i_master-gl_account   = '111'.

i_master-cost_center  = '???315*'.

APPEND i_master.

i_master-gl_account   = '222'.

i_master-cost_center  = '?????315**'.

APPEND i_master.

i_master-gl_account   = '333'.

i_master-cost_center  = '?315*****'.

APPEND i_master.

LOOP AT i_master.

  REPLACE ALL OCCURRENCES OF  '?'  IN i_master-cost_center WITH '+'.

  IF srch_str CP i_master-cost_center.

    WRITE: i_master-gl_account.

  ENDIF.

ENDLOOP.