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

fetching data from multiple table with select option

Former Member
0 Likes
1,369

hello experts,

I am new to abap development.

This is my requirement. I want to fetch data with the help of below three structures


types: begin of ty_bbpm_but_frg0061,

   PARTNER_GUID type BU_PARTNER_GUID,

   PURCHASE_ORG type BBP_PROC_ORG,

   end of ty_bbpm_but_frg0061.

types: BEGIN OF ty_but000,

   PARTNER type BU_PARTNER,

   PARTNER_GUID type BU_PARTNER_GUID,

   END OF ty_but000.

types: BEGIN OF ty_but100,

   partner TYPE BU_PARTNER,

   RLTYP TYPE BU_PARTNERROLE,

   END OF ty_but100.



with the selection screen

select-OPTIONS : s_org_id for wa_bbpm_but_frg0061-PURCHASE_ORG NO INTERVALS no-EXTENSION.

now the main thing is i will fetch data from ty_bbpm_but_frg0061 with reference to rest of the tables.

select PARTNER_GUID

        PURCHASE_ORG

   from bbpm_but_frg0061

   into TABLE it_bbpm_but_frg0061

   where  PURCHASE_ORG in s_org_id.

  

select partner

        partner_guid

   from but000

   into TABLE it_but000

   for ALL ENTRIES IN it_bbpm_but_frg0061

   where partner_guid = it_bbpm_but_frg0061-partner_guid.

  

select partner

        rltyp

   from but100

   into TABLE it_but100

   FOR ALL ENTRIES IN it_but000

   where partner = it_but000-partner and

   rltyp = 'bbp000'.

now the prob is my select option is not working and i am not able to filter the data extraction.

please help with the coding.

Regards,

Sarnava

5 REPLIES 5
Read only

Former Member
0 Likes
932

Hi , before select... for all entries, you need to check this internal tables in not empty

select PARTNER_GUID

        PURCHASE_ORG

   from bbpm_but_frg0061

   into TABLE it_bbpm_but_frg0061

   where  PURCHASE_ORG in s_org_id.

 

check not it_bbpm_but_frg0061[] is initial .

select partner

  partner_guid

   from but000

   into TABLE it_but000

   for ALL ENTRIES IN it_bbpm_but_frg0061

   where partner_guid = it_bbpm_but_frg0061-partner_guid.

check  not it_but000[] is initial.

select partner

        rltyp

   from but100

   into TABLE it_but100

   FOR ALL ENTRIES IN it_but000

   where partner = it_but000-partner and

   rltyp = 'bbp000'.

and run this code in debug step by step

Read only

0 Likes
932

Hello Maxim,


Thanks for your reply.

This is my coding can you please tell where i am doing wrong.


REPORT  z_avl_test.

tables: bbpm_but_frg0061.

types: begin of ty_bbpm_but_frg0061,

   PARTNER_GUID type BU_PARTNER_GUID,

   PURCHASE_ORG type BBP_PROC_ORG,

   end of ty_bbpm_but_frg0061.

types: BEGIN OF ty_but000,

   PARTNER type BU_PARTNER,

   PARTNER_GUID type BU_PARTNER_GUID,

   END OF ty_but000.

types: BEGIN OF ty_but100,

   partner TYPE BU_PARTNER,

   RLTYP TYPE BU_PARTNERROLE,

   END OF ty_but100.

data: it_bbpm_but_frg0061 type STANDARD TABLE OF ty_bbpm_but_frg0061,

       it_but000 TYPE STANDARD TABLE OF ty_but000,

       it_but100 TYPE STANDARD TABLE OF ty_but100.

data: wa_bbpm_but_frg0061 type ty_bbpm_but_frg0061,

       wa_but000 type ty_but000,

       wa_but100 type ty_but100.

INITIALIZATION.

select-OPTIONS : s_org_id for wa_bbpm_but_frg0061-PURCHASE_ORG NO INTERVALS no-EXTENSION.

select PARTNER_GUID

        PURCHASE_ORG

   from bbpm_but_frg0061

   into TABLE it_bbpm_but_frg0061

   where  PURCHASE_ORG in s_org_id.

 

check not it_bbpm_but_frg0061[] is initial .

 

select partner

        partner_guid

   from but000

   into TABLE it_but000

   for ALL ENTRIES IN it_bbpm_but_frg0061

   where partner_guid = it_bbpm_but_frg0061-partner_guid.

 

check  not it_but000[] is initial

 

select partner

        rltyp

   from but100

   into TABLE it_but100

   FOR ALL ENTRIES IN it_but000

   where partner = it_but000-partner and

   rltyp = 'bbp000'.

 

Thanks in advance,

Sarnava

Read only

0 Likes
932

before first select you need insert statement  START-OF-SELECTION

and add output results into ALV after last select

something like this:

data: gr_table  type ref to cl_salv_table.

*... Create Instance
  call method cl_salv_table=>factory
    importing
      r_salv_table = gr_table
    changing
      t_table      = it_but000


*... Display table
  gr_table->display( ).

Read only

0 Likes
932

Hi Sarnava,

Are you getting data into first 2 internal tables.?

I think this statement causing the problem


select partner

        rltyp

   from but100

   into TABLE it_but100

   FOR ALL ENTRIES IN it_but000

   where partner = it_but000-partner and

   rltyp = 'bbp000'.

it should be like this


select partner

        rltyp

   from but100

   into TABLE it_but100

   FOR ALL ENTRIES IN it_but000

   where partner = it_but000-partner and

   rltyp = 'BBP000'.

"rltyp -  should be in capital letter

Hope this helps you.

Regards,

Rama

Read only

0 Likes
932

Hi Saravana,

Delete the Initialization event and include the start-of-selection.

INITIALIZATION.

select-OPTIONS : s_org_id for wa_bbpm_but_frg0061-PURCHASE_ORG NO INTERVALS no-EXTENSION.

START-OF-SELECTION.

select PARTNER_GUID

        PURCHASE_ORG

   from bbpm_but_frg0061

   into TABLE it_bbpm_but_frg0061

   where  PURCHASE_ORG in s_org_id.

  

Arivazhagan S