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

ALV

Former Member
0 Likes
686

HI All,

Requirment is like this . I have a table looks like this .

WERKS ! LINE ! ZDATE ! ZTIME ! SHIFT ! flow(g)

1 lp 1.2.06 06:00 blue 20

1 lp 1.2.06 10:00 blue 30

1 lp 1.2.06 12:00 blue 50

1 lp 1.2.06 14:00 blue 80

1 lp 1.2.06 18:00 blue 120

I need to read the 'line' start time '6:00' to pick value for the flow(g) i.e 20 . And end of 'line' end of shift time '18:00' to pick up the value of flow '120 g ,

. So that i can calculate the varience of flow/line/shift/time/date.

Any example logic for this pls

thanks,

vin.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
656
SORT ITAB BY ZTIME DESCENDING.
read table itab index 1.
end_time = itab-ztime.

SORT ITAB BY ZTIME ASCENDING.
read table itab index 1.
start_time = itab-ztime.

diff = end_time - start_time.
4 REPLIES 4
Read only

Former Member
0 Likes
656

Hey,

You can use AT NEW LINE and AT END OF LINE. Move the corresponding flow values to a variable.

Reward if helpful.

Regards

Read only

Former Member
0 Likes
656

You will have these records in an internal table before passing them to the ALV.

Read the first record and the last record and calculate required values.

to read the last line find out line size of internal table and use index.

desribe table itab lines v_lines.

if v_lines ne 0.

  • Last line

read table itab into wa_temp1 index v_lines.

  • First line

read table itab into wa_temp2 index 1.

endif.

or if you always have to read the line with time 6:00 and time 18:00, use that as a where clause in the read statement.

Hope I have understood your problem correctly.

Read only

Former Member
0 Likes
657
SORT ITAB BY ZTIME DESCENDING.
read table itab index 1.
end_time = itab-ztime.

SORT ITAB BY ZTIME ASCENDING.
read table itab index 1.
start_time = itab-ztime.

diff = end_time - start_time.
Read only

Former Member
0 Likes
656

Hi Vind,

U can do it this way:-

DESCRIBE TABLE iTAB LINES count.

Read table itab into wa1 index 1.

Read table itab into wa2 index count.

now u have the vlaues in wa1 and wa2 for first and last row...wa1,wa2 are work areas of the same

Hope his helps...

Regards

-


Sachin Dhingra