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

Material configuration with BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Likes
1,946

Hi there,

I am trying to create a new sales order with material configuration using BAPI_SALESORDER_CREATEFROMDAT2. It's not working though. I have seen some comments that it is not possible to create configuration directly with this BAPI - is this really true? - and that the config should be created after sales order creation using function CE_C_PROCESSING.

I have played around a bit, but without succes. Could somebody help me out?

Kins regards,

Roy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,523

Hi, you can use this BAPI to create a sales order with configurable material.

Fisrt you can try with some hardcode config items.

You need the corresponding 'Characteristic values' in your system

eg:

*Header data

wa_header-doc_type = 'ZREK'.

wa_header-sales_org = '1020'.

wa_header-distr_chan = 'AS'.

wa_header-division = 'AS'. "not mandantory

wa_header-purch_no_c = 'mypohehe'.

*Partner data

it_partners-partn_role = 'AG'.

it_partners-partn_numb = '0000000104'.

APPEND it_partners.

it_partners-partn_role = 'WE'.

it_partners-partn_numb = '0000000105'.

APPEND it_partners.

*1st

*items

it_items-material = 'BC263R'.

it_items-po_itm_no = '000010'.

it_items-target_qty = '1.000'.

it_items-target_qu = 'ST'.

APPEND it_items.

it_schedules_in-itm_number = '000010'.

it_schedules_in-req_qty = '1.000'.

APPEND it_schedules_in.

*it_items_inx

  • not needed for creation

*reference

it_cfgs_ref-posex = '000010'.

it_cfgs_ref-config_id = '000001'.

it_cfgs_ref-root_id = '00000001'.

APPEND it_cfgs_ref.

*it_cfgs_inst

it_cfgs_inst-config_id = '000001'.

it_cfgs_inst-inst_id = '00000001'.

it_cfgs_inst-obj_type = 'MARA'.

it_cfgs_inst-class_type = '300'.

it_cfgs_inst-obj_key = 'Z-BC263R'.

APPEND it_cfgs_inst.

  • configuration values

it_cfgs_value-config_id = '000001'.

it_cfgs_value-inst_id = '00000001'.

it_cfgs_value-charc = 'ATS_GRUNDLAGE'.

it_cfgs_value-value = p_conf. "01 - 07

APPEND it_cfgs_value.

it_cfgs_value-config_id = '000001'.

it_cfgs_value-inst_id = '00000001'.

it_cfgs_value-charc = 'ATS_BESCHRIFTUNG'.

it_cfgs_value-value = 'N'.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

order_header_in = wa_header

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • int_number_assignment =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

salesdocument = v_salesdocument

TABLES

return = it_return

order_items_in = it_items

order_items_inx = it_items_inx

order_partners = it_partners

order_schedules_in = it_schedules_in

  • ORDER_SCHEDULES_INX =

  • ORDER_CONDITIONS_IN =

order_cfgs_ref = it_cfgs_ref

order_cfgs_inst = it_cfgs_inst

  • ORDER_CFGS_PART_OF = it_cfgs_part_of

order_cfgs_value = it_cfgs_value

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

  • ORDER_CCARD =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

.

*it_return

READ TABLE it_return WITH KEY type = 'E'.

Rgds,

JP

7 REPLIES 7
Read only

Former Member
0 Likes
1,523

hi

good

go through this weblog ,hope help you to solve your probelm

/people/flavio.ciotola3/blog/2006/09/19/sap-and-php-an-easy-way-for-sd-sales-order-entry

thanks

mrutyun^

Read only

Former Member
0 Likes
1,524

Hi, you can use this BAPI to create a sales order with configurable material.

Fisrt you can try with some hardcode config items.

You need the corresponding 'Characteristic values' in your system

eg:

*Header data

wa_header-doc_type = 'ZREK'.

wa_header-sales_org = '1020'.

wa_header-distr_chan = 'AS'.

wa_header-division = 'AS'. "not mandantory

wa_header-purch_no_c = 'mypohehe'.

*Partner data

it_partners-partn_role = 'AG'.

it_partners-partn_numb = '0000000104'.

APPEND it_partners.

it_partners-partn_role = 'WE'.

it_partners-partn_numb = '0000000105'.

APPEND it_partners.

*1st

*items

it_items-material = 'BC263R'.

it_items-po_itm_no = '000010'.

it_items-target_qty = '1.000'.

it_items-target_qu = 'ST'.

APPEND it_items.

it_schedules_in-itm_number = '000010'.

it_schedules_in-req_qty = '1.000'.

APPEND it_schedules_in.

*it_items_inx

  • not needed for creation

*reference

it_cfgs_ref-posex = '000010'.

it_cfgs_ref-config_id = '000001'.

it_cfgs_ref-root_id = '00000001'.

APPEND it_cfgs_ref.

*it_cfgs_inst

it_cfgs_inst-config_id = '000001'.

it_cfgs_inst-inst_id = '00000001'.

it_cfgs_inst-obj_type = 'MARA'.

it_cfgs_inst-class_type = '300'.

it_cfgs_inst-obj_key = 'Z-BC263R'.

APPEND it_cfgs_inst.

  • configuration values

it_cfgs_value-config_id = '000001'.

it_cfgs_value-inst_id = '00000001'.

it_cfgs_value-charc = 'ATS_GRUNDLAGE'.

it_cfgs_value-value = p_conf. "01 - 07

APPEND it_cfgs_value.

it_cfgs_value-config_id = '000001'.

it_cfgs_value-inst_id = '00000001'.

it_cfgs_value-charc = 'ATS_BESCHRIFTUNG'.

it_cfgs_value-value = 'N'.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

order_header_in = wa_header

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • int_number_assignment =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

salesdocument = v_salesdocument

TABLES

return = it_return

order_items_in = it_items

order_items_inx = it_items_inx

order_partners = it_partners

order_schedules_in = it_schedules_in

  • ORDER_SCHEDULES_INX =

  • ORDER_CONDITIONS_IN =

order_cfgs_ref = it_cfgs_ref

order_cfgs_inst = it_cfgs_inst

  • ORDER_CFGS_PART_OF = it_cfgs_part_of

order_cfgs_value = it_cfgs_value

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

  • ORDER_CCARD =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

.

*it_return

READ TABLE it_return WITH KEY type = 'E'.

Rgds,

JP

Read only

0 Likes
1,523

Thanks Jörn,

however, that is exactly what I have been trying to do, but the configuration data is not being displayed/recorded. Is there anything else you can think of or, like calling a function module or populating a particular field?

Kind regards,

Roy

Read only

0 Likes
1,523

are you working with "material substitutoion"? if you check my example you'll see the item has a material BC263R, the configurable materials is Z-BC263R.

The system will not accept your data if you didn't match exactly the mandantory configuration/values in your program.

Former hint:

ckeck mara-kzkfg if material is configurable

i hope you have only one class type, you'll find in table KLAH (compare with your screen in VA01)

all values for this class type are in table KSML.

Now you can get all characteristics which belongs to KSML from table CAWN. you have to filter out all

entries from CAWN which are EQ "your desired configuration".

you can use BAPI_SALESORDER_CREATEFROMDAT2 to create your order plus configuartion, provide the config data in the tables order_cfgs_ref, order_cfgs_inst, order_cfgs_value

Rgds,

JP

Message was edited by:

Jörn Peter

Read only

0 Likes
1,523

Hi Jörn,

solved. Thanks a lot for your input, it was very helpful. The problem was that I used the material (including leading zeroes) as config key, while the material class was without the leading zeroes...

Kind regards,

Roy

Read only

Former Member
0 Likes
1,523

Hi Jörn and Roy,

the orginal post was old but the last entry from this year.

We have a similar issue and we do an external document creation. It gets created and all data is in, only the configuration is missing.

Can you point out once more which data fields might be wrong filled here?

How was that with the leading 0 now.

We left out the sales_cfgs_part_of structure. I found that sometimes it is needed, sometimes not. We have another internal FM call where we leave it off and it works. We tried to copy the same call but still facing that issue.

lw_bapicucfg-POSEX = '000010'.
lw_bapicucfg-CONFIG_ID = '000001'.
lw_bapicucfg-ROOT_ID = '00000001'.
append lw_bapicucfg to lt_bapicucfg.

lw_bapicuins-CONFIG_ID = '000001'.
lw_bapicuins-INST_ID = '00000001'.
lw_bapicuins-OBJ_TYPE = 'MARA'.
lw_bapicuins-CLASS_TYPE = '300'.
lw_bapicuins-OBJ_KEY = '000000000012345678'.
append lw_bapicuins to lt_bapicuins.

lw_bapicuval-CONFIG_ID = '000001'.
lw_bapicuval-INST_ID = '00000001'.
lw_bapicuval-CHARC = 'C1'.
lw_bapicuval-VALUE = '1'.
append lw_bapicuval to lt_bapicuval.


lw_bapicuval-CONFIG_ID = '000001'.
lw_bapicuval-INST_ID = '00000001'.
lw_bapicuval-CHARC = 'C2'.
lw_bapicuval-VALUE = '3'.
append lw_bapicuval to lt_bapicuval.

Thanks for your answers in advance.

Best regards,

Volker

Read only

0 Likes
1,523

Case closed, simple solution = authoization issue of the inserting user ID ...