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

Internal Table Operations...

Former Member
0 Likes
1,392

hi all,

i have a internal table , iam sorting with three fields ,, say x1,x2, x3...

i have values like this

x1 x2 x3

001 inr 01.01.2007

001 inr 01.01.2007

001 inr 02.01.2007

001 cad 01.01.2007

001 cad 01.01.2007

002 us 01.01.2007

002 cad 03.01.2007 for the internal table ..

first two lines should be posted once, next one line item and then next two line item etc ,, in tat manner , how to control the statements ??

plz give some idea on it..

thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,294

Hi Krishna,

Use Control breaks.

sort itab by x1 x2 x3.

loop at itab.

at new x1.

write:/10 iatb-x1.

endat.

at new x2.

write:/10 iatb-x2.

endat.

write:/10 iatb-x3.

endloop.

Regards,

Hemant

11 REPLIES 11
Read only

Former Member
0 Likes
1,294

i think you want to delete the duplicate entries from internal table

use this..

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

Read only

0 Likes
1,294

i don't want to delete duplicate records ,,

i need to collect the records based on sorting and post it ...

Read only

Former Member
0 Likes
1,294

Hi,

i advise you to have a look at the statements 'at first.' and 'at new.' , to be used inside a loop.

regards,

Rolf

Read only

Former Member
0 Likes
1,295

Hi Krishna,

Use Control breaks.

sort itab by x1 x2 x3.

loop at itab.

at new x1.

write:/10 iatb-x1.

endat.

at new x2.

write:/10 iatb-x2.

endat.

write:/10 iatb-x3.

endloop.

Regards,

Hemant

Read only

0 Likes
1,294

hi ,

yeah iam using control Break Statements.. i am using AT new statement,, at end of x1 statements..

at end of X1 -- i need to post a doc

at end of x2 -- i need to post a doc

at end of x3 -- i need to post a doc

how to handle this part

Read only

0 Likes
1,294

Hi,

If using 'At New' is not giving you the desired result, create another internal table with same structure as the first one and append one record at a time, until one of the 3 fields changes from the previous record. Post those records that are appended into the second internal table.

Read only

Former Member
0 Likes
1,294

hi Krishna,

As your internal table is having duplicate records you can use.

delete adjacent duplicates....

to delete the duplicate entries in the internla table ..

Regards,

Jayant

Read only

Former Member
0 Likes
1,294

Hi

The data what is given is incorrect.Same data in 2 records(repetetive)

Are you talking about one header Header and mulitple Item records

Keep a Single char field first in the file (with H (header)and I (Item)values) and then do the processing of upload to post multpile item records for one single record.

Means there should be some differentiation key in the internal table to disntuinguish whether the record is a Header or Item record.

Reward points if useful

Regards

Anji

Read only

Former Member
0 Likes
1,294

HE'S RIGHT...

or you can also use

DELETE ADJACENT DUPLICATES FROM <NAME OF ITAB> COMPARING <NAME OF FIELD1>.

Read only

Former Member
0 Likes
1,294

Hi Krishna,

Use the following code after the sort statement:

DELETE ADJACENT DUPLICATES FROM itab COMPARING x1 x2 x3.

If you want to compare all fields, first sort table on all fields and then use the following satement:

DELETE ADJACENT DUPLICATES FROM itab COMPARING ALL FIELDS.

Hope it helps.

Regards,

Neeraj

Read only

Former Member
0 Likes
1,294

loop at itab.

At new x3.

"Post data using x1,x2,x3

End At.

endloop.