on 11-16-2006 4:04 PM
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
There is no diferent formats for dates, there is only one AAAAMMDD.
If you have different formats is because your IO not are dates else character ones.
Date IO can be assigned to temporary IO as 0calweek directly in update rules doing conversion automatically assign netduedate to 0calweek.
in all way:
result = zweek
shoul do the conversion if it can, it is said, there is no character non numeric in zweek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oscar --> I am using two types of IO's which is why one has to be changed. NETDUEDATE is of the type DATS but ALLOC_NMBR is of the type CHAR.
I can not do the conversion automatically as the week has to come from ALLOC_NMBR if it is not empty or else it has to be converted from NETDUEDATE.
Jerry --> I tried to change ZWEEK and ZDUEDATE to SCAL-WEEK and SCAL-DATE, but I still get the same error.
But after checking the FM it seems like it has to be like this, so thank you.
Arun --> That might be a problem as you mention.
I don't know if this is correct, but what I understand from the line:
CHANGING RESULT LIKE /BI0/V0FIAR_C03T-CALWEEK
is that RESULT has to be the same type as CALWEEK which is NUMC.
Isn't this what the error tells me and how can I solve this?
BR
Stefan
hi Stefan,
error 'E:The exception "RESULT" must be assigned to a number (literal), but "ZWEEK" is not numeric.... ' is due to there is no . after DATE_INVALID = 1
and as mentioned, import and export parameter should have data type exactly same as in function module (SCAL-DATE and SCAL-WEEK)....
hope this helps.
EXCEPTIONS
DATE_INVALID = 1<b>.</b>
<b>* put '.' (dot)</b>
TEST DATE_GET_WEEK END
RESULT = ZWEEK.
ENDIF.$$ end of routine - insert your code only before this line -
*
ENDFORM.
-
Also, even if you can get it to compile, you will get a runtime error unless you change the type of zduedate as well, to scal-date.
Otherwise, the FM will fail at runtime.
DATA: zduedate TYPE scal-date,
zweek TYPE scal-week,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Stefan,
this could also be due to the mismatch in the data types.. check the data types for 0calweek and zweek .. that might be the issue even though both values are the same.
Arun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I cannot recreate your syntax error in a standalone ABAP program, but you might try changing the type of ZWEEK.
I.e.
from
ZWEEK TYPE C LENGTH 6,
to
ZWEEK TYPE SCAL-WEEK,
or
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.