Application Development and Automation 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: 
Read only

Validation

Former Member
0 Likes
866

HI ,

for Sales Org field in selection screen for field validation i used below statement

SELECT SINGLE *

FROM TVKO

WHERE vkorg IN S_VKORG.

IF sy-subrc NE 0.

ERROR MESSAGE.

ENDIF.

BUT HERE i am getting syntax check warning like

"In " SELECT SINGLE .... " , the WHERE condition for the key field VKORG does not test for equality.therefore ,the single record in question may not be unique. "

so what is the solution for this ....

And i didnt used the table TVKO any where in program and defined with TABLES statement but showing warning like

" No Read Access to field string TVKO "

so what is wrong in that tell me ....

THX

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
848

It wont be a problem..

Its just telling that there is a chance of being more than one vkorg in the table...but u only have to validate the existence of that vkorg...so no problem...

8 REPLIES 8
Read only

former_member194669
Active Contributor
0 Likes
848

TABLES : TvkO.

SELECT SINGLE *
FROM TVKO
INTO TVKO  "<<<
WHERE vkorg IN S_VKORG.
IF sy-subrc NE 0.
ERROR MESSAGE.
ENDIF.

Read only

0 Likes
848

HI ,

THANKS but same error

i think some thing wrong in WHERE condition .

Tx

Read only

0 Likes
848

Try this way



TABLES : TvkO.
 
data : wa_tvko type tvko.

SELECT SINGLE *
FROM TVKO
INTO WA_TVKO  "<<<
WHERE vkorg IN S_VKORG.
IF sy-subrc NE 0.
ERROR MESSAGE.
ENDIF.

Read only

Former Member
0 Likes
848

Hi,

Warning message is due to: WHERE vkorg IN S_VKORG.

Here S_VKORG is not a parameter which identifies as a single value to determine single record.

Considering an example that S_VKORG holds 10 values, and only 8 are valid. You may proceed with the valid 8 entries whereas SELECT SINGLE extracts only one entry.

So SAP is unsure if you are actually extracting the required record with SELECT SINGLE, hence the warning message.

Ignore the warning message and activate the program for further processing or to overcome the warning message you might declare an internal table with VKORG as field and use select into table.

Regards

Eswar

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
849

It wont be a problem..

Its just telling that there is a chance of being more than one vkorg in the table...but u only have to validate the existence of that vkorg...so no problem...

Read only

0 Likes
848

try this....


select-options:so_vkorg for tvko-vkorg.


at selection-screen on so_vkorg.
select single vkorg into (tvko-vkorg) from tvko
where vkorg in so_vkorg.
if sy-subrc <> 0.

endif.

Read only

Former Member
0 Likes
848

see this small program for screen validations

REPORT ZNNR_REPORT NO STANDARD PAGE HEADING MESSAGE-ID ZNNR LINE-SIZE 100 LINE-COUNT 65(4).

******DATA DECLARATIONS**********

DATA : BEGIN OF IT_PLANT OCCURS 0,

MATNR LIKE MARA-MATNR,

WERKS LIKE MARC-WERKS,

PSTAT LIKE MARC-PSTAT,

EKGRP LIKE MARC-EKGRP,

END OF IT_PLANT.

DATA : BEGIN OF IT_PONO OCCURS 0,

EBELN LIKE EKKO-EBELN,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

END OF IT_PONO.

TABLES EKKO.

********END OF DATA DECLARATIONS*********

********SELECTION SCREEN DESIGN ***********

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.

SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.

SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R2 RADIOBUTTON GROUP G1.

SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK B2.

******END OF SELECTION SCREEN DESIGN****************

*********INITIALIZATION OF SELECTION SCREEN ELEMENTS.*****

INITIALIZATION.

P_WERKS = '1000'.

S_EBELN-LOW = '4500016926'.

S_EBELN-OPTION = 'EQ'.

S_EBELN-SIGN = 'I'.

APPEND S_EBELN.

CLEAR S_EBELN.

************END OF INITIALIZATION***********************

***********SCREEN MODIFICATIONS*******************

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

********END OF SCREEN MODIFICATIONS*****************

****************SCREEN VALIDATIONS ******************

at selection-screen.

*SELECT SINGLE **

FROM EKKO

INTO EKKO

WHERE EBELN IN S_EBELN.

IF SY-SUBRC <> 0.

SET CURSOR FIELD 'S_EBELN-LOW'.

MESSAGE E999 WITH TEXT-005.

ENDIF.

*********end of screen validation******************

Read only

Former Member
0 Likes
848

Hi,

U want to make a validation so always screen validation are done in

At selection-screen even.. there are different events for same screen vallidation with different type of events..

Like 1.At selection-screen on <field>

2. At selection-screen

3.At selection-screen output

4.At selection-screen on value-request for <field> like this...

For ur code, the problem is u didnt move ur fetched data into an internal table which very much necessary.

And one more thing is u can tune the perofrmance by writing SELECT SINGLE statement with the

UP TO some ROWS.

Try this...

TABLES : TVKO.

SELECT SINGLE *

FROM TVKO

INTO TVKO

WHERE vkorg IN S_VKORG.

IF sy-subrc NE 0.

MESSAGE E00(Z001).

    • ---Z001 : ERROR MESSAGE----

ENDIF.

Regards.