Quantcast
Channel: SCN: Message List - ABAP Development
Viewing all articles
Browse latest Browse all 10425

Re: Best way to process line items in an internal table?

$
0
0

Thank you for the replies everyone and sorry if I didn't make my requirement clear.

Basically I have an internal table (itab1) that has lots of documents and document line items e.g.

EBELN 1 EBELP 10

EBELN 1 EBELP 20

EBELN 2 EBELP 10

EBELN 3 EBELP 10

EBELN 3 EBELP 20

 

For each EBELN (document) I would like to process all their corresponding EBELP(lines) via  BDC.

So I'd like to extract from the internal table all the lines for each EBELN, pass them into a function module to process the BDC.

 

I've put together a messy solution:

-I loop through the internal table and add all the EBELN values to another internal table(itab2).

-I then remove duplicates from that itab2 table to then have a unique list of EBELN values.

-I then loop through this itab2 table and call another loop of the orginal table where I loop at itab1 where ebeln is the same.

I then have a third internal table where I save all the lines for that ebeln and this is what I pass to the BDC function module.

i.e.

loop at itab1.

     append itab1-ebeln to itab2.

endloop.

remove duplicates from itab2

 

loop at itab2.

     loop at itab1 where ebeln itab2-ebeln.

          append itab1 to itab3.

     endloop.

endloop.

 

perform BDC with itab3

 

It all seems to work but I'm ashamed to call myself a programmer with such a horrible verbose 'solution'.

Can anyone give tips ona  nice way to do the same thing?


Viewing all articles
Browse latest Browse all 10425

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>