‎2008 Apr 21 7:05 AM
Hi,
what does the below statement do exactly
"SELECT SINGLE WERKS INTO T001W-WERKS FROM T001W
WHERE WERKS = WERKS.
IF SY-SUBRC NE 0.
MESSAGE S398 WITH 'Plant ' WERKS ' not exists'.
STOP.
ENDIF."
‎2008 Apr 21 7:25 AM
Hai ,
in this code we are checking a Plant is valid as per Plants/Branches table.
so we will check the plant(WERKS) is present in T001W (Plants/Branches table) .
is sy-subrc is not equal to zero means no entry is present in the table.
then the code will populate a message
ef the plant is present over there then , the program will continue its execution
Select singele will select only one record at a time from the table .
WERKS INTO T001W-WERKS
here
plant is stored in to T001W-WERKS.
this is only doing for checking the existence.
Regards,
Sarath
Edited by: sarath p on Apr 21, 2008 8:26 AM
‎2008 Apr 21 7:12 AM
Hello Shilpa-
The below code indicates validation of WERKS.In detail if the user enters any wrong data on the selection screen in return the system should dispay an error.
SELECT SINGLE WERKS INTO T001W-WERKS FROM T001W
WHERE WERKS = WERKS.
*The above code pulls all the plant exisiting in the t table and compares with the data entered on selction-*screen.
IF SY-SUBRC NE 0.
**If unsuccessful sy-subrc fails
MESSAGE S398 WITH 'Plant ' WERKS ' not exists'.
The above message suppose to be E not S.
STOP.
‎2008 Apr 21 7:18 AM
but here it says "SELECT SINGLE WERKS INTO T001W-WERKS FROM T001W"
it is selecting the plant (WERKS) into T001W-WERKS what does this mean.
‎2008 Apr 21 7:24 AM
Hi,
The select query selects the value of werks from T001W table into T001W-WERKS if the value equals the user entered value, WERKS.
If no value is selected (SY-SUBRC NE 0), then, it means the entered plant value is not valid as it is not there in the table T001W.
STOP statement takes u out of that check and skips further execution. But, it is obsolete in ECC6.0.
So, better set flags.
Reward points if helpful.
Regards,
Ramya
‎2008 Apr 21 7:25 AM
Hai ,
in this code we are checking a Plant is valid as per Plants/Branches table.
so we will check the plant(WERKS) is present in T001W (Plants/Branches table) .
is sy-subrc is not equal to zero means no entry is present in the table.
then the code will populate a message
ef the plant is present over there then , the program will continue its execution
Select singele will select only one record at a time from the table .
WERKS INTO T001W-WERKS
here
plant is stored in to T001W-WERKS.
this is only doing for checking the existence.
Regards,
Sarath
Edited by: sarath p on Apr 21, 2008 8:26 AM
‎2008 Apr 21 7:33 AM
Hi Shilpa,
The below code indicates validation of WERKS.In detail if the user enters any wrong data on the selection screen in return the system should dispay an error.
MESSAGE S398 WITH 'Plant ' WERKS ' not exists'.
STOP.
Reward If Helpfull,
Naresh.
‎2008 Apr 21 7:33 AM
hi,
its validation of the werks fields
he is checking whtether the werks entered is in the t001w table or not.
regards
prasanth
‎2008 Apr 21 7:43 AM
hi shilpa
here only single record is geting fetched and if table t001 contins only werks as an primary key than is ok but if primary key consist of any other field alng with werks than only the frist record will be get fetched always even if contain more thsan 1 record for it this is becoz in select single if we want exact record we have to supply full prrimary key
so this validation is apropiat only if ther is werks as primary key
and in massage we r pasiing the valueto placeholder
‎2008 Apr 21 8:13 AM
Hi ,
This statement is used to check whether the value entered in the selection screen by the user for WERKS is a correct value or not. In case , its not a correct value, a message is thrown "Werks does not exist...".
What this select statement does is, it compares the value of werks entered in the selection screen with all the values of werks present in the table T001W.
In case , if the value entered in selection screen matches with the value of any of werks present in the table T001W, the werks value is stored in T001W-werks, and this sets the value of sy-subrc to 0.
Sy-subrc = 0 means, that the select has been successful.
Any other value of sy-subrc indicates error, and if the select fails { which will happen if the value of werks entered is not present in T001W table}, then sy-subrc is not equal to 0 and thus an error message is thrown.
Reward if helpful.