SAP Help Information and source code of example selection from COVP table









SELECT from COVP table

*Code to demonstrate COVP Select

*  The FOR ALL ENTRIES comand only retrieves data which matches
*  entries within a particular internal table.
** posid = wbs element name (i.e. DV.INSS.380950)
** pspnr = wbs element code (deduced using conversion routine)
  SELECT ekko~ebeln
         ekpo~ebelp
         ekko~lifnr
         ekko~bedat
         lfa1~name1
         ekpo~bednr
         covp~objnr
         covp~wtgbtr
*         cooi~wtgbtr
         ekpo~menge
         ekpo~netpr
         ekpo~mwskz
         ekpo~elikz
         ekkn~sakto
         ekkn~ps_psp_pnr
         prps~psphi
         prps~posid
         covp~matnr
***Added for call transaction
         covp~kokrs
         covp~vrgng
         covp~orgvg
         covp~varnr
         covp~belnr
         covp~buzei
         covp~refbt
         covp~refbn
         covp~refbk
         covp~refgj
         covp~awtyp
         covp~aworg
         ekpo~matkl
         covp~beknz
         prps~pspnr
    INTO TABLE it_reptab2
    FROM covp AS covp INNER JOIN prps AS prps
      ON prps~objnr EQ covp~objnr
         INNER JOIN ekko AS ekko
      ON ekko~ebeln = covp~ebeln
         INNER JOIN lfa1 AS lfa1
      ON lfa1~lifnr = ekko~lifnr
         INNER JOIN ekpo AS ekpo
      ON ekpo~ebeln = covp~ebeln AND
         ekpo~ebelp = covp~ebelp
         INNER JOIN ekkn AS ekkn
      ON ekkn~ebeln = covp~ebeln AND
         ekkn~ebelp = covp~ebelp
   WHERE prps~posid IN p_wbs  AND
         covp~kokrs       EQ '****' AND
         covp~lednr       EQ '00'   AND
*         ekkn~ps_psp_pnr  EQ prps~pspnr AND
         prps~pspnr      EQ prps~pspnr AND
         ekkn~sakto      IN p_sakto AND
         ekpo~matkl      IN p_matkl AND
         ekko~lifnr      IN p_lifnr AND
         ekko~bedat      IN p_bedat.