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

when the key fields not matching

Former Member
0 Likes
1,062

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.

6 REPLIES 6
Read only

Former Member
0 Likes
994

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...

Read only

Former Member
0 Likes
994

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

Read only

Former Member
0 Likes
994

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

Read only

Former Member
0 Likes
994

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.

Read only

Former Member
0 Likes
994

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

Read only

Former Member
0 Likes
994

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.....