Application Development 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: 

Auto-populate values in selection screen of report

Former Member
0 Kudos

Hi Experts,

I have created a query and depending on user selection in the report, some document numbers are populated into an internal table it_bkpf. I'd like these document numbers to be auto-populated in to the selection screen when the report is executed. Selection field dn relates to bseg-belnr. I've created some code below which doesn't work, it's at section AT SELECTION-SCREEN. All my other coding is at START-OF-SELECTION and works ok.

loop at it_bkpf into wa_bkpf.
     dn-low = wa_bkpf-belnr.
     dn-option = 'EQ'.
     dn-sign = 'I'.
     append dn.
     endloop.


Please can someone advise where I'm going wrong?


Kind regards


Dave

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Dave ,

You should modify the code as shown below and write the code in

AT SELECTION SCREEN OUTPUT .

Here is the modified code ....

INITIALIZATION.

if po[] is not initial.

READ TABLE PO Index 1.

   select ebeln gjahr belnr from ekbe

   into corresponding fields of table it_ekbe

   where ebeln = po-low

     and vgabe ne '9'.

   loop at it_ekbe into wa_ekbe.

     concatenate wa_ekbe-belnr wa_ekbe-gjahr into wa_ekbe-awkey.

     modify it_ekbe from wa_ekbe transporting awkey.

   endloop.

   select belnr from bkpf

     into corresponding fields of table it_bkpf

     for all entries in it_ekbe

     where awkey = it_ekbe-awkey

     and bukrs = '1000'

     and ( awtyp = 'MKPF' or awtyp = 'RMRP' ).

endif.


AT SELECTION SCREEN OUTPUT .

loop at it_bkpf into wa_bkpf.

   dn-low = wa_bkpf-belnr.

   dn-option = 'EQ'.

   dn-sign = 'I'.

   append dn.

endloop.

15 REPLIES 15

Former Member
0 Kudos

Hi Dave,

You should set the value to selection options in 'INITIALIZATIONS' event.

regards,

Archer

venuarun
Active Participant
0 Kudos

Hi Dave,

You should give this code in INITIALIZATION.

Regards

Arun VS

Former Member
0 Kudos

Hi,

you could try to work in this way:

.......

INITIALIZATION.

perform manage_data.

..............

START-OF-SELECTION.

form manage_data.

loop at it_bkpf into wa_bkpf.
     dn-low = wa_bkpf-belnr.
     dn-option = 'EQ'.
     dn-sign = 'I'.
     append dn.
endloop.


endform manage_data.

Regards

Ivan

0 Kudos

Hi Dave,

As Dengyong said, write your code in INITIALIZATION event. It works.

See this demo piece of code.

INITIALIZATION.

   SELECT BUKRS BELNR GJAHR BUDAT MONAT

          FROM BKPF

          INTO TABLE IT_BKPF

          WHERE BELNR BETWEEN 7600000000 AND 7600000010.

   LOOP AT IT_BKPF INTO WA_BKPF.

     BELNR-LOW = WA_BKPF-BELNR.

     BELNR-SIGN = 'I'.

     BELNR-OPTION = 'EQ'.

     APPEND BELNR.

   ENDLOOP.


Regards-

Chirag Keswani

0 Kudos

Hi,

Many thanks for the replies everyone. I've tried putting all my code in Initialization but the report still hangs. The user enters a PO number (po-low) at the selection screen, is this causing the problem?

INITIALIZATION.

if po-low is not initial.
   select ebeln gjahr belnr from ekbe
   into corresponding fields of table it_ekbe
   where ebeln = po-low
     and vgabe ne '9'.

   loop at it_ekbe into wa_ekbe.
     concatenate wa_ekbe-belnr wa_ekbe-gjahr into wa_ekbe-awkey.
     modify it_ekbe from wa_ekbe transporting awkey.
   endloop.

   select belnr from bkpf
     into corresponding fields of table it_bkpf
     for all entries in it_ekbe
     where awkey = it_ekbe-awkey
     and bukrs = '1000'
     and ( awtyp = 'MKPF' or awtyp = 'RMRP' ).

endif.


loop at it_bkpf into wa_bkpf.
   dn-low = wa_bkpf-belnr.
   dn-option = 'EQ'.
   dn-sign = 'I'.
   append dn.
endloop.



Regards


Dave

0 Kudos

What is the Issue now? I think you should use At selection screen Output event.

0 Kudos

Hi Dave,

Write the code this way:

INITIALIZATION.

if po-low is not initial.

   select ebeln gjahr belnr from ekbe

   into corresponding fields of table it_ekbe

   where ebeln = po-low

     and vgabe ne '9'.

   loop at it_ekbe into wa_ekbe.

     concatenate wa_ekbe-belnr wa_ekbe-gjahr into wa_ekbe-awkey.

     modify it_ekbe from wa_ekbe transporting awkey.

   endloop.

   select belnr from bkpf

     into corresponding fields of table it_bkpf

     for all entries in it_ekbe

     where awkey = it_ekbe-awkey

     and bukrs = '1000'

     and ( awtyp = 'MKPF' or awtyp = 'RMRP' ).

endif.


INITIALIZATION.

loop at it_bkpf into wa_bkpf.

   dn-low = wa_bkpf-belnr.

   dn-option = 'EQ'.

   dn-sign = 'I'.

   append dn.

endloop.


Regards-

Chirag Keswani

0 Kudos

Hi Chirag,

Thank you, tried this and the report still hangs.

Regards

Dave

Former Member
0 Kudos

check this, ekbe does not contain field awkey

0 Kudos

Thanks, but I created the field in my table it_ekbe.

Former Member
0 Kudos

Hi Dave ,

You should modify the code as shown below and write the code in

AT SELECTION SCREEN OUTPUT .

Here is the modified code ....

INITIALIZATION.

if po[] is not initial.

READ TABLE PO Index 1.

   select ebeln gjahr belnr from ekbe

   into corresponding fields of table it_ekbe

   where ebeln = po-low

     and vgabe ne '9'.

   loop at it_ekbe into wa_ekbe.

     concatenate wa_ekbe-belnr wa_ekbe-gjahr into wa_ekbe-awkey.

     modify it_ekbe from wa_ekbe transporting awkey.

   endloop.

   select belnr from bkpf

     into corresponding fields of table it_bkpf

     for all entries in it_ekbe

     where awkey = it_ekbe-awkey

     and bukrs = '1000'

     and ( awtyp = 'MKPF' or awtyp = 'RMRP' ).

endif.


AT SELECTION SCREEN OUTPUT .

loop at it_bkpf into wa_bkpf.

   dn-low = wa_bkpf-belnr.

   dn-option = 'EQ'.

   dn-sign = 'I'.

   append dn.

endloop.

0 Kudos

Hi,

Above code will work first time , but if we change the value again on selection screen , it will not work. Write your logic in AT SELECTION SCREEN OUTPUT .

0 Kudos

Hi Dave ,

You should modify the code as shown below and write the code in

AT SELECTION SCREEN OUTPUT .

Here is the modified code ....

AT SELECTION SCREEN OUTPUT . 

refresh it_bkpf[] .

if po[] is not initial.

READ TABLE PO Index 1.

   select ebeln gjahr belnr from ekbe

   into corresponding fields of table it_ekbe

   where ebeln = po-low

     and vgabe ne '9'.

   loop at it_ekbe into wa_ekbe.

     concatenate wa_ekbe-belnr wa_ekbe-gjahr into wa_ekbe-awkey.

     modify it_ekbe from wa_ekbe transporting awkey.

   endloop.

   select belnr from bkpf

     into corresponding fields of table it_bkpf

     for all entries in it_ekbe

     where awkey = it_ekbe-awkey

     and bukrs = '1000'

     and ( awtyp = 'MKPF' or awtyp = 'RMRP' ).


loop at it_bkpf into wa_bkpf.

   dn-low = wa_bkpf-belnr.

   dn-option = 'EQ'.

   dn-sign = 'I'.

   append dn.

endloop.

endif.


0 Kudos

Hi Rohit,

Thank you very much that works! Is there any way to make it work without having to press enter after PO number is entered? I'd like to stop users executing the transaction before they've pressed enter, as this makes the report hang.

Thanks for your help.

Regards

Dave

0 Kudos

Hi Dave ,

It is possible .

You can use AT SELECTION SCREEN ON FIELD <F1> event .

Write the logic like this :

AT SELECTION SCREEN ON FIELD PO-LOW .

IF PO-LOW  IS NOT VALID .  " WRITE THE LOGIC FOR VALIDATION OF PO .

MESSAGE "ENTER THE CORRECT PO"  TYPE 'E'.

ELSE .

CALL TRANSACTION 'xyz' . "call the the required transaction .

ENDIF .