Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
Error rendering macro 'code': Invalid value specified for parameter 'lang'
REPORT ZEXPECTEDDELV MESSAGE-ID ZAVEEK LINE-SIZE 132
NO STANDARD PAGE HEADING.
 ************************************************************************
* Expected Deliveries
* Aveek Ghose : April 2000
************************************************************************
* Standard Includesinclude zsi0009.* Tablestables: eket, ekko, ekpo, makt, lfa1, t001l, mara, marc, eban,
MCON, RESB, RKPF.
 * CONSTANTSCONSTANTS: CC_MAT_STD LIKE MARC-SOBSL VALUE '60'.
CONSTANTS: CC_MAT_CONS LIKE MARC-SOBSL VALUE '70'.* EXTRACTED DATA.DATA: BEGIN OF EXTRACT OCCURS 100,
EINDT LIKE EKET-EINDT,
UZEIT LIKE EKET-UZEIT,
LGORT LIKE EKPO-LGORT,
LIFNR LIKE LFA1-LIFNR,
NAME1(20) TYPE C,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
OUTST LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
MATNR LIKE EKPO-MATNR,
MAKTX(20) TYPE C,
RECTYPE(3) TYPE C,
DELVD(1) TYPE C,
QISTK(1) TYPE C.
DATA: END OF EXTRACT.* TMP EXTRACTDATA: BEGIN OF TMP_EXTRACT OCCURS 100,
EINDT LIKE EKET-EINDT,
UZEIT LIKE EKET-UZEIT,
LGORT LIKE EKPO-LGORT,
LIFNR LIKE LFA1-LIFNR,
NAME1(20) TYPE C,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
OUTST LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
MATNR LIKE EKPO-MATNR,
MAKTX(20) TYPE C,
RECTYPE(3) TYPE C,
DELVD(1) TYPE C,
QISTK(1) TYPE C.
DATA: END OF TMP_EXTRACT.
* Materials
DATA: BEGIN OF MATS OCCURS 100.
DATA: MATNR LIKE MARA-MATNR,
MATKL LIKE MARA-MATKL,
MTART LIKE MARA-MTART,
DISPO LIKE MARC-DISPO,
EKGRP LIKE MARC-EKGRP.
DATA END OF MATS.
* Temp Data
DATA: TMPQTY LIKE EKPO-MENGE.
DATA: COUNT(3) TYPE N.
DATA: LAST_MATNR LIKE EKPO-MATNR.
DATA: LAST_EBELN LIKE EKPO-EBELN.
DATA: FIRST(1) TYPE C.
DATA: LINES(6) TYPE N.
DATA: TMPVALUE(30) TYPE C.
DATA: TMPEBELN LIKE EKKO-EBELN.
DATA: ONEWEEK LIKE SY-DATUM VALUE '01122999'.
DATA: TMPDATE LIKE SY-DATUM.
DATA: LOWDATE LIKE SY-DATUM.
DATA: HIDATE LIKE SY-DATUM.
DATA: DAYTXT(9) TYPE C.
DATA: CUR_POS(30) TYPE C.
DATA: MAT_CHG(1) TYPE C.
DATA: LIF_CHG(1) TYPE C.
DATA: DEL_CHG(1) TYPE C.
DATA: TMP_LIFNR LIKE LFA1-LIFNR.
DATA: MATN LIKE MARA-MATNR.
DATA: MATNO LIKE MARA-BISMT.
DATA: FLAGS(1) TYPE C.
DATA: NOMAT(1) TYPE C.
DATA: ITEM(4) TYPE C.
DATA: ILEN TYPE I.
DATA: TIMESPOT TYPE T.
DATA: I_LINENUM TYPE I.
* Parms
SELECT-OPTIONS: WDATE FOR SY-DATUM OBLIGATORY DEFAULT SY-DATUM TO
SY-DATUM NO-EXTENSION.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 35.
PARAMETERS: WTEXT1(10) TYPE C MODIF ID WT1.
SELECTION-SCREEN POSITION 60.
PARAMETERS: WTEXT2(10) TYPE C MODIF ID WT2.
SELECTION-SCREEN END OF LINE.
SELECT-OPTIONS:UZEIT FOR TIMESPOT OBLIGATORY NO-EXTENSION.
*select-options: uzeit for eket-uzeit obligatory no-extension.
SELECT-OPTIONS: RDATE FOR SY-DATUM NO-EXTENSION.
PARAMETERS: WERKS LIKE LQUA-WERKS MEMORY ID WRK OBLIGATORY,
LGORT LIKE EKPO-LGORT,
FIXKZ RADIOBUTTON GROUP RAD1,                               "03/99
PROPO RADIOBUTTON GROUP RAD1,                               "03/99
OUTSTD RADIOBUTTON GROUP RAD1,                              "03/99
DELCO AS CHECKBOX DEFAULT ' ',                              "03/99
OLDNO AS CHECKBOX DEFAULT ' ',
LIFNR LIKE EKKO-LIFNR MATCHCODE OBJECT KRED,
DESC(40) TYPE C MODIF ID DES.
SELECT-OPTIONS: MTART FOR MARA-MTART,
DISPO FOR MARC-DISPO,
MATKL FOR MARA-MATKL.                                       "03/99
PARAMETERS: EKGRP LIKE MARC-EKGRP,
MATNR LIKE LQUA-MATNR MATCHCODE OBJECT MAT1
MEMORY ID MAT,
DSC2(40) TYPE C MODIF ID DS2.
* Init.
INITIALIZATION.
  GET PARAMETER ID 'WRK' FIELD WERKS.
  GET PARAMETER ID 'MAT' FIELD MATNR.
* Validate Inputs
AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF SCREEN-GROUP1 = 'DS2'.
      SCREEN-INPUT = '0'.
      SCREEN-INVISIBLE = '1'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
  IF NOT ( MATNR IS INITIAL ).
    LOOP AT SCREEN.
      IF SCREEN-GROUP1 = 'DS2'.
        CLEAR: DSC2.
        SELECT SINGLE MAKTX INTO (DSC2)
        FROM MAKT
        WHERE MATNR = MATNR
        AND SPRAS = SY-LANGU.
        IF SY-SUBRC EQ 0.
          SCREEN-INPUT = '0'.
          SCREEN-INVISIBLE = '0'.
          MODIFY SCREEN.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.
  LOOP AT SCREEN.
    IF SCREEN-GROUP1 = 'DES'.
      SCREEN-INPUT = '0'.
      SCREEN-INVISIBLE = '1'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
  IF NOT ( LIFNR IS INITIAL ).
    LOOP AT SCREEN.
      IF SCREEN-GROUP1 = 'DES'.
        CLEAR: DESC.
        SELECT SINGLE NAME1 INTO (DESC)
        FROM LFA1
        WHERE LIFNR = LIFNR.
        IF SY-SUBRC EQ 0.
          SCREEN-INPUT = '0'.
          SCREEN-INVISIBLE = '0'.
          MODIFY SCREEN.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.
  LOOP AT SCREEN.
    IF SCREEN-GROUP1 = 'WT1'.
      SCREEN-INPUT = '0'.
      SCREEN-INVISIBLE = '1'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
  IF NOT ( WDATE-LOW IS INITIAL ).
    LOOP AT SCREEN.
      IF SCREEN-GROUP1 = 'WT1'.
        MOVE WDATE-LOW TO TMPDATE.
        PERFORM GET_DAY USING TMPDATE DAYTXT.
        MOVE DAYTXT TO WTEXT1.
        SCREEN-INPUT = '0'.
        SCREEN-INVISIBLE = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.
  LOOP AT SCREEN.
    IF SCREEN-GROUP1 = 'WT2'.
      SCREEN-INPUT = '0'.
      SCREEN-INVISIBLE = '1'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
  IF NOT ( WDATE-HIGH IS INITIAL ).
    LOOP AT SCREEN.
      IF SCREEN-GROUP1 = 'WT2'.
        MOVE WDATE-HIGH TO TMPDATE.
        PERFORM GET_DAY USING TMPDATE DAYTXT.
        MOVE DAYTXT TO WTEXT2.
        SCREEN-INPUT = '0'.
        SCREEN-INVISIBLE = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.
* Validate Inputs
AT SELECTION-SCREEN.
  IF UZEIT-LOW IS INITIAL AND UZEIT-HIGH IS INITIAL.
    MOVE '240000' TO UZEIT-HIGH.
  ENDIF.
  IF NOT ( OUTSTD IS INITIAL ).
    MESSAGE W032.
  ENDIF.
* Get Materials
* The folllowing code has all changed again to allow multiple selection
* criteria instead of using the OR. First step is to populate mats
* table with all records matching one of the criteria. Then go through
* and delete those not matching the other criteria.
  REFRESH MATS.
  CLEAR MATS.
  COUNT = 0.
  IF NOT ( MATNR IS INITIAL ).
    MOVE MATNR TO MATS-MATNR.
    APPEND MATS.
    COUNT = 1.
  ELSE.
* Material group
    IF NOT ( MATKL-LOW IS INITIAL ).
      SELECT MATNR MTART MATKL DISPO EKGRP
      APPENDING CORRESPONDING FIELDS OF TABLE MATS
      FROM MCON
      WHERE MATKL IN MATKL
      AND WERKS = WERKS.
      IF SY-SUBRC EQ 0.
        COUNT = 2.
      ENDIF.
    ENDIF.
* Material type
    IF NOT ( MTART-LOW IS INITIAL ).
      SELECT MATNR MTART MATKL DISPO EKGRP
      INTO CORRESPONDING FIELDS OF MATS
      FROM MCON
      WHERE MTART IN MTART
      AND WERKS = WERKS.
        READ TABLE MATS WITH KEY MATNR = MATS-MATNR.
        IF SY-SUBRC NE 0.
          APPEND MATS.
          COUNT = 2.
        ENDIF.
      ENDSELECT.
    ENDIF.
* MRP controller
    IF NOT ( DISPO-LOW IS INITIAL ).
      SELECT MATNR MTART MATKL DISPO EKGRP
      INTO CORRESPONDING FIELDS OF MATS
      FROM MCON
      WHERE DISPO IN DISPO
      AND WERKS = WERKS.
        READ TABLE MATS WITH KEY MATNR = MATS-MATNR.
        IF SY-SUBRC NE 0.
          APPEND MATS.
          COUNT = 2.
        ENDIF.
      ENDSELECT.
    ENDIF.
* Purchasing group
    IF NOT ( EKGRP IS INITIAL ).
      SELECT MATNR MTART MATKL DISPO EKGRP
      INTO CORRESPONDING FIELDS OF MATS
      FROM MCON
      WHERE EKGRP = EKGRP
      AND WERKS = WERKS.
        READ TABLE MATS WITH KEY MATNR = MATS-MATNR.
        IF SY-SUBRC NE 0.
          APPEND MATS.
          COUNT = 2.
        ENDIF.
      ENDSELECT.
    ENDIF.
  ENDIF.
* Delete those records which don't meet all of the selection criteria
  IF COUNT = 2.
    IF NOT ( MATKL-LOW IS INITIAL ).                        "03/99
      DELETE MATS WHERE NOT ( MATKL IN MATKL ).             "03/99
    ENDIF.
    IF NOT ( MTART-LOW IS INITIAL ).
      DELETE MATS WHERE NOT ( MTART IN MTART ).
    ENDIF.
    IF NOT ( DISPO-LOW IS INITIAL ).
      DELETE MATS WHERE NOT ( DISPO IN DISPO ).
    ENDIF.
    IF NOT ( EKGRP IS INITIAL ).
      DELETE MATS WHERE NOT ( EKGRP = EKGRP ).
    ENDIF.
  ENDIF.
* Only do the following processing is we have populated mats table
  IF COUNT NE 0.
    SORT MATS BY MATNR.
    DESCRIBE TABLE MATS LINES LINES.
    IF LINES LT 1.
      MESSAGE S022.
* if sy-calld is initial.
* case sy-tcode.
* when 'ZC61'.
* leave to transaction sy-tcode.
* when others.
* leave list-processing.
* endcase.
* else.
* leave list-processing.
* endif.
    ENDIF.
  ENDIF.
* Main Select Processing.
START-OF-SELECTION.
* Set Gui
  SET PF-STATUS 'STD'.
  IF OUTSTD IS INITIAL.
    IF NOT ( FIXKZ IS INITIAL ).
      SET TITLEBAR '001'.
    ELSE.
      SET TITLEBAR '002'.
    ENDIF.
  ELSE.
    IF NOT ( FIXKZ IS INITIAL ).
      SET TITLEBAR '003'.
    ELSE.
      SET TITLEBAR '004'.
    ENDIF.
  ENDIF.
  FLAGS = 'N'.
* Get Data
  CLEAR EXTRACT.
  REFRESH EXTRACT.
  IF NOT ( FIXKZ IS INITIAL ).
    FLAGS = 'F'. " indicate fixed selected
    LOWDATE = WDATE-LOW.
    HIDATE = WDATE-HIGH.
    PERFORM EXTRACT_FIXED.                                  "03/99
* now we need to select the outstanding deliveries for the last two
* weeks.
    CLEAR EXTRACT.
    FLAGS = 'O'. " indicate doing outstanding orders
    HIDATE = WDATE-LOW - 1.
    LOWDATE = WDATE-LOW - 14.
    PERFORM EXTRACT_FIXED.                                  "03/99
  ENDIF.
* Now look for proposed deliveries
* Changed to look at eban table instead of eket table NS 05/97
  CLEAR EXTRACT.
  IF NOT ( PROPO IS INITIAL ).
    CLEAR LFA1.
* See if we use the delivery date or release date for requisition
* selection
    IF RDATE-LOW IS INITIAL.                                "03/99
      MOVE WDATE-LOW TO LOWDATE.
      MOVE WDATE-HIGH TO HIDATE.
    ELSE.
      MOVE RDATE-LOW TO LOWDATE.
      MOVE RDATE-HIGH TO HIDATE.
    ENDIF.
    FLAGS = 'P'.
    PERFORM EXTRACT_PROPOSED.                               "03/99
  ENDIF.
* Changed to look at eket table instead of mseg table NS 05/97
* Do extra bits if we want outstanding deliveries.
  CLEAR EXTRACT.
  IF NOT ( OUTSTD IS INITIAL ).
    FLAGS = 'O'. " indicate doing outstanding orders
    HIDATE = WDATE-HIGH.
    LOWDATE = WDATE-LOW.
    PERFORM EXTRACT_FIXED.                                  "03/99
  ENDIF.
END-OF-SELECTION.
* Check we found something.
  DESCRIBE TABLE EXTRACT LINES LINES.
  IF LINES LT 1.
    MESSAGE S022.
* if sy-calld is initial.
* case sy-tcode.
* when 'ZC56'.
* leave to transaction sy-tcode.
* when others.
* leave list-processing.
* endcase.
* else.
* leave list-processing.
* endif.
  ENDIF.
* Sort into Nice order
  SORT EXTRACT BY LIFNR MATNR EINDT UZEIT.
  PERFORM PRODUCE_REPORT.
* Top of Page
TOP-OF-PAGE DURING LINE-SELECTION.
  PERFORM TOP_OF_PAGE_HEADER.
TOP-OF-PAGE.
  PERFORM TOP_OF_PAGE_HEADER.
* Act on user commands.
AT LINE-SELECTION.
* Go to display the record selected
  GET CURSOR FIELD CUR_POS VALUE TMPVALUE.
  IF CUR_POS = 'EXTRACT-EBELN'.
* Check to see if the record is a PO or a requisition
    ILEN = STRLEN( TMPVALUE ).                              "03/99
    IF ILEN < 10.                                           "03/99
      CONCATENATE '0' TMPVALUE INTO TMPEBELN.               "03/99
    ELSE.                                                   "03/99
      MOVE TMPVALUE TO TMPEBELN.                            "03/99
    ENDIF.                                                  "03/99
    SELECT * FROM EKKO
    WHERE EBELN = TMPEBELN.
      EXIT.
    ENDSELECT.
    IF SY-SUBRC = 0.
* Purchase Order
      SET PARAMETER ID 'BES' FIELD TMPVALUE.
* ICE51 use new screen.
      SET PARAMETER ID 'BES' FIELD TMPEBELN.
      CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    ELSE.
      SELECT SINGLE RSNUM INTO (RKPF-RSNUM)
      FROM RKPF
      WHERE RSNUM = TMPEBELN.
      IF SY-SUBRC = 0.
* Reservation
        SET PARAMETER ID 'RES' FIELD TMPVALUE.
        CALL TRANSACTION 'MB23' AND SKIP FIRST SCREEN.
      ELSE.
* Requisition
        SET PARAMETER ID 'BAN' FIELD TMPVALUE.
* ICE51 use new screen.
        SET PARAMETER ID 'BAN' FIELD TMPEBELN.
        CALL TRANSACTION 'ME53N' AND SKIP FIRST SCREEN.
      ENDIF.
    ENDIF.
  ENDIF.
* Act on user commands.
AT USER-COMMAND.
  CASE SY-UCOMM.
    WHEN 'SRT1'.
      SORT EXTRACT BY MATNR EBELN EBELP EINDT UZEIT LIFNR.
      PERFORM PRODUCE_REPORT.
    WHEN 'SRT2'.
      SORT EXTRACT BY EBELN EBELP EINDT UZEIT LIFNR MATNR.
      PERFORM PRODUCE_REPORT.
    WHEN 'SRT3'.
      SORT EXTRACT BY EINDT UZEIT LIFNR MATNR EBELN EBELP.
      PERFORM PRODUCE_REPORT.
    WHEN 'SRT4'.
      SORT EXTRACT BY OUTST LIFNR MATNR EBELN EBELP EINDT.
      PERFORM PRODUCE_REPORT.
    WHEN 'SRT5'.
      SORT EXTRACT BY LIFNR MATNR EBELN EBELP EINDT UZEIT.
      PERFORM PRODUCE_REPORT.
    WHEN 'BCK'.
      IF SY-CALLD IS INITIAL.
* case sy-tcode.
* when 'ZC56'.
* leave to transaction sy-tcode.
* when others.
* leave list-processing.
* endcase.
      ELSE.
        LEAVE LIST-PROCESSING.
      ENDIF.
  ENDCASE.
*&---------------------------------------------------------------------*
*& Form PRODUCE_REPORT
*&---------------------------------------------------------------------*
FORM PRODUCE_REPORT.
* Screen or stright to the printer ?
  IF SY-BATCH = 'X'.
    NEW-PAGE PRINT ON NO DIALOG LINE-SIZE 80.
  ELSE.
    NEW-PAGE.
  ENDIF.
  FORMAT INTENSIFIED OFF.
  CLEAR LIF_CHG.
  CLEAR TMP_LIFNR.
* Now write the output
  I_LINENUM = 1.
  LOOP AT EXTRACT.
    IF OLDNO IS INITIAL. " if they want real material number
      MOVE EXTRACT-MATNR TO MATN.
    ELSE. " else they want the old material no.
      CLEAR MARA.
      SELECT SINGLE * FROM MARA
      WHERE MATNR = EXTRACT-MATNR.
      MOVE MARA-BISMT TO MATNO.
    ENDIF.
* Only want the last 4 of the item number 02/98
    MOVE EXTRACT-EBELP+1(4) TO ITEM.
    IF EXTRACT-LIFNR NE TMP_LIFNR.
      CASE I_LINENUM.
        WHEN 1.
* Write the vendor name on the first line
          WRITE: /1 SY-VLINE,
          2 EXTRACT-NAME1,
          23 SY-VLINE.
        WHEN 2.
* Write the previous vendor number on the next line
          WRITE: /1 SY-VLINE,
          2 TMP_LIFNR,
          23 SY-VLINE.
          WRITE: 43 SY-VLINE,
          64 SY-VLINE,
          68 SY-VLINE,
          84 SY-VLINE,
          89 SY-VLINE,
          91 SY-VLINE.
          WRITE: 109 SY-VLINE,
          112 SY-VLINE,
          123 SY-VLINE,
          132 SY-VLINE.
          WRITE: /1 SY-ULINE(132).
* Write new vendor name
          WRITE: /1 SY-VLINE,
          2 EXTRACT-NAME1,
          23 SY-VLINE.
* Reset the line counter
          I_LINENUM = 1.
        WHEN OTHERS.
* Underline previous line
          WRITE: /1 SY-ULINE(132).
* Write new vendor name
          WRITE: /1 SY-VLINE,
          2 EXTRACT-NAME1,
          23 SY-VLINE.
* Reset the line counter
          I_LINENUM = 1.
      ENDCASE.
    ELSE.
* Have to cope with requisitions that don't have a vendor
      IF I_LINENUM = 2 AND TMP_LIFNR NE SPACE.
* Write the vendor number on the second line
        WRITE: /1 SY-VLINE,
        2 EXTRACT-LIFNR,
        23 SY-VLINE.
      ELSEIF I_LINENUM = 3 AND TMP_LIFNR NE SPACE.
* Underline vendor number
        WRITE: /1 SY-ULINE(23),
        23 SY-VLINE.
      ELSE.
        WRITE: /23 SY-VLINE.
      ENDIF.
    ENDIF.
    I_LINENUM = I_LINENUM + 1.
    IF OLDNO IS INITIAL.
      WRITE 24 MATN.
    ELSE.
      WRITE 24 MATNO.
    ENDIF.
    WRITE: 43 SY-VLINE,
    44 EXTRACT-MAKTX,
    64 SY-VLINE,
    65 EXTRACT-MEINS,
    68 SY-VLINE,
    69 EXTRACT-EBELN HOTSPOT ON,
    80 ITEM,
    84 SY-VLINE,
    85 EXTRACT-RECTYPE,
    89 SY-VLINE,
    90 EXTRACT-DELVD,
    91 SY-VLINE,
    92 EXTRACT-OUTST.                                       "02/98
    WRITE: 109 SY-VLINE,
    111 EXTRACT-QISTK,
    112 SY-VLINE,
    113 EXTRACT-EINDT,
    123 SY-VLINE,
    124 EXTRACT-UZEIT,
    132 SY-VLINE.
    MOVE EXTRACT-LIFNR TO TMP_LIFNR.
  ENDLOOP.
* Catch the last line
  CASE I_LINENUM.
    WHEN 2.
* Write the previous vendor number
      IF TMP_LIFNR NE SPACE.
        WRITE: /1 SY-VLINE,
        2 TMP_LIFNR,
        23 SY-VLINE.
        WRITE: 43 SY-VLINE,
        64 SY-VLINE,
        68 SY-VLINE,
        84 SY-VLINE,
        89 SY-VLINE,
        91 SY-VLINE.
        WRITE: 109 SY-VLINE,
        112 SY-VLINE,
        123 SY-VLINE,
        132 SY-VLINE.
        WRITE: /1 SY-ULINE(132).
      ELSE.
        WRITE: /23 SY-ULINE(110).
      ENDIF.
    WHEN 3.
      IF TMP_LIFNR NE SPACE.
        WRITE: /1 SY-ULINE(132).
      ELSE.
        WRITE: /23 SY-ULINE(110).
      ENDIF.
    WHEN OTHERS.
      WRITE: /23 SY-ULINE(110).
  ENDCASE.
  INCLUDE ZSI0010.
ENDFORM.                    "produce_report
*&---------------------------------------------------------------------*
*& Form GET_DAY
*&---------------------------------------------------------------------*
FORM GET_DAY USING TMPDATE DAYTXT.
* call function 'Z_S_CALCULATE_DAY'
* exporting
* date = tmpdate
* importing
* day = daytxt.
ENDFORM. " GET_DAY
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE_HEADER
*&---------------------------------------------------------------------*
FORM TOP_OF_PAGE_HEADER.
  WRITE: /1 SY-DATUM.
* IF OUTSTD IS INITIAL.
  CASE FLAGS.
    WHEN 'F'.
      WRITE: 58 'Expected Deliveries'.
    WHEN 'P'.
      WRITE: 58 'Proposed Deliveries'.
    WHEN 'O'.
      WRITE: 57 'Outstanding Deliveries'.
    WHEN OTHERS.
      WRITE: 58 'Expected Deliveries'.
  ENDCASE.
  WRITE: 128 SY-PAGNO USING EDIT MASK 'RR____' NO-ZERO.
  ULINE.
  IF FLAGS = 'O'.
    WRITE: /1 '(ZC56) Outstanding Deliveries Report'.
  ELSE.
    WRITE: /1 '(ZC56) Expected Deliveries Report'.
  ENDIF.
  WRITE: /1 'Type: F - Fixed Delivery, ',
  27 '?/C - Indicates Completed Delivery, ',
  63 'P - Proposed Delivery, ',
  86 'O - Outstanding Delivery, R - VMI Reservation'.
  SKIP.
  FORMAT INTENSIFIED ON.
  WRITE: /1 SY-ULINE(132).
  WRITE: /1 SY-VLINE,
  'Vendor',
  23 SY-VLINE,
  'Material',
  43 SY-VLINE,
  'Description',
  64 SY-VLINE,
  65 'UoM',
  68 SY-VLINE,
  69 'Purch. Document',
  84 SY-VLINE,
  85 'Type',
  89 SY-VLINE,
  90 'D',
  91 SY-VLINE,
  93 'Outstanding Qty',
  109 SY-VLINE,
  110 'QI',
  112 SY-VLINE.
  WRITE: 115 'Date',
  123 SY-VLINE,
  126 'Time',
  132 SY-VLINE.
  WRITE: /1 SY-ULINE(132).
ENDFORM. " TOP_OF_PAGE_HEADER
*&---------------------------------------------------------------------*
*& Form EXTRACT_FIXED
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EXTRACT_FIXED.
* This form selects the fixed and outstanding deliveries
  DATA: TMPFLAG(3) TYPE C.
* Select the schedule line info to find fixed/outstanding deliveries
  PERFORM GET_FIXED_OUSTANDING_DEL.
* Select VMI reservations
  PERFORM GET_VMI_RESERVATIONS.
ENDFORM. " EXTRACT_FIXED
*&---------------------------------------------------------------------*
*& Form EXTRACT_PROPOSED
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EXTRACT_PROPOSED.
* This form extracts the proposed deliveries / purchase requisitions
  DATA: LT_EBAN LIKE EBAN OCCURS 100 WITH HEADER LINE.
  SELECT * FROM EBAN
  INTO TABLE LT_EBAN
  WHERE WERKS = WERKS
  AND STATU = 'N'.
  LOOP AT LT_EBAN.
* ICE53 Tivoli 65499
    CLEAR EXTRACT.
* Check either the delivery date or the release date depending which
* has been entered
    IF RDATE-LOW IS INITIAL.                                "03/99
      CHECK LT_EBAN-LFDAT >= LOWDATE AND LT_EBAN-LFDAT <= HIDATE.
    ELSE.
      CHECK LT_EBAN-FRGDT >= LOWDATE AND LT_EBAN-FRGDT <= HIDATE.
    ENDIF.
* Make sure it hasn't been deleted
    CHECK LT_EBAN-LOEKZ IS INITIAL.
* Check to see if it is for same storage locn as one entered
    IF NOT ( LGORT IS INITIAL ).
      CHECK LT_EBAN-LGORT EQ LGORT.
    ENDIF.
    IF LT_EBAN-MENGE GT 0.
      NOMAT = 'N'.
      IF COUNT GT 0.
        LOOP AT MATS
        WHERE MATNR = LT_EBAN-MATNR.
        ENDLOOP.
        IF SY-SUBRC NE 0.
          NOMAT = 'Y'. " doesn't match the selections
        ENDIF.
      ENDIF.
      CLEAR LFA1.
      SELECT SINGLE LIFNR NAME1
      INTO (EXTRACT-LIFNR, EXTRACT-NAME1)
      FROM LFA1
      WHERE LIFNR = LT_EBAN-FLIEF.
      IF NOT ( LIFNR IS INITIAL )
      AND EXTRACT-LIFNR NE LIFNR.
        NOMAT = 'Y'.
      ENDIF.
      IF NOMAT = 'N'. "process this material.
        SELECT SINGLE MAKTX
        INTO (EXTRACT-MAKTX)
        FROM MAKT
        WHERE SPRAS = SY-LANGU
* ICE52 variable correction
        AND MATNR = LT_EBAN-MATNR.
        CONDENSE EXTRACT-MAKTX.
        SELECT SINGLE INSMK
        INTO MARC-INSMK
        FROM MARC
* ICE52 variable correction
        WHERE MATNR = LT_EBAN-MATNR
        AND WERKS = WERKS.
        IF MARC-INSMK IS INITIAL.
          EXTRACT-QISTK = ' '.
        ELSE.
          EXTRACT-QISTK = 'Y'.
        ENDIF.
* ICE52 variable correction (lt_eban instead of eban)
        EXTRACT-EINDT = LT_EBAN-LFDAT.
        EXTRACT-LGORT = LT_EBAN-LGORT.
        EXTRACT-EBELN = LT_EBAN-BANFN.
        EXTRACT-EBELP = LT_EBAN-BNFPO.
        EXTRACT-OUTST = LT_EBAN-MENGE.
        EXTRACT-MEINS = LT_EBAN-MEINS.
        EXTRACT-MATNR = LT_EBAN-MATNR.
        EXTRACT-RECTYPE = FLAGS.
        EXTRACT-DELVD = SPACE.
        APPEND EXTRACT.
      ENDIF. " NOMAT = 'N'
    ENDIF.
  ENDLOOP.
ENDFORM. " EXTRACT_PROPOSED
*&---------------------------------------------------------------------*
*& Form GET_FIXED_OUSTANDING_DEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_FIXED_OUSTANDING_DEL.
  DATA: LT_EKET LIKE EKET OCCURS 100 WITH HEADER LINE.
  DATA: LT_V_EKKO_EKPO LIKE V_EKKO_EKPO OCCURS 100 WITH HEADER LINE.
  DATA: TMPFLAG(3) TYPE C.
  SELECT EBELN EBELP MENGE WEMNG EINDT UZEIT
  INTO CORRESPONDING FIELDS OF TABLE LT_EKET
  FROM EKET
  WHERE ( ( EINDT = LOWDATE AND UZEIT >= UZEIT-LOW )
  OR ( EINDT > LOWDATE ) )
  AND ( ( EINDT = HIDATE AND UZEIT <= UZEIT-HIGH )
  OR ( EINDT < HIDATE ) )
  AND FIXKZ = 'X'.
  LOOP AT LT_EKET.
* Check to see if the delivery is outstanding.
    IF FLAGS = 'O'.
      CHECK LT_EKET-MENGE > LT_EKET-WEMNG.
    ENDIF.
* Now get the order item info
    SELECT * FROM V_EKKO_EKPO
    INTO TABLE LT_V_EKKO_EKPO
    WHERE EBELN = LT_EKET-EBELN
    AND EBELP = LT_EKET-EBELP
    AND WERKS = WERKS
    AND BSART <> 'NBVM'
    AND LOEKZ <> 'L'.
    LOOP AT LT_V_EKKO_EKPO.
      TMPFLAG = FLAGS.
* See if delivery is complete, but only if parameter not set
      IF DELCO IS INITIAL.
        CHECK LT_V_EKKO_EKPO-ELIKZ <> 'X'.
      ELSE.
        IF LT_V_EKKO_EKPO-ELIKZ = 'X'.
          CONCATENATE FLAGS '/C' INTO TMPFLAG.
        ENDIF.
      ENDIF.
      IF NOT ( LGORT IS INITIAL ).
        CHECK LT_V_EKKO_EKPO-LGORT EQ LGORT.
      ENDIF.
      IF LT_V_EKKO_EKPO-MENGE GT 0.
* if count gt 0.
* read table mats with key matnr = lt_v_ekko_ekpo-matnr.
* check sy-subrc eq 0.
* endif.
* Select header info
        SELECT SINGLE LIFNR NAME1
        INTO (EXTRACT-LIFNR, EXTRACT-NAME1)
        FROM LFA1
        WHERE LIFNR = LT_V_EKKO_EKPO-LIFNR.
        IF NOT ( LIFNR IS INITIAL ).
          CHECK EXTRACT-LIFNR EQ LIFNR.
        ENDIF.
* Use the Order item description instead of material description
        CONDENSE LT_V_EKKO_EKPO-TXZ01.
* Received into QI stock?
* if lt_v_ekko_ekpo-insmk is initial.
* extract-qistk = ' '.
* else.
* extract-qistk = 'Y'.
* endif.
* Has it been delivered ?
        IF LT_EKET-WEMNG NE 0.
          EXTRACT-DELVD = 'Y'.
          EXTRACT-OUTST = LT_EKET-MENGE - LT_EKET-WEMNG.    "02/98
        ELSE.
          EXTRACT-DELVD = ' '.
          EXTRACT-OUTST = LT_EKET-MENGE.                    "02/98
        ENDIF.
        CLEAR: EXTRACT-MAKTX.
* select single maktx into extract-maktx
* from makt
* where spras = sy-langu
* and matnr = lt_v_ekko_ekpo-matnr.
        EXTRACT-EINDT = LT_EKET-EINDT.
        EXTRACT-UZEIT = LT_EKET-UZEIT.
        EXTRACT-LGORT = LT_V_EKKO_EKPO-LGORT.
        EXTRACT-EBELN = LT_V_EKKO_EKPO-EBELN.
        EXTRACT-EBELP = LT_V_EKKO_EKPO-EBELP.
        EXTRACT-MEINS = LT_V_EKKO_EKPO-MEINS.
* extract-matnr = lt_v_ekko_ekpo-matnr.
        IF LT_V_EKKO_EKPO-TXZ01 <> SPACE.
          EXTRACT-MAKTX = LT_V_EKKO_EKPO-TXZ01.
        ENDIF.
        EXTRACT-RECTYPE = TMPFLAG.
        APPEND EXTRACT.
      ENDIF.
    ENDLOOP.
  ENDLOOP. "EKET
ENDFORM. " GET_FIXED_OUSTANDING_DEL
*&---------------------------------------------------------------------*
*& Form GET_VMI_RESERVATIONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_VMI_RESERVATIONS.
  DATA: LT_EXTRACT LIKE RESB OCCURS 1000 WITH HEADER LINE.
  SELECT A~BDTER A~LGORT A~SGTXT A~RSNUM A~RSPOS A~BDMNG
  A~ENMNG A~MEINS A~MATNR A~KZEAR
  APPENDING CORRESPONDING FIELDS OF TABLE LT_EXTRACT
  FROM RESB AS A INNER JOIN MARC AS B
  ON A~MATNR = B~MATNR AND
  A~WERKS = B~WERKS
  WHERE B~WERKS = WERKS
  AND ( B~SOBSL = CC_MAT_STD OR B~SOBSL = CC_MAT_CONS )
  AND A~BDART = 'MR'
  AND A~XLOEK = SPACE
  AND A~BDTER BETWEEN LOWDATE AND HIDATE
  AND A~LGORT LIKE 'V%'
  AND B~DISPO IN DISPO "PH 12/02 restrict to MRP cont.
  ORDER BY A~MATNR.
  LOOP AT LT_EXTRACT.
    CLEAR: EXTRACT.
    IF DELCO = SPACE.
      CHECK LT_EXTRACT-KZEAR = SPACE.
    ENDIF.
    EXTRACT-EINDT = LT_EXTRACT-BDTER.
    CLEAR: EXTRACT-UZEIT.
    EXTRACT-LGORT = LT_EXTRACT-LGORT.
    IF LT_EXTRACT-SGTXT <> SPACE.
      PERFORM PARSE_VENDOR
      USING LT_EXTRACT-SGTXT EXTRACT-LIFNR EXTRACT-NAME1.
    ENDIF.
    EXTRACT-EBELN = LT_EXTRACT-RSNUM.
    EXTRACT-EBELP = LT_EXTRACT-RSPOS.
    EXTRACT-RECTYPE = 'R'.
    EXTRACT-OUTST = LT_EXTRACT-BDMNG - LT_EXTRACT-ENMNG.
    EXTRACT-MEINS = LT_EXTRACT-MEINS.
    EXTRACT-MATNR = LT_EXTRACT-MATNR.
    SELECT SINGLE MAKTX INTO EXTRACT-MAKTX
    FROM MAKT
    WHERE SPRAS = SY-LANGU
    AND MATNR = LT_EXTRACT-MATNR.
    IF LT_EXTRACT-ENMNG <> 0.
      EXTRACT-DELVD = 'Y'.
    ELSE.
      CLEAR: EXTRACT-DELVD.
    ENDIF.
    EXTRACT-QISTK = SPACE.
    APPEND EXTRACT.
  ENDLOOP.
ENDFORM. " GET_VMI_RESERVATIONS
*&---------------------------------------------------------------------*
*& Form PARSE_VENDOR
*&---------------------------------------------------------------------*
* The web routine that creates reservations inserts the text
* Vendor=XXXX;Name=XXXXXXXX; into the SGTXT field of RESB. This
* routine extracts the vendor number and looks up LFA1 to obtain
* the name. The Name=XXXX text is not used as there is a
* possibility that the vendor name is truncated.
*----------------------------------------------------------------------*
* -->P_LT_EXTRACT_SGTXT text
* -->P_EXTRACT_LIFNR text
* -->P_EXTRACT_NAME1 text
*----------------------------------------------------------------------*
FORM PARSE_VENDOR USING P_SGTXT
P_EXTRACT_LIFNR
P_EXTRACT_NAME1.
  DATA: LS_TEMP TYPE STRING.
  DATA: LS_REST TYPE STRING.
  DATA: LC_LIFNR LIKE LFA1-LIFNR.
  CLEAR: P_EXTRACT_LIFNR, P_EXTRACT_NAME1.
  IF P_SGTXT CS 'Vendor='.
    SPLIT P_SGTXT AT 'Vendor=' INTO LS_REST LS_TEMP.
    SPLIT LS_TEMP AT ';' INTO LC_LIFNR LS_REST.
    SELECT SINGLE NAME1
    INTO P_EXTRACT_NAME1
    FROM LFA1
    WHERE LIFNR = LC_LIFNR.
    P_EXTRACT_LIFNR = LC_LIFNR.
  ENDIF.
ENDFORM. " PARSE_VENDOR
  • No labels