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 Error Sales Order creation

Former Member
0 Likes
830

Please help.

I am using BAPI : BAPI_SALESORDER_CREATEFROMDAT2

I am using the basic data :

HEADER-DOC_TYPE = 'ZORJ'.

HEADER-SALES_ORG = '1000'.

HEADER-DISTR_CHAN = '10'.

HEADER-DIVISION = '10'.

PARTNERS-PARTN_ROLE = 'SP'.

PARTNERS-PARTN_NUMB = '6'.

PARTNERS-ITM_NUMBER = '000000'.

When I use this data in SE37 and directly execute the BAPI, I am getting return code as 'S' - success.

But when I cann the BAPI from my program, I am getting return code 'E' with the message "Please enter sold-to party or ship-to party"

Please correct me where I am going wrong.

Thanks in advance.

=====

My code is as below::

====

FORM CREAETE_SALES_ORDER .

DATA : RET LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,

ORDER_ITEMS LIKE BAPISDITM OCCURS 0 WITH HEADER LINE,

PARTNERS LIKE BAPIPARNR OCCURS 0 WITH HEADER LINE,

SCHEDULES_IN LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE.

DATA : HEADER LIKE BAPISDHD1.

DATA : ret1 like bapiret2.

*LOOP AT ITAB_SODATA.

HEADER-DOC_TYPE = 'ZORJ'.

HEADER-SALES_ORG = '1000'.

HEADER-DISTR_CHAN = '10'.

HEADER-DIVISION = '10'.

*HEADER-REQ_DATE_H = ITAB_SODATA-DELIVERY_DATE.

*SCHEDULES_IN-LOAD_DATE = ITAB_SODATA-SHIPPING_DATE.

*APPEND SCHEDULES_IN.

*CLEAR SCHEDULES_IN.

*ORDER_ITEMS-ITM_NUMBER = '000010'.

*ORDER_ITEMS-MATERIAL = ITAB_SODATA-ITEM_CODE.

*ORDER_ITEMS-ROUTE = ITAB_SODATA-ROUTE.

*ORDER_ITEMS-TARGET_QTY = ITAB_SODATA-QTY.

*ORDER_ITEMS-TARGET_QU = ITAB_SODATA-UNIT.

*APPEND ORDER_ITEMS.

*CLEAR ORDER_ITEMS.

PARTNERS-PARTN_ROLE = 'SP'.

PARTNERS-PARTN_NUMB = '6'.

PARTNERS-ITM_NUMBER = '000000'.

APPEND PARTNERS.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

ORDER_HEADER_IN = HEADER

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

  • IMPORTING

  • SALESDOCUMENT =

TABLES

RETURN = RET

  • ORDER_ITEMS_IN = ORDER_ITEMS

  • ORDER_ITEMS_INX =

ORDER_PARTNERS = PARTNERS

  • ORDER_SCHEDULES_IN = SCHEDULES_IN

  • ORDER_SCHEDULES_INX =

  • ORDER_CONDITIONS_IN =

  • ORDER_CONDITIONS_INX =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

  • ORDER_CCARD =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

  • NFMETALLITMS =

.

if RET-type = 'S'.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = ret1.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

IMPORTING

RETURN = ret1.

ENDIF.

*ENDLOOP.

ENDFORM. " CREAETE_SALES_ORDER

====

1 ACCEPTED SOLUTION
Read only

h_senden2
Active Contributor
0 Likes
549

partner types are language dependent, check table TPAR

SP (sold-to party) is stored into the table as AG (the german version of sold-to party).

So you always have to be careful with the internal and external presentation of the field.

regards,

Hans

3 REPLIES 3
Read only

h_senden2
Active Contributor
0 Likes
550

partner types are language dependent, check table TPAR

SP (sold-to party) is stored into the table as AG (the german version of sold-to party).

So you always have to be careful with the internal and external presentation of the field.

regards,

Hans

Read only

Former Member
0 Likes
549

Hi Thanks for the reply.

I have changed the sold-to party from SP to AG and the error is resolved.

However, the new error is coming up saying "No customer master record exists for customer 6"

Any idea??

And if I enter the same info in SE37 and execute the BAPI, why is it not giving error.

Please reply

regards,

Read only

h_senden2
Active Contributor
0 Likes
549

maybe it's missing preceding zero : so it should be '000....06' in stead of '6'.

The same internal/external format issue.

regards,

Hans