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 SALES ORDER CHANGE

26,636

Hi all,

    I'm using BAPI SALES ORDER CHANGE for change sales order,Now i want to add item with item text, Is it possible through tis BAPI?  if it's possible tell me how to do? wit example pgm. solution will be highly appreciable..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
16,902

   data: order_text ype table of BAPISDTEXT with header line.

   order_text-doc_number = p_vbeln.

   order_text-text_id = '0003'.

   order_text-langu = 'M'.

   order_text-langu_iso = 'ZF'.

   order_text-format_col = '*'.

   order_text-text_line = 'text line 1'.

   Order_text-function = '009'.

   append order_text.

order_text -itm_number = '00010'.

order_text-text_id = 'VBBP'.

order_text -langu = 'EN'.

concatenate 'This is for :' 'item note:'

into order_text -TEXT_LINE separated by space.

order_text -format_col = '*'.

order_text -function = '009'.

order_text-text_line = 'text line 2'.

append order_text.

order_text-text_line = 'text line 3'.

append order_text.

order_text-text_line = 'text line 4'.

append order_text.

order_text-doc_number = p_vbeln.

order_text-itm_number = '000010'.

order_text-text_id = '0002'.

order_text-langu = 'EN'.

order_text-format_col = '*'.

order_text-text_line = 'item text'.

append order_text.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

      EXPORTING

SALESDOCUMENT = DOC

ORDER_HEADER_INX = Header

      TABLES

RETURN =

ORDER_ITEM_IN = i_Item

ORDER_ITEM_INX = I_ItemX

SCHEDULE_LINES = I_Sched_L

SCHEDULE_LINESX = I_SchedX

ORDER_TEXT = order_Text.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

Once sales order is generated you can update texts using FM SAVE_TEXT

READ_TEXT, in order to read the text

COMMIT_TEXT, in order to commit saved texts.

DELETE_TEXT, in order to delete texts.

Hi all,

    I'm using BAPI SALES ORDER CHANGE for change sales order,Now i want to add item with item text, Is it possible through tis BAPI?  if it's possible tell me how to do? wit example pgm. solution will be highly appreciable..

8 REPLIES 8
Read only

former_member188827
Active Contributor
0 Likes
16,902

Please fill parameter "ORDER_TEXT" inorder to update text. Try as follows:

data :

        wa_text            like          bapisdtext,

        it_text         like table of bapisdtext.

    wa_text-itm_number = <item number>.

    wa_text-text_id    = <your_text ID>.

    wa_text-langu      = sy-langu.

    wa_text-text_line  = <desired_text line>.

    wa_text-function   = <choose from following values>

   003:   Delete

   004:   Append

   005:   Replace

   009:   Original

    append wa_text to it_text.

Then pass it_text to parameter order_text.

Regards

Read only

venkateswaran_k
Active Contributor
0 Likes
16,902

*Define dATa as

DATA :     
      ORDER_ITEM_IN  TYPE TABLE OF  BAPISDITM
      wa_item        type           BAPISDITM
      ORDER_ITEM_INX TYPE TABLE OF  BAPISDITMX
      wa_itemx       type           BAPISDITMX

*Create record in ABOVE table
        wa_item-ITM_NUMBER = l_posnr.           next position number
        wa_item-MATERIAL = gv_upload-matnr.     your item
        wa_item-PLANT = GV_UPLOAD-WERKS.        your plant
        wa_item-STORE_LOC = gv_upload-lgort.    your storage location
       wa_item-SHORT_TEXT = 'YOUR SHORT TEXT'

        APPEND WA_ITEM TO ORDER_ITEM_IN

* DO SAME AS ITEMX

THEN USE THEM IN THE BAPI.

Regards,

Venkat

Read only

Former Member
0 Likes
16,903

   data: order_text ype table of BAPISDTEXT with header line.

   order_text-doc_number = p_vbeln.

   order_text-text_id = '0003'.

   order_text-langu = 'M'.

   order_text-langu_iso = 'ZF'.

   order_text-format_col = '*'.

   order_text-text_line = 'text line 1'.

   Order_text-function = '009'.

   append order_text.

order_text -itm_number = '00010'.

order_text-text_id = 'VBBP'.

order_text -langu = 'EN'.

concatenate 'This is for :' 'item note:'

into order_text -TEXT_LINE separated by space.

order_text -format_col = '*'.

order_text -function = '009'.

order_text-text_line = 'text line 2'.

append order_text.

order_text-text_line = 'text line 3'.

append order_text.

order_text-text_line = 'text line 4'.

append order_text.

order_text-doc_number = p_vbeln.

order_text-itm_number = '000010'.

order_text-text_id = '0002'.

order_text-langu = 'EN'.

order_text-format_col = '*'.

order_text-text_line = 'item text'.

append order_text.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

      EXPORTING

SALESDOCUMENT = DOC

ORDER_HEADER_INX = Header

      TABLES

RETURN =

ORDER_ITEM_IN = i_Item

ORDER_ITEM_INX = I_ItemX

SCHEDULE_LINES = I_Sched_L

SCHEDULE_LINESX = I_SchedX

ORDER_TEXT = order_Text.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

Once sales order is generated you can update texts using FM SAVE_TEXT

READ_TEXT, in order to read the text

COMMIT_TEXT, in order to commit saved texts.

DELETE_TEXT, in order to delete texts.

Read only

0 Likes
16,902

Thanks for all immediate reply,

We can use the BAPISDTEXT, but the problem is TEXT_LINE length is only 132 char (TEXT_LINE    TDLINE    CHAR    132        Text Line ) but in standard item text there is no limit, My requirement also minimum 400 character and also one more in doubt in this structure BAPISDTEXT  no OBJECT ID field.

    Please suggest me this structure really helpful for my requirement? if it's helpful kindly send sample code  or shall i use SAVE_TEXT? suggestion highly appreciable..

Read only

0 Likes
16,902

Dear Senthil

See the following code to save a long text.     Here it_line is the table of line items where you can have multiple lines.  Break your 400 char into multiple lines and append them in the it_table.

Table TTXID


DATA: GW_THEAD LIKE THEAD,      
      IT_LINE  TYPE TABLE OF TLINE WITH HEADER LINE.

PARAMETERS: P_TXTNAM LIKE THEAD-TDNAME.

START-OF-SELECTION.
  GW_THEAD-TDNAME   = P_TXTNAM. 
  GW_THEAD-TDID     = ’ST’. 
  GW_THEAD-TDSPRAS  = SY-LANGU. 
  GW_THEAD-TDOBJECT = ’TEXT’.

  IT_LINE-TDFORMAT = ’*’. 
  IT_LINE-TDLINE   = ’Test Create Text’. 
  APPEND IT_LINE.

  CALL FUNCTION ’SAVE_TEXT’   
       EXPORTING
    *     CLIENT = SY-MANDT     
          HEADER = GW_THEAD
    *     INSERT                = ’ ’
    *     SAVEMODE_DIRECT       = ’ ’
    *     OWNER_SPECIFIED       = ’ ’
    *     LOCAL_CAT             = ’ ’
    *   IMPORTING
    *     FUNCTION              =
    *     NEWHEADER             =   
      TABLES     
          LINES                 = IT_LINE   
      EXCEPTIONS      ID    = 1     
      LANGUAGE              = 2     
      NAME                  = 3     
      OBJECT                = 4     
      OTHERS                = 5            . 

   IF SY-SUBRC <> 0.  
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
   ENDIF.

Read only

0 Likes
16,902

Hi Senthil,

For item 1 text exceeds 132 characters then split the line and append the splitted text as new row in the text table of type BAPISDTEXT.

The line to be appended will have same values except FORMAT_COL.

wa_bapisdtext-doc_number = lv_vbeln.

wa_bapisdtext-itm_number = lv_posnr

wa_bapisdtext-text_id        = 'ST'.

wa_bapisdtext-langu          = lv_langu

wa_bapisdtext-format_col = '/'. "New line

wa_bapisdtext-text_line     = lv_text+0(132).

append wa_bapitext to it_bapitext.

wa_bapisdtext-format_col = '='.     "Extended line

wa_bapisdtext-text_line     = lv_text+132(150).

append wa_bapitext to it_bapitext.

Regards

Praveen

Read only

0 Likes
16,902

Hi thanks for u reply,

        Using SAVE_TEXT FM having no issue,I'm trying to use this BAPISDTEXT in this BAPI_SALESORDER_CHANGE,I dont want to call again one more FM.

Read only

0 Likes
16,902

Hi Praveen Kumar,

Thanks for your reply i got logic,m going to implement...if it's work i wil give full score,Thanks a lot..

Message was edited by: kcm senthil