‎2013 Apr 03 12:04 PM
I have written this code and the results are correct. Can any one please suggest the code without the select statement. I appreciate it.
The reason is ....having a select statement in the loop will degrade the performance. I dont know how to exclude select's in the loop...in brief need to replace select's with internal table.
LOOP AT
c_t_data INTO l_MC02M_0ITM.
SELECT single * FROM EKPO
WHERE EBELN = l_MC02M_0ITM-EBELN
AND EBELP = l_MC02M_0ITM-EBELP.
if EKPO-BANFN is not INITIAL.
select single * from EBAN
where BANFN = ekpo-BANFN
AND BNFPO = ekpo-BNFPO.
IF sy-subrc = 0.
l_MC02M_0ITM-zzestkz = EBAN-ESTKZ.
endif.
MODIFY c_t_data FROM l_MC02M_0ITM.
endif.
ENDLOOP.
Thanks,
DR
‎2013 Apr 03 12:29 PM
Replace your code with below code- It will work.
_______________________________________________________________
DATA: it_ekpo TYPE STANDARD TABLE OF ekpo,
wa_ekpo LIKE LINE OF it_ekpo,
it_eban TYPE STANDARD TABLE OF eban,
wa_eban LIKE LINE OF it_eban.
SELECT * FROM ekpo INTO TABLE it_ekpo FOR ALL ENTRIES IN c_t_data
WHERE ebeln = c_t_data-ebeln
AND ebelp = c_t_data-ebelp.
SELECT * FROM eban INTO TABLE it_eban FOR ALL ENTRIES IN it_ekpo
WHERE banfn = it_ekpo-banfn
AND bnfpo = it_ekpo-bnfpo.
LOOP AT c_t_data INTO l_mc02m_0itm.
* SELECT SINGLE * FROM ekpo
* WHERE ebeln = l_mc02m_0itm-ebeln
* AND ebelp = l_mc02m_0itm-ebelp.
READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = l_mc02m_0itm-ebeln
ebelp = l_mc02m_0itm-ebelp.
* IF ekpo-banfn IS NOT INITIAL.
IF wa_ekpo-banfn IS NOT INITIAL.
* SELECT SINGLE * FROM eban
* WHERE banfn = ekpo-banfn
* AND bnfpo = ekpo-bnfpo.
READ TABLE it_eban INTO wa_eban WITH KEY banfn = wa_ekpo-banfn
bnfpo = wa_ekpo-bnfpo.
IF sy-subrc = 0.
* l_mc02m_0itm-zzestkz = eban-estkz.
l_mc02m_0itm-zzestkz = wa_eban-estkz.
ENDIF.
MODIFY c_t_data FROM l_mc02m_0itm.
ENDIF.
ENDLOOP.
_______________________________________________________
-SS-
‎2013 Apr 03 12:19 PM
Hi Daniel,
SELECT * FROM EKPO
into table it_ekpo
for all entries in c_t_data
WHERE EBELN = c_t_data-EBELN
AND EBELP = c_t_data-EBELP.
if sy-subrc = 0.
select * from EBAN
into table it_eban
for all entries in it_ekpo
where BANFN = ekpo-BANFN
AND BNFPO = ekpo-BNFPO.
endif.
sort it_ekpo by ebeln ebelp.
sort it_eban by banfn bnfpo.
LOOP AT c_t_data INTO l_MC02M_0ITM.
read table it_ekpo into wa_ekpo with key EBELN = l_MC02M_0ITM-EBELN
EBELP = l_MC02M_0ITM-EBELP binary serach.
if sy-subrc = 0 and wa_EKPO-BANFN is not INITIAL.
read table it_eban into wa_eban with key BANFN = ekpo-BANFN
BNFPO = ekpo-BNFPO binary serach.
IF sy-subrc = 0.
l_MC02M_0ITM-zzestkz = EBAN-ESTKZ.
endif.
MODIFY c_t_data FROM l_MC02M_0ITM.
endif.
ENDLOOP.
Hope this helps. Instead of selecting all fields from EKPO and EBAN, select only the needed fields and declare the internal table / work area accordingly.
Cheers
~Niranjan
‎2013 Apr 03 12:21 PM
Hi,
Before entering the loop, fetch all the required data from the table using for all entries. And then in the loop use the Read statement and fetch that particular record.
Ex:
if c_t_data is not initial.
select banfn banfo from EKPO into table lt_EKPO
for all entries in c_t_data
where ebeln = c_t_data-ebeln and
ebelp = c_t_data-ebelp.
if lt_ekpo is not initial.
select esktz from EBAN into table lt_eban
for all entries in lt_ekpo
where banfn = lt_ekpo-banfn and
banfo = lt_ekpo-banfo.
endif.
endif.
* now the main loop
loop at c_t_data into l_MC02M_0ITM.
read table lt_ekpo into ls_ekpo with key ebeln = l_MC02M_0ITM-ebeln
ebelp = l_MC02M_0ITM-ebelp.
if sy-subrc eq 0.
read table lt_eban into ls_eban with key banfn = ls_ekpo-banfn
banfo = ls_ekpo-banfo.
if sy-subrc eq 0.
l_MC02M_0ITM-zzestkz = ls_eban-ESTKZ.
MODIFY c_t_data FROM l_MC02M_0ITM.
endif.
endif.
endloop.
‎2013 Apr 03 1:03 PM
Hi Ramesh,
I liked your code, instead of using the complete select * statement. But can you please suggest how to declare the internal tables lt_EKPO, ls_EKPO, lt_eban, ls_eban,...Is it the complete table or only the required fields in EKPO & EBAN. Please suggest.
thanks,
DR
‎2013 Apr 03 12:27 PM
Hi Daniel,
Try using following changes given below,
Select * from ekpo
into table it_ekpo "(internal table for EKPO)
for all entries in c_t_data
where ebeln eq c_t_data-ebeln
and ebelp eq c_t_data-ebelp.
if not it_ekpo[] is initial.
Select * from eban
into table it_eban "(internal table for EBAN)
for all entries in it_ekpo
where banfn eq it_ekpo-banfn
and bnfpo eq it_ekpo-bnfpo.
endif.
loop at c_t_data into
l_MC02M_0ITM.
read table it_ekpo with key ebeln = l_MC02M_0ITM-ebeln
ebelp = l_MC02M_0ITM-ebelp.
if sy-subrc eq 0.
read table it_eban with key banfn = it_ekpo-banfn
bnfpo = it_ekpo-bnfpo .
if sy-subrc eq 0.
l_MC02M_0ITM-zzestkz = it_eban-ESTKZ.
endif.
endif.
Modify c_t_data FROM l_MC02M_0ITM.
endloop.
Thanks & regards,
Tushar
‎2013 Apr 03 12:59 PM
Hi Tushar,
Can you please suggest the same code without using select * and internal structure with req fields instead of using the complete EBAN/EKPO tables. It requires lot of memory and performance while selecting * and also using all unwanted fields instead of required fields in structure ?
thanks again,
DR
‎2013 Apr 04 6:21 AM
Hi daniel,
Try the following updated code,
data: begin of it_ekpo occurs 10.
data: ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
banfn like ekpo-banfn,
bnfpo like ekpo-bnfpo.
data: end of it_ekpo.
data: begin of it_eban occurs 10.
data: banfn like eban-banfn,
bnfpo like eban-bnfpo,
estkz like eban-estkz.
data: end of it_eban.
Select ebeln
ebelp
banfn
bnfpo
from ekpo
into table it_ekpo "(internal table for EKPO)
for all entries in c_t_data
where ebeln eq c_t_data-ebeln
and ebelp eq c_t_data-ebelp.
if not it_ekpo[] is initial.
Select banfn
bnfpo
estkz from eban
into table it_eban "(internal table for EBAN)
for all entries in it_ekpo
where banfn eq it_ekpo-banfn
and bnfpo eq it_ekpo-bnfpo.
endif.
loop at c_t_data into
l_MC02M_0ITM.
read table it_ekpo with key ebeln = l_MC02M_0ITM-ebeln
ebelp = l_MC02M_0ITM-ebelp.
if sy-subrc eq 0.
read table it_eban with key banfn = it_ekpo-banfn
bnfpo = it_ekpo-bnfpo .
if sy-subrc eq 0.
l_MC02M_0ITM-zzestkz = it_eban-ESTKZ.
endif.
endif.
Modify c_t_data FROM l_MC02M_0ITM.
endloop.
‎2013 Apr 04 6:59 AM
Hi Tushar,
THanks for the update. I have tried your code, corrected syntax errors. and I am getting an error....
"The specified type has no structure and therefore no component called EBELN "
Its shwoing at
Read table it_ekpo with key ebeln = l_MC02M_0ITM-ebeln
ebelp = l_MC02M_0ITM-ebelp.
Can you please suggest.
Thanks,
DR
‎2013 Apr 04 7:06 AM
Hi Daniel,
Can you please provide your full code.
Thanks & regards,
Tushar
‎2013 Apr 04 8:44 AM
Hi Tushar,
I am getting the below error, and trying from morning. Please help. I wasted 8 hours changing the code multiple time's, everyone is suggesting 1 code and I am unable to fix the below error.
"L_MC02M_0ITM" is a table without a header line and therefore has no component called EBELN".
This is showing at the first read statement.
*&---------------------------------------------------------------------**& Include ZXRSAU01*&---------------------------------------------------------------------*tables : EKPO, EBAN.**
Data : l_MC02M_0ITM type table of MC02M_0ITM,
ls_MC02M_0ITM type table of MC02M_0ITM.
Data : zzestkz like eban-estkz.
data: begin of it_ekpo occurs 10.
data: ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
banfn like ekpo-banfn,
bnfpo like ekpo-bnfpo.
data: end of it_ekpo.
data: begin of it_eban occurs 10.data: banfn like eban-banfn,
bnfpo like eban-bnfpo,
estkz like eban-estkz.data: end of it_eban.
CASE i_datasource.
WHEN '2LIS_02_ITM'.
ls_MC02M_0ITM[] = c_t_data[].
IF NOT c_t_data IS INITIAL .
Select ebeln
ebelp
banfn
bnfpo
from ekpo
into table it_ for all entries in ls_MC02M_0ITM
where ebeln eq ls_MC02M_0ITM-ebeln
and ebelp eq ls_MC02M_0ITM-ebelp.
if not it_ekpo[] is initial.
Select banfn
bnfpo
estkz from eban
into table it_eban for all entries in it_ekpo
where banfn eq it_ekpo-banfn
and bnfpo eq it_ekpo-bnfpo.endif.
loop at c_t_data into l_MC02M_0ITM.
read table it_ekpo with key ebeln = l_MC02M_0ITM-ebeln
ebelp = l_MC02M_0ITM-ebelp.
if sy-subrc eq 0.
read table it_eban with key banfn = it_ekpo-banfn
bnfpo = it_ekpo-bnfpo .
if sy-subrc eq 0.
l_MC02M_0ITM-zzestkz = it_eban-ESTKZ.endif.endif.
Modify c_t_data FROM l_MC02M_0ITM.
endloop.
Thanks,
‎2013 Apr 04 9:35 AM
Hi Daniel,
Try out the changes given,
* DATA : l_mc02m_0itm TYPE TABLE OF mc02m_0itm,
* ls_mc02m_0itm TYPE TABLE OF mc02m_0itm.
* DATA : zzestkz LIKE eban-estkz.
DATA: BEGIN OF ls_mc02m_0itm OCCURS 0.
INCLUDE STRUCTURE mc02m_0itm.
DATA: zzestkz LIKE eban-estkz.
DATA: END OF ls_mc02m_0itm.
DATA: l_mc02m_0itm LIKE ls_mc02m_0itm.
DATA: BEGIN OF it_ekpo OCCURS 10.
DATA: ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
banfn LIKE ekpo-banfn,
bnfpo LIKE ekpo-bnfpo.
DATA: END OF it_ekpo.
DATA: BEGIN OF it_eban OCCURS 10.
DATA: banfn LIKE eban-banfn,
bnfpo LIKE eban-bnfpo,
estkz LIKE eban-estkz.
DATA: END OF it_eban.
CASE i_datasource.
WHEN '2LIS_02_ITM'.
ls_mc02m_0itm[] = c_t_data[].
IF NOT c_t_data IS INITIAL .
SELECT ebeln
ebelp
banfn
bnfpo
FROM ekpo
INTO TABLE it_ekpo FOR ALL ENTRIES IN ls_mc02m_0itm
WHERE ebeln EQ ls_mc02m_0itm-ebeln
AND ebelp EQ ls_mc02m_0itm-ebelp.
IF NOT it_ekpo[] IS INITIAL.
SELECT banfn
bnfpo
estkz FROM eban
INTO TABLE it_eban FOR ALL ENTRIES IN it_ekpo
WHERE banfn EQ it_ekpo-banfn
AND bnfpo EQ it_ekpo-bnfpo.
ENDIF.
LOOP AT c_t_data INTO l_mc02m_0itm.
READ TABLE it_ekpo WITH KEY ebeln = l_mc02m_0itm-ebeln
ebelp = l_mc02m_0itm-ebelp.
IF sy-subrc EQ 0.
READ TABLE it_eban WITH KEY banfn = it_ekpo-banfn
bnfpo = it_ekpo-bnfpo .
IF sy-subrc EQ 0.
l_mc02m_0itm-zzestkz = it_eban-estkz.
ENDIF.
ENDIF.
MODIFY c_t_data FROM l_mc02m_0itm.
ENDLOOP.
Thanks & Regards,
Tushar
‎2013 Apr 04 1:40 PM
Hi Tushar,
I have used exactly the same code. I dint get any errors, it was good. But the ZZESTKZ value is blank and its not getting any values, even if EBAN & EKPO table has the values for the PO's. ....where as my earlier code wiht the select * used to fetch values. I am not sure where am I doing wrong.
Pls see the code if you want to go through.
tables : EKPO, EBAN.
Data : l_MC02M_0ITM like MC02M_0ITM,
it_MC02M_0ITM type table of MC02M_0ITM.
Data : zzestkz likeeban-estkz.
DATA: BEGIN OF ls_mc02m_0itm
OCCURS 0.
INCLUDE STRUCTURE mc02m_0itm.
DATA: END OF ls_mc02m_0itm.
DATA: BEGIN OF it_ekpo
OCCURS 10.
DATA: ebeln LIKEekpo-ebeln,
ebelp LIKE ekpo-ebelp,
banfn LIKE ekpo-banfn,
bnfpo LIKE ekpo-bnfpo.
DATA: END OF it_ekpo.
DATA: BEGIN OF it_eban
OCCURS 10.
DATA: banfn LIKEeban-banfn,
bnfpo LIKE eban-bnfpo,
estkz LIKE eban-estkz.
DATA: END OF it_eban.
CASE i_datasource.
WHEN '2LIS_02_ITM'.
ls_mc02m_0itm[] = c_t_data[].
IF NOT c_t_data IS
INITIAL .
SELECT ebeln
ebelp
banfn
bnfpo
FROM ekpo
INTO TABLE it_ekpo FOR ALL ENTRIES IN ls_mc02m_0itm
WHERE ebeln EQls_mc02m_0itm-ebeln
AND ebelp EQ ls_mc02m_0itm-ebelp.
IF NOT it_ekpo[] IS INITIAL.
SELECT banfn
bnfpo
estkz FROM eban
INTO TABLE it_eban FOR ALL ENTRIES IN it_ekpo
WHERE banfn EQ it_ekpo-banfn
AND bnfpo EQ it_ekpo-bnfpo.
ENDIF.
LOOP AT c_t_data INTO l_mc02m_0itm.
READ TABLE it_ekpo WITH KEY ebeln = l_mc02m_0itm-ebeln
ebelp = l_mc02m_0itm-ebelp.
IF sy-subrcEQ 0.
READ TABLE it_eban WITH KEY banfn = it_ekpo-banfn
bnfpo = it_ekpo-bnfpo .
IF sy-subrcEQ 0.
l_mc02m_0itm-zzestkz = it_eban-estkz.
ENDIF.
ENDIF.
MODIFY c_t_data FROM l_mc02m_0itm.
ENDLOOP.
endif.
ENDCASE.
‎2013 Apr 04 2:04 PM
Hi Daniel,
Declare the internal table as given below,
DATA: BEGIN OF ls_mc02m_0itm OCCURS 0.
INCLUDE STRUCTURE mc02m_0itm.
DATA: zzestkz LIKE eban-estkz.
DATA: END OF ls_mc02m_0itm.
DATA: l_mc02m_0itm LIKE ls_mc02m_0itm.
Please do not use the declaration
Data : l_MC02M_0ITM like MC02M_0ITM,
it_MC02M_0ITM type table of MC02M_0ITM.
Data : zzestkz likeeban-estkz.
DATA: BEGIN OF ls_mc02m_0itm
OCCURS 0.
INCLUDE STRUCTURE mc02m_0itm.
DATA: END OF ls_mc02m_0itm.
Thanks & Regards,
Tushar
‎2013 Apr 04 2:30 PM
This is not good programming. Do NOT use tables with header lines. There is really no need, and it is bad programming practice.
‎2013 Apr 04 3:15 PM
Hi Matthew,
Can i use this code. Is it fine if we use a select * for single row.
SELECT single * FROM EKPO
WHERE EBELN = l_MC02M_0ITM-EBELN
AND EBELP = l_MC02M_0ITM-EBELP.
if EKPO-BANFN is not INITIAL.
select single * from EBAN
where BANFN = ekpo-BANFN
AND BNFPO = ekpo-BNFPO.
IF sy-subrc = 0.
l_MC02M_0ITM-zzestkz = EBAN-ESTKZ.
endif.
MODIFY c_t_data FROM l_MC02M_0ITM.
endif.
ENDLOOP.
‎2013 Apr 04 4:27 PM
No. Define the fields you want to select. In this case, BANFN and BNFPO from EXPO, and just one field (it doesn't matter which) from EBAN:
This is very basic stuff - I suggest your read some of the blogs and posts by Siegfried Boes on performance.
‎2013 Apr 03 12:29 PM
Replace your code with below code- It will work.
_______________________________________________________________
DATA: it_ekpo TYPE STANDARD TABLE OF ekpo,
wa_ekpo LIKE LINE OF it_ekpo,
it_eban TYPE STANDARD TABLE OF eban,
wa_eban LIKE LINE OF it_eban.
SELECT * FROM ekpo INTO TABLE it_ekpo FOR ALL ENTRIES IN c_t_data
WHERE ebeln = c_t_data-ebeln
AND ebelp = c_t_data-ebelp.
SELECT * FROM eban INTO TABLE it_eban FOR ALL ENTRIES IN it_ekpo
WHERE banfn = it_ekpo-banfn
AND bnfpo = it_ekpo-bnfpo.
LOOP AT c_t_data INTO l_mc02m_0itm.
* SELECT SINGLE * FROM ekpo
* WHERE ebeln = l_mc02m_0itm-ebeln
* AND ebelp = l_mc02m_0itm-ebelp.
READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = l_mc02m_0itm-ebeln
ebelp = l_mc02m_0itm-ebelp.
* IF ekpo-banfn IS NOT INITIAL.
IF wa_ekpo-banfn IS NOT INITIAL.
* SELECT SINGLE * FROM eban
* WHERE banfn = ekpo-banfn
* AND bnfpo = ekpo-bnfpo.
READ TABLE it_eban INTO wa_eban WITH KEY banfn = wa_ekpo-banfn
bnfpo = wa_ekpo-bnfpo.
IF sy-subrc = 0.
* l_mc02m_0itm-zzestkz = eban-estkz.
l_mc02m_0itm-zzestkz = wa_eban-estkz.
ENDIF.
MODIFY c_t_data FROM l_mc02m_0itm.
ENDIF.
ENDLOOP.
_______________________________________________________
-SS-
‎2013 Apr 03 12:54 PM
Hi SS,
I liked your suggestion...except the select * option below. Can you please replace the below Select * statements without * and suggest by selecting the required fields before the Loop statement.....and also do we need the complete table of EKPO/EBAN instead of using the required fields in an internal table. wont it be better ?
SELECT * FROM ekpo INTO TABLE it_ekpo FOR ALL ENTRIES IN c_t_data
WHERE ebeln = c_t_data-ebeln
AND ebelp = c_t_data-ebelp.
SELECT * FROM eban INTO TABLE it_eban FOR ALL ENTRIES IN it_ekpo
WHERE banfn = it_ekpo-banfn
AND bnfpo = it_ekpo-bnfpo.
Thanks again,
DR
‎2013 Apr 03 5:29 PM
Hi DR ,
Please find the below code as per your requirement ,
*-- Declaration of the Types
TYPES : BEGIN OF type_ekpo ,
ebeln TYPE ekpo-ebeln ,
ebelp TYPE ekpo-ebelp ,
banfn TYPE ekpo-banfn ,
bnfpo TYPE ekpo-bnfpo ,
END OF type_ekpo .
TYPES : BEGIN OF type_eban ,
banfn TYPE eban-banfn ,
bnfpo TYPE eban-bnfpo ,
estkz TYPE eban-estkz ,
END OF type_eban .
*-- Declaration of the table types
TYPES : type_t_ekpo TYPE STANDARD TABLE OF type_ekpo ,
type_t_eban TYPE STANDARD TABLE OF type_eban .
*-- Declaration of the Internal table and Work area
DATA : it_ekpo TYPE type_t_ekpo ,
wa_ekpo TYPE type_ekpo ,
it_eban TYPE type_t_eban ,
wa_eban TYPE type_eban .
START-OF-SELECTION .
IF NOT c_t_data IS INITIAL .
REFRESH it_ekpo .
SELECT ebeln ebelp banfn bnfpo FROM ekpo INTO TABLE it_ekpo
FOR ALL ENTRIES IN c_t_data
WHERE ebeln = c_t_data-ebeln
AND ebelp = c_t_data-ebelp .
IF NOT it_ekpo IS INITIAL .
REFRESH it_eban .
SELECT banfn bnfpo estkz FROM eban INTO TABLE it_eban
FOR ALL ENTRIES IN it_ekpo
WHERE banfn = it_ekpo-banfn
AND bnfpo = it_ekpo-bnfpo .
ENDIF .
ENDIF .
*-- Moving the value to c_t_data
CLEAR l_mc02m_0itm.
LOOP AT c_t_data INTO l_mc02m_0itm.
CLEAR wa_ekpo .
READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = l_mc02m_0itm-ebeln
ebelp = l_mc02m_0itm-ebelp .
IF NOT wa_ekpo IS INITIAL .
CLEAR wa_eban .
READ TABLE it_eban INTO wa_eban WITH KEY banfn = wa_ekpo-banfn
bnfpo = wa_ekpo-bnfpo .
l_mc02m_0itm-estkz = wa_eban-estkz .
ENDIF .
MODIFY c_t_data FROM l_mc02m_0itm TRANSPORTING estkz .
CLEAR l_mc02m_0itm.
ENDLOOP .
Thanks
Mallikarjun
‎2013 Apr 04 2:00 AM
Hi Patil,
THanks for the update. I have tried your code, corrected syntax errors. and I am getting an error....
"The specified type has no structure and therefore no component called EBELN "
The error is showing at this place.
SELECT ebeln ebelp banfn bnfpo FROM EKPO INTO TABLE it_ekpo
FOR ALL ENTRIES IN c_t_data
WHERE ebeln = c_t_data-ebeln
AND ebelp = c_t_data-ebelp .
Please find my below code.
tables : EKPO, EBAN.
Data : l_MC02M_0ITM like MC02M_0ITM.Data : zzestkz like eban-estkz.
*-- Declaration of the TypesTYPES : BEGIN OF type_ekpo ,
ebeln TYPE ekpo-ebeln ,
ebelp TYPE ekpo-ebelp ,
banfn TYPE ekpo-banfn ,
bnfpo TYPE ekpo-bnfpo ,
END OF type_ekpo.
TYPES : BEGIN OF type_eban ,
banfn TYPE eban-banfn ,
bnfpo TYPE eban-bnfpo ,
estkz TYPE eban-estkz ,
END OF type_eban.
*-- Declaration of the table typesTYPES : type_t_ekpo TYPE STANDARD TABLE OF type_ekpo ,
type_t_eban TYPE STANDARD TABLE OF type_eban.
*-- Declaration of the Internal table and Work areaDATA : it_ekpo TYPE type_t_ekpo,
wa_ekpo TYPE type_ekpo,
it_eban TYPE type_t_eban,
wa_eban TYPE type_eban.
CASE i_datasource.
WHEN '2LIS_02_ITM'.
*START-OF-SELECTION .
IF NOT c_t_data IS INITIAL .
REFRESH it_ekpo .
SELECT ebeln ebelp banfn bnfpo FROM EKPO INTO TABLE it_ekpo
FOR ALL ENTRIES IN c_t_data
WHERE ebeln = c_t_data-ebeln
AND ebelp = c_t_data-ebelp .
IF NOT it_ekpo IS INITIAL .
REFRESH it_eban .
SELECT banfn bnfpo estkz FROM eban INTO TABLE it_eban
FOR ALL ENTRIES IN it_ekpo
WHERE banfn = it_ekpo-banfn
AND bnfpo = it_ekpo-bnfpo .
ENDIF .
ENDIF .
*-- Moving the value to c_t_data
CLEAR l_mc02m_0itm.
LOOP AT c_t_data INTO l_mc02m_0itm.
CLEAR wa_ekpo .
READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = l_mc02m_0itm-ebeln
ebelp = l_mc02m_0itm-ebelp .
IF NOT wa_ekpo IS INITIAL .
CLEAR wa_eban .
READ TABLE it_eban INTO wa_eban WITH KEY banfn = wa_ekpo-banfn
bnfpo = wa_ekpo-bnfpo .
l_mc02m_0itm-estkz = wa_eban-estkz .
ENDIF .
MODIFY c_t_data FROM l_mc02m_0itm TRANSPORTING estkz .
CLEAR l_mc02m_0itm.
ENDLOOP .ENDCASE.
‎2013 Apr 04 3:18 AM
I have corrected the error but getting another error.
"L_MC02M_0ITM" is a table without a header line and therefore has no component called ZZESKTZ".
tables : EKPO, EBAN.**Data : l_MC02M_0ITM type table of MC02M_0ITM,
ls_MC02M_0ITM type table of MC02M_0ITM. Data : zzestkz like eban-estkz.****-- Declaration of the TypesTYPES : BEGIN OF type_ekpo ,
ebeln TYPE ekpo-ebeln ,
ebelp TYPE ekpo-ebelp ,
banfn TYPE ekpo-banfn ,
bnfpo TYPE ekpo-bnfpo ,
END OF type_ekpo.
TYPES : BEGIN OF type_eban ,
banfn TYPE eban-banfn ,
bnfpo TYPE eban-bnfpo ,
estkz TYPE eban-estkz ,
END OF type_eban.
*-- Declaration of the table typesTYPES : type_t_ekpo TYPE STANDARD TABLE OF type_ekpo,
type_t_eban TYPE STANDARD TABLE OF type_eban.
*-- Declaration of the Internal table and Work areaDATA : it_ekpo TYPE type_t_ekpo,
wa_ekpo TYPE type_ekpo,
it_eban TYPE type_t_eban,
wa_eban TYPE type_eban.
* START-OF-SELECTION .
CASE i_datasource.
WHEN '2LIS_02_ITM'.
ls_MC02M_0ITM[] = c_t_data[].
IF NOT c_t_data IS INITIAL .
REFRESH it_ekpo .
SELECT ebeln ebelp banfn bnfpo INTO TABLE it_ekpo from EKPO
FOR ALL ENTRIES IN ls_MC02M_0ITM
WHERE ebeln = ls_MC02M_0ITM-ebeln
AND ebelp = ls_MC02M_0ITM-ebelp .
IF NOT it_ekpo IS INITIAL .
REFRESH it_eban .
SELECT banfn bnfpo estkz INTO TABLE it_eban from EBAN
FOR ALL ENTRIES IN it_ekpo
WHERE banfn = it_ekpo-banfn
AND bnfpo = it_ekpo-bnfpo .
ENDIF .
ENDIF .
*-- Moving the value to c_t_data
CLEAR l_mc02m_0itm.
LOOP AT c_t_data INTO l_mc02m_0itm.
CLEAR wa_ekpo .
READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = wa_ekpo-ebeln
ebelp = wa_ekpo-ebelp .
IF NOT wa_ekpo IS INITIAL .
CLEAR wa_eban .
READ TABLE it_eban INTO wa_eban WITH KEY banfn = wa_eban-banfn
bnfpo = wa_eban-bnfpo.
IF sy-subrc = 0.
l_MC02M_0ITM-zzestkz = EBAN-ESTKZ.
endif.
MODIFY c_t_data FROM l_MC02M_0ITM.
endif.
ENDLOOP .ENDCASE.
‎2013 Apr 04 7:55 AM
Hi Daniel,
Declare L_MC02M_0ITM as type of MC02M_0ITM and not as type table of. This will resolve your above issue.
Regards,
Sonal
‎2013 Apr 04 9:13 AM
Hi Sonal,
I have corrected the code witout errors. But there is no data in the ZZESTKZ field. Can you please validate my code.
*&---------------------------------------------------------------------*
*& Include ZXRSAU01
*&---------------------------------------------------------------------*
**declare strucctures/internal tables/work areas ..
tables : EKPO, EBAN.
Data : l_MC02M_0ITM like MC02M_0ITM,
it_MC02M_0ITM type table of MC02M_0ITM.
Data : zzestkz like eban-estkz.
data: begin of it_ekpo occurs 10.
data: ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
banfn like ekpo-banfn,
bnfpo like ekpo-bnfpo.
data: end of it_ekpo.
data: begin of it_eban occurs 10.
data: banfn like eban-banfn,
bnfpo like eban-bnfpo,
estkz like eban-estkz.
data: end of it_eban.
CASE i_datasource.
WHEN '2LIS_02_ITM'.
it_MC02M_0ITM[] = c_t_data[].
IF NOT c_t_data IS INITIAL .
*
Select ebeln
ebelp
banfn
bnfpo
from ekpo
into table it_ekpo "(internal table for EKPO)
for all entries in it_MC02M_0ITM
where ebeln eq it_MC02M_0ITM-ebeln
and ebelp eq it_MC02M_0ITM-ebelp.
if not it_ekpo[] is initial.
Select banfn
bnfpo
estkz from eban
into table it_eban "(internal table for EBAN)
for all entries in it_ekpo
where banfn eq it_ekpo-banfn
and bnfpo eq it_ekpo-bnfpo.
endif.
loop at c_t_data into l_MC02M_0ITM.
*
read table it_ekpo with key ebeln = l_MC02M_0ITM-ebeln
ebelp = l_MC02M_0ITM-ebelp.
if sy-subrc eq 0.
read table it_eban with key banfn = it_ekpo-banfn
bnfpo = it_ekpo-bnfpo .
endif.
*
if sy-subrc eq 0.
l_MC02M_0ITM-zzestkz = it_eban-ESTKZ.
endif.
Modify c_t_data FROM l_MC02M_0ITM.
endloop.
endif.
endcase.
‎2013 Apr 04 3:14 PM
Hi,
I have corrected the code, but the result is blank. Any suggestions.
‎2013 Apr 05 5:50 AM
Hi Daniel,
Have you tried debugging it? At which point is the data not appearing?
Regards,
Sonal
‎2013 Apr 04 7:40 AM
Hi Daniel,
Try this below code
DATA:
ls_ekpo TYPE ekpo, "Work Area for ekpo
ls_eban TYPE eban, "Work Area for eban
lt_ekpo TYPE TABLE OF ekpo, "Internal Table for ekpo
lt_eban TYPE TABLE OF eban. "Internal Table for eban
* Select the values from database table ekpo
SELECT *
FROM ekpo
INTO TABLE lt_ekpo.
IF sy-subrc = 0.
* Select the values from database table eban
SELECT *
FROM eban
INTO TABLE lt_eban.
IF sy-subrc = 0.
* Loop with your internal table
LOOP AT c_t_data INTO l_mc02m_0itm.
* Read required record from the internal table
READ TABLE lt_ekpo INTO ls_ekpo WITH KEY ebeln = l_mc02m_0itm-ebeln ebelp = l_mc02m_0itm-ebelp.
IF sy-subrc = 0 AND ls_ekpo-banfn IS NOT INITIAL.
* Read required record from the internal table
READ TABLE lt_eban INTO ls_eban WITH KEY banfn = ekpo-banfn bnfpo = ekpo-bnfpo.
IF sy-subrc = 0.
l_mc02m_0itm-zzestkz = ls_eban-estkz.
ENDIF.
MODIFY c_t_data FROM l_mc02m_0itm.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
‎2013 Apr 05 7:28 AM
Hi,
Use 2-RANGE statement outside the Loop for those SELECT Queries.
Then use those Range Table and read the values for your logic. It will boost ur performance issue..
Regards,
Anand V
‎2013 Apr 09 12:24 PM
‎2013 Apr 09 2:32 PM
Hi,
I hope it is better to use "for all entries" or "join statement" instead of select within loops.
Regards,
Rahul Singh