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

Selction screen options problem

Former Member
0 Likes
406

Hi all,

I have a scenario where I have got three tables two std ones and the third one is the custom one bseg,bkpf and ztest, and based on three fields i.e. belnr, blart and bukrs( which is in all the three tables )to join these tables and need to retreive the following the data from each table:

From BSEG - - -> saknr,kostl

From BKPF- - - - > blart,bldat

and

From Ztest -


> co_num, co_name

Now the problem is that at the selection screen there is no field mandatory for the user to enter and the following are the different selections options:

1. from date to date

2. Account number

3. Fiscal year

4. customer name

I mean a user can just enter the start date and end date to display the report b/w that period or he can just enter the name of a particular customer to view the report, or he can just enter the account number of a particlular customer and may also enter just fiscal year to have a look at the report leaving every other thing blank !!! Now my concern is I am not being able to figure out how to code this thing...I mean in one scenario a user enters his name and left anything else blank and just execute the report ....and in the other he may leave everythng balnk other than the document number and execute the report.

Can anyone of you please tell me how to achieve this.

Thanks,

Rajeev !!!!

2 REPLIES 2
Read only

Former Member
0 Likes
362

Hi Rajeev,

Option 1:

You can use left outer joins for all the three tables to retrieve the data.

If possible try to make at least 1 field mandatory.

Option 2:

Select saknr, kostl from BSEG for all the records where saknr in s_saknr

and kostl in s_kostl.. Say it_bseg internal table has 10000 records.

Now in the second internal table by using for all entries in it_bseg select the data from bkpf where condition in

s_blart..

loop at it_bseg.

wa_final-saknr = wa_bseg-saknr...

wa_final-kostl = wa_bseg-kostl...

read it_bkpf.

sy-subrc = 0.

wa_final-blart = wa_bseg-blart....

read it_ztest.

sy-subrc = 0.

wa_co_num = wa_ztest-co_num

endloop.

Hope it helps..

THanks,

Chaithanya K

Read only

peter_ruiz2
Active Contributor
0 Likes
362

hi Rajeev,

note:

it is not advisable to retrieve data from bseg. you can use the tables BSIS and BSAS as substitute for BSEG. I assume that those are the tables that you need since you only need to retrieve the GL Account (SAKNR) and Cost Center (KOSTL) from BSEG.

another thing is that you cannot link BSEG to BKPF since BSEG is a clustered table.

anyway,

try this code


tables:
  budat,
  ztest.

select-options: us_bldat for bkpf-bldat,
                      us_hkont for bsis-hkont.

parameter up_gjahr type gjahr.

select-options us_custo for ztest-co_num.

data:
  it_bkpf type standard table of bkpf,
  it_bsis type standard table of bsis,
  it_ztest type standard table of ztest.

data:
  wa_bkpf type bkpf,
  wa_bsis type bsis,
  wa_ztest type ztest.

data:
  begin of it_otput occurs 0,
    bukrs type bukrs,
    belnr type belnr,
    blart type blart,
    bldat type bldat,    
    hkont type hkont,
    kostl type kostl,
    co_num like ztest-co_num,
    co_name like ztest-co_name,
  end of it_otput.

data:
  wa_otput like line of it_otput.

start-of-selection.
select belnr blart bldat bukrs
  from bkpf
  into corresponding fields of table it_bkpf
 where bldat in us_bldat
    and gjahr eq up_gjahr.

if not it_bkpf[] is initial.
  select belnr hkont kostl
     from bsis
     into corresponding fields of table it_bsis
      for all entries in it_bkpf
    where belnr eq it_bkpf-belnr
       and hkont in us_saknr.

  select belnr hkont kostl
     from bsas
     appending corresponding fields of table it_bsis
     for all entries in it_bkpf
     where belnr eq it_bkpf-belnr
       and hkont in us_saknr.

  select co_num co_name
    from ztest
    into corresponding fields of table ztest
    for all entries in it_bkpf
    where belnr eq it_bkpf-belnr
        and bukrs eq it_bkpf-bukrs
        and co_num in us_custo.
endif.

loop at it_bkpf into wa_bkpf.
   loop at it_bsis into wa_bsis where belnr eq wa_bkpf-belnr.
      move-corresponding wa_bkpf to wa_otput.
      
      move-corresponding wa_bsis to wa_otput.

      read table it_ztest into wa_ztest
         with key bukrs = wa_bkpf-bukrs
                      belnr = wa_bkpf-belnr
                      blart = wa_bkpf-blart.
      if sy-subrc eq 0.
         move-corresponding wa_ztest to wa_otput.
      endif.

      append wa_otput to it_otput.
      clear wa_otput.
   endloop.
endloop.

Hope this helps.

Regards,

Peter