Application Development 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: 

Sales Order Creation Through BAPI

Former Member
0 Kudos

Hi,

I want to create New Sales Order using BAPI: BAPI_SALESORDER_CREATEFROMDAT2. I am populating the following fields:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_HEADER_INX : UPDATEFLAG as 'I' and the above fields as 'X'.

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

ORDER_ITEMS_INX..:

UPDATEFLAG as 'I' and the above fields as 'X'.

ORDER_SCHEDULES_IN ::Sales document number POSNR ITM_NUMBER

Order quantity KWMENG REQ_QTY .

I getting the following error message :

"Unpermitted combination of business object BUS2032 and sales doc. category H"

Can you tell me where the problem is?

Regards,

Tanmay

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor

Hello Tanmay

This is a shortcoming of this BAPI. If you look into the coding you will see that it call SD_SALESORDER_CREATE with restriction to business object 'BUS2032'.

  CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
       EXPORTING
...
            BUSINESS_OBJECT         = 'BUS2032'
 ...

Now if you look into SD_SALESORDER_CREATE you will find the following routine call where the function module checks the valid combination of business object and sales document type (DOC_TYPE):

*
  if business_object ne space.
     perform i_check_type tables return
                          using sales_header_in
                                business_object.
  endif.
*
  if not return is initial.
     exit.
  endif.

In the routine you will find the function module that makes the check:

...
* 3. determine the businessobject                                      *
     CALL FUNCTION 'SD_OBJECT_TYPE_DETERMINE'
          EXPORTING
               I_DOCUMENT_TYPE        = TVAK-VBTYP
          IMPORTING
               E_BUSINESS_OBJECT      = US_OBJTYPE
          EXCEPTIONS
               OTHERS                 = 1.

     IF US_OBJTYPE NE BUSINESS_OBJECT.

        PERFORM ERROR_PROCESSING TABLES US_RETURN
                                 USING  'E'
                                        'V1'
                                        '761'
                                        BUSINESS_OBJECT
                                        TVAK-VBTYP
                                        SPACE
                                        SPACE.

     ENDIF.
ENDFORM.

If you call this function module with I_DOCUMENT_TYPE = 'H' it will return 'BUS2102' as allowed business object.

To overcome the problem with BAPI_SALESORDER_CREATEFROMDAT2 simply call the (RFC-enabled) function module <b>SD_SALESORDER_CREATE directly.</b>. Leave the IMPORTING parameter BUSINESS_OBJECT empty since it it optional.

Regards

Uwe

8 REPLIES 8

graghavendra_sharma
Contributor
0 Kudos

Hi

Check what have you given in <b>ORDER_HEADER_IN-SD_DOC_CAT</b>

uwe_schieferstein
Active Contributor

Hello Tanmay

This is a shortcoming of this BAPI. If you look into the coding you will see that it call SD_SALESORDER_CREATE with restriction to business object 'BUS2032'.

  CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
       EXPORTING
...
            BUSINESS_OBJECT         = 'BUS2032'
 ...

Now if you look into SD_SALESORDER_CREATE you will find the following routine call where the function module checks the valid combination of business object and sales document type (DOC_TYPE):

*
  if business_object ne space.
     perform i_check_type tables return
                          using sales_header_in
                                business_object.
  endif.
*
  if not return is initial.
     exit.
  endif.

In the routine you will find the function module that makes the check:

...
* 3. determine the businessobject                                      *
     CALL FUNCTION 'SD_OBJECT_TYPE_DETERMINE'
          EXPORTING
               I_DOCUMENT_TYPE        = TVAK-VBTYP
          IMPORTING
               E_BUSINESS_OBJECT      = US_OBJTYPE
          EXCEPTIONS
               OTHERS                 = 1.

     IF US_OBJTYPE NE BUSINESS_OBJECT.

        PERFORM ERROR_PROCESSING TABLES US_RETURN
                                 USING  'E'
                                        'V1'
                                        '761'
                                        BUSINESS_OBJECT
                                        TVAK-VBTYP
                                        SPACE
                                        SPACE.

     ENDIF.
ENDFORM.

If you call this function module with I_DOCUMENT_TYPE = 'H' it will return 'BUS2102' as allowed business object.

To overcome the problem with BAPI_SALESORDER_CREATEFROMDAT2 simply call the (RFC-enabled) function module <b>SD_SALESORDER_CREATE directly.</b>. Leave the IMPORTING parameter BUSINESS_OBJECT empty since it it optional.

Regards

Uwe

0 Kudos

Hi Uwe ,

Thanks for your valuable reply.It solves my problem.

Regards,

Tanmay

0 Kudos

This is great, thanks!

Cheers

Alex

0 Kudos

Thank you very much Uwe.

Former Member
0 Kudos

Cheak wether u r giveing right combination sale area i.e.

<b>SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division</b> check in the table TVTA

Former Member
0 Kudos

hi

Probobly you are creating a sales order for the REturn order

BAPI_SALESORDER_CREATEFROMDAT2 will not work for return orders may be the reason as above.

for return orders use this BAPI <b>BAPI_CUSTOMERRETURN_CREATE</b>

0 Kudos

Thanks Naresh. Your comment helped me a lot.