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

query

Former Member
0 Likes
642

how to write the query for

picking the item del date from table eket with respect to ebeln and ebelp

and how to move output fields of 3 itab to one itb. i.e

itab1, itab2, itab3 to dtab

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
606

Please note that from EKET table you can get multiple lines for the same purchase order line...basically one po line item can have schedule defined consisting of multiple lines. Hence the key of table EKET is EBELNEBELPETENR. So you can read the table as below.

SELECT ebeln ebelp etenr eindt into tablt itab

from eket

where ebeln = pebeln and ebelp = pebelp.

Here you can receive multiple lines for a single purchase line item.

As for the second query related to 3 itab into one itab.

You can define your itab with fields from all three internal tables and follow the below code.

loop at itab1.

clear itab2.

loop at itab2 where fields = itab1-fields.

clear itab3.

loop at itab3 where fields = itab2-fields.

move-corresponding itab1 to itab.

move-corresponding itab2 to itab.

move-corresponding itab3 to itab.

append itab.

endloop.

endloop.

endloop.

The above is example where itab1->itab2->itab3 follow the hierarchy and have 1-many relationship.

4 REPLIES 4
Read only

Former Member
0 Likes
606

Hi,

if not itab[] is initial.

1) select ebeln ebelp eindt from eket into i_eket

for all entries in itab

where ebeln = itab-ebeln

and ebelp = itab-ebelp.

endif.

2) loop at itab1.

loop at itab2 where f1 = itab1-f1.

move-corresponding itab1 to itab3.

move-corresponding itab2 to itab3.

append itab3.

endloop.

endloop.

insert db form table itab3.

Regards

amole

Read only

Former Member
0 Likes
606

hi,

The following code helps you to put item and header data into a final internal table.


data:  begin of it_item occurs 0,
     vbeln like vbap-vbeln,
     posnr like vbap-posnr,
     matnr like vbap-matnr,
  end of it_item,
  begin of it_head occurs 0,
     vbeln like vbak-vbeln,
     vbtyp like vbak-vbtyp,
     auart like vbak-auart,
  end of it_head,
 
  begin of it_final occurs 0,
     vbeln like vbak-vbeln,
     vbtyp like vbak-vbtyp,
     auart like vbak-auart,
     vbeln like vbap-vbeln,
     posnr like vbap-posnr,
     matnr like vbap-matnr,
  end of it_final.
 
  loop at it_item.
    clear it_head.
    read table it_head with key vbeln = it_item-vbeln
                             binary search.
    if sy-subrc = 0.
       it_final-vbeln = it_head-vbeln.
       it_final-vbtyp = it_head-vbtyp.
       it_final-auart = it_head-auart.
    endif.
    it_final-posnr = it_item-posnr.
    it_final-matnr = it_item-matnr.
    append it_final.
    clear it_final.
  endloop.

Regards,

Sailaja.

Read only

Former Member
0 Likes
607

Please note that from EKET table you can get multiple lines for the same purchase order line...basically one po line item can have schedule defined consisting of multiple lines. Hence the key of table EKET is EBELNEBELPETENR. So you can read the table as below.

SELECT ebeln ebelp etenr eindt into tablt itab

from eket

where ebeln = pebeln and ebelp = pebelp.

Here you can receive multiple lines for a single purchase line item.

As for the second query related to 3 itab into one itab.

You can define your itab with fields from all three internal tables and follow the below code.

loop at itab1.

clear itab2.

loop at itab2 where fields = itab1-fields.

clear itab3.

loop at itab3 where fields = itab2-fields.

move-corresponding itab1 to itab.

move-corresponding itab2 to itab.

move-corresponding itab3 to itab.

append itab.

endloop.

endloop.

endloop.

The above is example where itab1->itab2->itab3 follow the hierarchy and have 1-many relationship.

Read only

Former Member
0 Likes
606

hi

good

Query->

Select EINDT from EKET into corresponding fields of table itab where ebeln EQ table name AND ebelp EQ tablename.

thanks

mrutyun^