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

How to exclude log from Longtext using READ_TEXT

VijayaKrishnaG
Active Contributor
0 Likes
3,147

Hi Experts, Good Day.

When I am using READ_TEXT function module, I want to exclude the line-item/row contains the log (System date, time, username etc.). When user edits long text multiple times READ_TEXT fetches all the log data, so user doesn't require that data.

So please let me how to exclude log row when calling READ_TEXT or logic to delete after fetching into Internal table.

Thanks & Regard,

-Vijay

12 REPLIES 12
Read only

Former Member
0 Likes
2,921

Hi Vijay,

Can you check this table "STXH" .

Regard's

Smruti

Read only

0 Likes
2,921

Hi Smruthi,

Firstly thanks for your reply. STXH table contains only last change details I think. But I required all the log.

Thanks,

-Vijay

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,921

Hi Vijay

Can you please attach screen shot of LT_TEXT table which you see in debugging showing the date time stuff

Nabheet

Read only

0 Likes
2,921

Hi Nabheet,

Please find the attached screen shot and I need to exclude or delete the highlighted rows.

Thanks,

-Vijay

Read only

0 Likes
2,921

Hi Vijay

Tell me one thing is the text is being saved by you or custom application?

Nabheet

Read only

0 Likes
2,921

You can delete the * from each row using this code.

LOOP AT it_tdlines.
    REPLACE FIRST OCCURRENCE OF '*' IN it_tdlines-tdline WITH ''.
    SHIFT it_tdlines-tdline LEFT DELETING LEADING ' '  .
    IF it_tdlines-tdline NE ' '.
       MODIFY it_tdlines INDEX sy-tabix TRANSPORTING tdline.
     ELSE.
        DELETE it_tdlines INDEX sy-tabix .
     ENDIF.
ENDLOOP.

Then for removing the timestamp row use this code.

LOOP AT it_tdlines .
    IF it_tdlines-tdline+2(1) EQ '.' AND it_tdlines-tdline+5(1) EQ '.' AND
        it_tdlines-tdline+13(1) EQ ':' AND it_tdlines-tdline+16(1) EQ ':'.

       DELETE it_tdlines INDEX sy-tabix .

    ENDIF.

ENDLOOP.

Read only

0 Likes
2,921

Hi-

You can use below logic:

DATA: it_line TYPE STANDARD TABLE OF tline,

       wa_line TYPE tline.

wa_line-tdformat = '*'.

wa_line-tdline = '24.11.2013 14:50:58 ABAP (ABAP)'.

APPEND wa_line TO it_line.

wa_line-tdline = 'Venkat Test'.

APPEND wa_line TO it_line.

wa_line-tdline = '29.12.2014 19:55:60 ABAP (ABAP)'.

APPEND wa_line TO it_line.

LOOP AT it_line INTO wa_line.

   IF ( wa_line-tdformat = '*'    AND

        wa_line-tdline+2(1) = '.' AND

        wa_line-tdline+5(1) = '.' AND

        wa_line-tdline+10(1) = ' ' AND

        wa_line-tdline+13(1) = ':' AND

        wa_line-tdline+16(1) = ':' ).

   ELSE.

     WRITE: wa_line.

   ENDIF.

ENDLOOP.

Output:


If you want you can also add more validations.

-Venkat

Read only

0 Likes
2,921

Hi Nabheet,

This text editor is from transaction WCTL for entering WCA Description (longtext). This will be entered by Customer. But when ever we open this editor automatically the log line will be filled by system.

Thanks,

-Vijay

Read only

0 Likes
2,921

Hi Venkat..

what if user enter the date in same formate then it is invalid i believe

Nabheet

Read only

0 Likes
2,921

Hello Nabheet-

In my logic I have considered time stamp value too( wa_line-tdline+13(1) = ':' AND wa_line-tdline+16(1) = ':'), so I don't think users will be adding these values. However if they add then those will be an exemption case and that line won't be considered.

-Venkat

Read only

VijayaKrishnaG
Active Contributor
0 Likes
2,921

Hi All,

I implemented my own logic comparing the string with Existing Usernames. And actually I posted this to know any standard method if exists. Thank you all for your helpful inputs.

-Vijay

Read only

Former Member
0 Likes
2,921

Hi All,

try it

FORM read_text  USING    p_id LIKE thead-tdid

                          p_name

                 CHANGING p_val.

   DATA : tdname TYPE thead-tdname .

   DATA : BEGIN OF tline OCCURS 0 .

           INCLUDE STRUCTURE tline .

   DATA : END OF tline .

   tdname = p_name.

*  compressed text data with text name

   TYPES: BEGIN OF ty_stxl,

            tdname TYPE stxl-tdname,

            clustr TYPE stxl-clustr,

            clustd TYPE stxl-clustd,

          END OF ty_stxl.

   DATAt_stxl TYPE STANDARD TABLE OF ty_stxl.

   FIELD-SYMBOLS: <stxl> TYPE ty_stxl.

* compressed text data without text name

   TYPES: BEGIN OF ty_stxl_raw,

            clustr TYPE stxl-clustr,

            clustd TYPE stxl-clustd,

          END OF ty_stxl_raw.

   DATAt_stxl_raw TYPE STANDARD TABLE OF ty_stxl_raw.

   DATAw_stxl_raw TYPE ty_stxl_raw.

* decompressed text

   DATAt_tline TYPE STANDARD TABLE OF tline.

   FIELD-SYMBOLS: <tline> TYPE tline.

*and then

* select compressed text lines in blocks of 3000 (adjustable)

   SELECT tdname clustr clustd

          INTO TABLE t_stxl

          FROM stxl

          PACKAGE SIZE 3000

*       for all entries in t_main"(itab with application data and TDNAME)

          WHERE relid    = 'TX'          "standard text

            AND tdobject = '/CSPL/EXPK'

            AND tdname   = tdname

            AND tdid     = p_id

            AND tdspras  = sy-langu.

*  loop at t_stxl assigning <stxl>.

     READ TABLE t_stxl ASSIGNING <stxl> INDEX 1.

*   decompress text

     CLEAR: t_stxl_raw[], t_tline[].

     w_stxl_raw-clustr = <stxl>-clustr.

     w_stxl_raw-clustd = <stxl>-clustd.

     APPEND w_stxl_raw TO t_stxl_raw.

     IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.

*  access text lines for further processing

     READ TABLE t_tline ASSIGNING <tline>  INDEX 1.

     p_val = <tline>-tdline."whatever

*    endloop.

*  endloop.

     FREE t_stxl.

   ENDSELECT.

ENDFORM.                    " read_text