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

BAPI_SALESORDER_SIMULATE problems

Former Member
0 Likes
3,193

Hi,

I am using this FM to simulate a salesorder but it is working a bit wierd.

When i use the transaction se37 and call the FM BAPI_SALESORDER_SIMULATE the results are shown perfect. But calling the FM BAPI_SALESORDER_SIMULATE within a program with the exsact same parameters produces the error Pleas enter Sold-to or Ship-to party. This is provided in both senarios.

Any

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,109

example:-

REPORT ZSALESORDER_SIMULATE.

DATA: order_header_in LIKE bapisdhead,

order_items_in LIKE TABLE OF bapiitemin,

return LIKE bapireturn,

wa_order_items_in LIKE LINE OF order_items_in,

order_partners LIKE TABLE OF bapipartnr,

wa_order_partners LIKE LINE OF order_partners,

order_items_out LIKE TABLE OF bapiitemex,

wa_order_items_out LIKE LINE OF order_items_out.

  • Fill order_header_in

order_header_in-doc_type = 'TA'.

  • Fill order_items_in

wa_order_items_in-material = '000000000000020927'.

wa_order_items_in-req_qty = '1000'.

APPEND wa_order_items_in TO order_items_in.

  • Fill order_items_in

wa_order_partners-partn_role = 'AG'.

wa_order_partners-partn_numb = '0000000001'.

APPEND wa_order_partners TO order_partners.

  • Execute Function Module BAPI_SALESORDER_SIMULATE

CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'

EXPORTING

order_header_in = order_header_in

IMPORTING

return = return

TABLES

order_items_in = order_items_in

order_partners = order_partners

order_items_out = order_items_out.

  • The return structure gives any error messages

WRITE: return-message.

  • Print out the order items

LOOP AT order_items_out INTO wa_order_items_out.

WRITE: wa_order_items_out-material,

wa_order_items_out-short_text,

wa_order_items_out-subtotal_2.

ENDLOOP.

9 REPLIES 9
Read only

Former Member
0 Likes
2,109

Pass the Sold to party (Or) ship to party value to the FM "CONVERSION_EXIT_ALPHA_INPUT" before passing the value to BAPI.

Then the out come value of "CONVERSION_EXIT_ALPHA_INPUT" u pass it to BAPI.

Read only

Former Member
0 Likes
2,110

example:-

REPORT ZSALESORDER_SIMULATE.

DATA: order_header_in LIKE bapisdhead,

order_items_in LIKE TABLE OF bapiitemin,

return LIKE bapireturn,

wa_order_items_in LIKE LINE OF order_items_in,

order_partners LIKE TABLE OF bapipartnr,

wa_order_partners LIKE LINE OF order_partners,

order_items_out LIKE TABLE OF bapiitemex,

wa_order_items_out LIKE LINE OF order_items_out.

  • Fill order_header_in

order_header_in-doc_type = 'TA'.

  • Fill order_items_in

wa_order_items_in-material = '000000000000020927'.

wa_order_items_in-req_qty = '1000'.

APPEND wa_order_items_in TO order_items_in.

  • Fill order_items_in

wa_order_partners-partn_role = 'AG'.

wa_order_partners-partn_numb = '0000000001'.

APPEND wa_order_partners TO order_partners.

  • Execute Function Module BAPI_SALESORDER_SIMULATE

CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'

EXPORTING

order_header_in = order_header_in

IMPORTING

return = return

TABLES

order_items_in = order_items_in

order_partners = order_partners

order_items_out = order_items_out.

  • The return structure gives any error messages

WRITE: return-message.

  • Print out the order items

LOOP AT order_items_out INTO wa_order_items_out.

WRITE: wa_order_items_out-material,

wa_order_items_out-short_text,

wa_order_items_out-subtotal_2.

ENDLOOP.

Read only

0 Likes
2,109

Hi,

This is the code i am using:

*Order header

wa_order_header_in-doc_type = 'ZOR'.

wa_order_header_in-sales_org = salesorganization.

wa_order_header_in-distr_chan = distchannel.

wa_order_header_in-division = division.

*Order items

LOOP AT it_material_list INTO wa_material_list.

wa_order_items_in-itm_number = counter.

wa_order_items_in-material = wa_material_list-material.

wa_order_items_in-target_qty = '1000'.

wa_order_items_in-req_qty = '1000'.

APPEND wa_order_items_in TO it_order_items_in.

add 10 to counter.

ENDLOOP.

*order header

wa_order_partners-partn_role = 'SP'.

wa_order_partners-partn_numb = customerno.

APPEND wa_order_partners TO it_order_partners.

CALL FUNCTION 'BAPI_SALESORDER_SIMULATE'

EXPORTING

order_header_in = wa_order_header_in

TABLES

order_items_in = it_order_items_in

order_partners = it_order_partners

order_condition_ex = it_order_condition_ex

MESSAGETABLE = messagetable.

Read only

0 Likes
2,109

Does anyone have any information to this problem cos i cannot get this FM to work from the codeing

Read only

0 Likes
2,109

Hi

Try to check the partener code: are you sure is SP?

Try to check in TPAUM table if the internal code is different from output code

Max

Read only

0 Likes
2,109

hi,

it works fine when i run the bapi in se37 then the result i expect comes out but when doing it from the program it give me the error .. so it should be right

Best regards

Lisa M simonsen

Read only

0 Likes
2,109

Hi

When u run the BAPI by SE37, all input data are automatically converted to input format by the convertion routine.

For example u insert 1 as customer code, and the system'll convert it in 0000000001, as the convetion routine ALPHA is assigned to customer field.

The partner rule field PARTN_ROLE uses the convertion routine PARVW based on table TPAUM.

That doesn't happen in your program, so u make sure to transfer the value in the right (input) format.

Anyway u aren't transfering the "Sold-to party" (partner rule AG) and the "Ship-to party" (partner rule WE), but only Forwarding agent (partner SP).

The Sold-to Party is mandatary, and usally the system loads Ship-to party automatically (if the customer has only one), so it's strange your BAPI can work in SE37 without Sold-to Party.

*order header

wa_order_partners-partn_role = 'SP'. <----


It should be AG?

wa_order_partners-partn_numb = customerno.

APPEND wa_order_partners TO it_order_partners.

Max

Read only

0 Likes
2,109

Hi,

Changing SP to AG seems to have soulved the problem.

Wierd it workind in se37 .

Best regards

Lisa M Simonsen

Read only

Former Member
0 Likes
2,109