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: 

BAPI_SALEORDER_ CREATEFROMDAT2

Former Member
0 Kudos

Hi All-

Goodmorning...Is there any way to create text messages while creating sales order using Standard BAPI BAPI_SALEORDER_ CREATEFROMDAT2? While creating Sales order in SAP I need to create text messages also like Internal order notes, Shipping instructions and so on...I hope we can't do that but needs to added manually after sales order has been created in SAP. Please correct me if I am wrong. If it is possible please give me the Solution.

Thnaks for your help.

Sony

6 REPLIES 6

Former Member
0 Kudos

Hi,

u cant directly add the notes with BAPI-BAPI_SALEORDER_ CREATEFROMDAT2.

u can do like this.

Create one ZBAPI where u call the BAPI-BAPI_SALEORDER_ CREATEFROMDAT2 with all inputs

then Call BAPI_TRANSACTION_COMMIT

then check whether Sales order creted or not

If YES

then Add the Notes thru logic

Then COMMIT.

This way u can do.

Mark points if helpful.

Regs

Manas Ranjan Panda

0 Kudos

Manas-

Thanks for your input. How do we add those notes into the created sales order? Is there any function module to append those text messages into the created sales order.

I will give you points if I get required answers.

Thanks,

Sony

0 Kudos

Sony,

You can use function modules SAVE_TEXT and COMMIT_TEXT to accomplish the task of creating texts for the documents.

Nanda

0 Kudos

Manas and Nanda...Thanks for your inputs. I have assgined points for both of you.

Thanks,

Sony.

0 Kudos

Hi Sony

I beleive there is a way we can add the texts directly when we create an order via the BAPI, please go through all the table structures in the BAPI. We can avoid, changing the Sales Document after creation just for texts.

Can give you exact details, when i get back to office tomorrow.

Kind Regards

Eswar

0 Kudos

Hi Sony

Table: ORDER_TEXT can be used for inserting texts in a sales document while creating.

<b>Values to be populated:</b>

<u>For Header Texts:</u>

TEXT_ID

LANGU

TEXT_LINE

<b>For Item Texts:</b>

Apart from the above, populate the ITM_NUMBER with the item number we use for ORDER_ITEMS_IN structure.

Below code can give you some idea, though am using SD_SALESDOCUMENT_CREATE, the structure for Texts is the same in both BAPI's.

*&---------------------------------------------------------------------*
*&      Form  ADD_TEXT
*&---------------------------------------------------------------------*
FORM ADD_TEXT  USING    P_TID   LIKE THEAD-TDID
                        P_TEXT  LIKE THEAD-TLINE.

*** Sales Document Header Texts
   CLEAR: IBAPISDTEXT.
   IBAPISDTEXT-TEXT_ID   = P_TID.
   IBAPISDTEXT-LANGU     = SY-LANGU.
   IBAPISDTEXT-TEXT_LINE = P_TEXT.
   APPEND IBAPISDTEXT.

ENDFORM.                    " ADD_TEXT

*&---------------------------------------------------------------------*
*&      Form  ORDER_CRE
*&---------------------------------------------------------------------*
FORM ORDER_CRE .

DATA: L_WAIT LIKE BAPITA-WAIT VALUE '2'.
DATA: LT_BAPIRET2 LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

   CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
     EXPORTING
*      SALESDOCUMENT                 =
       SALES_HEADER_IN               = IBAPISDHD1
       SALES_HEADER_INX              = IBAPISDHD1X
*      BUSINESS_OBJECT               = ' '
    IMPORTING
       SALESDOCUMENT_EX              = IBAPIVBELN
    TABLES
       RETURN                        = IBAPIRET2
       SALES_ITEMS_IN                = IBAPISDITM
       SALES_ITEMS_INX               = IBAPISDITMX
       SALES_PARTNERS                = IBAPIPARNR
       SALES_SCHEDULES_IN            = IBAPISCHDL
       SALES_SCHEDULES_INX           = IBAPISCHDLX
       SALES_CONDITIONS_IN           = IBAPICOND
       SALES_CONDITIONS_INX          = IBAPICONDX
       SALES_TEXT                    = IBAPISDTEXT.

Hope this helps you.

Kind Regards

Eswar