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

Basic programming help with nested loops

Former Member
0 Likes
915

Hi,

I have a ALV report program there five loops are using based on vbak and vbap table.So my requirement is after second loop if when third loop is not reading the records then earlier two loops data should come in main internal table.in third loop lips and likp data is reading so whose sales order line items delivery having blank it should show blank of delivery column.So how to pass first two loops data to main internal table if third internal table is not reading data.

Thanks.

<subject edited by moderator>

Message was edited by: Manish Kumar

5 REPLIES 5
Read only

former_member193737
Participant
0 Likes
764

hi

go through control level processing  (search it in Google)

in that use AT NEW for the third  field and write your  logic

Read only

former_member202818
Active Contributor
0 Likes
764

HI Pradeep,

Are you talking about loop inside a loop?

Don't do that... Instead you loop one internal table(which will determine number of records to output internal table)  and read(with any key) other internal tables from this loop to get related details.

Once one record(work area) is ready, append it to the output internal table at the end of loop.

Regards

Sreekanth

Read only

former_member188282
Active Participant
0 Likes
764

Hi Kumar,

Instead of nested loops, you can use parallel loop processing, it will give best performance.

Fro better understanding please check below sample example.

EX:


***** By using Read statement first you are checking the records available or not

***** If records available then find the INDEX of that records

***** Then LOOP your internal table from that INDEX

***** By doing like this you can SKIP the other records to LOOP.


LOOP AT VBAP INTO LS_VBAP.

READ TABLE LIPS INTO LS_LIPS WITH KEY VBELN = LS_VBAP-VBELN.

IF   SY-SUBRC EQ 0.

LOOP AT LIPS INTO LS_LIPS FROM SY-TABIX.

IF LS_LIPS-VBELN NE LS_VBAP-VBELN.

EXIT.

ENDIF.

HERE YOU CAN WRITE YOUR LOGIC.

ENDLOOP.

ENDIF.

ENDLOOP.

Regards,

Rajesh.B

Read only

matt
Active Contributor
0 Likes
764

Are you two related?

Read only

Former Member
0 Likes
764

At least these two discussions are now related via incoming links.