SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

CCM_GO_BACK_MONTHS



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
tdebug
Участник
Участник



Joined: 26 Feb 2009
Posts: 6

PostPosted: Thu Nov 11, 2010 3:11 pm    Post subject: CCM_GO_BACK_MONTHS Reply with quote

Поделитесь плиз, кто может, исходным кодом ФМ "CCM_GO_BACK_MONTHS". В нашей инсталяции такого модуля нет к сож. Если не ошибаюсь он из функ. группы CCMC.
Back to top
View user's profile Send private message
Igor_34_rus
Специалист
Специалист



Joined: 08 Apr 2009
Posts: 75

PostPosted: Thu Nov 11, 2010 5:00 pm    Post subject: Reply with quote

FUNCTION CCM_GO_BACK_MONTHS .
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(CURRDATE) LIKE SY-DATUM
*" VALUE(BACKMONTHS) TYPE NUMC3
*" EXPORTING
*" VALUE(NEWDATE) LIKE SY-DATUM
*"----------------------------------------------------------------------

DATA: YEAR(4) TYPE C,
TMONTHS TYPE NUMC3,
T1MONTHS TYPE NUMC3,
DAY(2) TYPE C.

MOVE: CURRDATE(4) TO YEAR,
CURRDATE+4(2) TO TMONTHS,
CURRDATE+6(2) TO DAY.

*t1months = tmonths - backmonths.
IF TMONTHS <= BACKMONTHS.
CURRDATE(4) = CURRDATE(4) - 1.
CURRDATE+4(2) = '12'.
BACKMONTHS = BACKMONTHS - TMONTHS.
CALL FUNCTION 'CCM_GO_BACK_MONTHS'
EXPORTING
CURRDATE = CURRDATE
BACKMONTHS = BACKMONTHS
IMPORTING
NEWDATE = NEWDATE.

* call function recursively
ELSE.
NEWDATE(4) = CURRDATE(4).
NEWDATE+6(2) = CURRDATE+6(2).
NEWDATE+4(2) = CURRDATE+4(2) - BACKMONTHS.
ENDIF.



ENDFUNCTION.
Back to top
View user's profile Send private message
tav_48
Участник
Участник



Joined: 27 Oct 2008
Posts: 3

PostPosted: Thu Nov 11, 2010 7:16 pm    Post subject: Reply with quote

Более новая версия ФМ'а:

Code:

FUNCTION CCM_GO_BACK_MONTHS .
*"----------------------------------------------------------------------
*"*"Local interface:
*"       IMPORTING
*"             VALUE(CURRDATE) LIKE  SY-DATUM
*"             VALUE(BACKMONTHS) TYPE  NUMC3
*"       EXPORTING
*"             VALUE(NEWDATE) LIKE  SY-DATUM
*"----------------------------------------------------------------------

*DATA: YEAR(4)    TYPE C,
*      TMONTHS TYPE NUMC3,
*      T1MONTHS TYPE NUMC3,
*      DAY(2)     TYPE C.
*
*MOVE: CURRDATE(4) TO YEAR,
*      CURRDATE+4(2) TO TMONTHS,
*      CURRDATE+6(2) TO DAY.
*
**t1months = tmonths - backmonths.
*IF TMONTHS <= BACKMONTHS.
*   CURRDATE(4) = CURRDATE(4) - 1.
*   CURRDATE+4(2) = '12'.
*   BACKMONTHS = BACKMONTHS - TMONTHS.
*   CALL FUNCTION 'CCM_GO_BACK_MONTHS'
*        EXPORTING
*             CURRDATE   =  CURRDATE
*             BACKMONTHS =  BACKMONTHS
*        IMPORTING
*             NEWDATE    =  NEWDATE.
*
** call function recursively
*ELSE.
*   NEWDATE(4) = CURRDATE(4).
*   NEWDATE+6(2) = CURRDATE+6(2).
*   NEWDATE+4(2) = CURRDATE+4(2) - BACKMONTHS.
*ENDIF.

  DATA:       BEGIN OF DAT,
               JJJJ(4) ,
               MM(2) ,
               TT(2) ,
               END OF DAT,

               BEGIN OF HDAT,
               JJJJ(4) ,
               MM(2) ,
               TT(2) ,
               END OF HDAT,
               NEWMM TYPE P,
               DIFFJJJJ TYPE P.

  WRITE:  CURRDATE+0(4) TO DAT-JJJJ,
          CURRDATE+4(2) TO  DAT-MM,
          CURRDATE+6(2) TO  DAT-TT.
  DIFFJJJJ =   ( DAT-MM + ( - BACKMONTHS ) - 1 ) DIV 12.
  NEWMM    =   ( DAT-MM + ( - BACKMONTHS ) - 1 ) MOD 12 + 1.
  DAT-JJJJ = DAT-JJJJ +  DIFFJJJJ.

  IF NEWMM < 10.
    WRITE '0' TO  DAT-MM+0(1).
    WRITE NEWMM TO  DAT-MM+1(1).
  ELSE.
    WRITE NEWMM TO  DAT-MM.
  ENDIF.
  IF DAT-TT > '28'.
    HDAT-TT = '01'.
    NEWMM   = ( DAT-MM  )  MOD 12 + 1.
    HDAT-JJJJ = DAT-JJJJ + ( (  DAT-MM ) DIV 12 ).

    IF NEWMM < 10.
      WRITE '0' TO HDAT-MM+0(1).
      WRITE NEWMM TO HDAT-MM+1(1).
    ELSE.
      WRITE NEWMM TO HDAT-MM.
    ENDIF.

    IF DAT-TT = '31'.
      NEWDATE = HDAT.
      NEWDATE = NEWDATE - 1.
    ELSE.
      IF DAT-MM = '02'.
        NEWDATE = HDAT.
        NEWDATE = NEWDATE - 1.
      ELSE.
        NEWDATE = DAT.
      ENDIF.
    ENDIF.
  ELSE.
    NEWDATE = DAT.
  ENDIF.


ENDFUNCTION.
Back to top
View user's profile Send private message
tdebug
Участник
Участник



Joined: 26 Feb 2009
Posts: 6

PostPosted: Fri Nov 12, 2010 1:16 am    Post subject: Reply with quote

Спасибо!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.