Application Development and Automation 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: 
Read only

reports

Former Member
0 Likes
873

hi

can anyone give me the solution for this logic

Get all entries from table EKKO where EKKO-BSTYP = ‘K’ and the other fields meet the selection critera entered.

The Validity Date entered must be >= EKKO-KDATB and <= EKKO-KDATE.

If Include Deleted Contracts ? = unset, only select entries where EKKO-LOEKZ = blank.

If any selection criteria (including Validity Date) is left blank, then the selection of EKKO entries should not be restricted by that selection criteria.

For each entry found on table EKKO, get the related Contract Items from table EKPO (i.e. where EKPO-EBELN = EKKO-EBELN).

If Include Deleted Contracts/Items ? = unset, only select entries where EKPO-LOEKZ = blank.

For each entry found on table EKPO, get the related PO Items from table EKPO (i.e. where EKPO-KONNR = EKPO-EBELN and EKPO-KTPNR = EKPO-EBELP and EKPO-LOEKZ = blank). Accumulate EKPO-NETWR to calculate the Actual Spend of a particular Contract Item.

If the currency of the PO is not the same as the currency of the Contract, then the value of EKPO-NETWR will need to be converted to the Contract currency before the accumulation takes place.

Note that all related POs are selected, irrespective of where they are in the purchasing cycle (e.g. just created, receipted but not invoiced etc).

2 REPLIES 2
Read only

Former Member
0 Likes
511

Hi,

This is a rough outline for the above requirement, modify it according to your needs.


REPORT zztest.

TABLES : ekko.

DATA : it_ekko TYPE STANDARD TABLE OF ekko WITH HEADER LINE.
DATA : it_ekpo TYPE STANDARD TABLE OF ekpo WITH HEADER LINE.
DATA : it_ekpo1 TYPE STANDARD TABLE OF ekpo WITH HEADER LINE.


SELECT-OPTIONS : s_kdatb FOR  ekko-kdatb NO-EXTENSION NO INTERVALS ,
                 s_kdate FOR  ekko-kdate NO-EXTENSION NO INTERVALS .

CONSTANTS : c_k(1) VALUE 'K'.


*Get all entries from table EKKO where EKKO-BSTYP = ‘K’ and date criteria

IF s_kdatb IS NOT INITIAL.
  s_kdatb-sign = 'GE'.
  APPEND s_kdatb.
ENDIF.

IF s_kdate IS NOT INITIAL.
  s_kdate-sign = 'LE'.
  APPEND s_kdate.
ENDIF.

SELECT * FROM ekko INTO TABLE it_ekko
   WHERE          bstyp EQ c_k
            AND   kdatb IN s_kdatb
            AND   kdatb IN s_kdate
            AND   loekz EQ space.


*For each entry found on table EKKO, get the related Contract Items from table EKPO

IF it_ekko[] IS NOT INITIAL.

  SELECT * FROM ekpo INTO TABLE it_ekpo
    FOR ALL ENTRIES IN it_ekko
     WHERE    ebeln  EQ it_ekko-ebeln
              AND   loekz EQ space.

ENDIF.



*For each entry found on table EKPO, get the related PO Items from table EKPO (i.e. where EKPO-KONNR = EKPO-EBELN and
*EKPO-KTPNR = EKPO-EBELP and EKPO-LOEKZ = blank).

IF it_ekpo[] IS NOT INITIAL.

  SELECT * FROM ekpo INTO TABLE it_ekpo1
    FOR ALL ENTRIES IN it_ekpo
     WHERE          konnr  EQ it_ekpo-ebeln
              AND   ktpnr EQ it_ekpo-ebelp
              AND   loekz EQ space.

ENDIF.


Then based on the entries in it_ekpo1 proceed further with your requirement.

Accumulate EKPO-NETWR to calculate the Actual Spend of a particular Contract Item.
If the currency of the PO is not the same as the currency of the Contract, then the value of EKPO-NETWR
will need to be converted to the Contract currency before the accumulation takes place.

Regards,

AS

Read only

Former Member
0 Likes
511

Varalakshmi,

Here is the logic :(please note that you might need to check the syntax)

SELECT AEBELN AEBELP ABSTYP AWAERS BKONNR BKTPNR

INTO ITAB

FROM EKKO AS A INNER JOIN EKPO AS B

ON AEBELN = BEBELN

WHERE A~BSTYP = 'K' AND

AKDATB <= P_DATE AND AKDATE >= P_DATE

AND ALOEKZ = SPACE AND BLOEKZ = SPACE.

SELECT AEBELN BEBELP AWAERS BNETWR INTO PTAB

FOR ALL ENTRIES IN ITAB

FROM EKKO AS A INNER JOIN EKPO AS B

ON AEBELN = BEBELN

WHERE A~EBELN = ITAB-KONNR

AND B~EBELP = ITAB-KTPNR

AND BLOEKZ = SPACE AND ALOEKZ = SPACE.

LOOP AT PTAB.

AT NEW EBELP.

CLEAR L_SUM.

ENDAT.

LOOP AT ITAB WHERE KONNR = PTAB-EBELN AND

KTPNR = PTAB-EBELP.

EXIT.

ENDLOOP.

IF PTAB-WAERS NE ITAB-WAERS.

CALL FUNCTION CONVERT_TO_FOREIGN_CURRENCY'

EXPORTING

FOREIGN_CURRENCY = PTAB-WAERS

LOCAL_AMOUNT = PTAB-NETWR

LOCAL_CURRENCY = ITAB-WAERS

IMPORTING

FOREIGN_AMOUNT = L_SUM1.

L_SUM = L_SUM + LSUM1.

ELSE.

L_SUM = L_SUM + PTAB-NETWR.

ENDIF.

AT END OF EBELP.

WRITE : / PTAB-EBELN, PTAB-EBELP, L_SUM.

ENDAT.

ENDLOOP.