cancel
Showing results for 
Search instead for 
Did you mean: 

Converting Period to 1st and last date of that month

rahul2000
Contributor
0 Kudos

Dear all,

is there any FM to to do the following:-

if in the selection screen i give the date as 09.2007 (MM.YYYY) then i want the output as

01.09.2007 to 30.09.2007

If u go to transaction MC.1 in that u will find this as select options.

So when i enter in the selection screen the period from 09.2007 to 11.2007

then the output should be 01.09.2007 to 30.11.2007. which i want to pass to MKPF table

PLZ help

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

try below:

w_poper = date+4(2).

w_gjahr = date+0(4).

CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

EXPORTING

i_gjahr = w_gjahr

i_periv = w_periv

i_poper = w_poper

IMPORTING

e_date = w_date.

IF NOT w_date IS INITIAL.

wa_e1lipm0-vontg = w_date.

ENDIF.

CLEAR w_date.

CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'

EXPORTING

i_gjahr = w_gjahr

i_periv = w_periv

i_poper = w_poper

IMPORTING

e_date = w_date.

IF NOT w_date IS INITIAL.

wa_e1lipm0-bistg = w_date.

ENDIF.

reward if answered

rahul2000
Contributor
0 Kudos

Is there any FM to convert date from MM.YYYY format to DD.MM.YYYY format?? it will be gr8 if there is one of this....

Former Member
0 Kudos

Hi you can use this logic,

data: first like sy-datum,

last like sy-datum.

parameter: date type sy-datum.

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

day_in = date.

IMPORTING

LAST_DAY_OF_MONTH = last

  • EXCEPTIONS

  • DAY_IN_NO_DATE = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

first = last.

first+6(2) = '01'.

rahul2000
Contributor
0 Kudos

is there any FM where we can straightwas=y enter date in mm.yyyy format and get the ouyput as mentioned?

former_member386202
Active Contributor
0 Kudos

Hi,

Just Hard code first day of every month as 1 and use fm

" RP_LAST_DAY_OF_MONTHS " to calculate last day of month.

Reaward Points

Regards,

Prashant

Former Member
0 Kudos

Hi Rahul

Please check MC_PERIO_GET_FIRST_AND_LASTDAY

Regards

Arun

rahul2000
Contributor
0 Kudos

hi arun,

is there any FM where we can straightaway enter the date in mm.yyyy format and the output as mentioned above?

Former Member
0 Kudos

Hi Rahul

In case we are talking about the month number and not the period (period and month number need not be the same -> In India for example )

Use SG_PS_GET_LAST_DAY_OF_MONTH to get last day and first day is always 01. <your input>

Former Member
0 Kudos

hi for selection screen

use this code

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(17) text-006 FOR FIELD p_abkrs1.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_abkrs1 TYPE qppnp-xabkr OBLIGATORY.

SELECTION-SCREEN POSITION 38.

PARAMETERS: p_begda TYPE pnpbegda.

SELECTION-SCREEN COMMENT 50(3) text-007 FOR FIELD p_endda.

PARAMETERS: p_endda TYPE pnpendda.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 10(17) text-008 FOR FIELD p_timr9.

SELECTION-SCREEN POSITION 1.

PARAMETERS: p_timr9 RADIOBUTTON GROUP a.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_ipabrp TYPE pnppabrp.

PARAMETERS: p_ipabrj TYPE pnppabrj.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 10(17) text-009 FOR FIELD p_timra.

SELECTION-SCREEN POSITION 1.

PARAMETERS: p_timra RADIOBUTTON GROUP a.

SELECTION-SCREEN POSITION 33.

PARAMETERS: p_pabrp TYPE pnppabrp,

p_pabrj TYPE pnppabrj.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK a.

Former Member
0 Kudos

hi rahul

AT SELECTION-SCREEN.

IF NOT p_abkrs1 IS INITIAL.

IF NOT p_timr9 IS INITIAL.

CALL FUNCTION 'PA03_PERIODDATES_GET'

EXPORTING

f_abkrs = p_abkrs1

IMPORTING

f_permo = wf_permo

f_current_begda = wf_begda

f_current_endda = wf_endda

CHANGING

f_current_period = wf_pabrp

f_current_year = wf_pabrj

EXCEPTIONS

pcr_does_not_exist = 1

abkrs_does_not_exist = 2

period_does_not_exist = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

p_begda = wf_begda.

p_endda = wf_endda.

p_ipabrp = wf_pabrp.

p_ipabrj = wf_pabrj.

IF NOT p_pabrp IS INITIAL OR NOT p_pabrj IS INITIAL.

MESSAGE e016(rp) WITH 'Do not enter other period'.

STOP.

EXIT.

ENDIF.

ELSE.

IF p_pabrp IS INITIAL OR p_pabrj IS INITIAL.

MESSAGE e016(rp) WITH 'Enter a period'.

STOP.

EXIT.

ENDIF.

SELECT SINGLE * FROM t549a

INTO int_t549a

WHERE abkrs = p_abkrs1.

IF sy-subrc = 0.

SELECT SINGLE * FROM t549q INTO int_t549q

WHERE permo = int_t549a-permo

AND pabrj = p_pabrj

AND pabrp = p_pabrp.

IF sy-subrc = 0.

p_begda = int_t549q-begda.

p_endda = int_t549q-endda.

p_ipabrp = p_pabrp.

p_ipabrj = p_pabrj.

ENDIF.

ENDIF.

reward points if useful

karthik