Application Development and Automation 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: 
Read only

Facing problem in fetching data from table LIPS using for all entries

former_member147380
Participant
0 Likes
2,163

Hi All,

Fetch on LIPS is taking long to run. The below is attached code.

SELECT VBELN " Delivery

INCO1 " Incoterms (part 1)

INCO2 " Incoterms (part 2)

KUNNR " Ship-To Party

KDGRP " Customer group

BTGEW " Total Weight

WADAT_IST " Actual goods movement date

GBSTK " Overall proc. stat of document

INTO TABLE T_LIKP

FROM LIKPUK

WHERE VBELN IN S_VBELN

AND INCO1 IN R_INCO1

AND KUNNR IN S_KUNNR

AND KDGRP IN S_KDGRP

AND WADAT_IST IN S_WADAT

AND WBSTK EQ C_WBSTK_C.

  • End of insertion DEVK913159

IF SY-SUBRC EQ 0.

  • Get the document reference numbers for delivery documents

SORT T_LIKP BY VBELN.

SELECT VBELN " Delivery

POSNR " Delivery Item

VGBEL " Document number of the

  • " reference document

FROM LIPS

INTO TABLE LT_LIPS

FOR ALL ENTRIES IN T_LIKP

WHERE VBELN EQ T_LIKP-VBELN.

Please let me know what is problem in below code.

Moderator message - Moved to the correct forum - by someone else!

Edited by: Rob Burbank on May 15, 2009 9:18 AM

Hi All,

Fetch on LIPS is taking long to run. The below is attached code.

SELECT VBELN " Delivery

INCO1 " Incoterms (part 1)

INCO2 " Incoterms (part 2)

KUNNR " Ship-To Party

KDGRP " Customer group

BTGEW " Total Weight

WADAT_IST " Actual goods movement date

GBSTK " Overall proc. stat of document

INTO TABLE T_LIKP

FROM LIKPUK

WHERE VBELN IN S_VBELN

AND INCO1 IN R_INCO1

AND KUNNR IN S_KUNNR

AND KDGRP IN S_KDGRP

AND WADAT_IST IN S_WADAT

AND WBSTK EQ C_WBSTK_C.

  • End of insertion DEVK913159

IF SY-SUBRC EQ 0.

  • Get the document reference numbers for delivery documents

SORT T_LIKP BY VBELN.

SELECT VBELN " Delivery

POSNR " Delivery Item

VGBEL " Document number of the

  • " reference document

FROM LIPS

INTO TABLE LT_LIPS

FOR ALL ENTRIES IN T_LIKP

WHERE VBELN EQ T_LIKP-VBELN.

Please let me know what is problem in below code.

Moderator message - Moved to the correct forum - by someone else!

Edited by: Rob Burbank on May 15, 2009 9:18 AM

8 REPLIES 8
Read only

Former Member
0 Likes
1,522

hi there.

the code you have written is correct... but what about lt_lips.

have you declared the internal table with type lips..

if yes.please define a strucure with only this three fields you are fetching. and then declare internal table lt_lips with that strucure:

ex: types: begin of line,

3 fields.

end of line,

data: lt_lips type standard table of line.

or use ' corresponding fields of table ' in the select statment.

Since you dont have the delivery line items ,primary key fetching cannot be done succssfuly.

Try to Create index for the particular table and then fetch the data using index keys.

this will reduce the fetchin time of the program.

safel

Edited by: Safel007 on May 15, 2009 4:50 PM

Read only

Former Member
0 Likes
1,522

Hi,

It should be fast as VBELN is primary key.

I suggest you to check with

SELECT on VBUK

NEXT SELECT on WB2_V_LIKP_LIPS / WB2_V_LIKP_LIPS2 (Views for LIKP and LIPS)

It may give better performance.

Check times with SQL Trace and decide.

Thanks,

Jyothi

Read only

Former Member
0 Likes
1,522

Hi,

whenever we use FOR ALL ENTRIES we should verify that the table is not initial.

If the query is taking long to run then, probabloy you can try by specifying the PACKAGE SIZE option.

Regards,

Anil

Read only

Former Member
0 Likes
1,522

The code you have written is absolutely right. Regarding performance problem it could be due to huge number of records in the internal table. try to add the necessary columns only in the internal table.

Read only

Former Member
0 Likes
1,522

Hi,

Explaining further the point mentioned by Mr. Anil; the table T_LIKP shouldn't be initial. If it is initial then the query will try to pull out all the entries from table LIPS hence taking long time to execute the query.

Hope I am clear.

Regards,

Farheen

Read only

Former Member
0 Likes
1,522

Hi

Write SORT Statement before IF Loop.

Also write Delete Adjacent Statement after SORT.

Regards.

Read only

Former Member
0 Likes
1,522

Hi,

Since the first internal table you mentioned would contain large number of records..That will be the main problem when you go for all entries using that table..

You can reduce the load in database server as below..But anyhow the load on application server will increase by following the below steps:

Just loop all the records of the first internal table and populate a range which contains vbeln field..

Now use select from lips where vbeln in range table..

Read only

Former Member
0 Likes
1,522

@everyone - the check on sy-subrc = 0 effectively checks that the internal table is not initial.

Rob