棚卸資産年齢分析レポート(中)
10039 ワード
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
PERFORM FRM_INITIALIZATION.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
PERFORM FRM_MODIFY_SCREEN.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
PERFORM FRM_CHECK_INPUT.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM FRM_RETRIVE_DATA.
PERFORM FRM_PROCESS_DATA.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM FRM_OUTPUT.
*&---------------------------------------------------------------------*
*& Form frm_initialization
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* DO NOTHING.
*----------------------------------------------------------------------*
FORM FRM_INITIALIZATION.
ENDFORM."frm_initialization.
*&---------------------------------------------------------------------*
*& Form frm_modify_screen.
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* FILL LIST BOX--->Do Nothing...
*----------------------------------------------------------------------*
FORM FRM_MODIFY_SCREEN.
* TYPE-POOLS:VRM.
*
* DATA: NAME TYPE VRM_ID,"
* LIST TYPE VRM_VALUES,"
* VALUE LIKE LINE OF LIST."
*
* CLEAR LIST.
*
* DEFINE FILL_LIST.
* VALUE-KEY = &1.
* VALUE-TEXT = &2.
* APPEND VALUE TO LIST.
* END-OF-DEFINITION.
*
* FILL_LIST '0-30 ' '0-30 '.
* FILL_LIST '31-60 ' '31-60 '.
* FILL_LIST '61-90 ' '61-90 '.
* FILL_LIST '91-180 ' '91-180 '.
* FILL_LIST '181-360 ' '181-360 '.
* FILL_LIST '361 ' '361 '.
*
* CALL FUNCTION 'VRM_SET_VALUES'
* EXPORTING
* id = 'STKYR'
* values = LIST
* EXCEPTIONS
* ID_ILLEGAL_NAME = 1
* OTHERS = 2
* .
* IF sy-subrc <> 0.
* MESSAGE ' ! 。' TYPE 'E'.
* ENDIF.
ENDFORM."frm_modify_screen.
*&---------------------------------------------------------------------*
*& Form frm_check_input.
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* DOUBLE CHECK WERKS VALUE.
*----------------------------------------------------------------------*
FORM FRM_CHECK_INPUT.
* IF BUKRS IS INITIAL.
* MESSAGE ' !' TYPE 'E'.
* LEAVE LIST-PROCESSING.
* ENDIF.
ENDFORM."frm_check_input
*&---------------------------------------------------------------------*
*& Form frm_retrive_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* DO NOTHING EITHER.
*----------------------------------------------------------------------*
FORM FRM_RETRIVE_DATA.
SELECT A~BUKRS A~WERKS A~LGORT A~MATNR A~MENGE A~MEINS A~MBLNR B~MAKTX INTO CORRESPONDING FIELDS OF TABLE GT_TMP1
FROM MSEG AS A
LEFT JOIN MAKT AS B ON A~MATNR = B~MATNR
WHERE A~MATNR IN MATNR AND A~WERKS IN WERKS AND A~LGORT IN LGORT AND A~BUKRS IN BUKRS AND A~SHKZG = 'S'.
SELECT A~WERKS A~LGORT A~MATNR A~LABST A~INSME A~SPEME INTO CORRESPONDING FIELDS OF TABLE GT_TMP2
FROM MARD AS A
FOR ALL ENTRIES IN GT_TMP1
WHERE A~MATNR = GT_TMP1-MATNR AND A~WERKS = GT_TMP1-WERKS AND A~LGORT = GT_TMP1-LGORT.
SELECT A~WERKS A~LGORT A~MATNR A~PRLAB INTO CORRESPONDING FIELDS OF TABLE GT_TMP3
FROM MSPR AS A
FOR ALL ENTRIES IN GT_TMP1
WHERE A~MATNR = GT_TMP1-MATNR AND A~WERKS = GT_TMP1-WERKS AND A~LGORT = GT_TMP1-LGORT.
SELECT A~WERKS A~LGORT A~MATNR A~KALAB INTO CORRESPONDING FIELDS OF TABLE GT_TMP4
FROM MSKA AS A
FOR ALL ENTRIES IN GT_TMP1
WHERE A~MATNR = GT_TMP1-MATNR AND A~WERKS = GT_TMP1-WERKS AND A~LGORT = GT_TMP1-LGORT.
SELECT A~WERKS A~LGORT A~MATNR A~SLABS INTO CORRESPONDING FIELDS OF TABLE GT_TMP5
FROM MKOL AS A
FOR ALL ENTRIES IN GT_TMP1
WHERE A~MATNR = GT_TMP1-MATNR AND A~WERKS = GT_TMP1-WERKS AND A~LGORT = GT_TMP1-LGORT.
SELECT A~BUKRS A~WERKS A~LGORT A~MATNR A~MBLNR B~BUDAT INTO CORRESPONDING FIELDS OF TABLE GT_TMP6
FROM MSEG AS A
INNER JOIN MKPF AS B ON A~MBLNR = B~MBLNR
FOR ALL ENTRIES IN GT_TMP1
WHERE A~MATNR = GT_TMP1-MATNR AND A~WERKS = GT_TMP1-WERKS AND A~LGORT = GT_TMP1-LGORT AND A~BUKRS = GT_TMP1-BUKRS AND A~MBLNR = GT_TMP1-MBLNR.
SELECT A~BUKRS A~WERKS A~LGORT A~MATNR A~MBLNR B~STPRS B~PEINH INTO CORRESPONDING FIELDS OF TABLE GT_TMP7
FROM MSEG AS A
INNER JOIN MBEW AS B ON A~WERKS = B~BWKEY AND A~MATNR = B~MATNR
FOR ALL ENTRIES IN GT_TMP6
WHERE A~MATNR = GT_TMP6-MATNR AND A~WERKS = GT_TMP6-WERKS AND A~LGORT = GT_TMP6-LGORT AND A~BUKRS = GT_TMP6-BUKRS AND A~MBLNR = GT_TMP6-MBLNR.
SELECT A~WERKS A~MATNR A~LBLAB INTO CORRESPONDING FIELDS OF TABLE GT_TMP8
FROM MSLB AS A
FOR ALL ENTRIES IN GT_TMP1
WHERE A~MATNR = GT_TMP1-MATNR AND A~WERKS = GT_TMP1-WERKS.
CLEAR: GT_TEMP[],GS_TEMP.
LOOP AT GT_TMP1 INTO GS_TMP1.
GS_TEMP-BUKRS = GS_TMP1-BUKRS.
GS_TEMP-WERKS = GS_TMP1-WERKS.
GS_TEMP-LGORT = GS_TMP1-LGORT.
GS_TEMP-MATNR = GS_TMP1-MATNR.
GS_TEMP-MAKTX = GS_TMP1-MAKTX.
GS_TEMP-MENGE = GS_TMP1-MENGE.
GS_TEMP-MEINS = GS_TMP1-MEINS.
READ TABLE GT_TMP2 INTO GS_TMP2 WITH KEY WERKS = GS_TMP1-WERKS LGORT = GS_TMP1-LGORT MATNR = GS_TMP1-MATNR.
IF SY-SUBRC = 0.
GS_TEMP-LABST = GS_TMP2-LABST.
GS_TEMP-INSME = GS_TMP2-INSME.
GS_TEMP-SPEME = GS_TMP2-SPEME.
ENDIF.
READ TABLE GT_TMP3 INTO GS_TMP3 WITH KEY WERKS = GS_TMP1-WERKS LGORT = GS_TMP1-LGORT MATNR = GS_TMP1-MATNR.
IF SY-SUBRC = 0.
GS_TEMP-PRLAB = GS_TMP3-PRLAB.
ENDIF.
READ TABLE GT_TMP4 INTO GS_TMP4 WITH KEY WERKS = GS_TMP1-WERKS LGORT = GS_TMP1-LGORT MATNR = GS_TMP1-MATNR.
IF SY-SUBRC = 0.
GS_TEMP-KALAB = GS_TMP4-KALAB.
ENDIF.
READ TABLE GT_TMP5 INTO GS_TMP5 WITH KEY WERKS = GS_TMP1-WERKS LGORT = GS_TMP1-LGORT MATNR = GS_TMP1-MATNR.
IF SY-SUBRC = 0.
GS_TEMP-SLABS = GS_TMP5-SLABS.
ENDIF.
READ TABLE GT_TMP6 INTO GS_TMP6 WITH KEY BUKRS = GS_TMP1-BUKRS WERKS = GS_TMP1-WERKS LGORT = GS_TMP1-LGORT MATNR = GS_TMP1-MATNR MBLNR = GS_TMP1-MBLNR.
IF SY-SUBRC = 0.
GS_TEMP-BUDAT = GS_TMP6-BUDAT.
ENDIF.
READ TABLE GT_TMP7 INTO GS_TMP7 WITH KEY BUKRS = GS_TMP1-BUKRS WERKS = GS_TMP1-WERKS LGORT = GS_TMP1-LGORT MATNR = GS_TMP1-MATNR MBLNR = GS_TMP1-MBLNR.
IF SY-SUBRC = 0.
GS_TEMP-STPRS = GS_TMP7-STPRS.
GS_TEMP-PEINH = GS_TMP7-PEINH.
ENDIF.
READ TABLE GT_TMP8 INTO GS_TMP8 WITH KEY WERKS = GS_TMP1-WERKS MATNR = GS_TMP1-MATNR.
IF SY-SUBRC = 0.
GS_TEMP-LBLAB = GS_TMP8-LBLAB.
ENDIF.
APPEND GS_TEMP TO GT_TEMP.
CLEAR GS_TEMP.
ENDLOOP.
LOOP AT GT_TEMP INTO GS_TEMP.
APPEND GS_TEMP TO GT_TEMP1.
APPEND GS_TEMP TO GT_TEMP2.
APPEND GS_TEMP TO GT_TEMP3.
APPEND GS_TEMP TO GT_TEMP4.
APPEND GS_TEMP TO GT_TEMP5.
APPEND GS_TEMP TO GT_TEMP6.
ENDLOOP.
LOOP AT GT_TEMP INTO GS_TEMP.
MOVE-CORRESPONDING GS_TEMP TO GS_OUTPUT.
COLLECT GS_OUTPUT INTO GT_OUTPUT.
ENDLOOP.
DATA: FIRSTDAY TYPE D,
LASTDATE TYPE D.
*
IF A1 IS INITIAL AND A2 IS INITIAL AND A3 IS INITIAL AND A4 IS INITIAL AND A5 IS INITIAL AND A6 IS INITIAL OR A6 = 'X'.
A1 = 'X'.
A2 = 'X'.
A3 = 'X'.
A4 = 'X'.
A5 = 'X'.
A6 = 'X'.
ENDIF.
DATA: T1 LIKE A1,
T2 LIKE A2,
T3 LIKE A3,
T4 LIKE A4,
T5 LIKE A5,
T6 LIKE A6.
T1 = A1.
T2 = A2.
T3 = A3.
T4 = A4.
T5 = A5.
T6 = A6.
IF A5 = 'X' AND A6 = ''.
A1 = 'X'.
A2 = 'X'.
A3 = 'X'.
A4 = 'X'.
ENDIF.
IF A4 = 'X' AND A5 = '' AND A6 = ''.
A1 = 'X'.
A2 = 'X'.
A3 = 'X'.
ENDIF.
IF A3 = 'X'AND A4 = '' AND A5 = '' AND A6 = ''.
A1 = 'X'.
A2 = 'X'.
ENDIF.
IF A2 = 'X' AND A1 = ''.
A1 = 'X'.
ENDIF.
DATA: STOCK1 TYPE I,
STOCK2 TYPE I,
STOCK3 TYPE I,
STOCK4 TYPE I,
STOCK5 TYPE I,
CURRENT_STOCK TYPE I.
TYPES:BEGIN OF TY_CURRENT_STOCK,
BUKRS TYPE MSEG-BUKRS,"
WERKS TYPE MSEG-WERKS,"
LGORT TYPE MSEG-LGORT," ( )
MATNR TYPE MSEG-MATNR,"
MAKTX TYPE MAKT-MAKTX,"
STOCK TYPE I,
MENGE1 TYPE MSEG-MENGE,
MENGE2 TYPE MSEG-MENGE,
MENGE3 TYPE MSEG-MENGE,
MENGE4 TYPE MSEG-MENGE,
MENGE5 TYPE MSEG-MENGE,
MENGE6 TYPE MSEG-MENGE,
END OF TY_CURRENT_STOCK.
DATA: GT_STOCK TYPE TABLE OF TY_CURRENT_STOCK,
GS_STOCK TYPE TY_CURRENT_STOCK.