Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Query having two column and both column required different months data.

Hi All,

My query consist of two column A & B. Data is coming from a single cube. Now i have  to implement below mentioned condition:

i) if run date of the report is during months January - March:

   Then report should display data of December of the previous year for column A and January - December from previous year for column B.

ii) if run date of the report is during months April - June:
    Then report should display data of March of the current year for column A and January - March from current year for column B.

iii) if run date of the report is during months July - September:

     Then report should display data of June of the current year for column A and January - June from current year for column B.


iv) if run date of the report is during months October - December:

     Then report should display data of September of the current year for column A and January - September from current year for column B.



Please guide me how to do this.



Thanks,

Sumadhur

Former Member
replied

Hi,

So you have SELECTIONS A and B right?

Insert all the filters and the KF needed for both selections..

Insert CALDAY for both of them..

Create a variable for CALDAY in SELECTION A with customer exit as its processing by and with INTERVAL options, let's call it ZONE_MONTH..

Create another variable for CALDAY in SELECTION B with customer exit as its processing by and with INTERVAL options, let's call it ZRANGE_MONTH..

After doing the variables I mentioned above, do this in CMOD:

For ZONE_MONTH...

data: range_low type d,

       range_high type d,

       temp_day type d.

WHEN 'ZONE_MONTH'.

CONCATENATE sy-datum(4) '0101' into temp_day.

temp_day = temp_day - 1.

if sy-datum+4(2) >= '01' and sy-datum+4(2) <= '03'.

concatenate temp_day(6) '01' into range_low.

concatenate temp_day(6) '31' into range_high.


elseif sy-datum+4(2) >= '04' and sy-datum+4(2) <= '06'.

concatenate sy-datum(4) '0301' into range_low.

concatenate sy-datum(4) '0331' into range_high.

elseif sy-datum+4(2) >= '07' and sy-datum+4(2) <= '09'.

concatenate sy-datum(4) '0601' into range_low.

concatenate sy-datum(4) '0630' into range_high.

elseif sy-datum+4(2) >= '10' and sy-datum+4(2) <= '12'.

concatenate sy-datum(4) '0901' into range_low.

concatenate sy-datum(4) '0930' into range_high.


endif.


L_S_RANGE-LOW         = range_low.

L_S_RANGE-HIGH        = range_high.

L_S_RANGE-SIGN        = 'I'.

L_S_RANGE-OPT         = 'BT'.

APPEND L_S_RANGE TO E_T_RANGE.

EXIT.








For ZRANGE_MONTH..


data: range_low type d,

       range_high type d,

       temp_day type d.

WHEN 'ZRANGE_MONTH'.

CONCATENATE sy-datum(4) '0101' into temp_day.

temp_day = temp_day - 1.

if sy-datum+4(2) >= '01' and sy-datum+4(2) <= '03'.

concatenate temp_day(4) '0101' into range_low.

concatenate temp_day(6) '31' into range_high.


elseif sy-datum+4(2) >= '04' and sy-datum+4(2) <= '06'.

concatenate sy-datum(4) '0101' into range_low.

concatenate sy-datum(4) '0331' into range_high.

elseif sy-datum+4(2) >= '07' and sy-datum+4(2) <= '09'.

concatenate sy-datum(4) '0101' into range_low.

concatenate sy-datum(4) '0130' into range_high.

elseif sy-datum+4(2) >= '10' and sy-datum+4(2) <= '12'.

concatenate sy-datum(4) '0101' into range_low.

concatenate sy-datum(4) '0930' into range_high.


endif.


L_S_RANGE-LOW         = range_low.

L_S_RANGE-HIGH        = range_high.

L_S_RANGE-SIGN        = 'I'.

L_S_RANGE-OPT         = 'BT'.

APPEND L_S_RANGE TO E_T_RANGE.

EXIT.

Just post here for question..

Regards,

Loed

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question