Skip to Content
author's profile photo Former Member
Former Member

small thing

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 11:44 AM

    Hi,

    You havent mentioned the value of KUNNR which needs to be inputted in EKPO.

    Please tell that.

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 12: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 12: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 12: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.