cancel
Showing results for 
Search instead for 
Did you mean: 

Need to load data from ODS or master data table

Former Member
0 Kudos

Hi folks,

I have a a situation where I have to populate Profit Center into my ODS when I load my data. The criteria is that if GL Accounts begin with '4' or '5' or '7' load Profit Center from /BI0/QCOSTCENTER <b>(master data)</b> and if GL Accounts begin with '1' or '2' or '3' load profit center from /BIC/AZPCA_F0800 (<b>ODS</b>) Here the code which doesn't seem to work. Please help.

<b>Tables: /BI0/PGL_ACCOUNT,

/BI0/QCOSTCENTER,

/BIC/AZPCA_F0800.</b>

data : itab like DATA_PACKAGE occurs 1 with header line.

loop at DATA_PACKAGE into itab.

if DATA_PACKAGE-GL_ACCOUNT eq '4' or DATA_PACKAGE-GL_ACCOUNT eq '5' or DATA_PACKAGE-GL_ACCOUNT eq '7*'.

select single Profit_CTR into ITAB-PROFIT_CTR

from /BI0/QCOSTCENTER where

Costcenter = DATA_PACKAGE-costcenter.

if sy-subrc = 0.

endif.

DATA_PACKAGE-Profit_CTR = ITAB-PROFIT_CTR.

modify DATA_PACKAGE.

elseif DATA_PACKAGE-GL_ACCOUNT eq '1' or DATA_PACKAGE-GL_ACCOUNT eq '2' or DATA_PACKAGE-GL_ACCOUNT eq '3*'.

select single Profit_CTR into ITAB-PROFIT_CTR from /BIC/AZPCA_F0800

where GL_ACCOUNT = DATA_PACKAGE-GL_ACCOUNT.

endif.

DATA_PACKAGE-Profit_CTR = ITAB-PROFIT_CTR.

endloop.

It is not working. Waiting for your response.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

hi Asad,

try ?

DATA_PACKAGE-GL_ACCOUNT+0(1) = '4' or ...

and put a break-point to debug

...

break-point.

loop ..

...

/BI0/QCOSTCENTER is time-dependent, check if you need to specify date from - date to.

hope this helps.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try this..

****************************************

Tables: /BI0/PGL_ACCOUNT,

/BI0/QCOSTCENTER,

/BIC/AZPCA_F0800.

data : itab like DATA_PACKAGE occurs 1 with header line.

loop at DATA_PACKAGE into itab.

IF DATA_PACKAGE-GL_ACCOUNT(1) eq '4' or DATA_PACKAGE-GL_ACCOUNT(1) eq '5' or DATA_PACKAGE-GL_ACCOUNT(1) eq '7'.

SELECT single Profit_CTR into ITAB-PROFIT_CTR

from /BI0/QCOSTCENTER where

Costcenter = DATA_PACKAGE-costcenter.

IF sy-subrc EQ 0.

DATA_PACKAGE-Profit_CTR = ITAB-PROFIT_CTR.

modify DATA_PACKAGE.

ENDIF.

ELSEIF DATA_PACKAGE-GL_ACCOUNT(1) <= '3'.

SELECT single Profit_CTR into ITAB-PROFIT_CTR from /BIC/AZPCA_F0800

where GL_ACCOUNT = DATA_PACKAGE-GL_ACCOUNT.

IF sy-subrc eq 0.

DATA_PACKAGE-Profit_CTR = ITAB-PROFIT_CTR.

modify DATA_PACKAGE.

ENDIF.

ENDIF.

endloop.

***********************************

Regards,

San!

Message was edited by: San!

Former Member
0 Kudos

Hi San,

I tried that and it still didn't work. Is there any other solution? Looking forward to your answer.

Former Member
0 Kudos

Hi,

Try this..

****************************************

Tables: /BI0/PGL_ACCOUNT,

/BI0/QCOSTCENTER,

/BIC/AZPCA_F0800.

DATA: s_data TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

DATA: it_data TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE

WITH HEADER LINE

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.

loop at DATA_PACKAGE into S_DATA.

IF S_DATA-GL_ACCOUNT(1) eq '4' or S_DATA-GL_ACCOUNT(1) eq '5' or S_DATA-GL_ACCOUNT(1) eq '7'.

SELECT single Profit_CTR into S_DATA-PROFIT_CTR

from /BI0/QCOSTCENTER where

Costcenter = S_DATA-costcenter

AND Objvers ='A'.

ELSEIF S_DATA-GL_ACCOUNT(1) <= '3'.

SELECT single Profit_CTR into S_DATA-PROFIT_CTR from /BIC/AZPCA_F0800

where GL_ACCOUNT = S_DATA-GL_ACCOUNT.

ENDIF.

APPEND S_DATA TO it_data.

endloop.

clear DATA_PACKAGE[].

DATA_PACKAGE[] = it_data[].

***********************************

Make sure that gl_account is your key in /BIC/AZPCA_F0800 ODS which gonna fetch you single value of profit.

and same in case of costcenter with /BI0/QCOSTCENTER.

Regards,

San!

Former Member
0 Kudos

Hi San,

It certainly picked up the ODS based profit Center but the first condition '4' or '5' or '7' didn't work. I am using the select statement to pick the value from a time dependent <b>(Q)</b> Cost center table and it has profit center only when there is an entry for field <b>OBJ_CURR</b> like 'BMD' or 'USD' or 'GBP'. So I coded

SELECT single Profit_CTR into S_DATA-PROFIT_CTR

from /BI0/QCOSTCENTER where

Costcenter = S_DATA-costcenter

<b>AND OBJ_CURR eq 'BMD'

or OBJ_CURR eq 'USD'

or OBJ_CURR eq 'GBP'.</b>

It still doesn't pick up the values from 0Cost Center table <b>(Q)</b> since it only has profit center . Am I missing anything?? waiting for your response.

Former Member
0 Kudos

Hi,

Try this

SELECT single Profit_CTR into S_DATA-PROFIT_CTR

from /BI0/QCOSTCENTER where

CO_AREA =s_data-co_area

AND Costcenter = S_DATA-costcenter

AND OBJVERS = 'A'

AND OBJ_CURR NE INITIAL.

from this "It has profit center only in Q table" you mean that You don't have costcenter and controlling area

Regards,

San!

Message was edited by: San!