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

Following code is simple to get the complex services functionality involved in Service Master when you have Purchase Order and its line item:
 
This code not only brings the Services under PO but also from Contracts.
 

Error rendering macro 'code': Invalid value specified for parameter 'lang'
DATA: BEGIN OF I_ESLL OCCURS 0,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
SRVPOS LIKE ESLL-SRVPOS,
MENGE LIKE ESLL-MENGE,
MEINS LIKE ESLL-MEINS,
PEINH LIKE ESLL-PEINH,
BRTWR LIKE ESLL-BRTWR,
OLD_MEINS LIKE ESLL-MEINS,
END OF I_ESLL.
DATA: L_PACKNO LIKE EKPO-PACKNO,BEGIN OF IT_ESUC_ESLL OCCURS 0,
SUB_PACKNO LIKE ESLL-SUB_PACKNO,
PACKAGE LIKE ESLL-PACKAGE,
END OF IT_ESUC_ESLL,
IT_PACK LIKE IT_ESUC_ESLL OCCURS 0 WITH HEADER LINE.
CLEAR: L_PACKNO, I_ESLL, I_ESLL[], IT_ESUC_ESLL,
IT_ESUC_ESLL[].
GET THE PACKAGE NO.
  FROM EKPO
SELECT SINGLE PACKNO FROM EKPO
INTO L_PACKNO
WHERE EBELN = I_EBELN
AND EBELP = I_EBELP
AND LOEKZ = ' '.
  IF NOT L_PACKNO IS INITIAL.
    FOR THE PACKAGE #, CHECK WHETHER SUB PACKAGES ARE FOR CONTRACT ITEMS?
   SELECT SUB_PACKNO FROM ESUC
   INTO TABLE IT_ESUC_ESLL
   WHERE PACKNO = L_PACKNO
   AND DEL = SPACE.
      IF SY-SUBRC <> 0.
        FOR THE PACKAGE #,IF SUB PACKAGES ARE IN NOT CONTRACT ITEMS,GO TO ESLL
       SELECT SUB_PACKNO PACKAGE FROM ESLL
       INTO TABLE IT_ESUC_ESLL
       WHERE PACKNO = L_PACKNO
       AND DEL = SPACE.
        ENDIF.
      ENDIF.
GET THE SUBPACKAGES WHICH ARE ONE LEVEL ABOVE SERVICE ITEMS
CLEAR: IT_PACK, IT_PACK[].
  LOOP AT IT_ESUC_ESLL.
    IF NOT IT_ESUC_ESLL-SUB_PACKNO IS INITIAL
    AND IT_ESUC_ESLL-PACKAGE = 'X'.
      MOVE IT_ESUC_ESLL TO IT_PACK.
      APPEND IT_PACK.
      CLEAR IT_PACK.
      DELETE IT_ESUC_ESLL.
    ELSEIF NOT IT_ESUC_ESLL-SUB_PACKNO IS INITIAL
    AND IT_ESUC_ESLL-PACKAGE = ' '.
      THIS SELECT WILL DRILL DOWN AND GET ALL THE HIERARCHIAL SUBPACKAGES
     SELECT SUB_PACKNO PACKAGE FROM ESLL
     APPENDING TABLE IT_ESUC_ESLL
     WHERE PACKNO = IT_ESUC_ESLL-SUB_PACKNO
     AND DEL = SPACE.
    ENDIF.
  ENDLOOP.
GET THE SERVICE ITEMS FOR ALL THE SUBPACKAGES
LOOP AT IT_PACK.
  SELECT SRVPOS MENGE MEINS PEINH BRTWR
  FROM ESLL
  APPENDING CORRESPONDING FIELDS OF TABLE I_ESLL
  WHERE PACKNO = IT_PACK-SUB_PACKNO
  AND DEL = SPACE.
ENDLOOP.
IF SY-SUBRC <> 0.
  IF THERE ARE NO SUB PACKAGES, BUT DIRECT LINK TO SERVICES FROM PACKAGE
  GO TO ESLL WITH PACKAGE DERIVED FROM EKPO FOR THE PO ITEM
 SELECT SRVPOS MENGE MEINS PEINH BRTWR
 FROM ESLL
 INTO CORRESPONDING FIELDS OF TABLE I_ESLL
 WHERE PACKNO = L_PACKNO
 AND DEL = SPACE.
  ENDIF.
  • No labels

1 Comment

  1. this is redundant to your wiki in the code gallery: Getting Service numbers under Service Entry sheet using PO Line

    And it has numerous errors, because you missed to copy  the * in the beginning of comment lines