Application Development 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: 

Extract Month From Date Using SAP Query.

former_member229716
Active Participant
0 Kudos

Hi Abap expert,

i'm using SAP query SQ01 to run the report from MKPF table, this table does not contain any monthly period. the available field that can i use is BUDAT.

how do i extract the month from date using SAP query report? example;

Date - 01.01.2007 (DD.MM.YYYY) extract to 01.2007 (MM.YYYY)

i think we can use 'local field' and just put the coding but i don't know how to use, please help ?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Check the default format for date then follow the code.

generally the default format is (yyyy.mm.dd)

data: month(2) type c .

date type sy-datum.

month = date+4(2).

4(2).

here 4 specifies the no of characters you are skipping. This is your starting point

and 2 is the no of characters you want to select.

so extract the month according to your date format.

6 REPLIES 6

Former Member
0 Kudos

Hi,

In SQ02 - Maintaining infoset u can add additional field for u r field groups.

U can add field code to that additional field where u can get month(mm.yyyy) from date field.

Create additional field in extras of the infoset.

Regards,

Sankar

Former Member
0 Kudos

Hi,

Ya for that u have to use local field but for that u sq01 in this goto edit menu and create local field in that. But for that u have to create one temp field at sq02 and then specify that temp field to local field. And make your all calculation in sq02.

Rewards points if it is useful.

0 Kudos

Hi need more information, i could not manage to figure out the solution

i have created one additional field in SQ02, that field i created referring to field MKPF-BUDAT.

in SQ01 i also have created one field referring to MKPF-BUDAT, how do i use

in calculation formula and what other thing do i need to enter in complex calculation

condition .... ?

formula ....?

0 Kudos

Create posting month as an additional field in the infoset using SQ02. Add some field code to convert BUDAT into month. Then in SQ01, just reference the new field.

0 Kudos

Hii

I have created extra field in my info set.

Detail-

Field Name = ZPOSTINGMONTH

Type = C

lnght = 8

Outputlenght = 10

and now i what to extract the month in field MKPF-BUDAT

i have use this statement below, it's seem cannot work

-


data: month(2) type c.

date type sy-datum.

month = date+4(2).

4(2).

-


When i do the checking the system give me this message-

The statement "DATE" is not expected. Correct similar statements are "DATA" and "UPDATE".

null

Former Member
0 Kudos

Check the default format for date then follow the code.

generally the default format is (yyyy.mm.dd)

data: month(2) type c .

date type sy-datum.

month = date+4(2).

4(2).

here 4 specifies the no of characters you are skipping. This is your starting point

and 2 is the no of characters you want to select.

so extract the month according to your date format.