Application Development 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: 

INITIAL Check on NUMC fields

Former Member
0 Kudos

Hey,

is there any nice way to make a check like "IS INITIAL" for char values on numc fields ? My problem is that there is a '000' in the numc field and so the "IS INITIAL" thinks that there are values.

Bad solution:

IF field IS NOT INITIAL AND NOT field EQ '000'.

***

ENDIF.

Greetz

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

This is just a logial way of dealing this. Not sure if there is anything else like IS INITIAL

You can try

If field + 1 NE 1

***

ENDIF .

This case if field is 000 Then field+1 will definitely have 1 and so will not enter the loop.

Edited by: Anushya S on Apr 14, 2010 4:33 PM

6 REPLIES 6

Former Member
0 Kudos

hi,

This is just a logial way of dealing this. Not sure if there is anything else like IS INITIAL

You can try

If field + 1 NE 1

***

ENDIF .

This case if field is 000 Then field+1 will definitely have 1 and so will not enter the loop.

Edited by: Anushya S on Apr 14, 2010 4:33 PM

0 Kudos

Hi Anushya,

How you are able to use '+' operator in an IF condition?

You should perform this operation before if condition right...

Regards,

Lakshman.

0 Kudos

Hi Lakshman ,

Fair enuough, i was wrong there .

It should be performed Before and stored in a variable and checked in the if condition .

Sorry for confusion there.

Thanks Lakshman for pointing it out.

Regards,

Anushya S

0 Kudos

A simple workaround :

DATA:
      v_numc TYPE numc3,
      v_char TYPE char3.

v_char = v_numc.

IF v_char IS NOT INITIAL.
  WRITE: / 'CHAR & NUMC do not have same initial values'.
ENDIF.

IF v_char CO '0'.
  WRITE: / 'I found a work around. Yipeee !!!'.
ENDIF.

Former Member
0 Kudos

Thanks for your reply. This will work but i think there should be a nicer way.

The problem exists when you copy the numc field with its initial values into a char. At this point the initial check will not work anymore on the new char field.

The best solution at this point is check just before the copy for initial values.

SuhaSaha
Advisor
Advisor
0 Kudos

IS INITIAL checks if the variable in concern has the initial values. In your case you have the variable as NUMC & initial value for this is '0' for every position (refer [http://help.sap.com/abapdocu_70/en/ABENBUILT_IN_TYPES_VALUES.htm|http://help.sap.com/abapdocu_70/en/ABENBUILT_IN_TYPES_VALUES.htm])

So your assumption that "My problem is that there is a '000' in the numc field and so the "IS INITIAL" thinks that there are values" is not correct. And your IS INITIAL check will be OK if field is defined as numc & has the value '000'

problem exists when you copy the numc field with its initial values into a char. At this point the initial check will not work anymore on the new char field.

Why dint you mention this before ? Anyways if you have character variable, and you want to check if it contains only zeroes you can go for:

IF FIELD CO '0'.

ENDIF.

BR,

Suhas

Edited by: Suhas Saha on Apr 14, 2010 4:38 PM