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

Substitution Rule

Former Member
0 Likes
756

hi Guru's,

I am not an ABAP person - trying to understand the logic of this program that is part of a substitution rule. We have a table that is being populated with country , cost center & profit center. The table is ZFREIGHT_COSTS.

e.g of the table .

country cost center profit center

France FRX1000 ZXY1234

Germany FRX1000 ZXY1235

Both have the same cost center, but the profit center is different. Now when billing is taking place a document is created on the SD side & one on the FI - the problem is occuring on the FI side - the cost center populated is wrong in the General Ledger.

So how the program should work is based on the contry it picks the profit center and in turn based on Profit center it picks up cost center - all this is happening from the tabl that is being populated ZFREIGHT_COSTS. However, this is not what is happening it's working fine until profit center - then when it comes time to pull to the cost center it's picking the wrong one? Even thought the table is having a different value populated.

Here is the program:-

SELECT SINGLE LAND1 "Country key

FROM KNA1 "General Data in Customer Master

INTO CORRESPONDING FIELDS OF KNA1

WHERE KUNNR = PCASUB-KUNNR.

*SELECT SINGLE * FROM ZFREIGHT_COSTS*

WHERE LAND1 = KNA1-LAND1. "Country key

IF SY-SUBRC = 0.

-


up to here i understand the program is pulling the country from the master data of customer master.

PCASUB-PRCTR = ZFREIGHT_COSTS-PRCTR. "PROFIT CENTER

ELSE.

MESSAGE E015 WITH KNA1-LAND1.

ENDIF. "SY-SUBRC=0

ENDFORM.

-


at this point it's pulling the profit center from the table based on country.

*&----


*

*& Form ASSIGN_FREIGHT_COSTS

*&----


*

    • text*

*----


*

    • -->P_KNA1_LAND1 text*

    • <--P_T_DRSEG_CO_KOSTL text*

*----


*

FORM ASSIGN_FREIGHT_COSTS USING P_LAND1

CHANGING P_KOSTL.

*SELECT SINGLE * FROM ZFREIGHT_COSTS*

WHERE LAND1 = P_LAND1. "COUNTRY

IF SY-SUBRC = 0.

P_KOSTL = ZFREIGHT_COSTS-KOSTL. "COST CENTER

ELSE.

-


at this point it should pull the cost center from the table based on the profit center?? - it does not seem to do it correctly.

MESSAGE E030 WITH P_LAND1.

ENDIF. "SY-SUBRC=0

ENDFORM. " ASSIGN_FREIGHT_COSTS

    • END RH1 ADD*

Can someone please tell me if i am understanding the logic of this program correctly. Also I do not know what is this P_Land1?? How can i find out what it is?? What do you think is causing this not to work just for these two countries?

Thanks for your help.

Regards,

Noopers

hi Guru's,

I am not an ABAP person - trying to understand the logic of this program that is part of a substitution rule. We have a table that is being populated with country , cost center & profit center. The table is ZFREIGHT_COSTS.

e.g of the table .

country cost center profit center

France FRX1000 ZXY1234

Germany FRX1000 ZXY1235

Both have the same cost center, but the profit center is different. Now when billing is taking place a document is created on the SD side & one on the FI - the problem is occuring on the FI side - the cost center populated is wrong in the General Ledger.

So how the program should work is based on the contry it picks the profit center and in turn based on Profit center it picks up cost center - all this is happening from the tabl that is being populated ZFREIGHT_COSTS. However, this is not what is happening it's working fine until profit center - then when it comes time to pull to the cost center it's picking the wrong one? Even thought the table is having a different value populated.

Here is the program:-

SELECT SINGLE LAND1 "Country key

FROM KNA1 "General Data in Customer Master

INTO CORRESPONDING FIELDS OF KNA1

WHERE KUNNR = PCASUB-KUNNR.

*SELECT SINGLE * FROM ZFREIGHT_COSTS*

WHERE LAND1 = KNA1-LAND1. "Country key

IF SY-SUBRC = 0.

-


up to here i understand the program is pulling the country from the master data of customer master.

PCASUB-PRCTR = ZFREIGHT_COSTS-PRCTR. "PROFIT CENTER

ELSE.

MESSAGE E015 WITH KNA1-LAND1.

ENDIF. "SY-SUBRC=0

ENDFORM.

-


at this point it's pulling the profit center from the table based on country.

*&----


*

*& Form ASSIGN_FREIGHT_COSTS

*&----


*

    • text*

*----


*

    • -->P_KNA1_LAND1 text*

    • <--P_T_DRSEG_CO_KOSTL text*

*----


*

FORM ASSIGN_FREIGHT_COSTS USING P_LAND1

CHANGING P_KOSTL.

*SELECT SINGLE * FROM ZFREIGHT_COSTS*

WHERE LAND1 = P_LAND1. "COUNTRY

IF SY-SUBRC = 0.

P_KOSTL = ZFREIGHT_COSTS-KOSTL. "COST CENTER

ELSE.

-


at this point it should pull the cost center from the table based on the profit center?? - it does not seem to do it correctly.

MESSAGE E030 WITH P_LAND1.

ENDIF. "SY-SUBRC=0

ENDFORM. " ASSIGN_FREIGHT_COSTS

    • END RH1 ADD*

Can someone please tell me if i am understanding the logic of this program correctly. Also I do not know what is this P_Land1?? How can i find out what it is?? What do you think is causing this not to work just for these two countries?

Thanks for your help.

Regards,

Noopers

2 REPLIES 2
Read only

guilherme_frisoni
Contributor
0 Likes
592

Hi Noopers,

I can't identify what is p_land1 value.

This is passed to ASSIGN_FREIGHT_COSTS form in the calling program.

Where this form is called?

Have you tried to set a break-point in the beginning of ASSIGN_FREIGHT_COSTS form?

Do this, and check P_LAND1 value before using in SELECT, I think this is the problem. P_LAND1 may have wrong value when you execute ASSIGN_FREIGHT_COSTS form.

Or maybe you have some old value in PCASUB, and the wrong value is coming from an old iteraction.

Regards,

Frisoni

Read only

0 Likes
592

Hi Frisoni,

Many thanks for your help ... I am still playing around with this. Will keep you posted

Thank again for your help !

Best Regards,

Noopers