Skip to Content
0
Former Member
Nov 16, 2006 at 04:04 PM

Update routine for 0CALWEEK

146 Views

Hi all.

I am trying to write an update routine for the date characteristic 0CALWEEK. It must be calculated from eather NETDUEDATE or ALLOC_NMBR both from the comm.str. The two dates are in different formats, so will have to be formatted correctly.

I am very new to ABAP so I need a little help here. ๐Ÿ˜‰

This is what I have made:

-


PROGRAM UPDATE_ROUTINE.

$$ begin of global - insert your declaration only below this line -

  • TABLES: ...

<b>DATA: ZDUEDATE TYPE C LENGTH 8,

ZWEEK TYPE C LENGTH 6,

ZEXPDATEY TYPE C LENGTH 4,

ZEXPDATEM TYPE C LENGTH 2,

ZEXPDATED TYPE C LENGTH 2,

ZEXPDATE TYPE C LENGTH 8.</b>

$$ end of global - insert your declaration only before this line -

FORM compute_key_field

TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring

USING COMM_STRUCTURE LIKE /BIC/CS0FI_AR_4

RECORD_NO LIKE SY-TABIX

RECORD_ALL LIKE SY-TABIX

SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS

CHANGING RESULT LIKE /BI0/V0FIAR_C03T-CALWEEK

RETURNCODE LIKE SY-SUBRC

ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update

*

$$ begin of routine - insert your code only below this line -

<b>CLEAR: ZDUEDATE, ZEXPDATEY, ZEXPDATEM, ZEXPDATED, ZEXPDATE.

  • COMM_STRUCTURE-ALLOC_NMBR IS IN FORMAT YYMMDD

IF COMM_STRUCTURE-ALLOC_NMBR NE 0.

ZEXPDATEY = '20' + COMM_STRUCTURE-ALLOC_NMBR(2).

ZEXPDATEM = COMM_STRUCTURE-ALLOC_NMBR+2(2).

ZEXPDATED = COMM_STRUCTURE-ALLOC_NMBR+4(2).

CONCATENATE ZEXPDATEY ZEXPDATEM ZEXPDATED INTO

ZEXPDATE.

  • ZEXPDATE MUST BE CALCULATED TO A WEEK BY FUNCTION 'DATE_GET_WEEK'

RESULT = 0.

ELSE.

ZDUEDATE = COMM_STRUCTURE-NETDUEDATE.

  • ZDUEDATE MUST BE CALCULATED TO A WEEK BY FUNCTION 'DATE_GET_WEEK'

  • TEST DATE_GET_WEEK START

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

DATE = ZDUEDATE

IMPORTING

WEEK = ZWEEK

EXCEPTIONS

DATE_INVALID = 1

  • TEST DATE_GET_WEEK END

RESULT = ZWEEK.

ENDIF.</b>$$ end of routine - insert your code only before this line -

*

ENDFORM.

-


If I check the routine I get the following error:

<i>E:The exception "RESULT" must be assigned to a number (literal), but "ZWEEK" is not numeric.</i>

I understand the error but does not know how to correct it. Also I am not quite sure in how to use the function DATE_GET_WEEK.

Please help me out here guys.

BR

Stefan