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 needed to retreive data

Former Member
0 Likes
1,759

Hello,

There is Selection Screen where it allows to enter KUNNR, LAND1 and VBELN.

I want to display below fields from table specified.

VBELN, FKART, FKDAT WAERK, KUNRG, KUNWE from VBRK Table, BSTNK, VBELN, AUART from VBAK Table, POSNR, MATNR, FKIMG, WAVWR from VBRP Table, KBETR from KOMV and MWSBP from KOMP.

So i need to find out query to display above fields data as output as per input in selection screen. default values if nothing entered in Selection screen are all data.

Please help me with Program or Query to retrieve above data.

Thanks,

1 ACCEPTED SOLUTION
Read only

pintoo_d
Participant
0 Likes
1,656

KONV table has field KBETR, and you can find MWSBP in VBRK (MWSBK). since they are not transparent tables. you need some common fields to fetch data frm konv. Field "knumv" is common to them.

regarding query, create internal table separately for each table.

At item level, fetch data from VBRP.

then proceed with other table with keyword "FOR ALL ENTRIES IN i_vbrp".

once you done with that, move ur data final internal table will have all details.

Thank You,

Pintoo D

Hello,

There is Selection Screen where it allows to enter KUNNR, LAND1 and VBELN.

I want to display below fields from table specified.

VBELN, FKART, FKDAT WAERK, KUNRG, KUNWE from VBRK Table, BSTNK, VBELN, AUART from VBAK Table, POSNR, MATNR, FKIMG, WAVWR from VBRP Table, KBETR from KOMV and MWSBP from KOMP.

So i need to find out query to display above fields data as output as per input in selection screen. default values if nothing entered in Selection screen are all data.

Please help me with Program or Query to retrieve above data.

Thanks,

10 REPLIES 10
Read only

former_member156446
Active Contributor
0 Likes
1,656

hi New

lets see what you can write first.. If you have any question then get back to forum..

Read only

0 Likes
1,656

If there was single table, i could have done that

for eg. Select vbeln fkart fkdat waerk from vbrk into table <internal table name> where kunrg in <selection screen parameter name>

But i m not sure of joining more than one tables and then fetching.

I would rather look for syntax not complete solution though.

Read only

Former Member
0 Likes
1,656

Well... you seem to be new to ABAP.. hope this helps.....


select VBELN, FKART, FKDAT WAERK, KUNRG, KUNWE
from vbrk
into table t_vbrk
where vbeln = s_vbeln. " given in selection screen
if sy-subrc = 0.
endif.

select BSTNK, VBELN, AUART 
from vbak
into table t_vbak
where vbeln = s_vbeln.
if sy-subrc = 0.
endif.

Similarly write the other select queries as well.

Its very useful if you pass the key fields while selecting from the database. Helps in faster processing.

Regards.

Read only

0 Likes
1,656

Make sure that the order of the fields is same as in the data base table, and in the internal table.

And remove the commas as well.

Regards.

Read only

Former Member
0 Likes
1,656

Hi ,

First make an internal table as it_final having all the req fields

second make it_vbrk, it_vbak, it_vbrp, it_komv, it_komp internal tables with required fields.

third, Open ddic tables & find out relations among all the tables,

fourth, now select data from tables into internal tables based on conditions,

and use for all entries to fill it_final table...

Try this, your logic will enhance........

Thanks & Regards,

Krishna..

Read only

Former Member
0 Likes
1,656

Hi ,

First make an internal table as it_final having all the req fields

second make it_vbrk, it_vbak, it_vbrp, it_komv, it_komp internal tables with required fields.

third, Open ddic tables & find out relations among all the tables,

fourth, now select data from tables into internal tables based on conditions,

and use for all entries to fill it_final table...

Try this, your logic will enhance........

Thanks & Regards,

Krishna..

Read only

Former Member
0 Likes
1,656

Hi,

I'm not going to help you with the code as Jay rightly said. for that you can use F1 on select queries. Once you find how to join tables, you can join tables VBRK and VBRP, then in the VBRP-AUBEL you will get the Sales order order number, using that you can fetch data from VBAK.

And KOMP is not a transparent table. So you might need to use some other table.

regards,

Advait

Read only

0 Likes
1,656

Any suggestion or idea as what needs to be done ??

jusst logic.

Read only

0 Likes
1,656

If you want to find the prices of the sales order,using the VBAK-KNUMH you can fetch data from KONV table.

regards,

Advait

Read only

pintoo_d
Participant
0 Likes
1,657

KONV table has field KBETR, and you can find MWSBP in VBRK (MWSBK). since they are not transparent tables. you need some common fields to fetch data frm konv. Field "knumv" is common to them.

regarding query, create internal table separately for each table.

At item level, fetch data from VBRP.

then proceed with other table with keyword "FOR ALL ENTRIES IN i_vbrp".

once you done with that, move ur data final internal table will have all details.

Thank You,

Pintoo D