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: 

Find occurences in every line of itab

Former Member
0 Kudos

Hi,

I had a csv file like this :

SPEC;STD;TC;;01/08/08;08/08/08;15/08/08;22/08/08;29/08/08

AAA;BBB;CC;DD;40.5;50.2;10.3

EEE;FFF;GG;HH;;;18.3;15.6;25.6

...

I put this into itab, it came out like this :

SPEC-STD-TC- -Date1-Date2-Date3-Date4-Date5

SPEC-STD-TC- -01/08/08-08/08/08-15/08/08-22/08/08-29/08/08

AAA-BBB-A1-DD-40.5-50.2-10.3

EEE-FFF-B1-HH- - -18.3-15.6-25.6

Line 1 is table header and line 2 data header.

What I have to do is to find the begining and end date of each line where there is a quantity.

For example :

Line 2 of itab -> A1 begins from 01/08/08 and ends at 15/08/08.

Line 3 of itab -> B1 begins from 15/08/08 and ends at 29/08/08.

So I need to make a another table with these informations.

Can anyone help me?

Thanks!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You can do it as follows:

Declare an internal table as"

DATA:

BEGIN OF ITAB2 OCCURS 0,

LINE(30) TYPE C,

END OF ITAB2.

LOOP AT ITAB1.

IF ITAB1-QTY IS NOT INITIAL.

W_DATE1 = ITAB1-BEGIN_DATE.

W_DATE2 = ITAB1-END_DATE.

A1 begins from 01/08/08 and ends at 15/08/08.

CONCATENATE ITAB1-A1 'begins from' W_DATE1 'and ends at' W_DATE2 INTO ITAB2-LINE.

APPEND ITAB2.

CLEAR ITAB2.

ENDLOOP.

Hope this helps you the basic logic creation.

Regards,

Rama chary.Pammi

2 REPLIES 2

Former Member
0 Kudos

Hi,

You can do it as follows:

Declare an internal table as"

DATA:

BEGIN OF ITAB2 OCCURS 0,

LINE(30) TYPE C,

END OF ITAB2.

LOOP AT ITAB1.

IF ITAB1-QTY IS NOT INITIAL.

W_DATE1 = ITAB1-BEGIN_DATE.

W_DATE2 = ITAB1-END_DATE.

A1 begins from 01/08/08 and ends at 15/08/08.

CONCATENATE ITAB1-A1 'begins from' W_DATE1 'and ends at' W_DATE2 INTO ITAB2-LINE.

APPEND ITAB2.

CLEAR ITAB2.

ENDLOOP.

Hope this helps you the basic logic creation.

Regards,

Rama chary.Pammi

Former Member
0 Kudos

Hi,

Thanks for ur answer!

U said :

LOOP AT ITAB1.

IF ITAB1-QTY IS NOT INITIAL.

W_DATE1 = ITAB1-BEGIN_DATE.

W_DATE2 = ITAB1-END_DATE.

I wanted to apply ur suggestion but itab1 doesn't have fields like QTY or BEGIN_DATE and END_DATE.

These datas are uploaded into my internal table.

My internal table has header which contains name like date01 date02 date03...

Any other suggestion?

Thanks!