2013 Sep 12 7:08 AM
Hello Experts,
My requirement is I am using dynamic where condition in select statement.
in where clause I ll pass system variable with field and it may be without system variable.
If my where condition contains system variable I want its value in variable.
I dont want to hard code of system variable as SY-DATUM, SY-UNAME.
DATA: SDATE TYPE STRING,
STR_DATE TYPE STRING,
V_STR TYPE STRING.
V_STR = 'sy-datum'.
STR_DATE = ' ersda = sy-datum'.
IF STR_DATE CS V_STR.
SDATE = V_STR.
ENDIF.
WRITE😕 SDATE.
Output is : SY-DATUM.
but i want to output current date as 20130912.
Kindly consider my request.
Thanks & regrads,
Ranjit Kumar
2013 Sep 12 7:24 AM
Hi,
Use field symbols. I have modified your code and its working now.
DATA: SDATE TYPE STRING,
STR_DATE TYPE STRING,
V_STR TYPE STRING.
FIELD-SYMBOLS <a> type sy-datum.
V_STR = 'sy-datum'.
ASSIGN (v_str) to <a>.
STR_DATE = ' ersda = sy-datum'.
IF STR_DATE CS V_STR.
SDATE = <a>.
ENDIF.
WRITE:/ SDATE.
This way you can store any system variable in V_STR and SDATE will get its value and not the name of the variable.
regards,
Ashish Rawat
Thanks Ashish,
My problem is solved. Thanks for quick response.
regards,
Ranjit
2013 Sep 12 7:21 AM
Hi Ranjit ,
According to my understanding you are not able to populate the sy-datum in the variable sdate.
If thats the case then change the statment to v_str = sy-datum.
If your requirment is someother just give a clear explanation , i couldnt understand from above explanation.
Regards,
Aditya.
2013 Sep 12 7:24 AM
Hi,
Use field symbols. I have modified your code and its working now.
DATA: SDATE TYPE STRING,
STR_DATE TYPE STRING,
V_STR TYPE STRING.
FIELD-SYMBOLS <a> type sy-datum.
V_STR = 'sy-datum'.
ASSIGN (v_str) to <a>.
STR_DATE = ' ersda = sy-datum'.
IF STR_DATE CS V_STR.
SDATE = <a>.
ENDIF.
WRITE:/ SDATE.
This way you can store any system variable in V_STR and SDATE will get its value and not the name of the variable.
regards,
Ashish Rawat
2013 Sep 12 7:29 AM
Thanks Ashish,
My problem is solved. Thanks for quick response.
regards,
Ranjit
2013 Sep 12 7:34 AM
hi,
a little editing needed in above code to allow it to work for all variables.
In declaring field symbol,
FIELD-SYMBOLS <a> TYPE DATA.
I used type sy-datum above so it will work for only that field. Declare as TYPE DATA then it will work for all variables.
And 1 more important thing,
do not use str_date = 'ersda = sy-datum' directly,
Instead use,
CONCATENATE 'ersda = ' sy-datum INTO str_date.
regards,
Ashish Rawat
2013 Sep 12 7:53 AM
2013 Sep 12 7:33 AM
Hello Ranjit.
This statement
STR_DATE = ' ersda = sy-datum'
will not pass the value of current date.
Make use of concatenate statement.
CONCATENATE ' Ersda ' sy-datum into STR_DATE.
Regards.
2013 Sep 12 7:42 AM
Don't sure to understand you requirement, are you willing to dynamically interpret a string which contains reference to system variables ?
If yes then search the string for occurence of "SY-" (converting to uppercase) then extract the full name(s) of system field (e.g. SY-DATUM) by searching next separator (space, ")" or end of string). Then replace this string with the actual value (using an ASSIGN and a WRITE (ASSIGN (stringfound) to <fs> and WRITE <fs> to a character field)
Regards,
Raymond
2013 Sep 12 8:13 AM
Hi Ranjit,
I am not sure of what you really want , But i can interpret that u want the date to be showed as 20130912 from a variable . If you want that , then the following code will do the job
DATA: V_STR TYPE STRING.
V_STR = sy-datum.
WRITE:/ V_STR.
Regards,
Sivaganesh.K
2013 Sep 12 8:48 AM
Hi Sivaganesh,
I have not to pass SY-DATUM directly to any variable.
basically SY-DATUM is a part of my string stored in variable.
like that
v_str = 'ersda = sy-datum'.
get the sy-datum from v_ster and pass it another variable .
Here i need system date but i get string sy-datum in stead of its value. thats the reason.
I use field symbol.
Thanks,
Ranjit K.
2013 Sep 12 8:29 AM
Dear Ranjith,
Please try this.
DATA: SDATE TYPE SYDATUM,
STR_DATE TYPE STRING,
V_STR TYPE SYDATUM.
V_STR = 'sy-datum'.
STR_DATE = 'ersda=sy-datum'."
IF STR_DATE CS V_STR.
V_STR = sy-datum.
SDATE = V_STR.""sy-datum.".
ENDIF.
WRITE:/ SDATE.
Thanks and Regrads,
buz_sap
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |