Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem while updating tcodes from tstc to Ztable

Hi Guys,

I have a program which updates tcodes from tstc table into a Ztable.

It has to be run on daily basis as a background job.

My problem is that if I create a new Tcode it will update only that tcode into custom table but before that it compares all the entries of tstc and ztable which is impacting the overall performance.

I means if I am having 100000 entries in both the tables and if I create a new tcode then to update only that record, I have to create a loop which will iterate for 100000 times.

Can anyone please suggest me any method which will improve the performance of report?

Thanks,

Neha

Former Member
Former Member replied

hi neha,

If you use hashed internal table then it is working very fast.

I have tried with this code. You can have a look at it.

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

REPORT  ZR_TSTC.

TABLES: TSTC.

DATA: ITAB TYPE HASHED TABLE OF  TSTC WITH UNIQUE KEY TCODE,
       ZITAB TYPE HASHED TABLE OF TSTC WITH UNIQUE KEY TCODE
       .
data: count TYPE i.

field-symbols:
                <fs> type TSTC,
                <fs2> type TSTC.              

START-OF-SELECTION.

SELECT * INTO TABLE ITAB  FROM TSTC .
SELECT * INTO TABLE ZITAB FROM ZTSTC.

LOOP AT ITAB assigning <fs>.
   READ TABLE zitab ASSIGNING <fs2> WITH KEY tcode = <fs>-tcode.
   IF SY-SUBRC NE 0.     
       INSERT INTO ZTSTC VALUES <fs>.
       IF SY-SUBRC EQ 0.
         WRITE: 'Record inserted', <fs>-tcode.
       else.
         WRITE: 'unable to insert record in tstc ', <fs>-tcode.
       ENDIF.
       count = count + 1.
   ENDIF.
ENDLOOP.

IF count = 0.
   write  ' both the contents are same'.
ELSE.
   write: / 'Different ', COUNT.
ENDIF.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question