Application Development 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: 

issue with select for EKPO and LIPS tables

Former Member
0 Kudos

Hi experts,

I am fetching data from EKPO table based on entries in LIPS table, where I am  getting an error as EBELP and I_LIPS-VGPOS must be of same type and length

SELECT ebeln ebelp cuobj

       FROM ekpo

       INTO TABLE i_cuobj

       FOR ALL ENTRIES IN i_lips

       WHERE ebeln  = i_lips-vgbel

       AND   ebelp  = i_lips-vgpos.

I know we can move the contents into a temporary internal table I_LIPS_TEMP, which is a copy of I_LIPS table , and use the temporary internal table I_LIPS_TEMP when fetching data from EKPO.

I also know that VGPOS is of type NUMC 6  and EKPO EBELP is of type NUMC 5 . Please suggest any good solution for this.

Thanks,

RG

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos
SELECT ebeln ebelp cuobj
       FROM ekpo
       INTO TABLE i_cuobj
       FOR ALL ENTRIES IN i_lips
       WHERE ebeln  = i_lips-vgbel
       AND   ebelp  = i_lips-vgpos(5).
10 REPLIES 10

Sandra_Rossi
Active Contributor
0 Kudos
SELECT ebeln ebelp cuobj
       FROM ekpo
       INTO TABLE i_cuobj
       FOR ALL ENTRIES IN i_lips
       WHERE ebeln  = i_lips-vgbel
       AND   ebelp  = i_lips-vgpos(5).

0 Kudos

Thanks Sandra..!!

It will work since, we have a reduction case of NUMC5 from NUMC6.

Is there any way around for reverse scenario ?

Thanking You All..!!

0 Kudos

Hi sandra,

what happens if there is an item with 055555 and 555555 ..

0 Kudos

You probably mean "what happens if there is an item in LIPS with numbers 555551 and 555552" 😉

Technically speaking, that would be an issue as both LIPS lines would be "joined" with EKPO item number 55555, but hopefully functionally that shouldn't happen as all VGBEL values are below 99999. In SAP tables, there are often fields larger than what there should be, but it's often because these fields are for multiple purposes, and may be used to be joined with fields from different tables and of different lengths (think of AWKEY field in BKPF table and a few other ones),

0 Kudos

Sorry. I think it should be +1(5) instead of (5) :

SELECT ebeln ebelp cuobj
       FROM ekpo
       INTO TABLE i_cuobj
       FOR ALL ENTRIES IN i_lips
       WHERE ebeln  = i_lips-vgbel
       AND   ebelp  = i_lips-vgpos+1(5).

Because of the replies to me, I have checked in the forum, I saw in thread Read Table into WITH KEY | SCN that VGPOS is probably right-aligned (with probably a leading zero).

0 Kudos

thanks for your clarification.

VenkatRamesh_V
Active Contributor
0 Kudos

Hi,

Try,

LOOP AT i_lips  INTO  w_LIPS.

SELECT ebeln ebelp cuobj

       FROM ekpo

       APPENDING  TABLE i_cuobj

       WHERE ebeln  = w_LIPS-vgbel

       AND   ebelp  = w_LIPS-vgpos.

ENDLOOP.

Hope  it helpful,

Regards,

Venkat.

raymond_giuseppi
Active Contributor
0 Kudos

Usually I use EKBE, joining EKPO and EKBE with EBELN, EBELP and filtering with EKBE-VGABE = '8' for delivery. Then select from LIPS with EKBE-BELNR = LIPS-VBELN and concatenate EKBE-GJAHR+2(2) + EKBE-BUZEI = POSNR ...

Regards,

Raymond

0 Kudos

Hello Raymond,

Sorry I am bit confused on your reply, can you please narrate more or paste any test code snippet how you using .

Thanks,

RG

0 Kudos

Was only useful once, with a (wild) huge order (dummy order at going live...) with big item number.

In 99.9999 % of the time this is not required. (The concatenate rule came form a standard SAP FM which returned VBELN and POSNR from PO item number)

Regards,

Raymond