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: 

Update Long text for Notification

reedtzj
Active Participant
0 Kudos

Hi all

I have a problem updating the “long text” for a PM/SM notification.

Scenario:

When the service notification is created (transaction IW51) the long text should have an additional row added upon saving the notification.

We really want this added information in the long text and not in some Z-field because the information is to be passed to a PDA running SAP MAM (Mobile Asset Management) and a customer defined field is not the first option.

I have so far used user-exit defined by transaction SMOD like QQMA0014, QM/PM/SM: Checks before saving a notification.

In the customer implementation (transaction CMOD) of QQMA0014 the following code is used:


*----------------------------------------------------------------------*
*   INCLUDE ZXQQMU20                                                   *
*----------------------------------------------------------------------*
DATA:
  ltxttab TYPE standard table of tline,
  line    TYPE tline,
  lines   TYPE sy-tabix.

---

*   Read long text for Notification from memory
    import tline to ltxttab from memory id 'SAPLSTXD000001'.
    if sy-subrc eq 0.
      describe table ltxttab lines lines.
      line-tdformat = '*'.
      line-tdline   = 'X1234567Y1234567'.
      append line to ltxttab.
      export tline = ltxttab to memory id 'SAPLSTXD000001'.
    endif.

---

This does work so far. I get the long text in table ltxttab and can add a line to this table. I can see that perfectly when debugging. I then hit F8 to continue the save processing of the new notification.

Now to the problem:

R/3 does not save the notification but issues an error message TD062, Text object is not available. Hm. I have a feeling that the update of the SAP defined memory id does not like to be changed at all.

As the notification number is not known in the user exit (as far as I understand it) then a direct update of the long text using function module SAVE_TEXT can not be done because the necessary key is not known.

Has anyone faced something similar and found a solution?

Any input is highly appreciated!

Yes, I have scanned OSS and the Internet and SDN etc. No luck so far.

Regards, Johan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

All long texts have a header and text lines. The header contains the text object, text id and a couple of other values(structure THEAD). On this structure there is also a field for the number lines in the line table.

Could it be that your text header area is not filled in, but you are trying to add lines to it?

Srinivas

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

>I have a feeling that the update of the SAP

> defined memory id does not like to be changed at all.

I have tested your code in some test programs, there is no problem in updating the table and exporting thru standard SAP memory ids.

There's gotton be another reason for your error.

Regards,

Rich Heilman

reedtzj
Active Participant
0 Kudos

Hi Rich,

Thanks for your answer. Did you test in the mentioned UE or was it just a separate program?

Yes, I agree with you that it should not be any problem updating a SAP "delivered" memory id. I fact, I am confident that the id is updated correctly. The problem most probably lies in the following code when running transaction IW51.

I will try the hint Srinivas gave.

Regards, Johan

0 Kudos

Hi Johan,

Thanks for posting the final code. This way others can benefit out of your posting.

Regards,

Srinivas

Former Member
0 Kudos

Hi,

All long texts have a header and text lines. The header contains the text object, text id and a couple of other values(structure THEAD). On this structure there is also a field for the number lines in the line table.

Could it be that your text header area is not filled in, but you are trying to add lines to it?

Srinivas

Hi Srinivas

Thanks for your answer. Yes! With your hint it worked.

When using the following code the notification did save gracefully with my added row in the long text.

*----------------------------------------------------------------------*
*   INCLUDE ZXQQMU20                                                   *
*----------------------------------------------------------------------*
DATA:
  headltx TYPE thead,
  ltxttab TYPE standard table of tline,
  line    TYPE tline,
  lines   TYPE sy-tabix.
 
---
*   Read long text for Notification from memory
    IMPORT thead TO headltx
           tline TO ltxttab
      FROM MEMORY ID 'SAPLSTXD000001'.
    IF sy-subrc EQ 0.
*     Lines
      line-tdformat = '*'.
      line-tdline   = 'X1234567Y1234567'.
      APPEND line TO ltxttab.
*     Header
      DESCRIBE TABLE ltxttab LINES lines.
      headltx-tdtxtlines = lines.
      EXPORT tline = ltxttab
             thead = headltx TO MEMORY ID 'SAPLSTXD000001'.
    ENDIF.
---

Interestingly, the field headltx-tdtxtlines did not have any value when doing the initial IMPORT although there was several rows in the long text. But when updated with the correct number of lines it worked.

Thanks again!

Regards, Johan

0 Kudos

Hi Johan,

I am also facing the same issue. The above solution provided by you is working fine when the long text is NOT EMPTY. i.e it is having at least one line.

However if the long text is empty(As per my requirement, the below statement fails

*   Read long text for Notification from memory

    IMPORT thead TO headltx

           tline TO ltxttab

      FROM MEMORY ID 'SAPLSTXD000001'.

Here SY-subrc becomes 4.

after this I am unable to export my string in the long text.

Whether the SAP can use the memory ID ''SAPLSTXD000001' only? Is it fixed for notification long text. I tried to change the name also and also manually filled the structure headltx...but still it is not saving my string.

My code is as below

*   Read long text for Notification from memory

            IMPORT thead TO ls_headltx

                   tline TO lt_ltxttab

              FROM MEMORY ID 'SAPLSTXD000001'.

IF sy-subrc EQ 0.

*Lines

              ls_line-tdformat = '*'.

              ls_line-tdline   = 'ABC'.

              APPEND ls_line TO lt_ltxttab.

*Header

              DESCRIBE TABLE lt_ltxttab LINES lv_lines.

              ls_headltx-tdtxtlines = lv_lines.

              EXPORT tline = lt_ltxttab

                     thead = ls_headltx TO MEMORY ID 'SAPLSTXD000001'.

ELSE.

*Lines

              ls_line-tdformat = '*'.

              ls_line-tdline   = 'ABC'.

              APPEND ls_line TO lt_ltxttab.

*Header

              CLEAR lv_tdname.

              LV_TDNAME = I_VIQMEL-QMNUM.   "At run time it is returning %00000000001

              ls_headltx-TDID       = 'LTXT'. 

              ls_headltx-TDSPRAS    = 'E'.    

              ls_headltx-TDNAME     =  LV_TDNAME.   "%00000000001

              ls_headltx-TDOBJECT   = 'QMEL'.  

              ls_headltx-TDFORM     = 'PM_QMEL'.

              ls_headltx-TDFUSER    = 'NSAQIB'.

              ls_headltx-TDFRELES   = '620'.

              ls_headltx-TDFDATE    = '20100513'.

              ls_headltx-TDFTIME    = '131921'.

              ls_headltx-TDLINESIZE = '072'.

              DESCRIBE TABLE lt_ltxttab LINES lv_lines.

              ls_headltx-tdtxtlines = lv_lines.

              EXPORT tline = lt_ltxttab

                     thead = ls_headltx TO MEMORY ID 'SAPLSTXD000001'.

ENDIF.

Could you please help in this.

Regards

Krishan

0 Kudos

Hi Srinivas,

I am still facing the issue when the when the long text is Initially EMPTY and I am try to add my string. It is not adding the same.

The solution provided by you is working fine when the long text is NOT EMPTY. i.e it is having at least one line.

However if the long text is empty(As per my requirement, the below statement fails

*   Read long text for Notification from memory

    IMPORT thead TO headltx

           tline TO ltxttab

      FROM MEMORY ID 'SAPLSTXD000001'.

Here SY-subrc becomes 4.

after this I am unable to export my string in the long text.

Whether the SAP can use the memory ID ''SAPLSTXD000001' only? Is it fixed for notification long text. I tried to change the name also and also manually filled the structure headltx...but still it is not saving my string.

My code is as below

*   Read long text for Notification from memory

            IMPORT thead TO ls_headltx

                   tline TO lt_ltxttab

              FROM MEMORY ID 'SAPLSTXD000001'.

IF sy-subrc EQ 0.

*Lines

              ls_line-tdformat = '*'.

              ls_line-tdline   = 'ABC'.

              APPEND ls_line TO lt_ltxttab.

*Header

              DESCRIBE TABLE lt_ltxttab LINES lv_lines.

              ls_headltx-tdtxtlines = lv_lines.

              EXPORT tline = lt_ltxttab

                     thead = ls_headltx TO MEMORY ID 'SAPLSTXD000001'.

ELSE.

*Lines

              ls_line-tdformat = '*'.

              ls_line-tdline   = 'ABC'.

              APPEND ls_line TO lt_ltxttab.

*Header

              CLEAR lv_tdname.

              LV_TDNAME = I_VIQMEL-QMNUM.   "At run time it is returning %00000000001

              ls_headltx-TDID       = 'LTXT'. 

              ls_headltx-TDSPRAS    = 'E'.    

              ls_headltx-TDNAME     =  LV_TDNAME.   "%00000000001

              ls_headltx-TDOBJECT   = 'QMEL'.  

              ls_headltx-TDFORM     = 'PM_QMEL'.

              ls_headltx-TDFUSER    = 'NSAQIB'.

              ls_headltx-TDFRELES   = '620'.

              ls_headltx-TDFDATE    = '20100513'.

              ls_headltx-TDFTIME    = '131921'.

              ls_headltx-TDLINESIZE = '072'.

              DESCRIBE TABLE lt_ltxttab LINES lv_lines.

              ls_headltx-tdtxtlines = lv_lines.

              EXPORT tline = lt_ltxttab

                     thead = ls_headltx TO MEMORY ID 'SAPLSTXD000001'.

ENDIF.

Could you please help in this.

Regards

Krishan

Former Member
0 Kudos

Hi Krsihan,

How did you resolved your issue?

Even Iam facing the same problem.

regards,

Anbu