09-25-2014 10:06 AM
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
09-25-2014 11:56 AM
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.
09-25-2014 10:12 AM
Hi Dave,
You should set the value to selection options in 'INITIALIZATIONS' event.
regards,
Archer
09-25-2014 10:25 AM
Hi Dave,
You should give this code in INITIALIZATION.
Regards
Arun VS
09-25-2014 10:27 AM
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
09-25-2014 10:39 AM
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
09-25-2014 10:59 AM
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
09-25-2014 11:03 AM
What is the Issue now? I think you should use At selection screen Output event.
09-25-2014 11:19 AM
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
09-25-2014 11:49 AM
Hi Chirag,
Thank you, tried this and the report still hangs.
Regards
Dave
09-25-2014 11:42 AM
09-25-2014 11:48 AM
09-25-2014 11:56 AM
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.
09-25-2014 12:11 PM
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 .
09-25-2014 12:17 PM
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.
09-25-2014 12:53 PM
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
09-26-2014 7:03 AM
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 .