Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Upgrade-Error in report

Former Member
0 Likes
1,236

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

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,199

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

8 REPLIES 8
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,200

Hello,

This is incorrect.

You have to try:

IF INFILE-MENGE+0(1) = '-'.

ENDIF.

BR,

Suhas

Read only

0 Likes
1,199

Hi Suhas,

will the minus sign be as suffix or prefix in ABAP .... im confused now !!!!!!

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,199

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

Read only

0 Likes
1,199

Oh its from aflat file

Read only

Former Member
0 Likes
1,199

Hi ALL,

Thanks for giving your replies.

I am closing this thread.

Points are given.

Read only

Former Member
0 Likes
1,199

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

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,199

data:value(13) type n.

move INFILE-MENGE to value.

if value le 0.

endif.

Read only

Clemenss
Active Contributor
0 Likes
1,199

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