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

Changing Sales Material Text using Bapi bapi_salesorder_change

Former Member
0 Likes
2,203

Hi Experts,

I have to change Sales orders Material sales text. I tried with BAPI_SALESORDER_CHANGE by passing data to ORDER_TEXT. Buts its not updating.

I passed the data in the following way.

     ls_order_item_in-itm_number = ls_salesorder-posnr.

     APPEND ls_order_item_in TO lt_order_item_in.

     ls_order_item_inx-itm_number = ls_salesorder-posnr.

     ls_order_item_inx-updateflag = 'U'.

     APPEND ls_order_item_inx TO lt_order_item_inx.

     ls_order_text-doc_number = ls_salesorder-vbeln.

     ls_order_text-itm_number = ls_salesorder-posnr.

     ls_order_text-text_id    = 001.

     ls_order_text-langu      = E.

     ls_order_text-text_line  = ls_salesorder-smtext.

     ls_order_text-function   = 005.

     APPEND ls_order_text TO lt_order_text.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

       EXPORTING

         salesdocument    = lv_vbeln

         order_header_inx = ls_order_header_inx

       TABLES

         return           = lt_return

         order_item_in    = lt_order_item_in

         order_item_inx   = lt_order_item_inx

         schedule_lines   = lt_schedule_lines

         schedule_linesx  = lt_schedule_linesx

         order_text       = lt_order_text.


Am I missing something? or is there any other way to achieve this?


Thanks in Advance.


Regards,

S Sivaganesh.

1 ACCEPTED SOLUTION
Read only

SandySingh
Active Contributor
0 Likes
1,410

Hello

Use following FM to change the Text

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

Sample Code:

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

       EXPORTING

            salesdocument       = pi_order_header-salesdocument

            order_header_in     = wa_bapisdhd1

            order_header_inx    = wa_bapisdhd1x

            convert_parvw_auart = convert_parvw_auart

       TABLES

            return              = it_return

            item_in             = it_items_in

            item_inx            = it_items_inx

            schedule_in         = it_schedule_lines

            schedule_inx        = it_schedule_linesx

            sales_text          = it_text

            conditions_in       = it_conditions_in

            conditions_inx      = it_conditions_inx.




* Process of commit work or rollback

  READ TABLE it_return WITH KEY type = flag_error

                       TRANSPORTING NO FIELDS.

  IF NOT ( sy-subrc IS INITIAL ).

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

         EXPORTING

              wait = 'X'.

  ELSE.

    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

  ENDIF.

Regards

Sandy

3 REPLIES 3
Read only

Arun_Prabhu_K
Active Contributor
0 Likes
1,410

Hello Sivag.

     Please read the BAPI's documentation first whenever you face some issues.

     You need to call BAPI_TRANSACTION_COMMIT after BAPI_SALESORDER_CHANGE.

Regards.

Read only

SandySingh
Active Contributor
0 Likes
1,411

Hello

Use following FM to change the Text

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

Sample Code:

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

       EXPORTING

            salesdocument       = pi_order_header-salesdocument

            order_header_in     = wa_bapisdhd1

            order_header_inx    = wa_bapisdhd1x

            convert_parvw_auart = convert_parvw_auart

       TABLES

            return              = it_return

            item_in             = it_items_in

            item_inx            = it_items_inx

            schedule_in         = it_schedule_lines

            schedule_inx        = it_schedule_linesx

            sales_text          = it_text

            conditions_in       = it_conditions_in

            conditions_inx      = it_conditions_inx.




* Process of commit work or rollback

  READ TABLE it_return WITH KEY type = flag_error

                       TRANSPORTING NO FIELDS.

  IF NOT ( sy-subrc IS INITIAL ).

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

         EXPORTING

              wait = 'X'.

  ELSE.

    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

  ENDIF.

Regards

Sandy

Read only

SandySingh
Active Contributor
0 Likes
1,410

Hello


Is this issue resolved ?


Close the thread with correct and helpful answers


Regards

Sandy