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

Select Statement

tnecnivo
Active Contributor
0 Likes
890

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

1 ACCEPTED SOLUTION
Read only

Sayan_C
Explorer
0 Likes
848

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

5 REPLIES 5
Read only

Sayan_C
Explorer
0 Likes
849

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

Read only

tnecnivo
Active Contributor
0 Likes
848

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

Read only

0 Likes
848

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.

Read only

tnecnivo
Active Contributor
0 Likes
848

Hi Sayan,

Thanks for the help, it worked!

Read only

Former Member
0 Likes
848

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