2009 Jun 08 12:48 PM
Hi,this is my code
selection-screen begin of block b_selection with frame title text-001.
SELECT-OPTIONS: s_belnr for rbkp-belnr, "Invoice number
s_gjahr for rbkp-gjahr NO-EXTENSION NO INTERVALS, "Fiscal year
s_stat for rbkp-rbstat OBLIGATORY NO-EXTENSION DEFAULT c_status, "Invoice status
s_blart for rbkp-blart OBLIGATORY DEFAULT c_doc_type, "Document type
s_lifnr for rbkp-lifnr. "Vendor
selection-screen end of block b_selection.
at selection-screen.
select belnr gjahr from rbkp into table i_inv_data
where belnr IN s_belnr
and gjahr IN s_gjahr
and blart IN s_blart
and rbstat IN s_stat.
and lifnr IN s_lifnr.
if i_inv_data[] is initial.
message e000 with 'No record matching the search criteria'(001).
endif.
This is working fine...now when I try to modularise it, it is nt working
selection-screen begin of block b_selection with frame title text-001.
SELECT-OPTIONS: s_belnr for rbkp-belnr, "Invoice number
s_gjahr for rbkp-gjahr NO-EXTENSION NO INTERVALS, "Fiscal year
s_stat for rbkp-rbstat OBLIGATORY NO-EXTENSION DEFAULT c_status, "Invoice status
s_blart for rbkp-blart OBLIGATORY DEFAULT c_doc_type, "Document type
s_lifnr for rbkp-lifnr. "Vendor
selection-screen end of block b_selection.
at selection-screen.
perform sub_validate_data.
FORM SUB_VALIDATE_DATA.
select belnr gjahr from rbkp into table i_inv_data
where belnr IN s_belnr
and gjahr IN s_gjahr
and blart IN s_blart
and rbstat IN s_stat.
and lifnr IN s_lifnr.
if i_inv_data[] is initial.
message e000 with 'No record matching the search criteria'(001).
endif.
*
ENDFORM. " SUB_VALIDATE_DATA
the error which I m getting is ' IN s_belnr should be followd by an internal table'Please tell how can I modularize this code and put the checking part in subroutine
2009 Jun 08 12:52 PM
at selection-screen.
perform sub_validate_data.
end of selection-screen.
FORM SUB_VALIDATE_DATA.
select belnr gjahr from rbkp into table i_inv_data
where belnr IN s_belnr
and gjahr IN s_gjahr
and blart IN s_blart
and rbstat IN s_stat. (" this full stop should not be present here)
and lifnr IN s_lifnr.
if i_inv_data[] is initial.
message e000 with 'No record matching the search criteria'(001).
endif.
*
ENDFORM. " SUB_VALIDATE
2009 Jun 08 1:01 PM
Except the period, the code seems ok'
tables: rbkp.
data: begin of i_inv_data occurs 0,
belnr like rbkp-belnr,
gjahr like rbkp-gjahr,
end of i_inv_data.
selection-screen begin of block b_selection with frame title text-001.
SELECT-OPTIONS: s_belnr for rbkp-belnr,
s_gjahr for rbkp-gjahr NO-EXTENSION NO INTERVALS,
s_stat for rbkp-rbstat OBLIGATORY NO-EXTENSION,
s_blart for rbkp-blart OBLIGATORY,
s_lifnr for rbkp-lifnr.
selection-screen end of block b_selection.
at selection-screen.
perform sub_validate_data.
*&--------------------------------------------------------------------*
*& Form SUB_VALIDATE_DATA
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM SUB_VALIDATE_DATA.
select belnr gjahr from rbkp into table i_inv_data
where belnr IN s_belnr
and gjahr IN s_gjahr
and blart IN s_blart
and rbstat IN s_stat "Remove the dot here
and lifnr IN s_lifnr.
if i_inv_data[] is initial.
* message e000 with 'No record matching the search criteria'(001).
endif.
ENDFORM. " SUB_VALIDATE_DATA
2009 Jun 08 1:03 PM
Hi
There is no syntax error in my code...it was just during typing in sdn the period got missed...can anyone make out something else...as even I dnt know whwere the error lies???
2009 Jun 08 1:10 PM
Error:
-the error which I m getting is ' IN s_belnr should be followd by an internal table-
-There is no syntax error in my code-
.
are u getting errors or not.????
2009 Jun 08 1:14 PM
I forgot to mention 1 thin..this form routine is in another include ztest_subroutine which is a include for forms
2009 Jun 08 1:18 PM
The problem is of events.
You cannot use select statement in the event at selection-screen..Its used for authority check.You have to write ur query in Start-of-selection event.
2009 Jun 08 1:30 PM
>
> I forgot to mention 1 thin..this form routine is in another include ztest_subroutine which is a include for forms
Hello Priya,
Please share all the details of your code for a better analysis. I donot find any INCLUDE stmts in the code you have shared.
Plz revert back with the details.
@Vijetasap: Please get your basics clear. From which source have you learnt that we cannot use SELECT stmts in AT SLECTION-SCREEN event?
BR,
Suhas
Edited by: Suhas Saha on Jun 8, 2009 2:30 PM
2009 Jun 08 8:37 PM
vijetasap wrote:
The problem is of events.
You cannot use select statement in the event at selection-screen..Its used for authority check.You have to write ur query in Start-of-selection event.
This is not true. I have numerous programs where I do SELECT in the AT SELECTION-SCREEN event without any such problem. And I verified this just now, looking at the code for various programs that use similar logic.
In most cases, these SELECT statements are done in subroutines in INCLUDES that are called from the AT SELECTION-SCREEN event, just as the original poster is doing here.
AT SELECTION-SCREEN is used for edits of ALL kinds, including validating against the database (using SELECT), not just authority check as suggested in the quote above.
The problem must lie elsewhere. I suspect that the problem is the placement of the INCLUDE, as Syed Abdul Adil noted in the previous post.
The INCLUDE should be placed after the definition of the selection screen and the various screen events.
Brian Sammond
Edited by: Brian Sammond on Jun 8, 2009 3:39 PM
Correct spelling, add poster's name who made INCLUDE suggestion originally
2009 Jun 08 9:08 PM
Declare your selection screen in the top include of the program. This should solve your problem. A top include is visible to all the other includes of the program.
Alternatively, pass the select options as using parameters to the subroutine. That is how you should modularize your code in order to make the code callable from different programs.
regards,
Edited by: Advait Gode on Jun 8, 2009 10:08 PM
2009 Jun 08 1:03 PM
If I remove the period after s_stat your code is compiling without problems:
SELECTION-SCREEN BEGIN OF BLOCK b_selection WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_belnr FOR rbkp-belnr,
s_gjahr FOR rbkp-gjahr NO-EXTENSION NO INTERVALS,
s_stat FOR rbkp-rbstat OBLIGATORY NO-EXTENSION DEFAULT 'X',
s_blart FOR rbkp-blart OBLIGATORY DEFAULT 'X',
s_lifnr FOR rbkp-lifnr.
SELECTION-SCREEN END OF BLOCK b_selection.
AT SELECTION-SCREEN.
PERFORM sub_validate_data.
*&---------------------------------------------------------------------*
*& Form SUB_VALIDATE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_validate_data.
SELECT belnr gjahr FROM rbkp INTO TABLE i_inv_data
WHERE belnr IN s_belnr
AND gjahr IN s_gjahr
AND blart IN s_blart
AND rbstat IN s_stat
AND lifnr IN s_lifnr.
IF i_inv_data[] IS INITIAL.
MESSAGE e000(oo) WITH 'No record matching the search criteria'(001).
ENDIF.
*
ENDFORM. " SUB_VALIDATE_DATA
Check, if you have an additional period somewhere else, or any other subtle differenec.
Michael
2009 Jun 08 1:32 PM
Hi,
code is O.k.
I think in SELECT command you can check.
and rbstat IN s_stat.
and lifnr IN s_lifnr.
in this only one statement is possible.
2009 Jun 08 1:44 PM
Place the include after selection screen declaration and check.
SELECTION-SCREEN BEGIN OF BLOCK b_selection WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_belnr FOR rbkp-belnr, "Invoice number
s_gjahr FOR rbkp-gjahr NO-EXTENSION NO INTERVALS, "Fiscal year
s_stat FOR rbkp-rbstat OBLIGATORY NO-EXTENSION, "Invoice status
s_blart FOR rbkp-blart OBLIGATORY, "Document type
s_lifnr FOR rbkp-lifnr. "Vendor
SELECTION-SCREEN END OF BLOCK b_selection.
INCLUDE <ZINCLUDE>. " sub_validate_data
AT SELECTION-SCREEN.
PERFORM sub_validate_data.
@aadil