Skip to Content
0
Former Member
Sep 19, 2006 at 02:42 PM

Performance issue

32 Views

Hi Experts,

can any body go thru this below code and tell me is there any performance issue in this.

Becoz it is taking long time and not exicuting in back ground.

I am sure of reward points.

&----


*& Report ZSERENA_INTEGRATION_MONDAY

*&

&----


*&

*&

&----


REPORT ZSERENA_INTEGRATION_MONDAY.

&----


*& Report ZTEST_XML

*&

&----


*&

*&

&----


*data: ifile like salfldir occurs 0 with header line.

data:p_path TYPE rsmrgstr-path value 'F:\usr\sap\CD5\serena\OCOS1\'.

data: p_file type string.

TYPES: BEGIN OF t_xml_line, "Structure for holding XML data

data(256) TYPE x,

END OF t_xml_line.

data: BEGIN OF t_xml occurs 0,

rec TYPE x,

END OF t_xml.

data: begin of jtab occurs 0,

text type string,

end of jtab.

DATA: l_xml_table TYPE TABLE OF t_xml_line. " XML Table of the structure

data: wa(256) type x.

data: wa_xml like l_xml_table occurs 0.

data: l_str type string.

data: start_line type i,

end_line type i,

v_str type string.

data: cnt type i,

idx type i,

count1 type i,

len type i,

diff type i.

data: catalogid type string.

DATA : BEGIN OF DAT OCCURS 0,

LIN type string,

END OF DAT.

DATA: BASIC_TEXT LIKE THEAD OCCURS 0 WITH HEADER LINE.

DATA: YGUID LIKE COMM_PCAT_CTY-GUID,

ZGUID LIKE COMM_PCAT_CTV-PARENT_CATEGORY.

DATA: BASICTEXT like TLINE OCCURS 0 WITH HEADER LINE.

DATA: IT_THEAD LIKE THEAD OCCURS 0 WITH HEADER LINE.

data: begin of IT_SERENA occurs 0,

ID LIKE COMM_PCAT_CTY-ID,

TEXT type string,

end of IT_SERENA.

DATA:WA_SERENA like IT_SERENA.

DATA: wa_files TYPE rsfillst,

ifile LIKE TABLE OF wa_files.

data: begin of it_error occurs 0,

err type string,

end of it_error.

data: errorfile type string value 'error.txt'.

CALL FUNCTION 'SUBST_GET_FILE_LIST'

EXPORTING

DIRNAME = p_path

FILENM = '.'

  • PATTERN =

TABLES

FILE_LIST = ifile

EXCEPTIONS

ACCESS_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

.

sort ifile.

loop at ifile into wa_files.

if not wa_files-name cs '.xml'.

delete ifile.

endif.

endloop.

data: id type i.

loop at ifile into wa_files.

concatenate p_path wa_files-name into p_file.

open dataset p_file for input in text mode encoding default.

if sy-subrc = 0.

do.

read dataset p_file into jtab-text.

if jtab-text = space.

exit.

endif.

if sy-subrc <> 0.

concatenate text-002 p_file into it_error-err.

append it_error.

clear it_error.

exit.

else.

  • jtab-text = l_str.

append jtab.

clear jtab.

endif.

enddo.

else.

concatenate text-001 p_file into it_error-err.

append it_error.

clear it_error.

continue.

endif.

loop at jtab.

if jtab-text cs 'Catalog ID'.

idx = sy-tabix .

endif.

endloop.

read table jtab index idx.

if sy-subrc = 0.

catalogid = jtab-text.

endif.

if catalogid cs '<![CDATA['.

shift catalogid left by 56 places.

endif.

if catalogid cs ']]></field>'.

replace ']]></field>' with space into catalogid.

endif.

write:/ 'Catalogid is:', catalogid.

IT_SERENA-ID = catalogid.

LOOP AT jTAB.

if jtab-text cs 'longDescription'.

start_line = sy-tabix + 1.

exit.

endif.

endloop.

cnt = start_line.

do.

read table jtab index cnt.

if jtab-text cs '</field>'.

end_line = sy-tabix.

exit.

else.

cnt = cnt + 1.

endif.

enddo.

loop at jtab from start_line to end_line.

concatenate jtab-text v_str into v_str separated by space.

endloop.

.

  • shift v_str left by 18 places.

shift v_str left by 10 places.

len = strlen( v_str ).

DO.

IF COUNT1 >= LEN.

EXIT.

ENDIF.

DIFF = LEN - COUNT1.

IF DIFF < 125.

DAT-LIN = v_str+COUNT1(DIFF).

ELSE.

DAT-LIN = v_str+COUNT1(125).

ENDIF.

  • DAT-LIN = v_str+COUNT1(125).

APPEND DAT.

WRITE :/ DAT-LIN.

CLEAR DAT.

COUNT1 = COUNT1 + 125.

ENDDO.

REFRESH BASIC_TEXT.

REFRESH BASICTEXT.

CLEAR YGUID.

CLEAR ZGUID.

SELECT SINGLE GUID FROM COMM_PCAT_CTY INTO YGUID

WHERE ID = IT_SERENA-ID.

  • IF NOT YGUID IS initial.

if sy-subrc <> 0.

concatenate text-003 p_file into it_error-err.

append it_error.

clear it_error.

else.

SELECT SINGLE GUID FROM COMM_PCAT_CTV INTO ZGUID

WHERE PARENT_CATEGORY = YGUID.

ENDIF.

BASIC_TEXT-TDOBJECT = 'PCAT_CTY'.

BASIC_TEXT-TDNAME = ZGUID.

BASIC_TEXT-TDID = '0001'.

BASIC_TEXT-TDSPRAS = 'EN'.

APPEND BASIC_TEXT.

loop at DAT.

BASICTEXT-TDFORMAT = '*'.

BASICTEXT-TDLINE = DAT-LIN.

APPEND BASICTEXT.

endloop.

refresh DAT.

loop at basictext.

if basictext-tdline cs '![CDATA['.

replace '![CDATA[' with space into basictext-tdline.

ENDIF.

modify basictext.

ENDLOOP.

loop at basictext.

if basictext-tdline cs ']]>'.

replace ']]>' with space into basictext-tdline.

modify basictext.

endif.

endloop.

if not catalogid is initial.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = basic_text

  • INSERT = ' '

SAVEMODE_DIRECT = 'X'

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

IMPORTING

  • FUNCTION =

NEWHEADER = it_thead

TABLES

LINES = basictext

  • 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.

else.

write:/ 'catalog id does not exist'.

endif.

CLEAR IT_THEAD.

refresh jtab.

refresh DAT.

COUNT1 = 0.

clear v_str.

REFRESH BASICTEXT.

refresh dat.

close dataset p_file.

endloop.

.