Selection Fields won't Select in custom report

Question:
I have created a report (my first) in ABAP. We are using 470.
On the whole, the report works, but some of the selection fields do not work.
I have searched
and help.sap.com but to no avail, and not having my ABAP team all week is rather a hindrance.
The Selection screen is as I wish, and you can F4 to look up all the available fields for the cell.
When the report is run, it displays everything for the selection of company code, customer number and dunning procedures.
I wish to be able to restrict these items further, by dunning level, dunning block and last dunned date, but these fields are not being taken into account at the selection stage in the program.
I feel there may be a problem with my select statement, although not being trained in ABAP is a disadvantage.
I have attached the code, in the hope that someone can correct me on my bad attempt at programming.
I look forward to reading your responses.
*&---------------------------------------------------------------------*
*& Report ZDEBT *
*& *
*&---------------------------------------------------------------------*
*& *
*& DEVELOPER: Barry Neaves DATE: 12-Jan-2004 *
*& TRANSPORT NO: DV1K907984 *
*& DESCRIPTION: New Program for reporting on Dunning/Debt Recovery. *
*& *
*&---------------------------------------------------------------------*
*Set style, tables for look up, creation of temporary table & constants
REPORT zdebt NO STANDARD PAGE HEADING.
TABLES: bsid,
kna1,
knb5,
vbrp.
DATA: BEGIN OF idat OCCURS 0,
bukrs LIKE bsid-bukrs,
kunnr LIKE bsid-kunnr,
blart LIKE bsid-blart,
mahna LIKE knb5-mahna,
mansp LIKE knb5-mansp,
mahns LIKE knb5-mahns,
xblnr LIKE bsid-xblnr,
vbeln LIKE vbrp-vbeln,
bldat LIKE bsid-bldat,
sgtxt LIKE bsid-sgtxt,
wrbtr LIKE bsid-wrbtr,
name1 LIKE kna1-name1,
gjahr LIKE bsid-gjahr,
vkgrp LIKE vbrp-vkgrp,
vkbur LIKE vbrp-vkbur,
shkzg LIKE bsid-shkzg,
zterm LIKE bsid-zterm,
mansp1 LIKE bsid-mansp,
belnr LIKE bsid-belnr,
END OF idat.
DATA: sum LIKE bsid-wrbtr,
total LIKE bsid-wrbtr,
record_count TYPE n.
*Selection screen fields -> goto->text elements->selection texts
*obligatoty function makes selection field mandatory
*Start-of-selection-----------------------------------------------------
START-OF-SELECTION.
SELECT-OPTIONS co_code FOR bsid-bukrs." OBLIGATORY.
SELECT-OPTIONS customer FOR bsid-kunnr." OBLIGATORY.
SELECT-OPTIONS dun_prc FOR knb5-mahna." OBLIGATORY.
SELECT-OPTIONS dun_blk FOR knb5-mansp.
SELECT-OPTIONS dun_lvl FOR knb5-mahns.
SELECT-OPTIONS sls_grp FOR vbrp-vkgrp.
SELECT-OPTIONS sls_off FOR vbrp-vkbur.
SELECT-OPTIONS doc_type FOR bsid-blart.
SELECT-OPTIONS blne_dte FOR bsid-bldat.
SELECT-OPTIONS blk_dun FOR bsid-mansp.
SELECT-OPTIONS lvl_dun FOR bsid-manst.
*Parameters-------------------------------------------------------------
PARAMETER max_recs LIKE record_count.
*Initialisation---------------------------------------------------------
INITIALIZATION.
record_count = 0.
max_recs = 1000.
*Create report headers and position on page
*Top-of-page------------------------------------------------------------
TOP-OF-PAGE.
WRITE: /1 sy-title,
50 'Date:',
sy-datum,
70 'Page No.',
sy-pagno.
ULINE.
WRITE: /1 'Customer No.',
15 'Name',
50 'Billing Number',
65 'Date',
85 'Amount',
98 'Doc',
105 'Text'.
ULINE.
*Select fields, table joins, selection fields and extract to temporary
*idat table
*Start-of-Selection-----------------------------------------------------
START-OF-SELECTION.
CLEAR: idat.
SELECT bsid~kunnr bsid~bukrs bsid~wrbtr bsid~bldat bsid~blart
bsid~mansp knb5~mansp knb5~mahna kna1~name1 bsid~shkzg
vbrp~vkgrp vbrp~vkbur bsid~sgtxt vbrp~vbeln bsid~zterm
bsid~xblnr bsid~belnr
INTO CORRESPONDING FIELDS OF TABLE idat
FROM ( bsid INNER JOIN knb5 ON bsid~kunnr = knb5~kunnr
INNER JOIN kna1 ON bsid~kunnr = kna1~kunnr
LEFT OUTER JOIN vbrp ON bsid~vbeln = vbrp~vbeln )
WHERE bsid~kunnr IN customer
AND bsid~bukrs IN co_code
AND knb5~mahna IN dun_prc
AND knb5~mansp IN dun_lvl
AND knb5~mahns IN dun_blk
AND bsid~blart IN doc_type
AND bsid~bldat IN blne_dte
AND bsid~mansp IN lvl_dun
AND bsid~manst IN blk_dun
*Sort table by customer number
ORDER BY bsid~kunnr ASCENDING.
*remove duplicate records
clear: idat.
DELETE ADJACENT DUPLICATES
FROM idat
COMPARING ALL FIELDS.
* kunnr xblnr vbeln belnr bukrs bldat sgtxt zterm.
CLEAR: idat.
LOOP AT idat.
IF sy-subrc = 0.
record_count = record_count + 1.
ENDIF.
*Show credit value as credit amount
IF idat-shkzg = 'S'.
idat-wrbtr = idat-wrbtr.
ELSE.
idat-wrbtr = ( idat-wrbtr * -1 ).
MODIFY idat TRANSPORTING wrbtr.
ENDIF.
*if an RA or IN Invoice copy accounting document number to billing
*document field
IF idat-blart E 'DC'.
idat-vbeln = idat-belnr.
ELSE.
idat-vbeln = idat-vbeln.
MODIFY idat TRANSPORTING vbeln.
ENDIF.
*Hotspot for drill down
FORMAT HOTSPOT ON.
WRITE:/1 idat-kunnr, 15 idat-name1, 50 idat-vbeln, 65 idat-bldat,
80 idat-wrbtr, 100 idat-blart, 105 idat-sgtxt.
HIDE: idat-bukrs, idat-gjahr, idat-kunnr.
FORMAT HOTSPOT OFF.
*Subtotal by customer number
AT END OF kunnr.
SUM.
WRITE: /'Customer Total', 80 idat-wrbtr.
ULINE.
CLEAR: sum.
ENDAT.
*In the last Loop run, final total
AT LAST.
SUM.
WRITE: /'Overall Total:', 80 idat-wrbtr.
ENDAT.
ENDLOOP.
*Call FBL5N, enter customer number and company code
*At Line-Selection------------------------------------------------------
AT LINE-SELECTION.
SET PARAMETER ID 'KUN' FIELD idat-kunnr.
SET PARAMETER ID 'BUK' FIELD idat-bukrs.
CALL TRANSACTION 'FBL5N' AND SKIP FIRST SCREEN.
Answer:
Maybe .... :
****************************
Left outer join between table 1 and table 2 where column D sets
the join condition.
Tabelle 1 Tabelle 2
A B C D D E F G H
a1 b1 c1 1 1 e1 f1 g1 h1
a2 b2 c2 1 3 e2 f2 g2 h2
a3 b3 c3 2 4 e3 f3 g3 h3
a4 b4 c4 3
\ /
\ /
\ /
\ /
\/
Left Outer Join
A B C D D E F G H
a1 b1 c1 1 1 e1 f1 g1 h1
a2 b2 c2 1 1 e1 f1 g1 h1
a3 b3 c3 2 NULL NULL NULL NULL NULL
a4 b4 c4 3 3 e2 f2 g2 h2
Note When you use a left outer join in the FROM clause of a SELECT
command, it makes a crucial difference whether the logical
condition is in the ON or the WHERE clause. Since not all of
the database systems supported by SAP themselves support the
standard syntax and semantics of the left outer join, the
syntax has been restricted to those cases that return the same
solution in all database systems:
1. Only a table or view may come after the JOIN statement, not
another join expression
2. The only logical operator allowed in the ON condition is AND
3. Each comparison in the ON comdition must contain a field
from the right-hand table
4. Comparisons in the WHERE condition may not contain fields
from the right-hand table
5. You can only use EQ (or =) as comparisons in the ON
condition
6. The ON condition must contain at least one "real" JOIN
condition (a condition containing a field from both tabref1
and tabref2)
*********************************
Hope it will be helpfull.
JLG
Answer:
After relooking at the code this morning, I have transposed my selection fields with the wrong fields.
I have reset them and it has worked..
I'm just glad i'm not a "Programmer" or I'd be in reciept of my P45 by now....
Thanks for your help JLG_odesse
I have kept those points to refer to again as they were useful.
Answer:
I'm just glad i'm not a "Programmer" or I'd be in reciept of my P45 by now....
Oh but you are....... you've just joined the ranks by writing your first ABAP!!
_________________
Regards
R
Abap KC

SFMDR

Answer:
I'm just glad i'm not a "Programmer" or I'd be in reciept of my P45 by now....
Oh but you are....... you've just joined the ranks by writing your first ABAP!!
It's an insiduous culture... and once you're in, you can't ever get out!
_________________
Kind Regards
Rosie Brent
Please remember to search the forum and check the FAQ before posting questions, thank you.
Tuly Idiot most of the time, part-time Guru

More Articles:

PO changes , imp?
GRID Formatting?
Program, missing authority check?
link between material and classifacion value?
ENTER function is activated, unwantedly.?
check start-date and end-date between periods entered?