2012 Aug 15 4:22 AM
Hi ABAP gurus,
I am working on BW and I need to do a select statement in BW Transformation Routine.
The select Statement goes by following:-
Blue Colour Text is entered by me.
Black Colour Text is standard default.
DATA: ls_source TYPE y_source_fields,
ls_target TYPE y_target_fields,
CALMTH TYPE /BI0/OICALMONTH,
ZCALMONTH TYPE /BIC/OIZCALMONTH.
LOOP AT it_source INTO ls_source.
MOVE-CORRESPONDING ls_source TO ls_target.
APPEND ls_target TO et_target.
ENDLOOP.
select single LOW into CALMTH
from RSRVARIANT
where VARI = 'ZQRCALMTH'.
CONCATENATE '01'CALMTH INTO ZCALMONTH.
What I am trying to do is to select the field from table RSRVARIANT and populate into ZCALMONTH for reporting.
The RSRVARIANT Table as following:-
But when I execute the loading, it failed with error message:
Category ABAP Programming Error
Runtime Errors DBIF_RSQL_INVALID_RSQL
Except. CX_SY_OPEN_SQL_DB
I have searched online, and this error message suppose to be related to Select statement issue.
But because I am not well-verse in ABAP, can anyone kindly please let me know what's wrong with the select statement I used?
What I want to do is to populate the characteristic (ZCALMONTH) with the filed from this table.
Thanks in advance!
Vince
2012 Aug 15 7:13 AM
Hi,
You defined a wrong data type in select statement, Please see code as below and apply to your
requirement.
DATA: lv_low TYPE rsrvariant-low,
lv_month TYPE /bi0/oicalmonth.
SELECT SINGLE low INTO lv_low
FROM rsrvariant
WHERE vari = 'ZQRCALMTH'.
IF sy-subrc = 0.
lv_month = lv_low. "Now you get month value
* if you want to convert month to first date of month
DATA: lv_firs_date TYPE sydatum.
CONCATENATE lv_month '01' INTO lv_firs_date. "Now you get date
ENDIF.
Regards,
Sayan
2012 Aug 15 7:13 AM
Hi,
You defined a wrong data type in select statement, Please see code as below and apply to your
requirement.
DATA: lv_low TYPE rsrvariant-low,
lv_month TYPE /bi0/oicalmonth.
SELECT SINGLE low INTO lv_low
FROM rsrvariant
WHERE vari = 'ZQRCALMTH'.
IF sy-subrc = 0.
lv_month = lv_low. "Now you get month value
* if you want to convert month to first date of month
DATA: lv_firs_date TYPE sydatum.
CONCATENATE lv_month '01' INTO lv_firs_date. "Now you get date
ENDIF.
Regards,
Sayan
2012 Aug 15 8:24 AM
Hi Sayan,
Thanks for the advice, I have used your code, the error message no longer showing, however, the code doesn't populate the field ZCALMONTH. it's just blank when I tried to display the data in the DSO.
Any suggestion on where should I check?
Many thanks,
Vince
2012 Aug 15 8:50 AM
Hi,
I think you can assign the value of ZCALMONTH in the loop as below, Please apply to your code.
*/ After you get the value from table "rsrvariant"
LOOP AT it_source INTO ls_source.
MOVE-CORRESPONDING ls_source TO ls_target.
ls_target-ZCALMONTH = lv_moth. "Assign the value from rsrvariant-low here
APPEND ls_target TO et_target.
ENDLOOP.
Regards,
Sayan.
2012 Aug 15 9:57 AM
2012 Aug 15 7:19 AM
Hi Vincent,
write this line in your code.
Tables : RSRVARIANT.
In the routine , write your code at "write your code below" line. R u sure u have wirtten the code at proper place.
And after concatenating the value into ZCALMONTH what u r going to do and where u r going to use it.
Regards,
Babu