Application Development 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: 

Alv Report time out

Former Member
0 Kudos

Hi Gurus,

I have given below the report ..its getting time out in production server

and its taking long time after running

can u please check and tell me where is the problem

REPORT Z21684R_PERFORMANCE_METRIC_REP NO STANDARD PAGE HEADING

MESSAGE-ID YSD.

  • LINE-SIZE 200

  • LINE-COUNT 62.

*===================================================================

  • PROGRAM Z21684R_PERFORMANCE_METRIC_REP

*===================================================================

----


  • TYPE-POOLS

----


TYPE-POOLS: SLIS.

----


  • INTERNAL TABLES

----


DATA : BEGIN OF TB_STOCK OCCURS 0,

MATNR LIKE MARA-MATNR, " Material number

MAKTX LIKE MAKT-MAKTX, " Material description

MEINS LIKE MARA-MEINS, " Base unit of measure

WERKS LIKE MCHA-WERKS, " Plant

CHARG LIKE MCH1-CHARG, " Batch number

  • LIFNR LIKE MCH1-LIFNR, " Vendor's account number

LICHA LIKE MCH1-LICHA, " Vendor batch number

VFDAT LIKE MCH1-VFDAT, " Shelf Life Expiration Date

CLABS LIKE MCHB-CLABS, " Valuated stock with unrest use

IND(6), " Stock Status

SHELF(10) TYPE C, " Remaining Self Life

ERSDA LIKE MCH1-ERSDA, " Creation date

LWEDT LIKE MCH1-LWEDT, " GR Date

HSDAT LIKE MCH1-HSDAT, " Production date

VDATUM LIKE QAVE-VDATUM, " Usage Decision Date

VEZEITERF LIKE QAVE-VEZEITERF, " Usage Decision Time

EBELN TYPE EBELN, " Pur doc number

CPUTM LIKE MKPF-CPUTM, " GR Time

END OF TB_STOCK.

DATA : BEGIN OF TB_INSP OCCURS 0,

MATNR TYPE MATNR, " Material

WERK TYPE WERKS_D, " Plant

CHARG TYPE CHARG_D, " Batch

PRUEFLOS TYPE QPLOS, " Inspection Lot Number

VDATUM TYPE QVEDATUM, " Usage Decision Date

VEZEITERF TYPE QVEZEITERF," Usage Decision Time

END OF TB_INSP.

DATA : BEGIN OF TB_MSLB OCCURS 0,

MATNR TYPE MATNR, " Material number

WERKS TYPE WERKS_D, " Plant

CHARG TYPE CHARG_D, " Batch number

LBLAB TYPE LABST, " Vendor Stock

LIFNR TYPE LIFNR, " Vendor number

ERSDA TYPE ERSDA, " Creation Date

END OF TB_MSLB.

DATA : BEGIN OF TB_BATCH OCCURS 0,

MATNR TYPE MATNR, " Material number

MAKTX TYPE MAKTX, " Material description

MEINS TYPE MEINS, " Base unit of measure

WERKS TYPE WERKS_D, " Plant

CHARG TYPE CHARG_D, " Batch number

LICHA TYPE LICHN, " Vendor batch number

VFDAT TYPE VFDAT, " Shelf Life Expiration Date

ERSDA TYPE ERSDA, " Creation date

LWEDT TYPE LWEDT, " GR Date

HSDAT TYPE HSDAT, " Production date

CLABS TYPE LABST, " Valuated stock with unrestricted use

CINSM TYPE INSME, " Stock in quality inspection

CSPEM TYPE SPEME, " Blocked stock

END OF TB_BATCH.

DATA : BEGIN OF TB_MCHB OCCURS 0,

MATNR TYPE MATNR, " Material number

WERKS TYPE WERKS_D, " Plant

CHARG TYPE CHARG_D, " Batch number

ERSDA TYPE ERSDA, " Creation date

CLABS TYPE LABST, " Valuated stock with unrestricted use

CINSM TYPE INSME, " Stock in quality inspection

CSPEM TYPE SPEME, " Blocked stock

END OF TB_MCHB.

DATA : BEGIN OF TB_PUR OCCURS 0,

EBELN TYPE EBELN, " Pur doc number

EBELP TYPE EBELP, " Item number

ZEKKN TYPE DZEKKN, " Seq no of acct assig

VGABE TYPE VGABE, " Tran/event type, pur ord his

GJAHR TYPE MJAHR, " Material doc. year

BELNR TYPE MBLNR, " Number of material document

BUZEI TYPE MBLPO, " Item in material document

MATNR LIKE MARA-MATNR, " Material number

WERKS LIKE MCHA-WERKS, " Plant

CHARG LIKE MCH1-CHARG, " Batch number

CPUTM TYPE CPUTM, " Time of entry

END OF TB_PUR.

  • Field catalog internal table

DATA : TB_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, " ALV Field Catalog

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV, " ALV Field Catalog

WA_LAYOUT TYPE SLIS_LAYOUT_ALV, " ALV Field Catalog

TB_SORT TYPE SLIS_T_SORTINFO_ALV. " ALV Sort

----


  • DATA DECLATATIONS

----


DATA : G_MATNR LIKE MARA-MATNR, " Material number

G_ERSDA LIKE MCHA-ERSDA, " Creation Date

G_REPID LIKE SY-REPID, " Report ID

G_VARIANT1 LIKE DISVARIANT, " To store variant

G_VARIANT2 LIKE DISVARIANT, " To store variant

G_VAR_SAVE TYPE C VALUE 'A', " Save

G_VAR_EXIT TYPE C, " Exit

X_SORT TYPE SLIS_SORTINFO_ALV, " For Sorting

F_DATA.

----


  • CONSTANTS DECLATATIONS

----


CONSTANTS: C_A(1) VALUE 'A',

C_X(1) VALUE 'X',

C_L(1) VALUE 'L',

C_ACTVT03 LIKE TACT-ACTVT VALUE '03'.

----


  • RANGES DECLATATIONS

----


RANGES: R_MTART FOR MARA-MTART.

----


  • Selection screen

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_MATNR FOR G_MATNR.

PARAMETER : P_WERKS LIKE MSLB-WERKS OBLIGATORY.

SELECT-OPTIONS : S_DATE FOR G_ERSDA.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

PARAMETERS : P_OH RADIOBUTTON GROUP RAD1 USER-COMMAND RIS DEFAULT 'X',

P_PER RADIOBUTTON GROUP RAD1.

SELECTION-SCREEN END OF BLOCK B2.

SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-002.

PARAMETERS:P_VAR LIKE DISVARIANT-VARIANT MODIF ID V1. " Variant for ALV

SELECTION-SCREEN END OF BLOCK B3.

************************************************************************

  • I N I T I A L I Z A T I O N *

************************************************************************

INITIALIZATION.

G_REPID = SY-REPID.

G_VARIANT1-REPORT = SY-REPID. " Report ID

  • Fill the Range for Material Type

R_MTART-LOW = 'FERT'.

R_MTART-SIGN = 'I'.

R_MTART-OPTION = 'EQ'.

APPEND R_MTART.

CLEAR R_MTART.

R_MTART-LOW = 'ROH'.

R_MTART-SIGN = 'I'.

R_MTART-OPTION = 'EQ'.

APPEND R_MTART.

CLEAR R_MTART.

R_MTART-LOW = 'VERP'.

R_MTART-SIGN = 'I'.

R_MTART-OPTION = 'EQ'.

APPEND R_MTART.

CLEAR R_MTART.

R_MTART-LOW = 'HALB'.

R_MTART-SIGN = 'I'.

R_MTART-OPTION = 'EQ'.

APPEND R_MTART.

CLEAR R_MTART.

************************************************************************

  • A T S E L E C T I O N S C R E E N O U T P U T *

************************************************************************

AT SELECTION-SCREEN OUTPUT.

  • Perform to modify the screen based on the selection

PERFORM CHANGE_SCREEN.

************************************************************************

  • A T S E L E C T I O N S C R E E N *

************************************************************************

AT SELECTION-SCREEN.

  • Validate the Material.

PERFORM VALIDATE_MATERIAL.

  • validate the Plant

PERFORM VALIDATE_PLANT.

  • To get the ALV GRID Variant

IF NOT P_VAR IS INITIAL.

PERFORM CHECK_VARIANT_EXISTENCE USING P_VAR.

ENDIF.

----


  • AT SELECTION SCREEN ON VALUE REQUEST

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.

  • To provide f4 help fot the display variant

PERFORM F4_HELP_FOR_VARIANT.

************************************************************************

  • S T A R T O F S E L E C T I O N *

************************************************************************

START-OF-SELECTION.

*-Get the On hand Stock

PERFORM GET_DATA.

************************************************************************

  • E N D O F S E L E C T I O N *

************************************************************************

END-OF-SELECTION.

IF F_DATA = 'X'.

EXIT.

ENDIF.

  • collect the Final data.

PERFORM COLLECT_DATA.

IF P_OH = 'X'.

READ TABLE TB_STOCK INDEX 1.

IF SY-SUBRC = 0.

  • Alv display

PERFORM ALV_DISPLAY.

ELSE.

MESSAGE I100 WITH 'No data present for the selection criteria'(003).

ENDIF.

ELSE.

READ TABLE TB_STOCK INDEX 1.

IF SY-SUBRC = 0.

  • Alv display

PERFORM ALV_DISPLAY.

ELSE.

MESSAGE I100 WITH 'No data present for the selection criteria'(003).

ENDIF.

ENDIF.

&----


*& Form GET_DATA

&----


  • Get all the data based on plant and material

----


FORM GET_DATA.

  • Get all the materials from MCH1 Table

PERFORM GET_MCH1_DATA.

  • GEt the Vendor Stock Data

PERFORM GET_STOCK_DATA.

  • Get the Material Stock Data with Batches

PERFORM GET_MATERIAL_STOCK.

IF P_PER = 'X'.

  • Get Purchase orders from EKBE Table

PERFORM GET_PURCHASE_GR_TIME.

ENDIF.

ENDFORM. " GET_DATA

&----


*& Form COLLECT_DATA

&----


  • Collect the data

----


FORM COLLECT_DATA.

DATA : L_SHELF TYPE I.

LOOP AT TB_BATCH.

CLEAR L_SHELF.

TB_STOCK-MATNR = TB_BATCH-MATNR.

TB_STOCK-MEINS = TB_BATCH-MEINS.

TB_STOCK-MAKTX = TB_BATCH-MAKTX.

TB_STOCK-WERKS = TB_BATCH-WERKS.

TB_STOCK-CHARG = TB_BATCH-CHARG.

TB_STOCK-VFDAT = TB_BATCH-VFDAT.

TB_STOCK-LICHA = TB_BATCH-LICHA.

TB_STOCK-ERSDA = TB_BATCH-ERSDA.

TB_STOCK-LWEDT = TB_BATCH-LWEDT.

TB_STOCK-HSDAT = TB_BATCH-HSDAT.

IF NOT TB_STOCK-VFDAT IS INITIAL.

L_SHELF = TB_STOCK-VFDAT - SY-DATUM.

MOVE L_SHELF TO TB_STOCK-SHELF.

IF L_SHELF < 0.

REPLACE '-' WITH SPACE INTO TB_STOCK-SHELF.

CONDENSE TB_STOCK-SHELF.

CONCATENATE '-' TB_STOCK-SHELF INTO TB_STOCK-SHELF.

ENDIF.

ENDIF.

IF P_PER = 'X'.

  • Read Purchase Order data

CLEAR TB_PUR.

READ TABLE TB_PUR WITH KEY MATNR = TB_BATCH-MATNR

WERKS = TB_BATCH-WERKS

CHARG = TB_BATCH-CHARG.

IF SY-SUBRC = 0.

TB_STOCK-EBELN = TB_PUR-EBELN.

TB_STOCK-CPUTM = TB_PUR-CPUTM.

ENDIF.

ENDIF.

CLEAR TB_MSLB.

READ TABLE TB_MSLB WITH KEY MATNR = TB_BATCH-MATNR

WERKS = TB_BATCH-WERKS

CHARG = TB_BATCH-CHARG.

IF SY-SUBRC = 0 AND NOT TB_MSLB-LBLAB IS INITIAL.

  • TB_STOCK-LIFNR = TB_MSLB-LIFNR.

TB_STOCK-CLABS = TB_MSLB-LBLAB.

TB_STOCK-IND = 'UR-SC'.

APPEND TB_STOCK.

DELETE TB_MSLB WHERE MATNR = TB_BATCH-MATNR AND

WERKS = TB_BATCH-WERKS AND

CHARG = TB_BATCH-CHARG.

ENDIF.

  • read table MCHB data for Stock

READ TABLE TB_MCHB WITH KEY MATNR = TB_BATCH-MATNR

WERKS = TB_BATCH-WERKS

CHARG = TB_BATCH-CHARG.

IF SY-SUBRC = 0.

  • append for Un restricted Stock

IF NOT TB_MCHB-CLABS IS INITIAL.

TB_STOCK-CLABS = TB_MCHB-CLABS.

TB_STOCK-IND = 'UR'.

APPEND TB_STOCK.

ENDIF.

  • append for Blocked Stock

IF NOT TB_MCHB-CSPEM IS INITIAL.

TB_STOCK-CLABS = TB_MCHB-CSPEM.

TB_STOCK-IND = 'BL'.

APPEND TB_STOCK.

ENDIF.

  • append for Quality Stock

IF NOT TB_MCHB-CINSM IS INITIAL.

TB_STOCK-CLABS = TB_MCHB-CINSM.

TB_STOCK-IND = 'QA'.

APPEND TB_STOCK.

ENDIF.

ENDIF.

CLEAR TB_STOCK.

ENDLOOP.

  • This would be a rear case where some the batch will be empty

  • at vendor place if the batch exists the above logic will get the

  • records

DESCRIBE TABLE TB_MSLB LINES SY-TFILL.

IF SY-TFILL > 0.

LOOP AT TB_MSLB.

TB_STOCK-MATNR = TB_MSLB-MATNR.

TB_STOCK-WERKS = TB_MSLB-WERKS.

TB_STOCK-CHARG = TB_MSLB-CHARG.

TB_STOCK-CLABS = TB_MSLB-LBLAB.

  • TB_STOCK-LIFNR = TB_MSLB-LIFNR.

TB_STOCK-IND = 'UR-SC'.

READ TABLE TB_BATCH WITH KEY MATNR = TB_STOCK-MATNR

WERKS = TB_STOCK-WERKS.

IF SY-SUBRC = 0.

TB_STOCK-MAKTX = TB_BATCH-MAKTX.

TB_STOCK-MEINS = TB_BATCH-MEINS.

ELSE.

SELECT SINGLE MEINS INTO TB_STOCK-MEINS

FROM MARA

WHERE MATNR = TB_STOCK-MATNR.

SELECT SINGLE MAKTX INTO TB_STOCK-MAKTX

FROM MAKT

WHERE MATNR = TB_STOCK-MATNR AND

SPRAS = SY-LANGU.

ENDIF.

IF NOT TB_STOCK-CHARG IS INITIAL.

SELECT SINGLE VFDAT LICHA

INTO (TB_STOCK-VFDAT, TB_STOCK-LICHA)

FROM MCH1

WHERE MATNR = TB_STOCK-MATNR AND

CHARG = TB_STOCK-CHARG.

ENDIF.

APPEND TB_STOCK.

CLEAR TB_STOCK.

ENDLOOP.

ENDIF.

  • select the Quality usade decision data

DATA : L_INDEX TYPE SY-TABIX.

SELECT QALS~MATNR

QALS~WERK

QALS~CHARG

QALS~PRUEFLOS

QAVE~VDATUM

QAVE~VEZEITERF

INTO TABLE TB_INSP

FROM QALS INNER JOIN QAVE ON

QALSPRUEFLOS = QAVEPRUEFLOS AND

QALSWERK = QAVEVWERKS

FOR ALL ENTRIES IN TB_STOCK

WHERE QALS~MATNR = TB_STOCK-MATNR AND

QALS~WERK = TB_STOCK-WERKS AND

QALS~CHARG = TB_STOCK-CHARG.

IF SY-SUBRC = 0.

SORT TB_INSP BY MATNR WERK CHARG.

LOOP AT TB_STOCK.

L_INDEX = SY-TABIX.

READ TABLE TB_INSP WITH KEY MATNR = TB_STOCK-MATNR

WERK = TB_STOCK-WERKS

CHARG = TB_STOCK-CHARG

BINARY SEARCH.

IF SY-SUBRC = 0.

TB_STOCK-VDATUM = TB_INSP-VDATUM.

TB_STOCK-VEZEITERF = TB_INSP-VEZEITERF.

MODIFY TB_STOCK INDEX L_INDEX TRANSPORTING VDATUM VEZEITERF.

ENDIF.

ENDLOOP.

ENDIF.

IF P_PER = 'X'.

DELETE TB_STOCK WHERE NOT ERSDA IN S_DATE.

ENDIF.

SORT TB_STOCK BY MATNR.

ENDFORM. " COLLECT_DATA

&----


*& Form CHANGE_SCREEN

&----


  • Change the Screen

----


FORM CHANGE_SCREEN.

  • change the Screen field based on the selection.

IF P_OH = 'X'.

LOOP AT SCREEN.

IF SCREEN-NAME = 'S_DATE-LOW' OR

SCREEN-NAME = 'S_DATE-HIGH' OR

SCREEN-NAME = '%_S_DATE_%_APP_%-TEXT'.

SCREEN-ACTIVE = '0'.

  • SCREEN-OUTPUT = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

ENDFORM. " CHANGE_SCREEN

&----


*& Form VALIDATE_MATERIAL

&----


  • Validate Material number

----


FORM VALIDATE_MATERIAL.

DATA : L_MATNR TYPE MATNR.

IF NOT S_MATNR IS INITIAL.

SELECT SINGLE MATNR

FROM MARA

INTO L_MATNR

WHERE MATNR IN S_MATNR.

IF SY-SUBRC <> 0.

MESSAGE E100 WITH 'Invalid Material number'(004).

ENDIF.

ENDIF.

ENDFORM. " VALIDATE_MATERIAL

&----


*& Form VALIDATE_PLANT

&----


  • validate the Plant

----


FORM VALIDATE_PLANT.

DATA : L_WERKS TYPE WERKS_D.

SELECT SINGLE WERKS

FROM T001W

INTO L_WERKS

WHERE WERKS = P_WERKS.

IF SY-SUBRC <> 0.

MESSAGE E100 WITH 'Invalid Plant'(005).

ENDIF.

  • Check authorization on plant level for all plants in the selection

AUTHORITY-CHECK OBJECT 'M_MSEG_WMB'

ID 'ACTVT' FIELD C_ACTVT03

ID 'WERKS' FIELD P_WERKS.

IF NOT SY-SUBRC IS INITIAL.

*------ NO AUTHORIZATION FOR THIS PLANT

MESSAGE E100 WITH

'You have no authorization for this transaction in plant'(006)

P_WERKS.

ENDIF.

ENDFORM. " VALIDATE_PLANT

&----


*& Form ALV_DISPLAY

&----


  • ALV Report

----


FORM ALV_DISPLAY.

  • Build field catalog

PERFORM F_BUID_CATELOG.

  • Modifying field catalog for column headers

PERFORM MODIFY_FIELDCAT.

  • List display

PERFORM F_DISPLAY_GRID.

ENDFORM. " ALV_DISPLAY

&----


*& Form F_BUID_CATELOG

&----


  • text

----


FORM F_BUID_CATELOG.

  • Local Variable.

DATA: L_TABNAME TYPE SLIS_TABNAME. " Table Name

L_TABNAME = 'TB_STOCK'.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = G_REPID

I_INTERNAL_TABNAME = L_TABNAME

I_INCLNAME = G_REPID

CHANGING

CT_FIELDCAT = TB_FIELDCAT

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

MESSAGE I100 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " F_BUID_CATELOG

&----


*& Form MODIFY_FIELDCAT

&----


  • Field Catalog

----


FORM MODIFY_FIELDCAT.

DATA : L_TABIX TYPE SY-TABIX.

LOOP AT TB_FIELDCAT INTO WA_FIELDCAT.

CLEAR L_TABIX.

L_TABIX = SY-TABIX.

CASE WA_FIELDCAT-FIELDNAME.

  • Material Number

WHEN 'MATNR'.

WA_FIELDCAT-SELTEXT_L = 'SAP Material #'(008).

WA_FIELDCAT-OUTPUTLEN = '18'.

WA_FIELDCAT-DDICTXT = C_L.

WA_FIELDCAT-COL_POS = 1.

  • Material Text

WHEN 'MAKTX'.

WA_FIELDCAT-SELTEXT_L = 'SAP Description'(009).

WA_FIELDCAT-OUTPUTLEN = '40'.

WA_FIELDCAT-DDICTXT = C_L.

WA_FIELDCAT-COL_POS = 2.

  • Vendor Batch Number

WHEN 'LICHA'.

WA_FIELDCAT-SELTEXT_L = 'Vendor Batch #'(010).

WA_FIELDCAT-OUTPUTLEN = '15'.

WA_FIELDCAT-DDICTXT = C_L.

WA_FIELDCAT-COL_POS = 3.

  • Vendor Batch Number

WHEN 'CHARG'.

WA_FIELDCAT-SELTEXT_L = 'SAP Batch #'(011).

WA_FIELDCAT-OUTPUTLEN = '10'.

WA_FIELDCAT-DDICTXT = C_L.

WA_FIELDCAT-COL_POS = 4.

  • Purchase Order No

WHEN 'EBELN'.

WA_FIELDCAT-SELTEXT_L = 'Purchase Order #'(027).

WA_FIELDCAT-OUTPUTLEN = '16'.

WA_FIELDCAT-DDICTXT = C_L.

WA_FIELDCAT-COL_POS = 5.

IF P_OH = 'X'.

WA_FIELDCAT-NO_OUT = C_X.

ENDIF.

  • On Hand Qty

WHEN 'CLABS'.

WA_FIELDCAT-SELTEXT_L = 'On Hand Quantity'(013).

WA_FIELDCAT-OUTPUTLEN = '20'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_OH = 'X'.

WA_FIELDCAT-COL_POS = 5.

ELSE.

WA_FIELDCAT-COL_POS = 6.

ENDIF.

WA_FIELDCAT-DO_SUM = C_X.

  • Unit of Measure

WHEN 'MEINS'.

WA_FIELDCAT-SELTEXT_L = 'UOM'(015).

WA_FIELDCAT-OUTPUTLEN = '5'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_OH = 'X'.

WA_FIELDCAT-COL_POS = 6.

ELSE.

WA_FIELDCAT-COL_POS = 7.

ENDIF.

  • Expiration Date

WHEN 'VFDAT'.

WA_FIELDCAT-SELTEXT_L = 'Expiration Date'(016).

WA_FIELDCAT-OUTPUTLEN = '10'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_OH = 'X'.

WA_FIELDCAT-COL_POS = 7.

ELSE.

WA_FIELDCAT-COL_POS = 8.

ENDIF.

  • Stock Status

WHEN 'IND'.

WA_FIELDCAT-SELTEXT_L = 'Stock Status'(017).

WA_FIELDCAT-OUTPUTLEN = '5'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_OH = 'X'.

WA_FIELDCAT-COL_POS = 8.

ELSE.

WA_FIELDCAT-COL_POS = 9.

ENDIF.

  • Production date

WHEN 'HSDAT'.

WA_FIELDCAT-SELTEXT_L = 'Production Date'(018).

WA_FIELDCAT-OUTPUTLEN = '10'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_OH = 'X'.

WA_FIELDCAT-NO_OUT = C_X.

ENDIF.

WA_FIELDCAT-COL_POS = 10.

  • GR date

WHEN 'LWEDT'.

WA_FIELDCAT-SELTEXT_L = 'GR Date'(019).

WA_FIELDCAT-OUTPUTLEN = '10'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_OH = 'X'.

WA_FIELDCAT-NO_OUT = C_X.

ENDIF.

WA_FIELDCAT-COL_POS = 11.

  • GR Time

WHEN 'CPUTM'.

WA_FIELDCAT-SELTEXT_L = 'GR Time'(020).

WA_FIELDCAT-OUTPUTLEN = '10'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_OH = 'X'.

WA_FIELDCAT-NO_OUT = C_X.

ENDIF.

WA_FIELDCAT-NO_ZERO = C_X.

WA_FIELDCAT-COL_POS = 12.

  • Usage Decision date

WHEN 'VDATUM'.

WA_FIELDCAT-SELTEXT_L = 'UD Date'(021).

WA_FIELDCAT-OUTPUTLEN = '10'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_OH = 'X'.

WA_FIELDCAT-NO_OUT = C_X.

ENDIF.

WA_FIELDCAT-COL_POS = 13.

  • Usage Decision Time

WHEN 'VEZEITERF'.

WA_FIELDCAT-SELTEXT_L = 'UD Time'(022).

WA_FIELDCAT-OUTPUTLEN = '10'.

WA_FIELDCAT-DDICTXT = C_L.

WA_FIELDCAT-NO_ZERO = C_X.

IF P_OH = 'X'.

WA_FIELDCAT-NO_OUT = C_X.

ENDIF.

WA_FIELDCAT-COL_POS = 14.

  • Remaining Self Life

WHEN 'SHELF'.

WA_FIELDCAT-SELTEXT_L = 'Remaining Shelf Life'(023).

WA_FIELDCAT-OUTPUTLEN = '10'.

WA_FIELDCAT-DDICTXT = C_L.

IF P_PER = 'X'.

WA_FIELDCAT-COL_POS = 15.

ELSE.

WA_FIELDCAT-COL_POS = 10.

ENDIF.

ENDCASE.

MODIFY TB_FIELDCAT FROM WA_FIELDCAT INDEX L_TABIX.

ENDLOOP.

DELETE TB_FIELDCAT WHERE FIELDNAME = 'ERSDA'.

  • To Remove The Totals that are getting Printed

WA_LAYOUT-NO_TOTALLINE = 'X'.

ENDFORM. " MODIFY_FIELDCAT

&----


*& Form F_DISPLAY_GRID

&----


  • Display the Grid

----


FORM F_DISPLAY_GRID.

  • Sorting with respect to plant

CLEAR X_SORT.

X_SORT-FIELDNAME = 'MATNR'.

X_SORT-UP = C_X.

X_SORT-GROUP = 1.

X_SORT-SUBTOT = C_X.

APPEND X_SORT TO TB_SORT.

CLEAR X_SORT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

IT_SORT = TB_SORT

IT_FIELDCAT = TB_FIELDCAT[]

I_DEFAULT = C_X

IS_LAYOUT = WA_LAYOUT

I_SAVE = C_A

IS_VARIANT = G_VARIANT1

TABLES

T_OUTTAB = TB_STOCK

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE I100 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " F_DISPLAY_GRID

&----


*& Form GET_MCH1_DATA

&----


  • GEt MCH1 Data

----


FORM GET_MCH1_DATA.

  • select all the Materials

SELECT MARA~MATNR

MAKT~MAKTX

MARA~MEINS

MCHA~WERKS

MCH1~CHARG

MCH1~LICHA

MCH1~VFDAT

MCH1~ERSDA

MCH1~LWEDT

MCH1~HSDAT

INTO TABLE TB_BATCH

FROM MCH1 INNER JOIN MCHA ON

MCHAMATNR = MCH1MATNR AND

MCHACHARG = MCH1CHARG

INNER JOIN MARA ON

MARAMATNR = MCH1MATNR

INNER JOIN MAKT ON

MAKTMATNR = MCH1MATNR

WHERE MCH1~MATNR IN S_MATNR AND

MCHA~WERKS = P_WERKS AND

MARA~MTART IN R_MTART AND

MAKT~SPRAS = SY-LANGU.

IF SY-SUBRC <> 0.

F_DATA = 'X'.

MESSAGE I100 WITH 'No data present for the selection criteria'(003).

STOP.

ENDIF.

ENDFORM. " GET_MCH1_DATA

&----


*& Form GET_STOCK_DATA

&----


  • Get the Stock Data

----


FORM GET_STOCK_DATA.

  • Select the stock.

SELECT MARA~MATNR

MSLB~WERKS

MSLB~CHARG

MSLB~LBLAB

MSLB~LIFNR

MSLB~ERSDA

INTO TABLE TB_MSLB

FROM MSLB INNER JOIN MARA ON

MARAMATNR = MSLBMATNR

WHERE MSLB~MATNR IN S_MATNR AND

MSLB~WERKS = P_WERKS AND

MSLB~LBLAB > 0 AND

MARA~MTART IN R_MTART.

IF SY-SUBRC = 0.

SORT TB_MSLB BY MATNR WERKS CHARG.

ENDIF.

ENDFORM. " GET_STOCK_DATA

&----


*& Form GET_MATERIAL_STOCK

&----


  • text

----


FORM GET_MATERIAL_STOCK.

  • select the Stocks from MCHB

SELECT MARA~MATNR

MCHB~WERKS

MCHB~CHARG

MCHB~ERSDA

MCHB~CLABS

MCHB~CINSM

MCHB~CSPEM

INTO TABLE TB_MCHB

FROM MCHB INNER JOIN MARA ON

MARAMATNR = MCHBMATNR

WHERE MARA~MATNR IN S_MATNR AND

MCHB~WERKS = P_WERKS AND

MARA~MTART IN R_MTART.

IF SY-SUBRC = 0.

SORT TB_MCHB BY MATNR WERKS CHARG.

ENDIF.

ENDFORM. " GET_MATERIAL_STOCK

&----


*& Form CHECK_VARIANT_EXISTENCE

&----


  • Check for Varaint

----


FORM CHECK_VARIANT_EXISTENCE USING P_P_VAR.

G_VARIANT1-VARIANT = P_P_VAR. "Display Variant

  • To check weather the variant is valid or not

IF NOT G_VARIANT1-VARIANT IS INITIAL.

CONSTANTS: C_SAVE(1) VALUE 'U'.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = C_SAVE

CHANGING

CS_VARIANT = G_VARIANT1

EXCEPTIONS

WRONG_INPUT = 1

NOT_FOUND = 2

PROGRAM_ERROR = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

MESSAGE E100 WITH 'Please Enter Valid ALV Variant'(025).

ENDIF.

ENDIF.

ENDFORM. " CHECK_VARIANT_EXISTENCE

&----


*& Form F4_HELP_FOR_VARIANT

&----


  • F4 ALV Varaint

----


FORM F4_HELP_FOR_VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = G_VARIANT1

I_SAVE = G_VAR_SAVE

IMPORTING

E_EXIT = G_VAR_EXIT

ES_VARIANT = G_VARIANT2

EXCEPTIONS

NOT_FOUND = 1

PROGRAM_ERROR = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

IF SY-SUBRC = 1.

MESSAGE I100 WITH 'No Variant exits for the ALV'(026).

ELSE.

MESSAGE I100 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDIF.

IF G_VAR_EXIT = SPACE.

P_VAR = G_VARIANT2-VARIANT.

G_VARIANT1 = G_VARIANT2.

ENDIF.

ENDFORM. " F4_HELP_FOR_VARIANT

&----


*& Form GET_PURCHASE_GR_TIME

&----


  • Get Purchase Orders and GR time

----


FORM GET_PURCHASE_GR_TIME.

SELECT EBELN

EBELP

ZEKKN

VGABE

GJAHR

BELNR

BUZEI

MATNR

WERKS

CHARG

CPUTM

FROM EKBE

INTO TABLE TB_PUR

FOR ALL ENTRIES IN TB_BATCH

WHERE MATNR = TB_BATCH-MATNR AND

WERKS = TB_BATCH-WERKS AND

CHARG = TB_BATCH-CHARG AND

BWART = '101'. " ONLY GOODS RECEPIT

IF SY-SUBRC = 0.

SORT TB_PUR BY EBELN.

ENDIF.

ENDFORM. " GET_PURCHASE_GR_TIME

1 REPLY 1

Former Member
0 Kudos

Have you run a performance trace on this to identify SQL problems?

I think your main problem may be in form COLLECT_DATA. there you do a number of READs without the BINARY SEARCH addition. Convert them to binary reads and the program should speed up.

Rob

Message was edited by:

Rob Burbank