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

Problem saving a long text for Operation Order

Former Member
0 Likes
5,876

Hi guys,

I'm using BAPI_ALM_ORDER_MAINTAIN to create an operation in a pm order and it works fine.

Besides the operation creation, i need to create a long text for that operation. And the problem is here...

I try using the the input tables it_text and it_text_lines but it does work...

Then i try to, after the order creation commit, run function module SAVE_TEXT to create the long text. With this last method, the long text is created but it doesn´t appear in IW33 (Order Display).

I analyse the situation, creating operations by IW32 and comparing the values, and i check that the problem is in the field "TXTSP" of the table AFVC (Operations Table)...

By the tcode IW32, when i create a long text for some operation and SAVE, this field is filled with the language, in my case "P".

In my case, running function module SAVE_TEXT, that field is never filled... and so, the icon of longtext in tcode IW33 never appears...

Is there something missing?

Thanks in advance.

Edited by: Luís Silva on Aug 19, 2009 7:30 PM

7 REPLIES 7
Read only

Former Member
0 Likes
2,899

I think there must be something to relate the order operation and the text...

This is very strange...

Any ideas?

Edited by: Luís Silva on Aug 20, 2009 10:58 AM

Read only

0 Likes
2,899

I found this... And with this, i solve my problem...

Thanks any way!

-

-


April 25, 2007

Working with production order operation long texts from ABAP.

Filed under: ABAP, SAP u2014 abaplog @ 6:03 am

The common task of changing the long text of a production orderu2019s operation can bring some surprises that were discussed several times at Sapfans ABAP forum. Composing right text ID and key to feed the READ_TEXT and SAVE_TEXT functions is the first step. If you are unsure on that, some tips are provided in Sapfans ABAP FAQ, or you can use the debugger as an alternative. All that is relatively straightforward.

The first problem that is usually encountered is that after updating the long text with the function SAVE_TEXT, the new text is not visible in standard SAP transactions like CO03. The new text can be read with the function READ_TEXT though. The trick is that SAP uses the u201Clong text existsu201D indicator, the field TXTSP in the table AFVC. To make the text u201Cvisibleu201D to standard transactions, we have to set the TXTSP value to the current language (or the textu2019s language). Unfortunately, this has to be done with the direct UPDATE on the AFVC u2013 there are no known workarounds.

Another problem can be seen when the same order is processed by users that use different languages. While SAP allows to store the long text for the same operation in several languages, actually, only one text object will be active at the same time in regard to standard transactions u2013 the object in the last saved language. That means, when SAP writes the text back, the TXTSP will be overwritten with the current language (say, language A). If the next user is working in another language (language B), SAP will present the text in the u201Cfirstu201D language (A) in the CO03 (even if the text in language B exists!). But after saving, the text will be written in the new language and TXTSP will be set accordingly.

So, when working with long texts directly, you have to read with READ_TEXT using the language stored in TXTSP, NOT with the current language. When saving, you save in the current language and set the TXTSP to the current language. This way you are consistent with what SAP does and this will prevent you from surprises in a multilingual environment.

Edited by: Luís Silva on Aug 20, 2009 11:07 AM

Read only

0 Likes
2,899

Thanks for sharing the solutions !!

Read only

0 Likes
2,899

Thanks for your solution. Realy useful...

Read only

Former Member
0 Likes
2,899

I solved myself...

Points for me

Edited by: Luís Silva on Aug 20, 2009 6:22 PM

Read only

0 Likes
2,899

hi

i too facing same problem .

could you able to post your code ?

regards

Indira

Read only

0 Likes
2,899

some of the client will not agree on direct update option. you may try below logic , twisted in your way...

I know I am posting answer to very old thread as did not find any answer so far, so giving clue. See if new solution seekers this helps you now…

Cause:

As the create_text or save_text  does creation of text at data base level and does not pass through all the screens of the particular transaction, so the text editor icon is not enabled  [like in tcode IW23 (IW33) Notification display text editor, tables holding damage text and cause text indicator qmfe-indtx & qmur-indtx I ]

Solution:

  1. Read existing text using FM READ_TEXT i.e. retain existing text in internal table, say IT_READ
  2. Delete existing text using FM 'DELETE_TEXT'. Remember to set save_direct = x
  3. Perform BDC to add dummy text doing call transaction. This will set text indicator to ‘X’.
  4. Append your new ext to IT_READ.
  5. Now create text again using FM 'CREATE_TEXT'. Remember to set save_direct = x
  6. If you have requirement that created text should not be editable then you need to change format of IT_READ.

Like IT_READ-tdformat = ‘>X’ & IT_READ-tdline = ‘*<one space><your text>’ [may use CONCATENATE '*' IT_READ-tdline INTO IT_READ-tdline SEPARATED BY space.].

Below are above steps code snap shots.

Bdc part for IW22

……….
PERFORM bdc_dynpro USING 'X' 'SAPLIQS0' '7200'.
PERFORM bdc_field USING 'BDC_OKCODE' '=TXPS'. "DAMAGE_TXT icon
or  
PERFORM bdc_field USING 'BDC_OKCODE' '=TXUR'. "CAUSE_TXT icon

Based on your text editor configured to keep track of timestamp log, use one of the option. My case first two lines of text editor shown timestamp log lines and they are non editable.
*  PERFORM bdc_dynpro USING 'X'  'SAPLSTXX' '1100'.
*  PERFORM bdc_field USING 'BDC_CURSOR'  'RSTXT-TXLINE(02)'.
*  PERFORM bdc_field USING 'BDC_OKCODE'  '=POSF'.
*  PERFORM bdc_field USING 'RSTXT-TXPARGRAPH(02)' '*'.
*  PERFORM bdc_field USING 'RSTXT-TXLINE(02)' 'Dummy text for indicator line 2'.

*  PERFORM bdc_dynpro USING 'X'  'SAPLSTXX' '1100'.
*  PERFORM bdc_field USING 'BDC_CURSOR'  'RSTXT-TXLINE(03)'.
*  PERFORM bdc_field USING 'BDC_OKCODE'  '=POSF'.
*  PERFORM bdc_field USING 'RSTXT-TXPARGRAPH(03)' '*'.
*  PERFORM bdc_field USING 'RSTXT-TXLINE(03)' 'Dummy text for indicator line 3'.

PERFORM bdc_dynpro USING 'X'  'SAPLSTXX' '1100'.
PERFORM bdc_field USING 'BDC_CURSOR'  'RSTXT-TXLINE(04)'.
PERFORM bdc_field USING 'BDC_OKCODE'  '=POSF'.
PERFORM bdc_field USING 'RSTXT-TXPARGRAPH(04)' '*'.
PERFORM bdc_field USING 'RSTXT-TXLINE(04)' 'Dummy text for indicator line 4'.

PERFORM bdc_field       USING 'BDC_OKCODE'  '=TXBA'.

…………….

FORM bdc_dynpro USING    value1
value2
value3
.
CLEAR bdcdata.
bdcdata
-dynbegin = value1.
bdcdata
-program = value2.
bdcdata
-dynpro = value3.
APPEND bdcdata.

ENDFORM.                               " BDC_DYNPRO

form DELETE_EXISTINGTEXT.
CALL FUNCTION 'DELETE_TEXT'
EXPORTING
CLIENT          = sy-mandt
ID              =   LTXT
LANGUAGE        =   E
name           
=   <notification number + suffix>

–  determine from text editor header damage text need suffixed 0001 , cause text need suffixed 00010001
object         
=   QMFE = damage or QMUR = CAUSE
savemode_direct
= 'X'
*     TEXTMEMORY_ONLY = ' '
*     LOCAL_CAT       = ' '
EXCEPTIONS
not_found      
= 1
OTHERS          = 2.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT          = gc_x
.

endform.                    " DELETE_EXISTINGTEXT

    CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid        
= LTXT
flanguage  
= E
fname      
= <notification number + suffix>

–  determine from text editor header damage text need suffixed 0001 , cause text need suffixed 00010001
object         
=   QMFE = damage or QMUR = CAUSE

        fobject     = QMFE = damage or QMUR = CAUSE
save_direct
= x
fformat    
= ‘>X’
TABLES
flines     
= t_editor_text
EXCEPTIONS
no_init    
= 1
no_save    
= 2
OTHERS      = 3.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = gc_x.
.