‎2008 Oct 24 3:27 PM
Hi.
what is to be done when the key fields of the tables are not matching and the other common fields between the tables are having different data elements.
i am not getting the entries from the ekpo table.
have alook
what to do.?
in this eban and ekpo,fields that are common is ebeln and ebelp but thier daat elements are diffrent.
SELECT BANFN
BNFPO
ERNAM
BADAT
AFNAM
TXZ01
MENGE
MEINS
PREIS
WAERS
PEINH
RLWRT
LFDAT
FRGDT
EBELN
EBELP
BEDAT
BSMNG
WERKS
FRGST
FROM EBAN
INTO CORRESPONDING FIELDS OF TABLE IT_EBAN
WHERE BANFN = IT_EBAN-BANFN
AND BNFPO = IT_EBAN-BNFPO
AND WERKS = IT_EBAN-WERKS
AND FRGST = IT_EBAN-FRGST.
WHERE BANFN IN S_REQNUM
AND BADAT IN S_REQCR
AND WERKS IN S_PLANT
AND FRGST IN S_RELSTR.
IF SY-SUBRC = 0.
SORT IT_EBAN BY BANFN BNFPO.
SELECT MEINS
NETPR
PEINH
NETWR
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE IT_EKPO
WHERE EBELN = it_ekpo-EBELN
AND EBELP =it_ekpo-EBELP.
IF SY-SUBRC = 0.
SORT IT_EKPO BY EBELN EBELP.
‎2008 Oct 24 3:35 PM
Don't worry about the data elements being different....
SELECT MEINS
NETPR
PEINH
NETWR
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE IT_EKPO
WHERE EBELN = it_ekpo-EBELN
AND EBELP =it_ekpo-EBELP.
That bit doesn't make sense since you are referring to it_ekpo even though you have no values in it. Sounds like you need to refer to the data from IT_EBAN...
‎2008 Oct 24 3:42 PM
Not able to understand what you are try to do in following select statment
SELECT MEINS
NETPR
PEINH
NETWR
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE IT_EKPO
WHERE EBELN = it_ekpo-EBELN
AND EBELP = it_ekpo-EBELP.
why you are using same table in INTO clause and where condition ?
if you want all entries from EKPO for EBELN , EBELP which you found in EBAN the try using FOR ALL ENTRIES addition in select statment.
SELECT meins
netpr
peinh
netwr
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekpo
"--> FOR ALL ENTRIES IN it_eban
WHERE ebeln = it_eban-ebeln
AND ebelp = it_eban-ebelp.
Edited by: mrugesh phatak on Oct 24, 2008 4:44 PM
‎2008 Oct 25 9:28 AM
Hi,
try this code....
SELECT BANFN
BNFPO
ERNAM
BADAT
AFNAM
TXZ01
MENGE
MEINS
PREIS
WAERS
PEINH
RLWRT
LFDAT
FRGDT
EBELN
EBELP
BEDAT
BSMNG
WERKS
FRGST
FROM EBAN
INTO CORRESPONDING FIELDS OF TABLE IT_EBAN
WHERE BANFN IN S_REQNUM
AND BADAT IN S_REQCR
AND WERKS IN S_PLANT
AND FRGST IN S_RELSTR.
IF SY-SUBRC = 0.
SORT IT_EBAN BY BANFN BNFPO.
SELECT meins
netpr
peinh
netwr
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekpo
FOR ALL ENTRIES IN it_eban
WHERE ebeln = it_eban-ebeln
AND ebelp = it_eban-ebelp.
endif.
Arunima
‎2008 Oct 25 1:44 PM
Hi,
don't use into corresponding fields as it degrades the pperformance related to output time.instead use for all entries:
do like this:
SELECT BANFN
BNFPO
ERNAM
BADAT
AFNAM
TXZ01
MENGE
MEINS
PREIS
WAERS
PEINH
RLWRT
LFDAT
FRGDT
EBELN
EBELP
BEDAT
BSMNG
WERKS
FRGST
FROM EBAN
INTO TABLE IT_EBAN
WHERE BANFN IN S_REQNUM
AND BADAT IN S_REQCR
AND WERKS IN S_PLANT
AND FRGST IN S_RELSTR.
IF SY-SUBRC = 0.
SORT IT_EBAN BY BANFN BNFPO.
SELECT meins
netpr
peinh
netwr
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_eban
WHERE ebeln = it_eban-ebeln
AND ebelp = it_eban-ebelp.
endif.
‎2008 Oct 25 3:59 PM
Hi Tanisha,
If the data element is different then I would sugeest you to do some change in the ineternal table data element other wise it will give you a short dump.
Thanks,
Chidanand
‎2008 Oct 25 4:10 PM
Hi,
Data Element needs to be same in case of FK & PK......Select Statement don't require same Data Element, only domain needs to be similar.
Your Second SELECT statement is incorrect...Looks you wanted to use FOR ALL ENTRIES on IT_EBAN but there is a mispell.....