2009 Nov 06 2:34 PM
Hi all,
I am working in an upgrade from 4.6C to ECC 6.0.
I came across error in one program.
You cannot specify a length <=0
The code regarding this is
DATA: BEGIN OF INFILE OCCURS 0, "format of input file
MATNR LIKE RC29N-MATNR, "(18) Material number
WERKS LIKE RC29N-WERKS, "(4) Plant
MENGE(13), "component quantity - char format
end of infile.
IF INFILE-MENGE(0) = '-'. "place negative sign at end
REPLACE
SHIFT INFILE-MENGE CIRCULAR.
CONDENSE INFILE-MENGE NO-GAPS.
ENDIF.I corrected like this in the code
IF INFILE-MENGE = '-'.
Now it is not giving any synatx errors.
Please correct me if i did wrong.
Regards
Jai
2009 Nov 06 2:37 PM
Hello,
This is incorrect.
You have to try:
IF INFILE-MENGE+0(1) = '-'.
ENDIF.BR,
Suhas
Hi all,
I am working in an upgrade from 4.6C to ECC 6.0.
I came across error in one program.
You cannot specify a length <=0
The code regarding this is
DATA: BEGIN OF INFILE OCCURS 0, "format of input file
MATNR LIKE RC29N-MATNR, "(18) Material number
WERKS LIKE RC29N-WERKS, "(4) Plant
MENGE(13), "component quantity - char format
end of infile.
IF INFILE-MENGE(0) = '-'. "place negative sign at end
REPLACE
SHIFT INFILE-MENGE CIRCULAR.
CONDENSE INFILE-MENGE NO-GAPS.
ENDIF.I corrected like this in the code
IF INFILE-MENGE = '-'.
Now it is not giving any synatx errors.
Please correct me if i did wrong.
Regards
Jai
2009 Nov 06 2:37 PM
Hello,
This is incorrect.
You have to try:
IF INFILE-MENGE+0(1) = '-'.
ENDIF.BR,
Suhas
2009 Nov 06 2:43 PM
Hi Suhas,
will the minus sign be as suffix or prefix in ABAP .... im confused now !!!!!!
2009 Nov 06 2:46 PM
Hello Keshu,
If you check the data declaration MENGE is defined as character field & not as decimal field.
May be the program uploads flat file data & processes the data & i am just trying to correct what the OP has posted.
What i feel is that the quantity is uploaded with '-' sign infront & the code puts the '-' sign at the end
BR,
Suhas
2009 Nov 06 2:50 PM
2009 Nov 06 3:05 PM
Hi ALL,
Thanks for giving your replies.
I am closing this thread.
Points are given.
2009 Nov 06 2:38 PM
Hi
It depends on what u need to check:
A) The first character of INFILE-MENGE is equal to -
B) INFILE-MENGE is equal to -
Case A)
IF INFILE-MENGE(1) = '-'. "place negative sign at end
REPLACE
SHIFT INFILE-MENGE CIRCULAR.
CONDENSE INFILE-MENGE NO-GAPS.
ENDIF.Case B)
IF INFILE-MENGE = '-'. "place negative sign at end
REPLACE
SHIFT INFILE-MENGE CIRCULAR.
CONDENSE INFILE-MENGE NO-GAPS.
ENDIF.But I believe the case A is yours
Max
2009 Nov 06 2:40 PM
data:value(13) type n.
move INFILE-MENGE to value.
if value le 0.
endif.
2009 Nov 06 4:10 PM
Hi Jayanth16,
the error is not related to the upgrade.
ABAP will always put the sign behind number. Human beings put it in front. The plus is omitted because positive is assumed default.
Your code will not help, because it will only work when only the '-' character is present in INFILE-MENGE.
I think this is a nice thing for regular expressions, it could be done as
REPLACE REGEX '[-]([0-9]{1,20}[.]{0,1}[0-9]{0,20})' IN menge WITH '$1-'find a preceding '-'
*followed by up to 20 digits [0-9]{1,20}
optionally followed by a dot [.]{0,1}
optionally followed by zero or more digits [0-9]{0,20}
and replace it with what you found (expression in brackets)
and put a '-' behind.
(I) Enjoy (since ECC600) the use of REGEX!
Regards,
Clemens