‎2006 Dec 26 6:25 AM
hi
i require wbs element or cost center from ekkn table
i m using below query to fetch but problem is cming is that
suppose wbs element or cost cente is for item no 20 than also its coming for item no 10.
its not coming item wise so please check below query and sugges me how can i do it.
SELECT AEBELN ALIFNR AKNUMV BVGABE BGJAHR BBELNR
FROM EKKO AS A
INNER JOIN EKBE AS B ON BEBELN = AEBELN
INTO CORRESPONDING
FIELDS OF TABLE ITAB WHERE B~VGABE = '2'.
SELECT EKPOEBELN EKPOEBELP EKPOMATNR EKPOTXZ01 EKPO~WERKS
EKPONETWR EKPOMENGE EKPO~MWSKZ
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE ITAB1
FOR ALL ENTRIES IN ITAB
WHERE EKPO~EBELN = ITAB-EBELN.
SELECT EKKNEBELN EKKNEBELP EKKNKOSTL EKKNPS_PSP_PNR
FROM EKKN
INTO CORRESPONDING FIELDS OF TABLE ITAB2
FOR ALL ENTRIES IN ITAB1
WHERE EKKN~EBELN = ITAB1-EBELN AND
EKKN~EBELP = ITAB1-EBELP.
LOOP AT ITAB.
READ TABLE ITAB1 WITH KEY EBELN = ITAB-EBELN.
IF ITAB1-EBELN = ITAB-EBELN.
IF sy-subrc eq 0.
ITAB1-LIFNR = ITAB-LIFNR.
ITAB1-BELNR = ITAB-BELNR.
modify itab1 index sy-tabix.
ENDIF.
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN.
IF sy-subrc eq 0.
ITAB1-EBELN = ITAB2-EBELN.
ITAB1-PS_PSP_PNR = ITAB2-PS_PSP_PNR.
ITAB1-KOSTL = ITAB2-KOSTL.
modify itab1 index sy-tabix.
ENDIF.
ENDLOOP.
thanks in advanced.
‎2006 Dec 26 7:26 AM
Sorry i forgot to see that .Eswar i got u . Im not logged on to sap as such couldn't make out your point . Just got confused what he was trying to modify itab1 or itab2.
Thanks for the check.
laxman i hope u r trying to modify the itab 2 value and bring the changes(final) to itab2 .
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN
AND EBELP = ITAB2-EBELP. "this one
IF sy-subrc eq 0.
ITAB2-PS_PSP_PNR = ITAB1-PS_PSP_PNR.
ITAB2-KOSTL = ITAB1-KOSTL.
modify itab2 index sy-tabix . or
*modify itab2 transporting ps_psp_pnr kostl where ebeln = itab2-ebeln and ebelp = itab2-ebelp.
*or modify itab2.
ENDIF.
ENDLOOP.you can use the additional options as well
regards,
vijay
‎2006 Dec 26 6:34 AM
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN
and ebelp = itab2-ebelp.
ITAB1-EBELN = ITAB2-EBELN.
itab1-ebelp = itab2-ebelp. "also check this
" add thisJust add the condtions for line item as well .
regards,
vijay
‎2006 Dec 26 6:47 AM
HI VIJAY,
HERE ONE PROBLEM IS COMING THAT
U GIVEN SECOND CONDITION
EBELP = ITAB2-EBELP IS NOT EXPECTED IS ERROR IS COMING
SUGGEST ME WHICH TABLE EBELP I HAS TO CHECK WITH ITAB2-EBELP.
I USED THIS BELOW INTERNAL TABLE
DATA: BEGIN OF ITAB1 OCCURS 10,
EBELN LIKE EKPO-EBELN,
LIFNR LIKE EKKO-LIFNR,
EBELP LIKE EKPO-EBELP,
KNUMH LIKE KONH-KNUMH,
BELNR LIKE EKBE-BELNR,
MATNR LIKE EKPO-MATNR,
TXZ01 LIKE EKPO-TXZ01,
PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
ED1(15) TYPE N,
KOSTL LIKE EKKN-KOSTL,
WERKS LIKE EKPO-WERKS,
NETWR LIKE EKPO-NETWR,
MENGE LIKE EKPO-MENGE,
MWSKZ LIKE EKPO-MWSKZ,
KBETR LIKE KONV-KBETR,
KBETR1 LIKE KONV-KBETR,
KBETR2 LIKE KONV-KBETR,
KNUMV LIKE KONV-KNUMV,
KSCHL LIKE KONV-KSCHL,
KSCHL LIKE KONH-KSCHL,
END OF ITAB1.
DATA: BEGIN OF ITAB2 OCCURS 10,
EBELN LIKE EKKN-EBELN,
EBELP LIKE EKKN-EBELP,
PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
KOSTL LIKE EKKN-KOSTL,
END OF ITAB2.
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN AND
ITAB1-EBELP = ITAB2-EBELP.
IF sy-subrc eq 0.
ITAB1-EBELN = ITAB2-EBELN.
itab1-ebelp = itab2-ebelp.
ITAB1-PS_PSP_PNR = ITAB2-PS_PSP_PNR.
ITAB1-KOSTL = ITAB2-KOSTL.
modify itab1 index sy-tabix.
ENDIF.
ENDLOOP.
THANKS TO REPLAY.
‎2006 Dec 26 6:53 AM
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN
AND EBELP = ITAB2-EBELP. "this one
IF sy-subrc eq 0.
ITAB1-EBELN = ITAB2-EBELN.
itab1-ebelp = itab2-ebelp.
ITAB1-PS_PSP_PNR = ITAB2-PS_PSP_PNR.
ITAB1-KOSTL = ITAB2-KOSTL.
modify itab1 index sy-tabix.
ENDIF.
ENDLOOP.dont write as
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN
AND itab1-EBELP = ITAB2-EBELP. "wrong ok.
‎2006 Dec 26 6:59 AM
hi same problem not able to identify
ebelp.
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN
AND EBELP = ITAB2-EBELP.
‎2006 Dec 26 7:02 AM
Hi Laxman
Have you tried by executing the piece of code i have provided???
Kind Regards
Eswar
‎2006 Dec 26 7:03 AM
DATA: BEGIN OF ITAB1 OCCURS 10,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP, " THIS IS MISSING ....
LIFNR LIKE EKKO-LIFNR,
KNUMH LIKE KONH-KNUMH,
BELNR LIKE EKBE-BELNR,
MATNR LIKE EKPO-MATNR,
TXZ01 LIKE EKPO-TXZ01,
PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
ED1(15) TYPE N,check the entries in ur itab1 in debugging.
when u r fetching the entries in second select it has to be there right ?
regards,
vijay
regards,
vijay
‎2006 Dec 26 7:05 AM
Vijay
Sorry for misleading you, infact the 3rd field in the internal table is EBELP. Sorry about that.
Though i guess this might lead to wrong data:
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN
AND EBELP = ITAB2-EBELP. "this one
IF sy-subrc eq 0.
ITAB1-EBELN = ITAB2-EBELN.
itab1-ebelp = itab2-ebelp.
ITAB1-PS_PSP_PNR = ITAB2-PS_PSP_PNR.
ITAB1-KOSTL = ITAB2-KOSTL.<b>modify itab1 index sy-tabix.</b>
ENDIF.
ENDLOOP.Kind Regards
Eswar
‎2006 Dec 26 7:09 AM
‎2006 Dec 26 7:09 AM
Yeah noticed that .Thank you Eswar.
But he is using
INTO CORRESPONDING FIELDS OF TABLE ITAB1
Im wondering how it is not fetching the data into itab1.
Laxman .
Just check the entries in the internal table itab1 .
i think some debugging will solve ur probelm .
regards,
vijay
‎2006 Dec 26 7:10 AM
Hi Laxman
Take the sample code i have provided in my first post, copy to a temporary program, execute and check the entries in table <b>IT_PUR</b> if that is what your are expecting...
Regards
Eswar
‎2006 Dec 26 6:40 AM
Hi Laxman
The problem is with your second loop considering only the PO number and not the item number.
Please try with below code:
types: begin of t_pur,
ebeln type ebeln,
ebelp type ebelp,
lifnr type lifnr,
knumv type knumv,
matnr type matnr,
txz01 type txz01,
werks type werks_d,
netwr type netwr,
menge type menge_d,
mwskz type mwskz,
vgabe type vgabe,
gjahr type gjahr,
belnr type mblnr,
kostl type kostl,
ps_psp_pnr type ps_psp_pnr,
end of t_pur.
data: it_pur type table of t_pur,
wa_pur type t_pur.
select a~ebeln b~ebelp a~lifnr a~knumv b~matnr
b~txz01 b~werks b~netwr b~menge b~mwskz
c~vgabe c~gjahr c~belnr d~kostl d~ps_psp_pnr
into table it_pur
from ekko as a
inner join ekpo as b
on a~ebeln = b~ebeln
inner join ekbe as c
on a~ebeln = c~ebeln
and b~ebelp = c~ebelp
inner join ekkn as d
on a~ebeln = d~ebeln
and b~ebelp = d~ebelp
where c~vgabe = '2'.Kind Regards
Eswar
‎2006 Dec 26 7:26 AM
Sorry i forgot to see that .Eswar i got u . Im not logged on to sap as such couldn't make out your point . Just got confused what he was trying to modify itab1 or itab2.
Thanks for the check.
laxman i hope u r trying to modify the itab 2 value and bring the changes(final) to itab2 .
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY EBELN = ITAB2-EBELN
AND EBELP = ITAB2-EBELP. "this one
IF sy-subrc eq 0.
ITAB2-PS_PSP_PNR = ITAB1-PS_PSP_PNR.
ITAB2-KOSTL = ITAB1-KOSTL.
modify itab2 index sy-tabix . or
*modify itab2 transporting ps_psp_pnr kostl where ebeln = itab2-ebeln and ebelp = itab2-ebelp.
*or modify itab2.
ENDIF.
ENDLOOP.you can use the additional options as well
regards,
vijay