Update VC (Variant configuration) data using standard BAPI in Sales Order
Updating Variant Configuration data for SO item became little tricky for us in an ongoing implementation. After spending some hours investigating the correct combination of data to pass, we were able to post the document correctly. As no detailed documentation is available online for this scenario, I hope this post will help community for similar requirements.
For updating Variant configuration (VC) data for Sales order item, we need to populate below tables of standard FM or BAPI (e.g. SD_SALESDOCUMENT_CREATE).
Normally the standard FM or BAPI does not return any error messages in case configuration data is not updated successfully.
· SALES_SCHEDULES_IN: The required date field should be populated with appropriate value (REQ_DATE).
· SALES_ITEMS_IN: Field PO_ITM_NO should be populated with appropriate value.
· SALES_CFGS_REF Table:
1. This table should have 1 record per item.
2. Combination of CONFIG_ID and ROOT_ID should be unique across line items.
POSEX |
000010 |
CONFIG_ID |
000001 |
ROOT_ID |
00000001 |
SCE |
1 |
COMPLETE |
T |
CONSISTENT |
T |
CBASE_ID_TYPE |
G |
· SALES_CFGS_INST:
1. This table should have 1 record per item.
2. Combination of CONFIG_ID and INST_ID should be unique across line items.
CONFIG_ID |
000001 |
INST_ID |
00000001 |
OBJ_TYPE |
MARA |
CLASS_TYPE |
300 |
OBJ_KEY |
MATNR value |
QUANTITY |
Quantity value |
QUANTITY_UNIT |
Quantity Unit |
COMPLETE |
T |
CONSISTENT |
T |
OBJECT_GUID |
MATNR value |
PERSIST_ID_TYPE |
G |
· SALES_CFGS_VALUE:
1. Combination of CONFIG_ID and INST_ID should be unique across line items.
2. We can have multiple characteristics for a material. In that case appropriate records should be inserted in this table. Note that CONFIG_ID and INST_ID should be same for all the rows you insert in this table for multiple characteristics for a material.
3. The characteristic value should be in SAP internal format.
CONFIG_ID |
000001 |
INST_ID |
00000001 |
CHARC |
Material characteristics |
VALUE |
Material characteristics value |
· SALES_CFGS_VK:
1. Combination of CONFIG_ID and INST_ID should be unique across line items.
2. We can have multiple characteristics for a material. In that case appropriate records should be inserted in this table. Note that CONFIG_ID and INST_ID should be same for all the rows you insert in this table for multiple characteristics for a material.
CONFIG_ID |
000001 |
INST_ID |
00000001 |
VKEY |
Material characteristics |
Thank you for sharing. I'm curious why would PO_ITM_NO field be needed, wouldn't you just need the ITM_NUMBER? Also BAPI name is BAPI_SALESORDER_CREATEFROMDAT2, it calls the FM inside though.
I've never had to deal with this, but I also found the documentation to be incomplete and, unfortunately, the SCN members sometimes don't bother updating their posts with a solution (e.g. this one).
Just wondering if anyone has ever raised a message with SAP that documentation on this is missing? It just mentions what needs to be populated but doesn't document the actual structures and doesn't provide an example. It wouldn't be a problem if this was intuitive but apparently it isn't.
I can answer that one. It took me weeks to work this out in 2011 in Germany, trying to work out why the item number vanished even though I thought I was passing it in correctly.
During the standard BAPI the code takes the customer purchase order item number and copies it to POSEX which is the important field in the VC structure.
So when populating the sales order item data for the BAPI I had to copy the value from ORDER_CFG_REFS-POSEX into BAPISDITM-PO_ITEM_NO. You don't need to bother with the customer PO number, just the item! This only works because the customer purchase order item number is called POSEX, the same name as the VC item number field.
That took a lot of debugging to work out.
There is no way anyone could reasonably be expected to guess that the customer purchase order item number was important. I imagine 99.9% of sites have never filled in this field ever.
I would guess at any given instant there are about a dozen developers all around the world working on this very problem....
I don't think anyone bothers to raise a message with SAP asking for documentation because they know for a fact it won't happen. That's what you pay your 18% a year licence fee for, so SAP can laugh at you if you try to get anything for that money.
To change a comedy sketch from many years ago slightly....
Stephen Fry : You don't seem to understand how the SAP licence agreement works.
Bob Geldof: Well, how does it work?
SF : You pay us large amounts of money.......
BG: And?
SF: And what?
Interesting thing - the POSEX info is actually buried inside the note 93091 - Information about the BAPIs in Sales and Distribution . This note doesn't come up in search by 'BAPI_SALESORDER_CREATEFROMDAT2 VC', but if we spell out 'variant configuration' then it's found (with a dozen of completely unrelated notes).
What beats me - it also says 'This documentation is available on the DOCU CD'. I honestly have no clue what that DOCU CD is, but why not just add this information to the BAPI documentation? Or at least mention "about VC read note so-and-so" instead of just leaving it blank...
Thanks for sharing Apeksha. It would be great if you can also include example of a SO, PO and characteristics. As you can see that SAP has not provided a very detailed documentation for this scenario, it would certainly help developers going ahead. 🙂
HI,
I am using BAPI to update the characteristics in Sales order.
Values are update but VC rules which was assigned to the configuration is not getting update. can you help me if i need to add any value in BAPI while processing.
BR