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

Sales Order header text issue

former_member295881
Contributor
0 Likes
6,916

Hello Experts,

I've a requirement where I need to read header text from a document  'A' and copy into document 'B'. I've been able to read text from document 'A' using FM READ_TEXT table and able to create text in document 'B' using CREATE_TEXT. However, when I look at Incompletion log then I see error (refer to the attached scree shot).

Can anybody suggest what change I should make in my following code to make it working? I've a feeling that maybe I'm not using correct ID in FM to create text on sales order.

-------------  READ HEADER TEXT FROM DOC A --------------------

constants: lc_id  type thead-tdid         value  'ZINH',
                lc_idc type thead-tdid        value  'ZCRH',
                lc_obj type thead-tdobject  value  'VBBK'.


clear: v_tdname.
            v_tdname = lw_zrerate_dtl-vbeln.
             call function 'READ_TEXT'
               exporting
                 client                       = sy-mandt
                 id                            = lc_id
                 language                  = sy-langu
                 name                       = v_tdname
                 object                      = lc_obj
               importing
                  header                       = header
               tables
                 lines                         = l_text_table
               exceptions
                 id                             = 1
                 language                  = 2
                 name                       = 3
                 not_found                 = 4
                 object                      = 5
                 reference_check               = 6
                 wrong_access_to_archive       = 7
                 others                        = 8.
               if sy-subrc <> 0.
               " MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               "         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                   "r_flag = 'C'.
               elseif sy-subrc eq 0.
                   if l_text_table[] is not initial.
                     "r_flag = 'E'.
                     loop at l_text_table into lw_tdline.
                       lw_o_tdline = lw_tdline-tdline.
                         append lw_o_tdline to o_tdline.
                     endloop.
                   endif.
               endif.

-----------------------------------------------------------------------------------------

----------- CREATE HEADER TEXT IN DOC B IF TEXT FOUND IN DOC A  ------------------

if lw_zrerate_dtl-zvbeln_pr is not initial and o_tdline[] is not initial.
                clear: wa_tdline.
                loop at o_tdline into wa_tdline.
                 wa_ftext-tdformat = '*'.
                 wa_ftext-tdline = wa_tdline.
                 append wa_ftext to it_ftext.
                endloop.

               clear: i_tdname.
               i_tdname = lw_zrerate_dtl-zvbeln_pr.
               call function 'CREATE_TEXT'
                 exporting
                   fid                     = lc_idc
                   flanguage          = sy-langu
                   fname               = i_tdname
                   fobject              = lc_obj
*                 SAVE_DIRECT       = 'X'
*                 FFORMAT           = '*'
                 tables
                   flines            it_ftext
                 exceptions
                   no_init              = 1
                   no_save            = 2
                   others               = 3.
             endif.

--------------------------------------------------------------------------------------------------------------------------

Many thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,269

Hi

If you need to update a sales order long text, why not use the sales order BAPI - BAPI_SALESORDER_CHANGE? Using the BAPI will ensure that any other sales order logic (such as the incompletion check) will be executed in addition to your data changes.

Regards

Glen

13 REPLIES 13
Read only

Former Member
0 Likes
4,269

would you uncomment save_direct parameter while calling create_text. also, try save_text after create_text. i know this irrelevant as create_text too save the text internally but just to double save.

Rgds

Read only

0 Likes
4,269

Many thanks for your input Sudhanshu I uncomment save_direct parameter while calling create_text and also tried to use save_text but still nothing changes and I still get Incompletion log error.

Read only

Former Member
0 Likes
4,269

Hi.

Check the name of the i_tdname in the second part when you create the text, because you are using another ID, the first ID is ZINH with the name v_tdname and the second ID is ZCRH with the name i_tdname.

What I think is that the name could have something different.

You can create the sales orden directly using text ID ZCRH and check how it is save on the table, maybe there are some values that you need to pass to the FM create text.

Regards

Miguel

Read only

0 Likes
4,269

I imagine that Miguel's hint will get you there, but just one other possibility.  Some of the documents that allow long texts also provide a long text flag.  If you don't set the flag, then no long text can be seen on the document even though you successfully save the long text.  Probably won't be relevant here, but maybe you'll need it some where else.

Neal

Read only

0 Likes
4,269

Thanks for your input Miguel. Yes I use two different ID's (first ID is ZINH with the name v_tdname and the second ID is ZCRH with same name) because if I use ZINH to CREATE_TEXT then It doesn't work at all. With ZCRH I can at least save text but get Incompletion log error.

Read only

Former Member
0 Likes
4,269

Can you check with SAVE_TEXT FM in place of Create_Text FM .

also check Header Information Field Value are Correct .

Regard's

Smruti

Read only

0 Likes
4,269

Thanks for you input Smruti I even tried with SAVE_TEXT instead of CREATE_TEXT but still nothing changes. Same Incompletion log error. Here is my SAVE_TEXT code.

constants:

            lc_idc type thead-tdid     value  'ZCRH',
           lc_obj type thead-tdobject value  'VBBK'.

if sy-subrc eq 0.
                   sv_header-mandt     = sy-mandt.
                   sv_header-tdobject  = lc_obj.
                   sv_header-tdname    = i_tdname. (
6010001540)
                   sv_header-tdid      = lc_idc.
                   sv_header-tdspras   = sy-langu.

                     call function 'SAVE_TEXT'
                       exporting
                         client                 = sy-mandt
                         header               = sv_header
                         savemode_direct = 'X'
                         owner_specified  = 'X'
                       tables
                         lines           = it_ftext
                       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
4,269

Hi,

Check with below Code .

                   sv_header-mandt     = sy-mandt.

                   sv_header-tdobject  = lc_obj.

                   sv_header-tdname    = i_tdname. (6010001540)

                   sv_header-tdid      = lc_idc.

                   sv_header-tdspras   = sy-langu.

                   MOVE '*' TO it_ftext-TDFORMAT.

                   MOVE  'TEST LONG TEXT' TO it_ftext-TDLINE.

 

                   APPEND it_ftext.

                   CLEAR it_ftext.

                     call function 'SAVE_TEXT'

                       exporting

                         client                 = sy-mandt

                         header               = sv_header

                         INSERT               = ' '

                         savemode_direct = 'X'

                       tables

                         lines           = it_ftext

                       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.

Regard's

Smruti

Read only

0 Likes
4,269

Thank you Smruti for your suggestion but I"m already passing values in table it_ftext as you showed.

Read only

Former Member
0 Likes
4,270

Hi

If you need to update a sales order long text, why not use the sales order BAPI - BAPI_SALESORDER_CHANGE? Using the BAPI will ensure that any other sales order logic (such as the incompletion check) will be executed in addition to your data changes.

Regards

Glen

Read only

0 Likes
4,269

Thanks for your input Glen. I've not used BAPI_SALESORDER_CHANGE and not sure how I can pass header text values. Can you provide any example, please?

Read only

0 Likes
4,269

You might look at :

CL_IM_SRM_SALES_ITEMS_TEXT  -  IF_EX_DIP_SALES_ITEMS_TEXT~FILL_TEXT_TABLE

They seem to be doing a similar coding for SRM to get long text.  That should be what the use of bapisdtext is about.

Neal

Read only

0 Likes
4,269

Check this Note Create/change texts via BAPIs,Note : 426980

How to Create/Change  Header and Item Level Long Text Using BAPI for Sales Order , Check above note .

If you still finding text incompleteness using BAPI create/change Header and Item Text then check below Note .

BAPI SD: Document creation - texts and incompleteness :Notes - 390465

Regard's

Smruti