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

regarding run time error

Former Member
0 Likes
589

hi experts,

i have developed a report on status of the stock but this report is showing some run time error.....here i m giving the complete codes kindly help me...and the system is showing this error:::

( ShrtText::Time limit exceeded.

What happened?

The program "ZRAW_PRODUCTION_REPORT_FINAL" has exceeded the maximum permitt

runtime without

interruption, and has therefore been terminated.

Error analysis

After a certain length of time, the program is terminated. In the case

of a work area, this means that

- endless loops (DO, WHILE, ...),

- database accesses producing an excessively large result set,

- database accesses without a suitable index (full table scan)

do not block the processing for too long.

The system profile "rdisp/max_wprun_time" contains the maximum runtime of a

program. The

current setting is 600 seconds. Once this time limit has been exceeded,

the system tries to terminate any SQL statements that are currently

being executed and tells the ABAP processor to terminate the current

program. Then it waits for a maximum of 60 seconds. If the program is

still active, the work process is restarted.

successfully processed, the system gives it another 600 seconds.

Hence the maximum runtime of a program is at least twice the value of

the system profile parameter "rdisp/max_wprun_time". )

REPORT ZRAWPRACTICE.

*______________________________________________________________________

----


*Module:MM & PP.

*Description :

----


*_______________________________________________________________________

INCLUDE YINCLUDERAVI.

*INCLUDE ZINCLUDERAVI. "for data declaration

*for selection screen:

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME title text-001.

PARAMETERS: s_werks like mseg-werks obligatory,

s_date like mkpf-budat obligatory.

select-options:matnr for mard-matnr no intervals obligatory.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME title text-002.

PARAMETERS: LIST RADIOBUTTON GROUP G1,

FORM RADIOBUTTON GROUP G1.

SELECTION-SCREEN END OF BLOCK B2.

*for start of selection event:

start-of-selection.

perform get_data.

perform get_mkpf_data.

perform get_mseg_data.

perform get_opening_stock.

perform alv_display. ""for opening and closing stcok

perform get_mseg_cancellation.

perform get_mseg_recvtoday_quantity .

perform get_refresh_alltable.

perform get_mseg_recvtilldate_quantity .

perform get_refresh_alltable.

perform get_mseg_recvtillyear_quantity .

perform get_refresh_alltable.

perform get_mseg_issuedtoday_quantity .

perform get_refresh_alltable.

perform get_mseg_issdtilldate_quantity .

perform get_refresh_alltable.

perform get_mseg_issdtillyear_quantity .

perform refresh_mseg_mkpf.

perform define_fieldcatalog.

*perform sort_field.

perform check_options.

&----


*& Form define_fieldcatalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM define_fieldcatalog .

WA_FIELDCAT-COL_POS = 1.

WA_FIELDCAT-FIELDNAME = 'WERKS'.

WA_FIELDCAT-SELTEXT_L = 'Plant id'.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 2.

WA_FIELDCAT-FIELDNAME = 'NAME1'.

WA_FIELDCAT-SELTEXT_L = 'Plant name'.

WA_FIELDCAT-OUTPUTLEN = 30.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 3.

WA_FIELDCAT-FIELDNAME = 'MAKTX'.

WA_FIELDCAT-SELTEXT_L = 'Material Description'.

WA_FIELDCAT-OUTPUTLEN = 40.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 4.

WA_FIELDCAT-FIELDNAME = 'MATNR'.

WA_FIELDCAT-SELTEXT_L = 'Material Number'.

WA_FIELDCAT-OUTPUTLEN = 15.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

  • WA_FIELDCAT-COL_POS = 5.

  • WA_FIELDCAT-FIELDNAME = 'MBLNR'.

  • WA_FIELDCAT-SELTEXT_L = 'Material Doc.No.'.

  • WA_FIELDCAT-OUTPUTLEN = 15.

  • WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

  • APPEND WA_FIELDCAT TO IT_FIELDCAT.

  • CLEAR WA_FIELDCAT.

*

WA_FIELDCAT-COL_POS = 5.

WA_FIELDCAT-FIELDNAME = 'LGORT'.

WA_FIELDCAT-SELTEXT_L = 'Storage Location'.

WA_FIELDCAT-OUTPUTLEN = 17.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

*

WA_FIELDCAT-COL_POS = 6.

WA_FIELDCAT-FIELDNAME = 'LGOBE'.

WA_FIELDCAT-SELTEXT_L = 'Storage Location Descriptions'.

WA_FIELDCAT-OUTPUTLEN = 28.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 7.

WA_FIELDCAT-FIELDNAME = 'NAME2'.

WA_FIELDCAT-SELTEXT_L = 'Source/Vendor'.

WA_FIELDCAT-OUTPUTLEN = 33.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 8.

WA_FIELDCAT-FIELDNAME = 'LABST_TM'.

WA_FIELDCAT-SELTEXT_L = 'Target Monthly'.

WA_FIELDCAT-OUTPUTLEN = 15.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

WA_FIELDCAT-DO_SUM = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 9.

WA_FIELDCAT-FIELDNAME = 'LABST'.

WA_FIELDCAT-SELTEXT_L = 'Opening Stock'.

WA_FIELDCAT-OUTPUTLEN = 15.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 10.

WA_FIELDCAT-FIELDNAME = 'LABST_RT'.

WA_FIELDCAT-SELTEXT_L = 'Receive today'.

WA_FIELDCAT-OUTPUTLEN = 15.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 11.

WA_FIELDCAT-FIELDNAME = 'LABST_RTLD'.

WA_FIELDCAT-SELTEXT_L = 'Receive till date'.

WA_FIELDCAT-OUTPUTLEN = 20.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 12.

WA_FIELDCAT-FIELDNAME = 'LABST_RTY'.

WA_FIELDCAT-SELTEXT_L = 'Receive till year'.

WA_FIELDCAT-OUTPUTLEN = 20.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 13.

WA_FIELDCAT-FIELDNAME = 'LABST_IT'.

WA_FIELDCAT-SELTEXT_L = 'Issued today'.

WA_FIELDCAT-OUTPUTLEN = 13.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 14.

WA_FIELDCAT-FIELDNAME = 'LABST_ITLD'.

WA_FIELDCAT-SELTEXT_L = 'Issued till date'.

WA_FIELDCAT-OUTPUTLEN = 20.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 15.

WA_FIELDCAT-FIELDNAME = 'LABST_ITY'.

WA_FIELDCAT-SELTEXT_L = 'Issued till year'.

WA_FIELDCAT-OUTPUTLEN = 20.

WA_FIELDCAT-DO_SUM = 'X'.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 16.

WA_FIELDCAT-FIELDNAME = 'EISBE_CL'.

WA_FIELDCAT-SELTEXT_L = 'Closing Balance'.

WA_FIELDCAT-OUTPUTLEN = 16.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

WA_FIELDCAT-DO_SUM = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 17.

WA_FIELDCAT-FIELDNAME = 'LABST_CL'.

WA_FIELDCAT-SELTEXT_L = 'Closing Stock'.

WA_FIELDCAT-OUTPUTLEN = 16.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

WA_FIELDCAT-DO_SUM = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 18.

WA_FIELDCAT-FIELDNAME = 'EISBE'.

WA_FIELDCAT-SELTEXT_L = 'Safety stock'.

WA_FIELDCAT-OUTPUTLEN = 14.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

WA_FIELDCAT-DO_SUM = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = 19.

WA_FIELDCAT-FIELDNAME = 'GPTXT'.

WA_FIELDCAT-SELTEXT_L = 'Remarks'.

WA_FIELDCAT-OUTPUTLEN = 100.

WA_FIELDCAT-TABNAME = 'ITAB_FINAL'.

WA_FIELDCAT-INPUT = 'X'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. " define_fieldcatalog

&----


*& Form check_options

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM check_options .

WA_EVENTS-NAME = 'TOP_OF_PAGE'.

WA_EVENTS-FORM = 'TOP'.

APPEND WA_EVENTS TO IT_EVENTS.

CLEAR WA_EVENTS.

WA_EVENTS-NAME = 'END_OF_LIST'.

WA_EVENTS-FORM = 'END_LIST'.

APPEND WA_EVENTS TO IT_EVENTS.

CLEAR WA_EVENTS.

  • IF LIST = 'X'.

*

  • PERFORM LIST_DISP.

*

  • ENDIF.

*

  • IF FORM = 'X'.

*

  • PERFORM FORM_DISP.

*

  • ENDIF.

ENDFORM. " check_options

&----


*& Form LIST_DISP

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM LIST_DISP .

PERFORM DEFINE_LAYOUT.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IT_FIELDCAT = IT_FIELDCAT

IS_LAYOUT = LAYOUT

IT_SORT = IT_SORT

  • I_CALLBACK_PF_STATUS_SET = 'STATUS'

  • IT_EXCLUDING = I_FCODE_EXTAB

  • I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_EVENTS = IT_EVENTS[]

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab_final

EXCEPTIONS

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

ENDFORM. " LIST_DISP

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data .

*for different types of stock with material number.

select mard~matnr

mard~werks

mard~lgort

mard~labst

mard~insme

mard~speme

mard~einme

mard~retme

mseg~lifnr

into

table itab_final from mard inner join mseg on

mard~matnr =

msegmatnr where mardmatnr in matnr and mard~werks = s_werks.

delete adjacent duplicates from itab_final comparing matnr werks lgort .

*for vendor name:

select lifnr

name1

from lfa1 into

table

itab_lfa1 for all entries in itab_final where lifnr =

itab_final-lifnr.

*for plant name:

select werks

name1 from t001w into table

itab_t001w for all entries in itab_final where werks =

itab_final-werks.

*for opening stock:

select matnr

werks

labst from mard into table

itab_mard for all entries in itab_final where matnr = itab_final-matnr.

*for material description:

select matnr

maktx from makt into table

itab_makt for all entries in itab_final where matnr = itab_final-matnr.

*for safety stock:

select matnr

werks

eisbe from marc into table

itab_marc for all entries in itab_final where matnr = itab_final-matnr.

*for storage location description

select lgort

lgobe from t001l into table

itab_t001l for all entries in itab_final where lgort = itab_final-lgort

.

sort itab_final by matnr lgort.

loop at itab_final.

read table itab_t001w with key werks = itab_final-werks

.

if sy-subrc = 0.

itab_final-name1 = itab_t001w-name1.

endif.

read table itab_lfa1 with key lifnr = itab_final-lifnr

.

if sy-subrc = 0.

itab_final-name2 = itab_lfa1-name1.

endif.

read table itab_makt with key matnr = itab_final-matnr

.

if sy-subrc = 0.

itab_final-maktx = itab_makt-maktx.

endif.

read table itab_marc with key matnr = itab_final-matnr

werks = itab_final-werks

.

if sy-subrc = 0.

itab_final-eisbe = itab_marc-eisbe.

endif.

read table itab_t001l with key lgort = itab_final-lgort

.

if sy-subrc = 0.

itab_final-lgobe = itab_t001l-lgobe.

endif.

itab_final-labst = itab_final-labst + itab_final-insme +

itab_final-speme.

modify itab_final.

endloop.

delete adjacent duplicates from itab_final comparing matnr lgort.

*loop and case for the quantity of the field " target monthly.

loop at itab_final.

case itab_final-matnr.

when '000000001000000008'.

itab_final-labst_tm = '3000.000'.

when '000000001000000007'.

itab_final-labst_tm = '500.000'.

when '000000001000000006'.

itab_final-labst_tm = '400.000'.

when '000000001000000005'.

itab_final-labst_tm = '3000.000'.

when '000000003000000011'.

itab_final-labst_tm = '18000.000'.

when '000000001000000000'.

itab_final-labst_tm = '20000.000'.

when '000000001000000001'.

itab_final-labst_tm = '20000.000'.

endcase.

modify itab_final.

endloop.

ENDFORM. " get_data

form top.

clear itab_final-p_date.

WRITE:/ SY-ULINE.

WRITE:/ 'REPORT DATE:', SY-DATUM, 60 'VISA STEEL LTD.' color 5,

100'Report Developed By Ravi kumar Gupta.' .

WRITE:/ 'TIME:', SY-UZEIT.

*for previous date

clear itab_final-p_date.

itab_final-p_date = S_date - 1.

WRITE:/ 'USER NAME:', SY-UNAME,55'STOCK REPORT FOR:',73

ITAB_FINAL-P_DATE,100'Application:MM & PP.'.

WRITE:/ 'PAGE', SY-PAGNO.

  • write:/ 'Unit of Measure =','MT.'.

translate itab_final-name1 to upper case.

WRITE:/54 itab_final-name1 color 6.

WRITE:/ SY-ULINE.

skip 1.

endform.

form end_list.

skip 1.

write:/ sy-uline.

write:/ 'Cc:S.B.Singh Executive Director.'.

write:/04'K.M.Lal Executive Director Raw Material.'.

write:/04'A.K.Lamba President Project.'.

write:/04'A.K.Agarwal VP Commercial.'.

write:/04'Murli Dhar Manager Blast Furnace.'.

write:/04'S.N.Sarangi DGM Commercial.'.

WRITE:/ SY-ULINE. .

SKIP 2.

WRITE:/60 'END OF PAGE'.

endform.

&----


*& Form FORM_DISP

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FORM_DISP .

ENDFORM. " FORM_DISP

&----


*& Form DEFINE_LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DEFINE_LAYOUT .

LAYOUT-ZEBRA = 'X'.

  • LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL SUM'.

LAYOUT-WINDOW_TITLEBAR = 'STOCK REPORT'.

LAYOUT-TOTALS_TEXT = 'TOTAL'.

ENDFORM. " DEFINE_LAYOUT

&----


*& Form get_mkpf_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mkpf_data .

itab_mkpf-p_date1 = s_date.

itab_mkpf-p_date1+6 = '01'.

**for the current date

select mkpf~mblnr

mkpf~budat

mseg~matnr

mseg~werks

mseg~lgort

mseg~bwart

mseg~shkzg

mseg~menge into

table itab_mkpf1 from mkpf inner join mseg on mkpf~mblnr =

mseg~mblnr where

budat eq itab_mkpf-p_date1 and mseg~matnr in matnr. "for matnr

.

*for the whole year

select mkpf~mblnr

mkpf~mjahr

mkpf~budat

mkpf~blart

mseg~matnr

mseg~werks

mseg~lgort

mseg~bwart

mseg~erfmg

mseg~shkzg

mseg~menge into

table itab_mkpf_mseg from mkpf inner join mseg on mkpf~mblnr =

mseg~mblnr where

budat gt itab_mkpf-p_date1

and budat le sy-datum and mseg~matnr in matnr . "for matnr

delete itab_mkpf1 where matnr is initial.

delete itab_mkpf_mseg where matnr is initial.

ENDFORM. " get_mkpf_data

&----


*& Form get_mseg_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mseg_data .

sort itab_mkpf_mseg by werks lgort matnr .

*for the deletion of material from mseg.

sort itab_mkpf_mseg by matnr lgort.

*loop at itab_mkpf_mseg .

*

*read table itab_final with key matnr = itab_mkpf_mseg-matnr

  • .

*

*if sy-subrc eq 4.

*delete itab_mkpf_mseg.

*endif.

*

*endloop.

*

*

**for material deletion of itab_mkpf1

*loop at itab_mkpf1 .

*

*read table itab_mkpf_mseg with key matnr = itab_mkpf1-matnr

  • .

*

*if sy-subrc eq 4.

*delete itab_mkpf1.

*endif.

*

*endloop.

sort itab_mkpf_mseg by matnr werks lgort shkzg.

delete itab_mkpf_mseg where lgort is initial.

*________________________________________________________

*for closing stock i.e,all mvmnt type summation

*loop at itab_final.

  • loop at itab_mkpf_mseg.

*

  • IF itab_final-werks = itab_mkpf_mseg-werks AND

  • itab_final-lgort = itab_mkpf_mseg-lgort and

  • itab_final-matnr = itab_mkpf_mseg-matnr.

*

*

  • weg_mat-werks = itab_mkpf_mseg-werks.

  • weg_mat-lgort = itab_mkpf_mseg-lgort.

  • weg_mat-matnr = itab_mkpf_mseg-matnr.

  • weg_mat-shkzg = itab_mkpf_mseg-shkzg.

  • weg_mat-menge = itab_mkpf_mseg-menge.

*

*

  • COLLECT weg_mat.

*

  • ENDIF.

  • ENDLOOP.

*ENDLOOP.

*

*

loop at itab_mkpf_mseg.

read table itab_final with key werks = itab_mkpf_mseg-werks

matnr = itab_mkpf_mseg-matnr

lgort = itab_mkpf_mseg-lgort.

check sy-subrc = 0.

weg_mat-werks = itab_mkpf_mseg-werks.

weg_mat-lgort = itab_mkpf_mseg-lgort.

weg_mat-matnr = itab_mkpf_mseg-matnr.

weg_mat-shkzg = itab_mkpf_mseg-shkzg.

weg_mat-menge = itab_mkpf_mseg-menge.

*

COLLECT weg_mat.

endloop.

*___________________________________________________________

*for current date movement type

*loop at itab_final.

  • loop at itab_mkpf1.

*

  • IF itab_final-werks = itab_mkpf1-werks AND

  • itab_final-lgort = itab_mkpf1-lgort and

  • itab_final-matnr = itab_mkpf1-matnr.

*

*

  • sum_mat-werks = itab_mkpf1-werks.

  • sum_mat-lgort = itab_mkpf1-lgort.

  • sum_mat-matnr = itab_mkpf1-matnr.

  • sum_mat-shkzg = itab_mkpf1-shkzg.

  • sum_mat-menge = itab_mkpf1-menge.

*

  • COLLECT sum_mat.

*

  • ENDIF.

  • ENDLOOP.

*ENDLOOP.

loop at itab_mkpf1.

read table itab_final with key werks = itab_mkpf1-werks

matnr = itab_mkpf1-matnr

lgort = itab_mkpf1-lgort.

check sy-subrc = 0.

sum_mat-werks = itab_mkpf1-werks.

sum_mat-lgort = itab_mkpf1-lgort.

sum_mat-matnr = itab_mkpf1-matnr.

sum_mat-shkzg = itab_mkpf1-shkzg.

sum_mat-menge = itab_mkpf1-menge.

COLLECT sum_mat.

ENDLOOP.

*_____________________________________________________________

*for closing stock

loop at itab_final.

CLEAR weg_mat-menge.

bestand-WERKS = itab_final-werks.

bestand-lgort = itab_final-lgort.

bestand-MATNR = itab_final-matnr.

READ TABLE weg_mat WITH KEY werks = itab_final-werks

lgort = itab_final-lgort

matnr = itab_final-matnr

shkzg = 'S'.

bestand-endmenge = itab_final-labst + itab_final-insme +

itab_final-speme + itab_final-einme +

itab_final-retme - weg_mat-menge.

CLEAR weg_mat-menge.

READ TABLE weg_mat WITH KEY werks = itab_final-werks

lgort = itab_final-lgort

matnr = itab_final-matnr

shkzg = 'H'.

bestand-endmenge = bestand-endmenge + weg_mat-menge. "closing stock

COLLECT bestand.

endloop.

ENDFORM. " get_mseg_data

&----


*& Form refresh_mseg_mkpf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM refresh_mseg_mkpf .

REFRESH itab_mkpf.

REFRESH itab_mseg.

REFRESH itab1.

REFRESH itab2.

ENDFORM. " refresh_mseg_mkpf

&----


*& Form get_mseg_cancellation

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mseg_cancellation .

itab_mkpf_rcvdate-p_date2 = s_date - 1.

select mblnr

mjahr

blart

budat from mkpf into

table itab_mkpf_rcvdate where

budat eq itab_mkpf_rcvdate-p_date2

and blart in

('WA','WE','WL').

if not itab_mkpf_rcvdate[] is initial.

select matnr

erfmg

mblnr

ebeln

werks

lgort

bwart

lfbnr

smbln from mseg into table itab_101

for

all entries in itab_mkpf_rcvdate

where mblnr = itab_mkpf_rcvdate-mblnr and

bwart in ('101','531') and werks = s_werks.

endif.

select mandt

bwart

matnr

ebeln

lfbnr

smbln from mseg client specified into

table itab3 for

all entries in itab_101 where ebeln =

itab_101-ebeln and bwart in ('102','532') and mandt = sy-mandt

.

loop at itab_101.

read table itab3 with key lfbnr = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

read table itab3 with key smbln = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

endloop.

sort itab_101 by matnr.

ENDFORM. " get_mseg_cancellation

&----


*& Form get_mseg_recvtoday_quantity .

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mseg_recvtoday_quantity .

loop at itab_final.

loop at itab_101 where matnr = itab_final-matnr.

IF itab_final-werks = itab_101-werks AND

itab_final-lgort = itab_101-lgort and

itab_final-matnr = itab_101-matnr.

at end of matnr.

sum.

itab_101-erfmg_rt = itab_101-erfmg.

itab_final-labst_rt = itab_101-erfmg_rt .

endat.

endif.

endloop.

modify itab_final.

endloop.

clear itab_final-labst_rt.

ENDFORM. " get_mseg_recvtoday_quantity .

&----


*& Form get_mseg_recvtilldate_quantity

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mseg_recvtilldate_quantity .

select mblnr

mjahr

blart

budat

from mkpf into

table itab_mkpf_rcvdate where

budat between itab_mkpf-p_date1 and itab_mkpf_rcvdate-p_date2

and blart in

('WA','WE','WL').

select matnr

erfmg

mblnr

ebeln

werks

lgort

bwart

lfbnr

smbln from mseg into table itab_101

for

all entries in itab_mkpf_rcvdate

where mblnr = itab_mkpf_rcvdate-mblnr and

bwart in ('101','531') and werks = s_werks.

select mandt

bwart

matnr

ebeln

lfbnr

smbln from mseg client specified

into corresponding fields of table itab3 for

all entries in itab_101 where ebeln =

itab_101-ebeln and bwart in ('102','532') and mandt = sy-mandt

.

loop at itab_101.

read table itab3 with key lfbnr = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

read table itab3 with key smbln = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

endloop.

*

sort itab_101 by matnr.

loop at itab_final.

loop at itab_101 where matnr = itab_final-matnr.

IF itab_final-werks = itab_101-werks AND

itab_final-lgort = itab_101-lgort and

itab_final-matnr = itab_101-matnr.

at end of matnr.

sum.

itab_101-erfmg_rt = itab_101-erfmg.

itab_final-labst_rtld = itab_101-erfmg_rt.

endat.

endif.

endloop.

modify itab_final.

endloop.

ENDFORM. " get_mseg_recvtilldate_quantity

&----


*& Form get_refresh_alltable

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_refresh_alltable .

refresh itab_mkpf_rcvdate.

refresh itab_101.

refresh itab3.

*refresh itab_mkpf.

clear itab_mkpf_rcvdate.

clear itab_101.

clear itab3.

ENDFORM. " get_refresh_alltable

&----


*& Form get_mseg_recvtillyear_quantity

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mseg_recvtillyear_quantity .

select mblnr

mjahr

blart

budat from mkpf into

table itab_mkpf_rcvdate where

budat le itab_mkpf_rcvdate-p_date2

and blart in

('WA','WE','WL').

select matnr

erfmg

mblnr

ebeln

werks

lgort

bwart

lfbnr

smbln from mseg into table itab_101

for

all entries in itab_mkpf_rcvdate

where mblnr = itab_mkpf_rcvdate-mblnr and

bwart in ('101','531') and werks = s_werks.

select mandt

ebeln

matnr

bwart

lfbnr

smbln from mseg client specified

into corresponding fields of table itab3 for

all entries in itab_101 where ebeln =

itab_101-ebeln and bwart in ('102','532') and mandt = sy-mandt

.

loop at itab_101.

read table itab3 with key lfbnr = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

read table itab3 with key smbln = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

endloop.

sort itab_101 by matnr.

loop at itab_final.

loop at itab_101 where matnr = itab_final-matnr.

IF itab_final-werks = itab_101-werks AND

itab_final-lgort = itab_101-lgort and

itab_final-matnr = itab_101-matnr.

at end of matnr.

sum.

itab_101-erfmg_rt = itab_101-erfmg.

itab_final-labst_rty = itab_101-erfmg_rt.

endat.

endif.

endloop.

modify itab_final.

endloop.

ENDFORM. " get_mseg_recvtillyear_quantity

&----


*& Form get_mseg_issuedtoday_quantity

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mseg_issuedtoday_quantity .

select mblnr

mjahr

blart

budat from mkpf into

table itab_mkpf_rcvdate where

budat eq itab_mkpf_rcvdate-p_date2

and blart in

('WA','WE','WL').

if not itab_mkpf_rcvdate[] is initial.

select matnr

erfmg

mblnr

ebeln

werks

lgort

bwart

lfbnr

smbln from mseg

into table itab_101

for

all entries in itab_mkpf_rcvdate

where mblnr = itab_mkpf_rcvdate-mblnr and

bwart in ('261') and werks = s_werks.

endif.

select mandt

ebeln

matnr

bwart

lfbnr

smbln from mseg client specified

into corresponding fields of table itab3 for

all entries in itab_101 where ebeln =

itab_101-ebeln and bwart = 262 and mandt = sy-mandt.

loop at itab_101.

read table itab3 with key lfbnr = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

read table itab3 with key smbln = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

endloop.

sort itab_101 by matnr.

loop at itab_final.

loop at itab_101 where matnr = itab_final-matnr.

IF itab_final-werks = itab_101-werks AND

itab_final-lgort = itab_101-lgort and

itab_final-matnr = itab_101-matnr.

at end of matnr.

sum.

itab_101-erfmg_rt = itab_101-erfmg.

itab_final-labst_it = itab_101-erfmg_rt.

endat.

endif.

endloop.

modify itab_final.

endloop.

ENDFORM. " get_mseg_issuedtoday_quantity

&----


*& Form get_mseg_issdtilldate_quantity

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mseg_issdtilldate_quantity .

select mblnr

mjahr

blart

budat from mkpf into

table itab_mkpf_rcvdate where

budat between itab_mkpf-p_date1 and itab_mkpf_rcvdate-p_date2

and blart in

('WA','WE','WL').

select matnr

erfmg

mblnr

ebeln

werks

lgort

bwart

lfbnr

smbln from mseg into table itab_101

for

all entries in itab_mkpf_rcvdate

where mblnr = itab_mkpf_rcvdate-mblnr and

bwart in ('261') and werks = s_werks.

select mandt

ebeln

matnr

bwart

lfbnr

smbln from mseg client specified

into corresponding fields of table itab3 for

all entries in itab_101 where ebeln =

itab_101-ebeln and bwart = 262 and mandt = sy-mandt.

loop at itab_101.

read table itab3 with key lfbnr = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

read table itab3 with key smbln = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

endloop.

sort itab_101 by matnr.

loop at itab_final.

loop at itab_101 where matnr = itab_final-matnr.

IF itab_final-werks = itab_101-werks AND

itab_final-lgort = itab_101-lgort and

itab_final-matnr = itab_101-matnr.

at end of matnr.

sum.

itab_101-erfmg_rt = itab_101-erfmg.

itab_final-labst_itld = itab_101-erfmg_rt.

endat.

endif.

endloop.

itab_final-eisbe_cl = itab_final-labst + itab_final-labst_rtld

- itab_final-labst_itld.

modify itab_final.

endloop.

ENDFORM. " get_mseg_issdtilldate_quantity

&----


*& Form get_mseg_issdtillyear_quantity

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mseg_issdtillyear_quantity .

select mblnr

mjahr

blart

budat from mkpf into

table itab_mkpf_rcvdate where

budat le itab_mkpf_rcvdate-p_date2

and blart in

('WA','WE','WL').

select matnr

erfmg

mblnr

ebeln

werks

lgort

bwart

lfbnr

smbln from mseg into table itab_101

for

all entries in itab_mkpf_rcvdate

where mblnr = itab_mkpf_rcvdate-mblnr and

bwart in ('261') and werks = s_werks.

select mandt

ebeln

matnr

bwart

lfbnr

smbln from mseg client specified

into corresponding fields of table itab3 for

all entries in itab_101 where ebeln =

itab_101-ebeln and bwart = 262 and mandt = sy-mandt.

*

loop at itab_101.

read table itab3 with key lfbnr = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

read table itab3 with key smbln = itab_101-mblnr.

if sy-subrc = 0.

delete itab_101.

continue.

endif.

endloop.

sort itab_101 by matnr.

loop at itab_final.

loop at itab_101 where matnr = itab_final-matnr.

IF itab_final-werks = itab_101-werks AND

itab_final-lgort = itab_101-lgort and

itab_final-matnr = itab_101-matnr.

at end of matnr.

sum.

itab_101-erfmg_rt = itab_101-erfmg.

itab_final-labst_ity = itab_101-erfmg_rt .

endat.

endif.

endloop.

modify itab_final.

endloop.

ENDFORM. " get_mseg_issdtillyear_quantity

&----


*& Form for_closing_balance

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM for_closing_balance .

loop at itab_final.

loop at itab_101 where matnr = itab_final-matnr.

IF itab_final-werks = itab_101-werks AND

itab_final-lgort = itab_101-lgort and

itab_final-matnr = itab_101-matnr.

itab_final-eisbe_cl = itab_final-labst + itab_final-labst_rtld

- itab_final-labst_itld.

endif.

endloop.

modify itab_final.

endloop.

ENDFORM. " for_closing_balance

&----


*& Form sort_field

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sort_field .

WA_SORT-FIELDNAME = 'MATNR'.

WA_SORT-TABNAME = 'ITAB_FINAL'.

WA_SORT-SPOS = 1.

WA_SORT-UP = 'X'.

WA_SORT-SUBTOT = 'X'.

APPEND WA_SORT TO IT_SORT.

CLEAR WA_SORT.

  • WA_SORT-FIELDNAME = 'LABST1'.

  • WA_SORT-TABNAME = 'ITAB_FINAL'.

  • WA_SORT-UP = 'X'.

  • WA_SORT-SPOS = 2.

  • WA_SORT-SUBTOT = 'X'.

  • APPEND WA_SORT TO IT_SORT.

  • CLEAR WA_SORT.

*

ENDFORM. " sort_field

&----


*& Form get_opening_stock

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_opening_stock .

LOOP AT bestand.

CLEAR sum_mat-menge.

READ TABLE sum_mat WITH KEY werks = bestand-werks

matnr = bestand-matnr

lgort = bestand-lgort

shkzg = 'S'.

MOVE sum_mat-menge TO bestand-soll.

CLEAR sum_mat-menge.

READ TABLE sum_mat WITH KEY werks = bestand-werks

matnr = bestand-matnr

lgort = bestand-lgort

shkzg = 'H'.

MOVE sum_mat-menge TO bestand-haben.

bestand-anfmenge = bestand-endmenge - bestand-soll

+ bestand-haben.

MODIFY bestand.

ENDLOOP.

ENDFORM. " get_opening_stock

&----


*& Form alv_display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM alv_display . "for opening and closing stcok

loop at itab_final.

loop at bestand.

IF itab_final-werks = bestand-werks AND

itab_final-lgort = bestand-lgort and

itab_final-matnr = bestand-matnr.

if sy-subrc = 0.

itab_final-labst = bestand-anfmenge.

itab_final-labst_cl = bestand-endmenge.

endif.

endif.

modify itab_final.

endloop.

endloop.

ENDFORM. " alv_display

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
554

hi,

if you are sure that endless loop do not occur in your program, might as well run it in background...maybe data retrieval take too much time...

4 REPLIES 4
Read only

Former Member
0 Likes
555

hi,

if you are sure that endless loop do not occur in your program, might as well run it in background...maybe data retrieval take too much time...

Read only

Former Member
0 Likes
554

Hi Ravi,

As Leo suggested, you could either run the program in background.

Before that, just try to replace all the SQL <b>IN</b> statement with <b>FOR ALL ENTRIES IN <itab></b>. A friend of mine faced a similar problem, and this is what he did. And do get back, if it works.

Regards

Anil Madhavan

Read only

Former Member
0 Likes
554

Hi,

You can try to free up any internal tables that may not be needed any longer in your program. Use the FREE statement. This may help with your memory issue.

<b>Free itab.</b>

Regards

Read only

dev_parbutteea
Active Contributor
0 Likes
554

Hi,

In form get_data, you have used for all entries without checking whether itab_final is initial. So, if it is the case the select statement will retreive all data from tables!

That will b taking enormous amount of time to process giving timeout exception.

Also, you should be creating temporary tables for each select where you used for all entries and do delete adjacent duplicates for each select.

e.g.

<b>itab_final_matnr[] = itab_final [].

sort itab_final_matnr by matnr.

delete adjacent duplicates from itab_final_matnr comparing matnr.

*for opening stock:

select matnr

werks

labst from mard into table

itab_mard for all entries in itab_final_matnr where matnr = itab_final_matnr-matnr.

do same for lgort, werks, lifnr.</b>

FORM get_data .

*for different types of stock with material number.

select mard~matnr

mard~werks

mard~lgort

mard~labst

mard~insme

mard~speme

mard~einme

mard~retme

mseg~lifnr

into

table itab_final from mard inner join mseg on

mard~matnr =

msegmatnr where mardmatnr in matnr and mard~werks = s_werks.

<b>here you may add : if sy-subrc = 0. </b>

delete adjacent duplicates from itab_final comparing matnr werks lgort .

*for vendor name:

select lifnr

name1

from lfa1 into

table

itab_lfa1 for all entries in itab_final where lifnr =

itab_final-lifnr.

*for plant name:

select werks

name1 from t001w into table

itab_t001w for all entries in itab_final where werks =

itab_final-werks.

*for opening stock:

select matnr

werks

labst from mard into table

itab_mard for all entries in itab_final where matnr = itab_final-matnr.

*for material description:

select matnr

maktx from makt into table

itab_makt for all entries in itab_final where matnr = itab_final-matnr.

*for safety stock:

select matnr

werks

eisbe from marc into table

itab_marc for all entries in itab_final where matnr = itab_final-matnr.

*for storage location description

select lgort

lgobe from t001l into table

itab_t001l for all entries in itab_final where lgort = itab_final-lgort

.

Regards,

Sooness.