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_CREATEFROMDAT2

Former Member
0 Likes
1,169

When I am trying to create a sales order with reference to invoice by first testing the BAPI I am getting the error

Unpermitted combination of business object BUS2032 and sales doc. category

I have given the reference doc type(that is invoice type) and and doc type(sales order type to be created).I have also given partner role and partner number and given the invoice number in the sales document number field but still I am getting the above error.Have I missed out on any field.I first wanted to test the function module in SE

3 REPLIES 3
Read only

Former Member
0 Likes
911

hi,

check this....

&----


*& Report ZSD_R_SALESORDER

&----


report zsd_r_salesorder1 line-size 132 message-id zmmbapi .

&----


*& Created By : shailaja

*& Created on : 13.10.2007

*& Requested By : vardhman

*& Description of program :

&----


----


  • Internal table definition *

----


data: gt_order_header_in like bapisdhead occurs 0 with header line,

gt_return like bapireturn1 occurs 0 with header line, " Return Messages

gt_order_items_in like bapiitemin occurs 0 with header line, " Item Data

gt_salesdocument like bapivbeln-vbeln , "Number of Generated Document

gt_order_partners like bapiparnr occurs 0 with header line, "Document Partner

gt_return1 like bapiret2 occurs 0 with header line.

----


  • Data definition *

----


types: begin of ty_gt_ft_sales ,

partn_numb(10) type n ,"Customer Number 1

partn_role(2) ,"Partner function

sales_org(4) , "Sales Organization

distr_chan(2) , "Distribution Channel

division(002), "DIVISION

doc_type(4) , "Sales Document Type

purch_no(020), "Purchase order

material(18), "MATERIAL

targetquantity(020),"Target quantity

reqqty(020), "Req quantity

reqdate(010), "req date

*REQ_DATE_H(010),

ref_1(012), "Ref

unload_pt(025),

*PARTN_ROLE(2) ,"Partner function

*PARTN_NUMB(10) ,"Customer Number 1

end of ty_gt_ft_sales,

begin of ty_header ,

partn_numb(10) ,"Customer Number 1

partn_role(2) ,"Partner function

sales_org(4) , "Sales Organization

distr_chan(2) , "Distribution Channel

division(002), "DIVISION

doc_type(4) , "Sales Document Type

purch_no(020), "Purchase order

unload_pt(025),

req_date_h(010),

end of ty_header,

begin of ty_item,

material(18), "MATERIAL

targetquantity(020),"Target quantity

reqqty(020), "Req quantity

reqdate(010), "req date

ref_1(012), "Ref

*UNLOAD(025),

end of ty_item.

data : msg(240) type c, " Return Message

e_rec(8) type c, " Error Records Counter

rec_no(8) type c, " Records Number Indicator

s_rec(8) type c, " Successful Records Counter

t_rec(8) type c, " Total Records Counter

v_matnr like mara-matnr,

v_parvw type parvw.

data : gt_ft_sales type standard table of ty_gt_ft_sales with header line.

data : wa_gt_ft_sales type ty_gt_ft_sales,

wa_order_items_in like gt_order_items_in,

wa_gt_ft_sales1 type ty_gt_ft_sales,

wa_header type ty_header,

salesdocument like bapivbeln-vbeln.

    • selection block for EXCEL UPLOAD FILE

selection-screen begin of block b1 with frame title text-000.

parameters file type ibipparms-path obligatory.

selection-screen end of block b1.

*<<<<AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE .

at selection-screen on value-request for file .

perform getname.

form getname.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

importing

file_name = file.

endform.

*TOP-OF-PAGE.

top-of-page.

skip 3.

format color col_heading inverse on.

write 40 text-001.

format color col_heading inverse off.

skip 1.

format color col_negative inverse on.

write 😕 text-002, 13 sy-mandt , 104 text-003, 121 sy-uname,

/ text-004, 13 sy-datum , 104 text-005, 121 sy-uzeit.

format color col_negative inverse off.

skip 3.

*START-OF-SELECTION.

start-of-selection.

perform get_data.

perform bapi.

*end-of-page.

perform result.

form result.

t_rec = e_rec + s_rec.

skip 3.

format color col_total inverse on.

write: /38 text-007, t_rec.

format color col_total inverse off.

format color col_negative inverse on.

write: /38 text-008, e_rec.

format color col_negative inverse off.

format color col_total inverse on.

write: /38 text-009, s_rec.

format color col_total inverse off.

endform.

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

call function 'WS_UPLOAD' "#EC *

exporting

filename = file

filetype = 'DAT'

tables

data_tab = gt_ft_sales

exceptions

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

no_authority = 10

others = 11.

if sy-subrc <> 0 .

message e000.

endif.

endform. " get_data

&----


*& Form BAPI

&----


form bapi .

loop at gt_ft_sales into wa_gt_ft_sales.

wa_gt_ft_sales1 = wa_gt_ft_sales.

at new partn_numb.

wa_header-doc_type = wa_gt_ft_sales1-doc_type..

wa_header-sales_org = wa_gt_ft_sales1-sales_org . "'0001'

wa_header-distr_chan = wa_gt_ft_sales1-distr_chan. "'01'

wa_header-division = wa_gt_ft_sales1-division. " '01'

wa_header-purch_no = wa_gt_ft_sales1-purch_no.

wa_header-req_date_h = wa_gt_ft_sales1-reqdate.

call function 'CONVERSION_EXIT_PARVW_INPUT'

exporting

input = wa_gt_ft_sales1-partn_role

importing

output = v_parvw.

wa_header-partn_role = v_parvw.

wa_header-partn_numb = wa_gt_ft_sales1-partn_numb.

wa_header-unload_pt = wa_gt_ft_sales1-unload_pt.

move-corresponding wa_header to gt_order_partners.

move-corresponding wa_header to gt_order_header_in.

append gt_order_header_in.

append gt_order_partners.

endat.

call function 'CONVERSION_EXIT_CCMAT_INPUT'

exporting

input = wa_gt_ft_sales1-material

importing

output = v_matnr.

.

gt_order_items_in-material = v_matnr .

gt_order_items_in-target_qty = wa_gt_ft_sales1-targetquantity . "'1000'

gt_order_items_in-req_qty = wa_gt_ft_sales1-reqqty.

gt_order_items_in-req_date = wa_gt_ft_sales1-reqdate.

*GT_ORDER_ITEMS_IN-BILL_DATE = wa_GT_FT_SALES1-REQDATE.

gt_order_items_in-ref_1 = wa_gt_ft_sales1-ref_1.

append gt_order_items_in.

clear : wa_gt_ft_sales1,wa_header.

at end of partn_numb.

call function 'BAPI_SALESORDER_CREATEFROMDAT1'

exporting

order_header_in = gt_order_header_in

  • WITHOUT_COMMIT = ' '

  • CONVERT_PARVW_AUART = 'X'

importing

salesdocument = salesdocument

  • SOLD_TO_PARTY =

  • SHIP_TO_PARTY =

  • BILLING_PARTY =

return = gt_return

tables

order_items_in = gt_order_items_in

order_partners = gt_order_partners.

  • ORDER_ITEMS_OUT =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CCARD =

  • ORDER_CFGS_BLOB =

  • ORDER_SCHEDULE_EX =

if gt_return-type eq 'E' .

e_rec = e_rec + 1.

read table gt_return with key id = 'V1'.

format color col_negative inverse on.

rec_no = e_rec + s_rec.

concatenate text-006 rec_no ':'

gt_return-message into msg separated by space .

condense msg.

write: / msg.

format color col_negative inverse off.

elseif gt_return-number = '000'.

s_rec = s_rec + 1.

format color col_positive inverse on.

msg = 'SUCCESS'.

condense msg.

write: / msg .

format color col_positive inverse off.

write 😕 salesdocument, 'Has been created'.

perform commit_mm.

endif.

clear: gt_return[], msg.

endat.

endloop.

endform. " SLALE_UPLOAD_DATA

&----


*& Form COMMIT_MM

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form commit_mm .

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'

importing

return = gt_return1.

clear: gt_order_items_in[]."GT_ORDER_CONDITIONS_IN[].

endform. " COMMIT_MM

Read only

Former Member
0 Likes
911

Hi,

The FM:BAPI_SALESORDER_CREATEFROMDAT2 allows only specific order types to create. If you trying to create with types which are not allowed, you will be getting these types of errors.

There is another BAPI: BAPI_CUSTOMERRETURN_CREATE which allows to create order types of RZ also.

Check this one.

Read only

Former Member
0 Likes
911

To Avoid this We have to create another Custom Function, and make it RFC enabled, if you want to call the Function from external.

Copy the Whole Code from the BAPI

BAPI_SALESORDER_CREATEFROMDAT2

to your Function (Z"FUNCTION)

Now change this part...

Observe this part

BUSINESS_OBJECT = 'BUS2032'

Invoice means...

Are you taking about credit/Debit memo's.

BUS2094 CustCreditMemoRequest

BUS2096 CustDebitMemoRequest

then replace the Business object with that

BUSINESS_OBJECT = 'BUS2094'. "example

CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
       EXPORTING
            SALESDOCUMENT           = salesdocumentin
            SALES_HEADER_IN         = ORDER_HEADER_IN
            SALES_HEADER_INX        = ORDER_HEADER_INX
            SENDER                  = SENDER
            BINARY_RELATIONSHIPTYPE = BINARY_RELATIONSHIPTYPE
            INT_NUMBER_ASSIGNMENT   = INT_NUMBER_ASSIGNMENT
            BEHAVE_WHEN_ERROR       = BEHAVE_WHEN_ERROR
            LOGIC_SWITCH            = LOGIC_SWITCH
            BUSINESS_OBJECT         = 'BUS2032'
            TESTRUN                 = TESTRUN
            convert_parvw_auart     = convert

Change it where ever you see BUS2032 with correct object.

Then it will not give that error.

Or else you have to go With BDC.