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

Pls check it

Former Member
0 Likes
810

Hi Experts,

Please have a lok at this code and help me to modify this

so as to improve performance of the program.

REPORT ZVENDERMASTERINTERFACE_OPT .

TABLES : lfa1,lfb1,lfm1,zvendormaster , tvarv.

DATA : i_vendormaster TYPE TABLE OF zvendormaster WITH HEADER LINE

.

DATA : BEGIN OF i_lfm1 OCCURS 0,

lifnr TYPE lifnr, "Vendor account No

ekorg TYPE ekorg, "Purchasing Organization

zterm TYPE dzterm, "Terms of payment key

ekgrp TYPE ekgrp, "Purchasing Group

END OF i_lfm1.

DATA : BEGIN OF i_lfa1 OCCURS 0,

lifnr TYPE lifnr, "Vendor account No

name1 TYPE name1_gp, "Name 1

name2 TYPE name2_gp, "Name 2

ort01 TYPE ort01_gp, "City

ort02 TYPE ort02_gp, "District

pstlz TYPE pstlz, "Postal Code

regio TYPE regio, "Region (State, Province, County)

stras TYPE stras_gp, "House number and street

adrnr TYPE adrnr, "Address

anred TYPE anred, "Title

ktokk type ktokk, "Vendor account group

stceg TYPE stceg, "VAT registration number

END OF i_lfa1.

DATA : BEGIN OF i_lfb1 OCCURS 0,

lifnr TYPE lifnr, "Vendor account No

bukrs TYPE bukrs, "Company Code

END OF i_lfb1.

DATA : BEGIN OF i_cdhdr OCCURS 0, "internal table for delta vendor no:

lifnr TYPE lifnr,

END OF i_cdhdr.

DATA : BEGIN OF i_cdhdra OCCURS 0,

lifnr TYPE lifnr,

END OF i_cdhdra.

DATA : BEGIN OF i_failedvendor OCCURS 0,

lifnr TYPE lifnr,

END OF i_failedvendor.

DATA : v_objekt LIKE cdhdr-objectclas

VALUE 'KRED',

v_datum TYPE sy-datum,

v_time TYPE sy-uzeit,

v_low TYPE tvarv-low,

v_high TYPE tvarv-high.

START-OF-SELECTION.

SELECT SINGLE low high INTO (v_low, v_high)

FROM tvarv

WHERE name = 'Zvendormaster'.

IF v_low IS INITIAL.

  • v_datum = sy-datum.

v_datum = '20080104'." Change this date to Initial download date.

ELSE.

v_datum = v_low. "Last date the program was run.

ENDIF.

IF v_high IS INITIAL.

  • v_time = sy-uzeit.

  • v_time = '130657'." Initial download time.

ELSE.

v_time = v_high. "Last time the program was run.

ENDIF.

IF v_datum = sy-datum." Ïf the program is again run on the same day.

SELECT objectid FROM cdhdr INTO TABLE i_cdhdr

WHERE objectclas = v_objekt

AND udate >= v_datum

AND utime >= v_time.

select lifnr from zvendormaster into table i_failedvendor where

upd_flag = 'E' .

if sy-subrc = 0.

append lines of i_failedvendor to i_cdhdr.

endif.

ELSE. " If the program is again run on any other day

SELECT objectid FROM cdhdr INTO TABLE i_cdhdr

WHERE objectclas = v_objekt

AND udate = v_datum

AND utime >= v_time.

SELECT objectid FROM cdhdr INTO TABLE i_cdhdra

WHERE objectclas = v_objekt

AND udate > v_datum.

APPEND LINES OF i_cdhdra TO i_cdhdr.

select lifnr from zvendormaster into table i_failedvendor where

upd_flag = 'E' .

if sy-subrc = 0.

append lines of i_failedvendor to i_cdhdr.

endif.

ENDIF.

"Selecting all the mandatory fields for the delta vendor nos :

SORT i_cdhdr.

IF i_cdhdr[] IS NOT INITIAL.

"Selecting from lfa1 whose purchasing organisation is 1000 alone

SELECT lifnr ekorg zterm ekgrp FROM lfm1 INTO TABLE i_lfm1

FOR ALL ENTRIES IN i_cdhdr WHERE lifnr = i_cdhdr-lifnr AND ekorg =

'1000'.

sort i_lfm1.

IF i_lfm1[] IS NOT INITIAL.

SELECT lifnr name1 name2 ort01 ort02 pstlz regio stras adrnr anred

ktokk stceg FROM lfa1 INTO TABLE i_lfa1 FOR ALL ENTRIES IN

i_lfm1

WHERE lifnr = i_lfm1-lifnr .

"Selecting from lfb1 whose company code is 1000 alone

SELECT lifnr bukrs FROM lfb1 INTO

TABLE i_lfb1 FOR ALL ENTRIES IN i_lfm1 WHERE

lifnr = i_lfm1-lifnr AND bukrs = '1000' .

ENDIF.

sort i_lfm1 by lifnr.

LOOP AT i_lfm1.

READ TABLE i_lfa1 WITH KEY lifnr = i_lfm1-lifnr BINARY SEARCH.

IF sy-subrc = 0.

MOVE-CORRESPONDING i_lfm1 TO i_vendormaster.

MOVE-CORRESPONDING i_lfa1 TO i_vendormaster.

ENDIF.

LOOP AT i_lfm1.

READ TABLE i_lfb1 WITH KEY lifnr = i_lfm1-lifnr BINARY SEARCH.

IF sy-subrc = 0.

MOVE-CORRESPONDING i_lfb1 TO i_vendormaster.

ENDIF.

ENDLOOP.

APPEND i_vendormaster.

ENDLOOP.

DELETE ADJACENT DUPLICATES FROM i_vendormaster.

LOOP AT i_vendormaster.

i_vendormaster-update_date = sy-datum.

i_vendormaster-update_time = sy-uzeit.

i_vendormaster-flag = 'X'. "To indicate the records to be

transferred.

zvendormaster = i_vendormaster. "To update the Z-Table.

MODIFY zvendormaster.

MODIFY i_vendormaster.

ENDLOOP.

ENDIF.

CLEAR tvarv.

tvarv-name = 'Zvendormaster'.

tvarv-type = 'P'.

tvarv-sign = 'I'.

tvarv-opti = 'EQ'.

tvarv-low = sy-datum. " Setting the last run date in the tvarv table

tvarv-high = sy-uzeit. " Setting the last run time in the tvarv

MODIFY tvarv.

Sincerely

Jayalakshmy

Hi Experts,

Please have a lok at this code and help me to modify this

so as to improve performance of the program.

REPORT ZVENDERMASTERINTERFACE_OPT .

TABLES : lfa1,lfb1,lfm1,zvendormaster , tvarv.

DATA : i_vendormaster TYPE TABLE OF zvendormaster WITH HEADER LINE

.

DATA : BEGIN OF i_lfm1 OCCURS 0,

lifnr TYPE lifnr, "Vendor account No

ekorg TYPE ekorg, "Purchasing Organization

zterm TYPE dzterm, "Terms of payment key

ekgrp TYPE ekgrp, "Purchasing Group

END OF i_lfm1.

DATA : BEGIN OF i_lfa1 OCCURS 0,

lifnr TYPE lifnr, "Vendor account No

name1 TYPE name1_gp, "Name 1

name2 TYPE name2_gp, "Name 2

ort01 TYPE ort01_gp, "City

ort02 TYPE ort02_gp, "District

pstlz TYPE pstlz, "Postal Code

regio TYPE regio, "Region (State, Province, County)

stras TYPE stras_gp, "House number and street

adrnr TYPE adrnr, "Address

anred TYPE anred, "Title

ktokk type ktokk, "Vendor account group

stceg TYPE stceg, "VAT registration number

END OF i_lfa1.

DATA : BEGIN OF i_lfb1 OCCURS 0,

lifnr TYPE lifnr, "Vendor account No

bukrs TYPE bukrs, "Company Code

END OF i_lfb1.

DATA : BEGIN OF i_cdhdr OCCURS 0, "internal table for delta vendor no:

lifnr TYPE lifnr,

END OF i_cdhdr.

DATA : BEGIN OF i_cdhdra OCCURS 0,

lifnr TYPE lifnr,

END OF i_cdhdra.

DATA : BEGIN OF i_failedvendor OCCURS 0,

lifnr TYPE lifnr,

END OF i_failedvendor.

DATA : v_objekt LIKE cdhdr-objectclas

VALUE 'KRED',

v_datum TYPE sy-datum,

v_time TYPE sy-uzeit,

v_low TYPE tvarv-low,

v_high TYPE tvarv-high.

START-OF-SELECTION.

SELECT SINGLE low high INTO (v_low, v_high)

FROM tvarv

WHERE name = 'Zvendormaster'.

IF v_low IS INITIAL.

  • v_datum = sy-datum.

v_datum = '20080104'." Change this date to Initial download date.

ELSE.

v_datum = v_low. "Last date the program was run.

ENDIF.

IF v_high IS INITIAL.

  • v_time = sy-uzeit.

  • v_time = '130657'." Initial download time.

ELSE.

v_time = v_high. "Last time the program was run.

ENDIF.

IF v_datum = sy-datum." Ïf the program is again run on the same day.

SELECT objectid FROM cdhdr INTO TABLE i_cdhdr

WHERE objectclas = v_objekt

AND udate >= v_datum

AND utime >= v_time.

select lifnr from zvendormaster into table i_failedvendor where

upd_flag = 'E' .

if sy-subrc = 0.

append lines of i_failedvendor to i_cdhdr.

endif.

ELSE. " If the program is again run on any other day

SELECT objectid FROM cdhdr INTO TABLE i_cdhdr

WHERE objectclas = v_objekt

AND udate = v_datum

AND utime >= v_time.

SELECT objectid FROM cdhdr INTO TABLE i_cdhdra

WHERE objectclas = v_objekt

AND udate > v_datum.

APPEND LINES OF i_cdhdra TO i_cdhdr.

select lifnr from zvendormaster into table i_failedvendor where

upd_flag = 'E' .

if sy-subrc = 0.

append lines of i_failedvendor to i_cdhdr.

endif.

ENDIF.

"Selecting all the mandatory fields for the delta vendor nos :

SORT i_cdhdr.

IF i_cdhdr[] IS NOT INITIAL.

"Selecting from lfa1 whose purchasing organisation is 1000 alone

SELECT lifnr ekorg zterm ekgrp FROM lfm1 INTO TABLE i_lfm1

FOR ALL ENTRIES IN i_cdhdr WHERE lifnr = i_cdhdr-lifnr AND ekorg =

'1000'.

sort i_lfm1.

IF i_lfm1[] IS NOT INITIAL.

SELECT lifnr name1 name2 ort01 ort02 pstlz regio stras adrnr anred

ktokk stceg FROM lfa1 INTO TABLE i_lfa1 FOR ALL ENTRIES IN

i_lfm1

WHERE lifnr = i_lfm1-lifnr .

"Selecting from lfb1 whose company code is 1000 alone

SELECT lifnr bukrs FROM lfb1 INTO

TABLE i_lfb1 FOR ALL ENTRIES IN i_lfm1 WHERE

lifnr = i_lfm1-lifnr AND bukrs = '1000' .

ENDIF.

sort i_lfm1 by lifnr.

LOOP AT i_lfm1.

READ TABLE i_lfa1 WITH KEY lifnr = i_lfm1-lifnr BINARY SEARCH.

IF sy-subrc = 0.

MOVE-CORRESPONDING i_lfm1 TO i_vendormaster.

MOVE-CORRESPONDING i_lfa1 TO i_vendormaster.

ENDIF.

LOOP AT i_lfm1.

READ TABLE i_lfb1 WITH KEY lifnr = i_lfm1-lifnr BINARY SEARCH.

IF sy-subrc = 0.

MOVE-CORRESPONDING i_lfb1 TO i_vendormaster.

ENDIF.

ENDLOOP.

APPEND i_vendormaster.

ENDLOOP.

DELETE ADJACENT DUPLICATES FROM i_vendormaster.

LOOP AT i_vendormaster.

i_vendormaster-update_date = sy-datum.

i_vendormaster-update_time = sy-uzeit.

i_vendormaster-flag = 'X'. "To indicate the records to be

transferred.

zvendormaster = i_vendormaster. "To update the Z-Table.

MODIFY zvendormaster.

MODIFY i_vendormaster.

ENDLOOP.

ENDIF.

CLEAR tvarv.

tvarv-name = 'Zvendormaster'.

tvarv-type = 'P'.

tvarv-sign = 'I'.

tvarv-opti = 'EQ'.

tvarv-low = sy-datum. " Setting the last run date in the tvarv table

tvarv-high = sy-uzeit. " Setting the last run time in the tvarv

MODIFY tvarv.

Sincerely

Jayalakshmy

4 REPLIES 4
Read only

Former Member
0 Likes
756

Hi,

Instead of using Occurs 0 to declare the internal table try to declare the internal table and work area as follows.

types: begin of struct,

ur fields,

end of struct.

data: itab type table of struct,

workarea type struct.

select * from table into table itab

where condition.

This way of writing code will improve the performance of ur code.

Reward if Helpful

Jagadish

Read only

Former Member
0 Likes
756

Hi,

1.Instead of Using Occurs 0,define the types and declare the internal table with ref to it.

2.you are using same code multiple times:Instead of that use form routine and Call it is.

3.In select single ,Use all primary key fields in sequence.

4.That can improve the Performance.

Regards,

Shiva.

Read only

Former Member
0 Likes
756

Hi,

Before using the tables in FOR ALL ENTRIES........check the duplicate entries in the table for the fields in where class......

Example.

I_LFM1.

move this table into a temporary table and delete the duplicate entries by comparing the LIFNR.

temp_lfm1[] = i_lfm1[].

sort temp_lfm1 by lifnr.

delete adjacent duplicates from temp_lfm1 comparinf lifnr..

use TEMP_LFM1 in select statement..

***

and one more thing is u r looping the i_lfm1....two times in code........check this once............

Regards,

Vamshidhar.

Read only

Former Member
0 Likes
756

Hi Jaya,

instead of using this

DATA : BEGIN OF i_cdhdr OCCURS 0, "internal table for delta vendor no:

lifnr TYPE lifnr,

END OF i_cdhdr.

DATA : BEGIN OF i_cdhdra OCCURS 0,

lifnr TYPE lifnr,

END OF i_cdhdra.

DATA : BEGIN OF i_failedvendor OCCURS 0,

lifnr TYPE lifnr,

END OF i_failedvendor.

try with this one.....

TYPES: begin of ty_name,

lifnr type lifnr,

end of ty_name.

DATA: it_cdhdr type table of ty_name,

wa_cdhdr type ty_name.

DATA: it_cdhdra type table of ty_name,

wa_cdhdra type ty_name.

DATA: it_failedvendor type table of ty_name,

wa_failedvendor type ty_name.