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: 

How to do the Validations in Report Programming?

Former Member
0 Kudos

How to do the Validations in Report Programming?

how to do screen Validations and Field Validations if posssible can any one send the code regarding the Validation ....

Tks

Durusoju

7 REPLIES 7

Former Member
0 Kudos

hi,

u can do the validattion like this.

PROCESS AFTER INPUT.

FIELD wa_weight-order_no MODULE validate_order.

&----


*& Module VALIDATE_ORDER INPUT

&----


  • Validate the Order number

----


MODULE validate_order INPUT.

IF NOT wa_weight-order_no IS INITIAL.

************************************************************

PERFORM conv_exit USING wa_weight-order_no.

************************************************************

IF r1 = 'X' AND r3 = 'X'.

CLEAR v_order.

SELECT ebeln UP TO 1 ROWS FROM ekpo INTO v_order

WHERE ebeln = wa_weight-order_no AND

( matkl = '0110001' OR

matkl = '0210005' OR

matkl = '0310010' OR

matkl = '1126301' OR

matkl = '1026202' OR

matkl = '1026203' OR

matkl = '1026204' OR

matkl = '1026205' OR

matkl = '1026206' OR

matkl = '1026207' OR

matkl = '1026208' OR

matkl = '1026209' OR

matkl = '1026210' OR

matkl = '1026211' OR

matkl = '1026231' OR

matkl = '1026251' OR

matkl = '1026270' OR

matkl = '1026275' OR

matkl = '1026290' OR

matkl = '1026292' OR

matkl = '0437501' ).

ENDSELECT.

IF sy-subrc NE 0.

MESSAGE i027(zwb).

CLEAR wa_weight-order_no.

ENDIF.

ELSEIF r1 = 'X' AND r4 = 'X'.

CLEAR v_order.

SELECT ebeln UP TO 1 ROWS FROM ekpo INTO v_order

WHERE ebeln = wa_weight-order_no AND

( matkl = '0110001' OR

matkl = '0210005' ).

ENDSELECT.

IF sy-subrc NE 0.

MESSAGE i027(zwb).

CLEAR wa_weight-order_no.

ENDIF.

ELSEIF r2 = 'X' AND r3 = 'X'.

CLEAR v_order.

SELECT vbeln UP TO 1 ROWS FROM lips INTO v_order

WHERE vbeln = wa_weight-order_no AND

( mtart = 'FERT' OR mtart = 'FGNV' ).

ENDSELECT.

IF sy-subrc NE 0.

MESSAGE i027(zwb).

CLEAR wa_weight-order_no.

ENDIF.

ENDIF.

ENDIF.

ENDMODULE. " VALIDATE_ORDER INPUT

Reward points if helpful,

Regards,

Sumanjeet

Former Member
0 Kudos

hello phani,

we can validate the screen valitadtyion events like.

1) At selection-screen.

2) At selection-screen on filed .

3) At selection-screen on value request.

4) At selection-screen on output filed .

like this we have some events for validating. check those events u will get it....

ok fine all the best

try those .

Lakshmant1
Active Contributor
0 Kudos

Hi Phani,

Have a look at demo programs

DEMO_SELECTION_SCREEN_EVENTS

DEMO_DYNPRO_VALUE_SELECT

Hope this helps

Thanks

Lakshman

p244500
Active Contributor
0 Kudos

hai

u can validate the report using like this....

after the selection-option used this

1) At selection-screen.

2) At selection-screen on filed .

3) At selection-screen on value request.

4) At selection-screen on output filed .

Ex:

selection-screen begin of block b1.

parameters: p_datum1 type sy-datum,

p_datum2 type sy-datum.

selection-screen end of block b1.

at selection-screen on block b1.

if p_datum1 is initial

and p_datum2 is initial.

message e001(00) with 'Enter at least one date'.

endif.

regard

nawa

Former Member
0 Kudos

hi phani ,

i can tell you the field validations,i am not sure about screen validations in report programming,

In the "Initialization "event you can initialize the fields :

We can initialize the selection-screen with calculated default values under this event.

Initialization.

s_date-high = sy-datum.

s_date-low = sy-datum - 15.

Append s_date.

In the event "At selection-screen.":

We can validate all the inputs on selection screen fields under this event.

At selection-screen.

If s_carrid-low is initial or s_connid-low is initial or s_date is initial.

< ... code for validation... >.

Endif.

In the event "At selection-screen on <field>."

We can validate a particular field input on selection screen under this event.

At selection-screen on s_carrid.

If s_carrid-low ‘LH’.

<… code for validation…>

Endif.

please get back to me for further queries;

reward if helpful.

thanks and regards,

srikanth.

Former Member
0 Kudos

hi Phani,

This is kiran kumar.G(working on SAP).I will send a same code for u.plz check it once.It is very much uesful for u.

If u r satisfy with my answer give me REWARD POINTS..

VALIDATIONS CAN BE USED IN "AT SELECTION-SCREEN"

EVENT.

EX:

AT SELECTION-SCREEN.

select single vbeln

from vbak

into vbak-vbeln

where vbeln in s_vbeln.

CODE:

TABLES: VBAK. "COMPULSORY WE HAVE TO MENTION

SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.

*For Validations

AT SELECTION-SCREEN.

select single vbeln

from vbak

into vbak-vbeln

where vbeln in s_vbeln.

Regards,

Kiran Kumar.G

Former Member
0 Kudos

AT SELECTION-SCREEN - selscreen_event

Syntax

...

| { ON {para|selcrit} }

| { ON END OF selcrit }

| { ON BLOCK block }

| { ON RADIOBUTTON GROUP radi }

| { }

| { ON {HELP-REQUEST|VALUE-REQUEST}

| FOR {para|selcrit-low|selcrit-high} }

| { ON EXIT-COMMAND }.

Alternatives:

1. ... OUTPUT

2. ... ON {para|selcrit}

3. ... ON END OF selcrit

4. ... ON BLOCK block

5. ... ON RADIOBUTTON GROUP radi

6. ... { }

7. ... ON {HELP-REQUEST|VALUE-REQUEST} FOR

{para|selcrit-low|selcrit-high} }

8. ... ON EXIT-COMMAND

Effect

These additions allow individual evaluation of specific elements of the selection screens of the program. The information as to which selection has triggered the event is contained in the system field sy-dynnr.

Alternative 1

... OUTPUT

Effect

This event is triggered at the screen event PBO of a selection screen. In the event block, the selection screen can be prepared through assignments to the data objects of parameters and selection criteria and through dynamic screen modifications.

Note

The assignments to input fields in the event block AT SELECTION-SCREEN OUTPUT always affect the selection screen and overwrite the user inputs from previous displays of the same selection screen. Assignments in the event blocks LOAD-OF-PROGRAM oder INITIALIZATION, on the other hand, only have an effect at first program start.

Alternative 2

... ON {para|selcrit}

Effect

This event is triggered at the screen event PAI of a selection screen if the content of the input field of a parameter para or a line of a selection criterion selcrit was passed to the ABAP program. In the event block, the user input can be checked. Sending a warning or an error message in the event block makes the fields para and selcrit ready for input again.

No parameter that is defined as a radio button can be specified. For this purpose, the addition ON RADIOBUTTON GROUP is provided.

Note

If a user action takes place in the dialog box for the multiple selection of a selection criterion selcrit, the entries of the selection table are passed to the program, line by line. For each line, the event AT SELECTION-SCREEN ON selcrit is triggered.

Alternative 3

... ON END OF selcrit

Effect

This event is triggered after the selection table selcrit has been fully passed to the program after a user action in the dialog box for the multiple selection has taken place. In the event block, the entire selection table can be checked.

Alternative 4

... ON BLOCK block

Effect

This event is triggered at the screen event PAI of a selection screen if all the input fields of a block block of the selection screen were passed to the ABAP program. In the event block, the user inputs can be checked. Sending a warning or an error message in the event block makes all the fields of the block block ready for input again.

Alternative 5

... ON RADIOBUTTON GROUP radi

Effect

This event is triggered at the screen event PAI of a selection screen if all the fields of a radio button group radi of the selection screen were passed to the ABAP program. In the event block, the user input can be checked. Sending a warning or error message in the event block makes all the radion buttons of the block radi ready for input again.

Note

The individual fields of a radio button group are not passed individually and do not trigger the event AT SELECTION-SCREEN ON par.

Alternative 6

... { }

Effect

The event AT SELECTION-SCREEN itself is triggered as the last event of selection screen processing if all the input values were passed to the program. In this event block, all the user inputs can be checked. Sending a warning or an error message in the event block makes all the screen fields ready for input once again.

Alternative 7

... ON { HELP-REQUEST | VALUE-REQUEST } FOR

{para|selcrit-low|selcrit-high} }

Effect

The two events ON HELP-REQUEST and ON VALUE-REQUEST are triggered at the screen events POH and POV of a selection screen if - for the input field of a parameter para or one of the input fields of a selection criterion selcrit - the field help F1 or the input help F4 was called. Other selection events are not triggered.

In the event blocks, a self-defined field or input field can be programmed, which overrides any helps possibly defined in the ABAP Dictionary.

Notes

These event blocks can only be implemented for fields of the selection screen that are defined in the same ABAP program and not in a possibly linked logical database.

With the events for the field and input help, no data is transported between the selection screen and the ABAP program. As with general screens, suitable function modules must be used for these. The parameters and selection criteria changed for the input help are transported to the selection screen.

Alternative 8

... ON EXIT-COMMAND

Effect

This event is triggered if the user has called one of the functions Back, Exit or Cancel. In the event block, possible clean-up actions can be executed.

Example

In these executable programs, a standard selection screen and a further selection screen are defined. In the event blocks AT SELECTION-SCREEN, the inputs in the selection screens can be specially handled using the name p_carrid and the screen number in sy-dynnr.

REPORT demo_at_selection_screen.

  • Global data

DATA: sflight_tab TYPE TABLE OF sflight,

sflight_wa LIKE LINE OF sflight_tab.

  • Selection screens

PARAMETERS p_carrid TYPE spfli-carrid.

SELECTION-SCREEN BEGIN OF SCREEN 500.

SELECT-OPTIONS s_conn FOR sflight_wa-connid.

DATA s_conn_wa LIKE LINE OF s_conn.

SELECTION-SCREEN END OF SCREEN 500.

  • Handling selection screen events

AT SELECTION-SCREEN ON p_carrid.

IF p_carrid IS INITIAL.

MESSAGE 'Please enter a value' TYPE 'E'.

ENDIF.

AUTHORITY-CHECK OBJECT 'S_CARRID'

ID 'CARRID' FIELD p_carrid

ID 'ACTVT' FIELD '03'.

IF sy-subrc = 4.

MESSAGE 'No authorization for carrier' TYPE 'E'.

ELSEIF sy-subrc <> 0.

MESSAGE 'Error in authority check' TYPE 'A'.

ELSE.

IF sy-ucomm = 'ONLI'.

CALL SELECTION-SCREEN '0500'.

ENDIF.

ENDIF.

AT SELECTION-SCREEN.

IF sy-dynnr = '0500'.

IF s_conn IS INITIAL.

MESSAGE 'Please enter values' TYPE 'W'.

ELSE.

SELECT *

FROM sflight

INTO TABLE sflight_tab

WHERE carrid = p_carrid AND

connid IN s_conn.

IF sy-subrc <> 0.

MESSAGE 'No flights found' TYPE 'E'.

ENDIF.

ENDIF.

ENDIF.

  • Main program

START-OF-SELECTION.

...