Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8944

Re: Internal table Query

$
0
0

Hello Ventat,

Following understanding of your requirement, I would resolve it like this:

 

types: begin of In_typ,

            customer(3) type c,

  Addr(6)     type c,

       end of in_typ.

data: In_t_1         type standard table of In_typ,

      wa_1           type in_typ.

 

 

types: begin of in_typ_2,

            customer(3) type c,

            india(6)    type c,

            USA(6)      type c,

            UK(6)       type c,

       end of in_typ_2.

data: in_t_2         type standard table of in_typ_2,

        wa_2           type in_typ_2.

 

data sy_counter type i.

 

start-of-selection.

**->Sample data for testing the logic**start

wa_1-customer = '1000'.

wa_1-addr     = 'IN_201'.

append wa_1 to in_t_1.

clear wa_1.

 

wa_1-customer = '1000'.

wa_1-addr     = 'US_203'.

append wa_1 to in_t_1.

clear wa_1.

 

wa_1-customer = '1000'.

wa_1-addr     = 'UK_205'.

append wa_1 to in_t_1.

clear wa_1.

**->Sample data ** End

 

clear sy_counter.

loop at in_t_1 into wa_1.

 

      add 1 to sy_counter.

 

if wa_1-addr(2) = 'IN'.

   move:   wa_1-customer to wa_2-customer,

              wa_1-addr     to wa_2-india.

 

elseif wa_1-addr(2) = 'US'.

move:   wa_1-customer to wa_2-customer,

            wa_1-addr     to wa_2-USA.

 

elseif wa_1-addr(2) = 'UK'.

move:   wa_1-customer to wa_2-customer,

            wa_1-addr     to wa_2-UK.

endif.

 

if sy_counter = 3. " Count of 3 means I've a complete record that I can append to in_t_2.

    append wa_2 to in_t_2.

    clear sy_counter.

endif.

endloop.


Viewing all articles
Browse latest Browse all 8944

Trending Articles



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