06-17-2008 12:37 PM
Hello gurus,
I have a requirement of getting Service number from field Konnr in table EKPO.
The logic is as follows.
1)Get EBELN based on Konnr from EKPO table
2)Get PACKNO based on EBELN from step1 and BSTYP='K' from ESLH table
3)Get SRVPOS,PACKAGE based on PACKNO from step2 from ESLL table.
If SRVPOS is blank,Make PACKAGE as PACKNO and get SRVPOS .
Here repeating of same Package should be eliminated
Can anyone give me efficient code for the above logic?
Max points wil be awarded
Thanks in Advance
06-17-2008 12:44 PM
Hi,
You havent mentioned the value of KUNNR which needs to be inputted in EKPO.
Please tell that.
Regards.
06-17-2008 12:58 PM
Konnr comes from Selection screen(select option).so it should get for generalised konnr
06-17-2008 1:13 PM
1) Get EBELN based on Konnr from EKPO table
data: it_ekko type table of ekpo,
wa_ekko type ekpo,
it_eslh type table of eslh,
wa_eslh type eslh,
it_esll type table of esll,
wa_esll type esll,
it_esll1 type table of esll,
wa_esll1 type esll,
select ebeln
from ekpo
into correpsonding fields of it_ekpo
where konnr in s_konnr.
2)Get PACKNO based on EBELN from step1 and BSTYP='K' from ESLH table
if not it_ekpo is initial.
select packno
from eslh
into corresponding fields of table it_ekpo
where ebeln eq it_ekpo-ebeln
and bstyp eq 'K'.
endif.
3)Get SRVPOS,PACKAGE based on PACKNO from step2 from ESLL table.
if not it_eslh is initial.
select srvpos
package
from esll
into corresponding fields of table it_eslh
where package eq it_eslh-packno.
endif.
4)If SRVPOS is blank,Make PACKAGE as PACKNO and get SRVPOS .
loop at it_esll into wa_esll.
if wa_esll-srvpos is initial.
move wa_esll to wa_esll1.
append wa_esll1 to it_esll1.
endif.
endloop.
refresh: it_esll[].
sort it_esll1 by package.
delete adjacent duplicates from it_esll1 by comparing all fields.
select srvpos
package
into it_esll
for all entries in it_esll1
where package eq it_esll1-package.
Regards
Kannaiah
06-17-2008 1:17 PM
Hi ,
check this.........
1 select ebeln from ekpo into table itab where kunnr in s_kunnr
2 if itab[] is not initial.
select packno from eslh into table itab1 for all entries in itab where ebeln = itab-ebeln and BSTYP='K'
endif.
3 if itab[] is not initial
select SRVPOS,PACKAGE from ESLL into table itab2 for all entries in itab1 where PACKNO = itab-PACKNO.
endif.
06-17-2008 1:19 PM
Hi,
Try following.
data : begin of itab1 occurs 0,
ebeln like ekpo-ebeln,
end of itab1.
data : begin of itab2 occurs 0,
PACKNO like eslh-PACKNO,
end of itab2.
data : begin of itab3 occurs 0,
SRVPOS like esll-SRVPOS ,
PACKAGE like esll-PACKAGE ,
end of itab3.
data index type sy-tabix.
select ebeln from ekpo
into table itab1
where kunnr in konnr.
if itab1[] not initial.
select PACKNO from eslh
into table itab2
for all entries in itab1
where ebeln = itab1-ebeln and
BSTYP='K' .
endif.
if itab2[] not initial.
select SRVPOS PACKAGE from esll
into table itab3
for all entries in itab2
where PACKNO = itab2-PACKNO.
endif.
if itab3[] not initial.
loop at itab3.
if itab3-SRVPOS is initial.
index = sy-tabix.
select SRVPOS PACKAGE from esll
into table itab3
for all entries in itab2
where PACKNO = itab1-PACKAGE.
modify itab3 ndex index.
endif.
endloop.
endif.
Reward pts. if helphull.
Regards,
Dhan