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

selecting values into same internal table from 2 differrnt select statement

Former Member
0 Likes
826

Hi Friends,

code :


 types : 
   begin of ty_bsad,
     augbl type bsad-augbl,
  end of ty_bsad.

 begin of ty_bsad1,
     augbl type bsad-augbl,
     belnr type bsad-belnr,
  end of ty_bsad1.

  select augbl 
           from bsad
          into table it_bsad
          where belnr = l_vbeln and
                   bukrs = l_bukrs and
                  kunnr  = l_kunrg.
       if sy-subrc = 0 .

           select belnr
                     into table lt_bsad1
                     from bsad
                    for all entries in lt_bsad
                   where augbl = lt_bsad-augbl and
                            kunnr = l_kunnr  and
                            burks  = l_bukrs and
                            blart   = 'xy'.

now my requiremnt is i need to get both the augbl and belnr in single internal table but not in differnrnt internal table.

how can i get it.

Regards,

Priyanka.

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:53 AM

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
780

data: begin of it_bsad occur 0,
           augbl type bsad-augbl,
           belnr type bsad-belnr,
        end of it_bsdad.

select augbl belnr 
   from bsad
   into table it_bsad
   where belnr = l_vbeln and
            kunnr = l_kunnr and
            burks = l_bukrs and
            blart = 'xy'.
8 REPLIES 8
Read only

Former Member
0 Likes
780

hi,

create one more final internal table.

move each one into final.

thanks

vinod

Read only

0 Likes
780

Hi,

try with this code. it's just an example.



types : begin of rec_line,
         augbl type bsad-augbl,
         augbl2 type bsad-augbl,
         belnr type bsad-belnr,
        end of rec_line.
        
data : wa_line type rec_line,
       itab type standard table of rec_line.

select * from bsad where belnr = l_vbeln and bukrs = l_bukrs and
 kunnr = l_kunrg.
  clear wa_line.
  wa_line-augbl = bsad-augbl.
  select * from *bsad where augbl = bsad-augbl and kunnr = l_kunnr and
   bukrs = l_bukrs and blart = 'xy'.
   wa_line-augbl2 = *bsad-augbl.
   wa_line-belnr =  *bsad-belnr.
   append wa_line to itab.
  endselect.
 endselect. 

If you want you can optiomize it selecting only the right colums from the SELECT statement.

Bye

Andrea

Read only

Former Member
0 Likes
780

Hi Try this,


select augbl 
from bsad
into table it_bsad
where belnr = l_vbeln and
bukrs = l_bukrs and
kunnr = l_kunrg and blart = 'xy'.
if sy-subrc = 0 .

This code will work..you dont need two internal tables...

Regards

Vasavi kotha

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:55 AM

Read only

Former Member
0 Likes
780

Hi,

Use APPENDING CORRESPONDING FIELDS OF TABLE lt_bsad in the second select query.

Read only

MarcinPciak
Active Contributor
0 Likes
781

data: begin of it_bsad occur 0,
           augbl type bsad-augbl,
           belnr type bsad-belnr,
        end of it_bsdad.

select augbl belnr 
   from bsad
   into table it_bsad
   where belnr = l_vbeln and
            kunnr = l_kunnr and
            burks = l_bukrs and
            blart = 'xy'.
Read only

Former Member
0 Likes
780

Hi,

I think the below code will help u,


select augbl belnr
into table lt_bsad
from bsad
where belnr = I_vbeln and
kunnr = l_kunnr and
burks = l_bukrs and
blart = 'xy'.

I think this will work.

Thanks.

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:56 AM

Read only

Former Member
0 Likes
780

HI.

No Need to create two internal table because your feyching values from same table BSAD with diffrent where condition.try this code.it s work.


select augbl 
from bsad
into table it_bsad
where belnr = l_vbeln and
bukrs = l_bukrs and
kunnr = l_kunrg and
blart = 'xy'.

else Refer this code.


LOOP AT it_bill_data INTO wa_bill_data.
    MOVE-CORRESPONDING wa_bill_data TO wa_final_data.

    READ TABLE it_material_data INTO wa_material_data
                                WITH KEY matnr = wa_bill_data-matnr.
    IF sy-subrc = 0.
      wa_final_data-meins_mara = wa_material_data-meins.
    ENDIF.
    APPEND wa_final_data TO it_final_data.
ENDLOOP.

Regards.

Jay

Edited by: Jay on Jan 8, 2009 2:53 PM

Edited by: Jay on Jan 8, 2009 2:57 PM

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:56 AM

Read only

Former Member
0 Likes
780

hi priyanka ,

write below code it will work


move it_bsad []  to  it_bsad1 []
select belnr
from bsad
appending table lt_bsad
for all entries in lt_bsad1
where augbl = lt_bsad1-augbl and
kunnr = l_kunnr and
burks = l_bukrs and
blart = 'xy'.

try this .....

Regards ,

prem Chander

Edited by: Premchander Arumugam on Jan 8, 2009 7:37 PM

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:56 AM