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: 

Cost center in FM BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hi all,

while creating a salesorder with the function module BAPI_SALESORDER_CREATEFROMDAT2 I want to pass the cost center within the positions.

But I don't find any fields where I can transfer the cost center into the BAPI function module.

The table for the items (bapisditm) and the table for the conditions (bapicond) do not offer the possibility to pass the cost center.

If you go into the transaction VA01 and enter a position you are able to open the detail for the positions and switch to the account assignments for entering the cost center.

Does anyone has a solution how to transfer the cost enter using the BAPI function module?

Kind regards,

Georg

1 ACCEPTED SOLUTION

SantiMoreno
Participant
0 Kudos

Hi, Georf...

I've followed the path provided by you but what I find there is the Profit Center... That field is placed in the BAPISDITM structure as PROFIT_CTR.

Cheers.

8 REPLIES 8

SantiMoreno
Participant
0 Kudos

Hi, Georf...

I've followed the path provided by you but what I find there is the Profit Center... That field is placed in the BAPISDITM structure as PROFIT_CTR.

Cheers.

0 Kudos

Hi Santiago,

many thanks for your fast answer.

Yes, you are able to transfer the profit center but not the cost center.

A profit center is a higher hierarchy towards a cost center. A profit center can obtain several cost centers.

I need to create sales orders on the basis of the cost centers.

Kind regards,

Georg

0 Kudos

Hi

The cost center should be set automatically (it's from material master data), anyway u can manage the extension table in order to transfer values of fields not used by BAPI structure.

So u need to enhance (by append structure) the structures BAPE_VBAP and BAPE_VBAPX in order to insert the new fields (in your case KOSTL).

The values of "new" fields has to be transfered by table parameter EXTENSIONIN, here u need to transfer the values loaded in the both structures BAPE_VBAP and BAPE_VBAPX:

For example:

TABLES: BAPE_VBAP, BAPE_VBAPX.

* After loading item data, fill the value for extensions:

BAPE_VBAP-POSNR = ORDER_ITEMS_IN-ITM_NUMBER.
BAPE_VBAP-KOSTL = <cost center>.
EXTENSIONIN-STRUCTURE = 'BAPE_VBAP'.
EXTENSIONIN+30                 =  BAPE_VBAP.
APPEND EXTENSIONIN.

BAPE_VBAPX-POSNR = ORDER_ITEMS_IN-ITM_NUMBER.
BAPE_VBAPX-KOSTL = 'X'.
EXTENSIONIN-STRUCTURE = 'BAPE_VBAPX'.
EXTENSIONIN+30                 =  BAPE_VBAPX.
APPEND EXTENSIONIN.

EXTENSIONIN is internal table like BAPIPAREX

Also u make sure the "new" field is included in the structures VBAPKOM and VBAPKOMX

Max

Edited by: max bianchi on Nov 18, 2009 3:28 PM

0 Kudos

Hi Max,

it works perfectly !! Realy cool solution.

Many thanks for your help!

You saved my day !!

Regards,

Georg

0 Kudos

Good....that means you owe me a beer

Max

0 Kudos

Right, , I certainly would.

If you live near Munich, Germany just pass by ;-).

Regards,

Georg

0 Kudos

I'm in italy....but I'm not so far from you (just close to the border with Switzerland)...so perhaps one day...or the next october fest

Max

0 Kudos

Hi,

We have tried to perform the same as suggested in my code but the cost center still does not get copied into the sales order that created. We could not add the cost center into VBAPKOM and VBAPKOMX as there is an error during the activation mentioned there is duplicate field name KOSTL in the structure. Please advise if anything is missed.

**  Moving extension of VBAP

     lwa_bape_vbap-vbeln = space.

     lwa_bape_vbap-posnr = '000010'.

     lwa_bape_vbap-kostl = lwa_cntrct_item-kostl.

     APPEND lwa_bape_vbap TO lt_bape_vbap.

     lwa_bape_vbapx-vbeln = space.

     lwa_bape_vbapx-posnr = '000010'.

     lwa_bape_vbapx-kostl = 'X'.

     APPEND lwa_bape_vbapx TO lt_bape_vbapx.

     CLEAR lwa_extensionin.

     MOVE 'BAPE_VBAP' TO lwa_extensionin-structure.

** Conversion to Unicode

     CALL METHOD cl_abap_container_utilities=>fill_container_c

       EXPORTING

         im_value     = lwa_bape_vbap

       IMPORTING

         ex_container = lwa_extensionin-valuepart1.

     APPEND lwa_extensionin TO lt_extensionin.

     MOVE 'BAPE_VBAPX' TO lwa_extensionin-structure.

     MOVE lwa_bape_vbapx TO lwa_extensionin-valuepart1.

     APPEND lwa_extensionin TO lt_extensionin.

Thanks.